Shop OBEX P1 Docs P2 Docs Learn Events
PBasic Questions Again — Parallax Forums

PBasic Questions Again

koolitudekoolitude Posts: 37
edited 2007-02-22 18:00 in BASIC Stamp
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.?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-02-22 16:05
    1) Look at Martin Hebel's Stamp Plot program (www.selmaware.com).

    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.
  • koolitudekoolitude Posts: 37
    edited 2007-02-22 17:09
    Thanks Mike, you are very helpful! =)

    Post Edited (koolitude) : 2/22/2007 5:31:23 PM GMT
  • koolitudekoolitude Posts: 37
    edited 2007-02-22 17:29
    oh.. just another follow up question for Q.2

    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.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2007-02-22 18:00
    The best way to do that is to attach an external clock chip that can change state accurately once every 0.1 second. Then synchronize your program to that.

    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
Sign In or Register to comment.