PDA

View Full Version : pulseout vs high + lows.



Brad Bentley
11-27-2006, 08:17 AM
So I understand both the pulsout commands, and hi and low commands.

Arent they essentially the same command with a different badging? What separates the two commmands from one another? And why cant you use the high and low commands to run a servo? I have tried it, it works, but why does everyone choose to use the pulsout instead of the high and low command?

Steve Joblin
11-27-2006, 09:00 AM
good question! probably just to make programming easier?

Martin Hebel
11-27-2006, 09:03 AM
Using HIGH, PAUSES and LOW doesn't give very accurate timing. There is instruction processing time, etc.

The PULSOUT has a resolution of 2uS providing very short and very precise timing.

-Martin

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Martin Hebel
StampPlot - Graphical Data Acquisition and Control (http://www.stampplot.com/)
AppBee -·2.4GHz Wireless Adapters & transceivers·for the BASIC Stamp & Other controllers (http://www.selmaware.com/appbee)·

Brad Bentley
11-27-2006, 10:01 AM
you could just create a loop or end it, and use a counter for precise timing.

do

HIGH 14 'high 12, 13 14 etc. could be added for more signals.
PAUSE 1
LOW 14
PAUSE 20

loop

this will give you 1ms on 20 ms off.

This is the same signal as a pulsout command of:

pulsout 14, 500
pause 20

this will give you 1ms on 20 ms off.

You could even use the pause to control less than 2us by making a fraction like:
HIGH 14
Pause 1/6 'which is 1/6th of 1 of 1000 which is very small pulse

Im trying to build a brushless motor controller with signals right now, im using a c4 dynamite 540 6 pole motor, and a 70amp mag 8 programmable brushless controller 32khz possible. I need to control the signal wire that runs to the brushless controller. Im looking to get the max rpm out of this motor which is about 110,000 rpm. So i need to write a program for it and will be experimenting with this as soon as I get the parts. would using different pins and fractions for a high pause command be the best route to take or would the pulsout be the best route instead of the HIGH lOW commands?

this is the program I have set up so far:

' allows 2 signal wires for brushless motor connected to pin 14 and pin 15 on and off. both signal wires run into 1 ESC signal wire but is pulsed one after the other.

'{$STAMP BS2}
'{$PBASIC 2.5}

DO

HIGH 14 'high 12, 13 14 etc. could be added for more signals.
PAUSE 1
LOW 14
PAUSE 20
HIGH 15 'waits for high 14 to finish first then high 15 works.
PAUSE 1
LOW 15
PAUSE 20

LOOP

So im thinking I may end up using fractions for the high pause commands to get like 6 commands per 1uS

Martin Hebel
11-27-2006, 10:09 AM
The BASIC Stamp does not do fractions, 1/6 will probably be 0. Also, if you measure with a scope:
DO
HIGH 1
PAUSE 1
LOW 1
PAUSE 20
LOOP

It will be greater than 1mS and NOT precise timing. I just measured this loop, the pulse lasts for 1.4mS roughly. The instuctions are not instaneous, they require processing time.

If you don't need the accuracy, fine, enjoy, but the PULSOUT command exists for a reason.

-Martin

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Martin Hebel
StampPlot - Graphical Data Acquisition and Control (http://www.stampplot.com/)
AppBee -·2.4GHz Wireless Adapters & transceivers·for the BASIC Stamp & Other controllers (http://www.selmaware.com/appbee)·

Kevin Wood
11-27-2006, 11:09 AM
Programming involves creating very basic operations (called primitives), and combining them in such a way that you create highly functional operations that look like very basic operations (called abstraction).

Generally speaking, the higher level a language is, the more it has been abstracted away from the cpu's most basic operations.

I don't know the internal details of PULSOUT, but assuming that DO..LOOP, HIGH, LOW, and PAUSE could be considered primitives, it would make sense to create a more abstract command for commonly used sequences designed for a particular application.

This is the same concept used in creating subroutines, which are sequences of basic commands designed to implement a specific functionality in a program.

So, in this case, you could create a subroutine called MyPulsout, and basically duplicate the functionality of the PULSOUT command, although for various reasons, it likely won't be exactly the same.

If your HIGH/LOW servo code produced exactly the same results as PULSOUT, it would still be easier syntax-wise to use PULSOUT, since it would be less code to write. But there's nothing to prevent you from writing it either way.

Brad Bentley
11-27-2006, 02:34 PM
Ya, either way, as long as I make the program to run the motor full speed I will be happy. I will try both to see the effects on high RPM. I cant wait, I just scored a bunch of cool stuff off ebay this week. I got the motor, brushless ESC, and I just snagged a boe bot tonite for $80!

The funny thing about the HIGH LOW command, Martin in fraction form is it will run an LED, so my guess is it really is fractioned off, or it just rounds to the nearest whole number which would be 1 since it still has a command to turn something on, it cant be 0 , so it will run it for 1 ms. Because It looks the same, but at those frequencies my eye cant pick up 1/6th of 1ms which its probably not, you are right its probably 1.4 ms.

Just curious martin how you are measuring the total program execution time?

And one more question for ya, im new to this, but really into the motor control. What would be the fastest loop execute program for controlling rpm of a motor with pulsout? ive hear 500 was, but if I were to run a brushless motor thats not part of a servo, would I be able to drop the pulsout down to 250 which would be 1/2 ms or can the bs2 only go as low as 500?

Bruce Bates
11-27-2006, 04:40 PM
Brad -

By using long strings of instructions (as your HIGH, PAUSE, LOW, PAUSE does) you are inviting a LOT more overhead than is necessary in your program. Please remember that PBASIC is an interpretive language. Thus, there is an instrucation fetch, and instruction interpret overhead for EVERY instruction executed. When you can use ONE instruction rather than FOUR (or more) to accomplish the same thing, you will have at least 1/4th less interpreter overhead. That's one good reason to keep it short and simple!

Regards,

Bruce Bates

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->

Martin Hebel
11-28-2006, 09:12 AM
Brad Bentley said...

The funny thing about the HIGH LOW command, Martin in fraction form is it will run an LED, so my guess is it really is fractioned off, or it just rounds to the nearest whole number which would be 1 since it still has a command to turn something on, it cant be 0 , so it will run it for 1 ms. Because It looks the same, but at those frequencies my eye cant pick up 1/6th of 1ms which its probably not, you are right its probably 1.4 ms.

Just curious martin how you are measuring the total program execution time?



Hi Brad,
The PAUSE instruction alone has overhead even if the time is 0, which is why you see it doing something.

I use the Parallax Oscilliscope i have on my desk at home to measure the pulse times.

You can go as low as PULSOUT value of 1 which is 2uS of time reliably. 500 is just the servo's needs (1000uS).

-Martin

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Martin Hebel
StampPlot - Graphical Data Acquisition and Control (http://www.stampplot.com/)
AppBee -·2.4GHz Wireless Adapters & transceivers·for the BASIC Stamp & Other controllers (http://www.selmaware.com/appbee)·

Brad Bentley
11-28-2006, 10:54 AM
Oh, thats good to know everyone, I will be re writing this program using the pulsout. Basically im gonna keep as short and simple as possible, keeping the program loop very fast. since its a 6 pole motor I may end up using 2 more pins, so I will use 12 13 and 14 but im not sure if it will require a pause duration that long. So i may end up cutting the pause down to 10 or something, but will start with a pause at 20, and work down to 10 if the motor can handle those speeds.

probably something like:

do

pulsout 12, 1
pulsout 13, 1
pulsout 14, 1

pause 20

loop

If i can make this a subsystem that starts the motor, and once the rpm is up there, then I can switch the pause duration down even more to create almost like a second gear within the motor sort of increasing the motor timing. That is if the ESC and motor can handle it. I may have problems with this code tho. Heres what I got. I want the system to start with about 1,000 revolutions of 20 ms pause, then 100 revolutions of each number 19-11, and then loop the 10 second pause forever at the end of the programming. so how can I isolate the programming so it loops each one a certain number than moves onto the next ramp down on pause time? I was thinking of a counter for each number but not sure on how I will go about that. heres the way i think it should work if the program will work.

counter var word

for counter = 1 to 1000
pulsout 12, 1
pulsout 13, 1
pulsout 14, 1

pause 20

next

for counter = 1 to 100
pulsout 12, 1
pulsout 13, 1
pulsout 14, 1

pause 19

next

for counter = 1 to 100
pulsout 12, 1
pulsout 13, 1
pulsout 14, 1

pause 18

next

for counter = 1 to 100
pulsout 12, 1
pulsout 13, 1
pulsout 14, 1

pause 17

next

for counter = 1 to 100
pulsout 12, 1
pulsout 13, 1
pulsout 14, 1

pause 16

next

for counter = 1 to 100
pulsout 12, 1
pulsout 13, 1
pulsout 14, 1

pause 15

next

for counter = 1 to 100
pulsout 12, 1
pulsout 13, 1
pulsout 14, 1

pause 14

next

for counter = 1 to 100
pulsout 12, 1
pulsout 13, 1
pulsout 14, 1

pause 13

next

for counter = 1 to 100
pulsout 12, 1
pulsout 13, 1
pulsout 14, 1

pause 12

next

for counter = 1 to 100
pulsout 12, 1
pulsout 13, 1
pulsout 14, 1

pause 11

next
do

pulsout 12, 1
pulsout 13, 1
pulsout 14, 1

pause 10

loop

Hopefully it will work as a 2 second ramp up to speed, then start switching down the pause time once the motor is spinning at max speed increasing the speed of the brushless motor even further.

Bruce Bates
11-28-2006, 05:32 PM
Brad -

If it makes your programming any easier or faster, you can use a variable in the PAUSE statement like this:

PAUSE Time_Delay

Prior to issuing that PAUSE statement, set Time_Delay to whatever amount you choose. If you wish, it can even be a mathematical expression:

Time_Delay = Base_Delay + (2 * Increment)
PAUSE Time_Delay

or something like that.

Regards,

Bruce Bates

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->

Brad Bentley
11-29-2006, 06:09 AM
Oh nice, thats very helpful. I have done half of the programming book so far once already. Then I forgot about it for a while, and now im back into it, but only up to the servo section again, I started over to relearn everything. So It has been a while, I have learned alot of the commands, I remember doing the pause time delay command a while back. But im only a fraction of the way to learning all the commands.

So im gonna redo my program a few more times, maximizing the program efficiency, and ease of readability while im still waiting for the goods to get here.

I cant wait for the boe bot, thats gonna be a fun project. I got lots of plans for that little guy, since I already have a bs2ic, and now i will be getting the BOE so i can program multiple chips. I plan on building this bot guy up into something very usable.

brad B.