PDA

View Full Version : BS2 - PULSOUT - time between pulses



curious1
04-24-2007, 07:36 AM
Hello,
· I cannot find in the WAM or Command Ref. the time frame between pulses if no Pause command is given.
I assume that it is 1 ms, this being the units for the pause command.
for instance :
·· low 1
·· for counter = 1 to 1000
·· Pulsout 1,1
·· next
The pulses in this pulse train would be high for 2us and low for ???, 1ms ???
If so, is there a method to make it pulse faster ?
Thanks,
RC

Post Edited (curious1) : 4/24/2007 12:59:14 AM GMT

Duffer
04-24-2007, 08:36 AM
Mr. 1,

Your code does in fact produce 2us pulses 1ms apart (on a BS2)·measured using a BS logic analyser. It would appear that the shortest program loop on a BS2 is 1ms. In the processor comparison chart the BS2 is rated at ~4,000 instructions/sec. The BS2px is rated at ~19,000 instructions/sec (currently the fastest Stamp), so I guess that going to a faster processor would be the only way to shorten the width between pulses using the PULSOUT cmd.

Steve

curious1
04-24-2007, 06:25 PM
Thanks Steve,

I have·some, (limited) experience with·PLC based··pulse generators ·that operates like this:

A single pulse is described as having a 50% duty cycle. This means it is ON for 50% of the pulse and consequently OFF for the remaining 50% of the pulse. The actual output is·controlled by interrupt handling, i.e. the output cycle is NOT affected by the scan time of the program.

Do you know if any of the Parallax products can be configured to operate this way ?

Thanks again Steve,

RC

Duffer
04-24-2007, 09:37 PM
I'm not sure what your're trying to do, but I have the feeling that you're trying to generate frequencies that the Stamps just aren't capable of. The PBasic FREQUOT command generates a sine wave using a pulse-width modulation algorithm, but the BS2 can only go to just over 32KHz and the fastest Stamp (BS2px) tops out at about 198KHz. If you're talking about generating frequencies in the MHz range, I'm pretty clueless about that area.

Tracy Allen
04-25-2007, 01:14 AM
The time taken has nothing to do with the 1 millisecond time of the pause command. It is the operation of the PBASIC interpreter. It is true that the loop you mentioned takes about 1 millisecond. The FOR NEXT command is relatively slow, so you should be able to get a faster loop going with a carefully constructed DO LOOP or BRANCH. But it will be only marginally faster. There are trick ways using the PWM command to generate a high frequency burst at certain specific high frequencies. What are you trying to do?

There is more about the timing of the interpreter here: www.emesys.com/BS2speed.htm (http://www.emesys.com/BS2speed.htm)

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com (http://www.emesystems.com)

curious1
04-25-2007, 07:04 AM
Tracy,
·· Thanks for the link, much useful info. I will have to modify my plans.
I will experiment with the stamps "unconventional" PWM, on / off pulses as short as 1.6us in duration.
May have to ask you about the "TRICK WAYS" that you mentioned.
Thanks again for the direction,
RC
·

curious1
04-25-2007, 10:26 AM
For example, in this sequence:


loop:high 1 ' 140 microseconds highlow 1 ' 140 microseconds lowhigh 1 ' 140 microseconds highgoto loop ' 290 microseconds, P1 still highAbove is a clip from the emesys write-up.I am not sure why the pin is set high the second time in the loop.I ran a small stepper motor with above coding, then like this:do high 1 low 1loop and the motor ran noticibly faster.Also ran used Toggle command: do, high 1, toggle 1, loop .It was also faster but no mention of Toggle speed in the chart.side note: how do you keep this darn thing from writing the same way as the pastedmaterial ???? I'm running out of paper here !RC

Tracy Allen
04-25-2007, 11:37 AM
I think those were just examples on how to calculate the timing, not an attempt to find the fastest way to toggle a pin.
There is also


DO : TOGGLE 1 : LOOP


I think TOGGLE takes the same time as HIGH or LOW.

As example of a PWM trick, the following gives a sequence of 8 equally spaced pulses in a period of 1.15 millisecond (BS2)


PWM 1, 8, 1


The pulses are always 4.5 microseconds long, and the low periods are long, 278.5 microseconds each. That would probably work to advance a stepper controller. The pin is left as an input at the conclusion of the command, so you may want to use a pulldown resistor depending on what the pin is driving.

The following gives 8 pulses over a period of 4.6 milliseconds


PWM 1, 2, 4

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com (http://www.emesystems.com)