Shop OBEX P1 Docs P2 Docs Learn Events
Is there an alternative for making the processor pause, which would work at the — Parallax Forums

Is there an alternative for making the processor pause, which would work at the

paulc22paulc22 Posts: 7
edited 2007-09-02 18:59 in Learn with BlocklyProp
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

Comments

  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2007-08-20 18:00
    Hi paul , you could try a For Next loop or· Do While loop

    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
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-08-20 18:06
    Let's see, at 2000 instructions per second, even a HIGH followed by a GOTO would take 1 mSec to execute. In theory you could use a "PULSOUT" in 2 uSec steps, but you'd still have a 500 uSec or so 'overhead' while the PULSOUT instruction was being interpreted.

    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.
  • paulc22paulc22 Posts: 7
    edited 2007-08-20 22:23
    I like the idea of using NoOps in a tight loop.· I didn't even think of that.· I guess I've been working with relatively large pre-emptive multitasking systems so long that I forgot we have complete control over the processor when working with the stamp.· This is for sure the way to go for my problem.· All I need to do now is experiment to see how long a NoOp takes in my processor.

    Thanks a million, Jeff!

    Paul C.
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-08-21 14:06
    Yup, that's one reason I like the BS2 -- you get complete control, no RTOS, just you, the module, and the code.
  • cyplesmacyplesma Posts: 76
    edited 2007-08-30 18:43
    hehehe and a lot of caffeine.


    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
  • Mike GreenMike Green Posts: 23,101
    edited 2007-08-31 22:47
    The hardware exists, but you'd have to "roll your own" software.· Look at the BS2px Motherboard on the webstore.· It consists of a BS2px plus two AVR microprocessors pre-programmed with some code to do a few functions.· The AVRs could do what you want and you could probably modify the existing AVR code to substitute your timer for one of the existing functions.· I don't have a copy of the documentation handy to check, but have a look.
  • Capt. QuirkCapt. Quirk Posts: 872
    edited 2007-09-02 18:59
    Are you working on a TCI ignition system?
Sign In or Register to comment.