programming delays less than 1ms
![davejames](https://forums.parallax.com/uploads/userpics/936/nZ2GD6713B1FA.jpg)
Hi All,
I have need to program a delay less than the 1ms of which the PAUSE statement offers.
My first thought was to set up a test case where an I/O pin would be driven high, issue a "PAUSE 0", drive the I/O pin low and observe the time between the rising and falling edges on a scope to get an idea of how long the PAUSE command takes to execute.· Placing this method inside a FOR/NEXT with a variable for the upper count would give a level of less-than-1ms, programmable delay.· Granted, it wouldn't be overly accurate, but I'm not looking for high accuracy.
Anyone else have a nifty way of dealing with·this?
Thanks,
DJ
·
I have need to program a delay less than the 1ms of which the PAUSE statement offers.
My first thought was to set up a test case where an I/O pin would be driven high, issue a "PAUSE 0", drive the I/O pin low and observe the time between the rising and falling edges on a scope to get an idea of how long the PAUSE command takes to execute.· Placing this method inside a FOR/NEXT with a variable for the upper count would give a level of less-than-1ms, programmable delay.· Granted, it wouldn't be overly accurate, but I'm not looking for high accuracy.
Anyone else have a nifty way of dealing with·this?
Thanks,
DJ
·
Comments
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
Suzuki SV1000S motorcycle
Mr. Green - thanks, I'll read up on PULSOUT.
I'm attempting to program some LS573 data latches that have setup/hold/propagation times in the order of 50ns and I'd like to not be saddle with 1ms intervals of delay time.· Every little bit helps, you know?
DJ
Did an experiment last night (12AM...yawn...) where I programmed a PAUSE command with a value of 0 (zero) wedged in between an I/O pin going high and going low.· Using the nifty BSLA tool, it appears that a "PAUSE 0" has an execution time of approximately 390us.· This was a one-shot event.· I did not set up a loop, view it with a scope and calculate averages.
This experiment was performed on with a Basic Stamp 2 running Parallax 2.5 BASIC.· I would imagine the other members of the Basic Stamp product line would give different results due to different clock rates and different internal efficiencies.
I've yet to try the dummy PULSOUT suggestion from Mr. Green.
Just in case you were wondering,
DJ
You can also use other "do nothing" commands other than PAUSE 0 to create a small similar effect delay... Here are some examples with ones you've tried included.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Thank you for the info.· May I ask what Stamp module was used to determine the noted time values?· And what method was used to qualify them?
The 390us value I saw for a "PAUSE 0" on a BS2 was from the BSLA setup for 1M samples.· I think the BSLA reports fairly accurately as I used it to verify a "PULSOUT 1, 5" of 10us, although I haven't proved it with a scope yet.
Thank you and thanks to the other Parallax employees who monitor this forum so frequently,
DJ
I used a BS2 RevE connected to a Tektronix TDS 220 scope. (Screen shot attached).
The program uses the TOGGLE command to flip a pin either HIGH or LOW. The reason that TOGGLE is used instead of using the HIGH or LOW command is mainly for program execution symmetry. This allows the program to take the same amount of time to make the pin HIGH as it does to make the pin LOW. When using this method, program execution symmetry is important for correct timing measurements. Just keep in mind that if you look at the signal on a scope from rise time to rise time (The period) or fall time to fall time, that the value you read is actually twice the execution value that you are looking for. This is because the program (via the TOGGLE command) has to run through twice to accomplish the two similar events that you are looking for on the scope.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Understood - I forgot about the time it takes for a HIGH or LOW command to execute (as previously warned by Mr. Green).
Thank you for the follow up, for taking the time to research the question and providing a scope shot.
TDS220; great line of scopes. I've been using the TDS210 model over 10 years for debug in my classes. Hardly any problems.
Regards,
DJ