Is there an alternative for making the processor pause, which would work at the
paulc22
Posts: 7
Hello,
I am calculating a time delay for given angular offset of a rotating motor shaft.· I am using the BS2's PAUSE command, which has a resolution in the millisecond range.· I am finding that for RPMs larger than 400,·my angular offsets are limited to around 3 degrees of precision.· This is because if I use an angular offset less than 3 degrees, the calculated time delay is sub-msec, and the PAUSE command cannot work w/such values.
Is there an alternative for making the processor pause, which would work at the micro second level?
I have read that the BSp has greater precision, but this is around 279 micro-seconds.· I'd really like something down to 10 or even 1 micro seconds.
Also, is this a limitation of the processor itself, or just a BASIC PAUSE limitation?· In other words, could I do better if I coded it in assembler?· Thanks,
Paul C.
[noparse][[/noparse]Subject Added, Duplicate Post Deleted]
Post Edited By Moderator (Chris Savage (Parallax)) : 8/20/2007 5:58:54 PM GMT
I am calculating a time delay for given angular offset of a rotating motor shaft.· I am using the BS2's PAUSE command, which has a resolution in the millisecond range.· I am finding that for RPMs larger than 400,·my angular offsets are limited to around 3 degrees of precision.· This is because if I use an angular offset less than 3 degrees, the calculated time delay is sub-msec, and the PAUSE command cannot work w/such values.
Is there an alternative for making the processor pause, which would work at the micro second level?
I have read that the BSp has greater precision, but this is around 279 micro-seconds.· I'd really like something down to 10 or even 1 micro seconds.
Also, is this a limitation of the processor itself, or just a BASIC PAUSE limitation?· In other words, could I do better if I coded it in assembler?· Thanks,
Paul C.
[noparse][[/noparse]Subject Added, Duplicate Post Deleted]
Post Edited By Moderator (Chris Savage (Parallax)) : 8/20/2007 5:58:54 PM GMT
Comments
For x=1 to a_variable
a_variable=a_variable+1
Next x
or place a couple of dummy instructions in your code
Jeff T
This is a limitation of the PBasic run-time architecture. The native 'PIC' chip runs at about 5 MIPS (with a 20 Mhz crystal), and so takes about 200 nSecs/instruction. And an SX chip runs at 50 MIPS (with a 50 Mhz crystal) and so takes about 20 nSec/instruction. You might try the SX boards offered by Parallax.
Note that SX programming is slightly harder than PBasic programming. The nice thing about PBasic/Stamp programming is that the language is simple, and gives you good access to millisecond events, and is an extremely reliable and simple hardware platform -- give it a nine-volt battery and you're working. But native SX code can be MUCH faster, if slightly harder to get right.
Thanks a million, Jeff!
Paul C.
I kinda notice this has come up a few times.
maybe the question is, does there exist or could parallax make a gadget to generate a numerical value based on a signals single up and down cycle at the nano or pico level. (I guess maybe I could or someone else could also, I haven't got the time though and it be worth a few bucks per nano time gadget thingie to just buy it)
It doesn't have to be constantly updated it would just need to collect the timing of the first cycle (when told by the stamp to take a sample and report that back to the stamp, the stamp can then tell the nano timer to take a another sample when needed.
but the stamp would at least get a value of the target cycle to do something with or make a decision about.
Post Edited (cyplesma) : 8/31/2007 4:34:58 PM GMT