PDA

View Full Version : Help with short very short delays



Nick L
01-21-2006, 01:06 PM
Hi,

Can any one tell me a how to generate a short delay? The 1ms time base of the Pause command is too coarse, I need to generate varing delays with units of microseconds. What's the equivalent to a NOP in a BS2? If you can't tell I'm just starting to use a BS2. I tried a quick search of·the archives and forums, but nothing came up.

Thanks for any and all help,
-Nick L

Jon Williams
01-21-2006, 02:09 PM
The shortest delay you can generate is with PAUSE 0 - if I remember correctly, about 100 uS. If you're need timing precision greater than the BASIC Stamp offers, you might consider the SX and SX/B.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

Bean
01-21-2006, 07:49 PM
Nick,
As Jon has stated SX/B is the way to go. It has a command "PAUSEUS" for pause microseconds. If the delay value is a constant you can even use fractional values. For example "PAUSEUS 65.5". Of course the resolution depends on the clock frequency of the SX chip.

Bean.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95

http://www.parallax.com/detail.asp?product_id=30012

"SX-Video OSD module" Now available from Parallax for only·$49.95
http://www.parallax.com/detail.asp?product_id=30015

Product web site: www.sxvm.com (http://www.sxvm.com)

"Ability may get you to the top, but it takes character to keep you there."
·

allanlane5
01-21-2006, 08:55 PM
You can use the 'pulsout' command to generate precise pulse widths down to 2 uSec resolution. Be aware, it will take the BS2 some 300 to 500 uSec to prepare to execute the command, so this may not be very effective.

Yeah, for that resolution, use the SX-28, 48, or 54 modules; with the SX/Basic toolkit from Parallax.

Nick L
01-21-2006, 09:07 PM
Thanks Bean and Jon,

I'll look at the sx modules. So even a loop that does nothing can't be used for a short delay?

Hi Alan,

The time you mention for the BS2 to prepare the caommand, is that for every 'pulsout' command? If it is than what I want to do isn't going to work. I'm trying to generate IR commands to trigger a camera. The pulses are in hundreds of microseconds followed by delays of hundreds of microseconds. I can't have milliseconds of delay between the pulses.

Wish I seen some information about this in the Parallax·documention some place. Maybe I should just learn to program in PIC assembly? Think the SX modules could generate IR control signals?

Thanks
Nick L

Paul Baker
01-21-2006, 09:16 PM
Since the stamp is an interpretor and the interpreted code resides on an external serial EEPROM, there is a fixed access time for each command to retrieve the next token to be interpreted, this is added to the actual execution time of each command which is variable, depending on the specific command.

To achieve the precision you are looking for you would need an SX. A pic would also work, but SXs are heavily supported not only by the community but by Parallax employees whose only job is to help customers. There are 3 employees (Jon, Chris and Ryan) who are on the forums all the time (frequently even late at night), there are also an additional handful of Parallax employees who make regular appearances in the forums in an additional support role. Even the CEO (Ken Gracey) is on almost everyday answering questions (mainly to do with business end type questions, but also the occasional tech question). I have not found any other company which provides this level of dedicated support. Also when you compare the raw power of SXs to other commonly availible microcontrollers, the SX runs circles around them in most respects. I carefully researched various microcontroller platforms for 2 1/2 years before deciding on the SX, and I have never regretted the decision.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10

Post Edited (Paul Baker) : 1/21/2006 2:22:09 PM GMT

bobledoux
01-21-2006, 09:24 PM
How big is Parallax? How many employees? How many programming or other technical staff?

Paul Baker
01-21-2006, 09:40 PM
Ken can answer that question for you, Ive never been to thier headquarters in Rocklin, CA, but I will soon (Im quite excited).

My last post unintentionally downplayed Jon Williams' role in the company. He is sort of thier Renaissance man, answering questions, creating new applications for the Stamp and SX, writing the articles for Nuts and Volts, and an additional career as an actor·having appeared in·several Hollywood movies (and Im probably forgetting other things he does).

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10

Nick L
01-21-2006, 11:12 PM
OK I've looked over the SX modules, looks like these use a basic compiler to load assembly to the micro unlike the basic stamp modules. How does using the SX-Key compare to using the Pic Basic compiler? Has any one used both? The SX Tech Tool kit Lite looks like a good deal compared to the cost of the Pic Basic Compiler. I'm looking to generate IR control signals and now realize I can't use interpreted basic. Any thoughts.

Thanks
Nick L

Paul Baker
01-21-2006, 11:48 PM
PBASIC and SX/B are very similar in structure but not exactly the same. PBASIC has built in support for dealing with word sized variables, SX/B only natively deals with bytes, though some work arounds can be used to deal with larger sizes. Think of SX/B being PBASIC lite, Parallax developed SX/B to ease the transition of a customer already familiar with PBASIC into using the SX. I still prefer using assembly on the SX, but Bean has used SX/B quite a bit and could probably give you more detail on the differences.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10

allanlane5
01-22-2006, 12:28 AM
You can't really go wrong with the SX. It cycles at 50 MIPS, which once was one of the fastest clock times for small PIC-type processors -- it's still amazingly fast, (0.02 uSec per instruction time).

And the SX/B lets you use a basic variant, which is nice. The SX-Key kit lets you download, debug and single step on the processor while connected to your PC.