In another thread, I solved, how to utilize Picaxe's TOUCH -command to detect something else than living material (dry "dead" material, water level)
It seems, that "real world" apps (sensoring) is not as interesting in this forum, as coding. That is why, I am starting a new thread, for the code.
After getting ground data from sensing materials, I am thinking about a code, that can determine a "zero-point" for touch-command, and transfer it to the main program.
The main program senses material level in a container. How much the reading rises, when material reaches the sensor is (roughly) known. But the value in a empty container is not known! (depends on the material/size of the container)
The subroutine, I am thinking of, should read the " base value" in a empty container, and store it (permanently) somewhere. The main program then uses this value as a "zero point" (=empty) and uses "predicted" (by material) value to determine, when material level has reached the sensor.
The "sensitivity" should also be adjustable...
Anyway, subroutine that determines the base value, is to be called only when asked! (not every time program starts! f.e.x after a power down)
After a power down, the main program should read the "base value" from a stored location.
The "base value" represents a empty container. When sensed reading rises to a predicted value (=base+known rise when contact) ,main program decides, that sensor has detected material, and something has to be done.
I have had "gray hair" with Picaxe's IF-command, since it does not compare variables the same way, that common BASIC-languages...
Here is the same problem. If the "base-value" is stored in a variable, how do I execute: IF read value > base value + predicted contact value rise , THEN gosub do something...
Another subroutine (called) should be able to change the "predicted rise of the value ,when contact" (= sensitivity), and store the new value (permanently) somewhere.
I could do this this on my own, in a rude and space-consuming way, but I am asking the forum for hints ,for doing it in a more sophisticated way!
Ideas?
It seems, that "real world" apps (sensoring) is not as interesting in this forum, as coding. That is why, I am starting a new thread, for the code.
After getting ground data from sensing materials, I am thinking about a code, that can determine a "zero-point" for touch-command, and transfer it to the main program.
The main program senses material level in a container. How much the reading rises, when material reaches the sensor is (roughly) known. But the value in a empty container is not known! (depends on the material/size of the container)
The subroutine, I am thinking of, should read the " base value" in a empty container, and store it (permanently) somewhere. The main program then uses this value as a "zero point" (=empty) and uses "predicted" (by material) value to determine, when material level has reached the sensor.
The "sensitivity" should also be adjustable...
Anyway, subroutine that determines the base value, is to be called only when asked! (not every time program starts! f.e.x after a power down)
After a power down, the main program should read the "base value" from a stored location.
The "base value" represents a empty container. When sensed reading rises to a predicted value (=base+known rise when contact) ,main program decides, that sensor has detected material, and something has to be done.
I have had "gray hair" with Picaxe's IF-command, since it does not compare variables the same way, that common BASIC-languages...
Here is the same problem. If the "base-value" is stored in a variable, how do I execute: IF read value > base value + predicted contact value rise , THEN gosub do something...
Another subroutine (called) should be able to change the "predicted rise of the value ,when contact" (= sensitivity), and store the new value (permanently) somewhere.
I could do this this on my own, in a rude and space-consuming way, but I am asking the forum for hints ,for doing it in a more sophisticated way!
Ideas?