PBasic Questions Again
koolitude
Posts: 37
Thank you very much for all of you who have answered my questions.
I would like to·ask if there are ways to code such procedures:
1) Output the value to a file:
I manage to send the readings obtained from a sensor to the Debug window, but I would also like to send the reading to a file such that I can analyze the readings received from the sensor.· How can·I do this?
2)·Run a·certain·subroutine every·certain time interval:
I would like to get a value from the sensor say every 0.1sec.· How can I trigger a certain subroutine every 0.1sec then?
Thank you very much for your help! If you know there are answers for my questions in the manual, could you please let me know the page no.?
I would like to·ask if there are ways to code such procedures:
1) Output the value to a file:
I manage to send the readings obtained from a sensor to the Debug window, but I would also like to send the reading to a file such that I can analyze the readings received from the sensor.· How can·I do this?
2)·Run a·certain·subroutine every·certain time interval:
I would like to get a value from the sensor say every 0.1sec.· How can I trigger a certain subroutine every 0.1sec then?
Thank you very much for your help! If you know there are answers for my questions in the manual, could you please let me know the page no.?
Comments
2) If you're just reading the sensor and it doesn't take too long to deal with the resulting value, use a PAUSE statement to wait a specific period (like 100ms) before reading the sensor again.
Post Edited (koolitude) : 2/22/2007 5:31:23 PM GMT
What if I will do something else, which may last for relatively quite a long time, after reading the sensor for the first time? I'm wondering if the microcontroller is doing something else, how can I make sure that the microcontroller can still run the 'Read Sensor' subrountine every say 0.1 sec?
Do you understand what I am trying to say? Sorry for my poor description.
Some real time clocks offer a heartbeat output, and there is a chip meant for this purpose at www.rhombus-tek.com/co-processors.html.
It is also possible to write code so that it is time certain. So you just subtract the time taken by the code from the total interval needed and throw the rest into a PAUSE. The feasibility of that depends on the precision required and the complexity of the program.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com