Shop OBEX P1 Docs P2 Docs Learn Events
Time counter with basic stamp. — Parallax Forums

Time counter with basic stamp.

tilemachostilemachos Posts: 2
edited 2009-01-11 16:52 in BASIC Stamp
hello!!

I want to use my basic stamp to make a counter-clock with nanosec accuracy. Without an lcd, in a debug home. Can i have this accuracy? What about the code? Should i use "rctime"; What about pulsout and freqout? Is there a way to take nanosecond-measurements?

Any ideas?

Thanks a lot.

Comments

  • sylvie369sylvie369 Posts: 1,622
    edited 2009-01-11 15:35
    The fastest Stamp module - the 2px - runs at 32 MHz and runs about 19,000 instructions per second.
    That's not fast enough by a couple of orders of magnitude. I think you're going to need to use some other controller.

    1 nanosecond = 1/1,000,000,000 seconds = .000000001 seconds, right?

    1/32,000,000 = .00000003125 seconds, or 32 nanoseconds. Even if your instructions took only a single clock cycle and you only needed one instruction to make the count*, 32 nanoseconds would pass between counts.

    Now since I said that, someone else will probably show up with a way to do it. smile.gif


    * Neither of which is even remotely reasonable to assume. Each PBasic instruction (with the possible exceptions of WAIT and maybe a couple others) compiles to several machine-level instructions, and I think that each machine-level instruction takes several clock cycles to perform. As I understand it, that's why a chip running at 32 MHz only performs something like 19,000 instructions/second.

    Post Edited (sylvie369) : 1/11/2009 3:50:08 PM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2009-01-11 16:17
    None of the Parallax microcontrollers will get you nanosecond accuracy measurements. The Propeller has a system clock that runs at 80MHz and can do pulse width timing with a resolution of one system clock (12.5ns) which is still an order of magnitude less than what you're asking for. The clock does drift with temperature changes and voltage changes and is not that accurate to begin with. An external precision temperature controlled crystal oscillator can be used, but may only have an accuracy on the order of parts per million (an accumulated error of say 5us in one second).
  • tilemachostilemachos Posts: 2
    edited 2009-01-11 16:52
    First of all, thanks a lot for your answers.
    Both of them are very helpful.

    To be honest with you, its possible that an accuracy of 10^-8 will be fine for my experiment so i would like to try it.
    Propably i ll use another microcontroller in the end, but now i would like to make some experiments with my bs2.
    I know that there is not so fast but i want to do it just for the experience, and to know how to continue with the others.

    So, can you give me some advice about the code i need to do something like this? Should i use the "pulsout" ? How?

    thanks again.

    Post Edited (tilemachos) : 1/11/2009 6:41:12 PM GMT
Sign In or Register to comment.