I have searched everywhere and I can't find anything that really covers this. How exactly do you control a servo with·the PWMPAL? Can anyone help? Thanks.
It's not hard to do: set the on-time to a value between 1 and 2 milliseconds for the servo pulse and make the off-time 20 ms. A centering command for a standard servo, for example, would be:
To center a servo we send it a 1.5 ms pulse. The PWMPAL pulse widths are specified in units of 25 uS, or 0.025 ms. Take 1.5/0.025 and you get 60. This is the on-time value. The off time is 20 ms, so 20/0.025 = 800 (hex $0320). Remember that values passed to the PWMPAL go low-byte, then high-byte.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ Jon Williams Applications Engineer, Parallax
Dallas, TX· USA
I have·tried this many times and it won't move the servo. I can control the servo with the PULSOUT command and the PWMPAL will give me its version number just fine, so I know that neither is broken. What could be wrong?
I don't know ... I've used the PWMPAL to control servos in a Boe-Bot robot. If you have a 'scope you should connect it and see what's going on.
BTW, you MUST make sure that the BASIC Stamp pin that corresponds to your PWMPAL output pin is an input; if it's an output low (like after a PULSOUT) then the PWMPAL output will be swamped.· There are resistors on the PWMPAL that prevent pin burn-out, but they're so small (220) that they'll look like a short to your servo.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ Jon Williams Applications Engineer, Parallax
Dallas, TX· USA
Post Edited (Jon Williams) : 1/2/2005 9:33:00 PM GMT
I don't have an oscilloscope, but I know someone who does and I'll see if I can can borrow it. Anyway I have ordered another PWMPAL and when it comes in I will try again with the new one and see if it works. Thanks for your help.
Oh! I didn't realize that you have to set the pin as an output before you can use it. I just assumed that if you tell it to generate an signal than it sets it as an output automatically. It's working now. Thank you very much!
OK, here is my situation.· I'm a highschool aged· kid with a boe bot.· I haven't done much any thing with it besides the projects detailed in the boe-bot book.· On project i did make was a ramping roaming program, that ramps the servos up and down to steer around objects.·
The problem with this program was that the ir sensing part of the program took too long, that resulted in the driving of the boe bot to be very jerky, as it would stop the servos compleatly between each pulse.·
This week i ordered a PWMPAL to·continue·sending the same pulses while the·stamp·controler was analyzing the ir.· I really didn't understand the syntax·for the PWMPAL and the waves.· I played around with diferent commands and found an old post (below).· I also found an attached program that worked great, but i just can't get·the syntax to work in my own programs.· One thing i really don't understand is the Lowbyte Hibyte and byte0 byte1· hows that work, whys it do that, what's the low-byte pass, and the high byte pass?· i can use windows calculator to convert 800 to 302 but it converts 60 to something else.· So i guess what i'm really looking for is an explaination of the byte0. and byte1. commands, and how to use them.
thx,
Jonathan
Jon Williams (Parallax) said...
It's not hard to do: set the on-time to a value between 1 and 2 milliseconds for the servo pulse and make the off-time 20 ms. A centering command for a standard servo, for example, would be:
To center a servo we send it a 1.5 ms pulse. The PWMPAL pulse widths are specified in units of 25 uS, or 0.025 ms. Take 1.5/0.025 and you get 60. This is the on-time value. The off time is 20 ms, so 20/0.025 = 800 (hex $0320). Remember that values passed to the PWMPAL go low-byte, then high-byte.
Okay, no problem -- and we don't discriminate based on age·· if you're new, you may need to reread the docs a few times so that it sinks in (I used to work for a guy who maintained it took 5 to 7 times to make something "stick").
The key with the PWMPAL is that it used Word (16-bit) values, but serial communication is with bytes.· What this means is that we have to split the word variable into two bytes for serial transmission to the PWMPAL.· Lucky for us, PBASIC makes this pretty simple with LOWBYTE and HIGHBYTE -- these are the constituent portions of a Word variable.· Chapter 4 in the PBASIC manual covers variables and you may want to review this as well, it will help.
You can use use the Windows calculator for fixed values -- and convert to hex so you can see the high and low bytes.· The key to remember is that transmission is low byte, then high byte, so if you get $0320 from the Windows calculator the order in the SEROUT block is going to be $20, then $03.
It will also be helpful for you to post the program(s) that is giving you trouble.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ Jon Williams Applications Engineer, Parallax
1. Is there a protocol or specification on the format of the tOn and tOff values? Do they have to be in decimal or hex or can it be a combination like shown below? Could the off time of 800 be written as a lowbyte and a highbyte still in decimal form?
2. In general, are the specifications of the type of information sent, i.e. Binary, Decimal, or Hex? If so, how do you know which type to send when?
Jon Williams said...
It's not hard to do: set the on-time to a value between 1 and 2 milliseconds for the servo pulse and make the off-time 20 ms. A centering command for a standard servo, for example, would be:
To center a servo we send it a 1.5 ms pulse. The PWMPAL pulse widths are specified in units of 25 uS, or 0.025 ms. Take 1.5/0.025 and you get 60. This is the on-time value. The off time is 20 ms, so 20/0.025 = 800 (hex $0320). Remember that values passed to the PWMPAL go low-byte, then high-byte.
Another questions about commands to and from the PWMPal: (based on sample commands found in PWMPAL documentation, downloaded from the Parallax website)
3. When using the "SS" command to set motor control/status, how is the status byte determined? The documentation gives this example:
"SEROUT 0, 6, [noparse][[/noparse]"!PWMSS", %00010000]
The example above enables PWM output channel 1 (P12). The PWM output will begin immediately with the frequency and duty cycle as set with the "Mn" command." And gives the table Control/Status Byte Definitions Table. If you convert that Binary number to a decimal number you get 16.
How do you use the numbers in the table to translate to a status byte to send to the PWMPAL?
4.If you wanted to put PWM output channel 1 (P12) to hardware control, how would you set control channel 1 (P8) high?
Post Edited (Casey_SCU) : 7/10/2006 10:33:27 PM GMT
Comments
·PWMPAL can control servos or DC motors, but I would only use it for the later.. but that is me
SEROUT Sio, Baud, [noparse][[/noparse]"!PWM1", 60, 0, $20, $03]
The math:
To center a servo we send it a 1.5 ms pulse. The PWMPAL pulse widths are specified in units of 25 uS, or 0.025 ms. Take 1.5/0.025 and you get 60. This is the on-time value. The off time is 20 ms, so 20/0.025 = 800 (hex $0320). Remember that values passed to the PWMPAL go low-byte, then high-byte.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
BTW, you MUST make sure that the BASIC Stamp pin that corresponds to your PWMPAL output pin is an input; if it's an output low (like after a PULSOUT) then the PWMPAL output will be swamped.· There are resistors on the PWMPAL that prevent pin burn-out, but they're so small (220) that they'll look like a short to your servo.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
Post Edited (Jon Williams) : 1/2/2005 9:33:00 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
Post Edited (Jon Williams) : 1/2/2005 10:35:18 PM GMT
The problem with this program was that the ir sensing part of the program took too long, that resulted in the driving of the boe bot to be very jerky, as it would stop the servos compleatly between each pulse.·
This week i ordered a PWMPAL to·continue·sending the same pulses while the·stamp·controler was analyzing the ir.· I really didn't understand the syntax·for the PWMPAL and the waves.· I played around with diferent commands and found an old post (below).· I also found an attached program that worked great, but i just can't get·the syntax to work in my own programs.· One thing i really don't understand is the Lowbyte Hibyte and byte0 byte1· hows that work, whys it do that, what's the low-byte pass, and the high byte pass?· i can use windows calculator to convert 800 to 302 but it converts 60 to something else.· So i guess what i'm really looking for is an explaination of the byte0. and byte1. commands, and how to use them.
thx,
Jonathan
The key with the PWMPAL is that it used Word (16-bit) values, but serial communication is with bytes.· What this means is that we have to split the word variable into two bytes for serial transmission to the PWMPAL.· Lucky for us, PBASIC makes this pretty simple with LOWBYTE and HIGHBYTE -- these are the constituent portions of a Word variable.· Chapter 4 in the PBASIC manual covers variables and you may want to review this as well, it will help.
You can use use the Windows calculator for fixed values -- and convert to hex so you can see the high and low bytes.· The key to remember is that transmission is low byte, then high byte, so if you get $0320 from the Windows calculator the order in the SEROUT block is going to be $20, then $03.
It will also be helpful for you to post the program(s) that is giving you trouble.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
2. In general, are the specifications of the type of information sent, i.e. Binary, Decimal, or Hex? If so, how do you know which type to send when?
Another questions about commands to and from the PWMPal: (based on sample commands found in PWMPAL documentation, downloaded from the Parallax website)
3. When using the "SS" command to set motor control/status, how is the status byte determined? The documentation gives this example:
"SEROUT 0, 6, [noparse][[/noparse]"!PWMSS", %00010000]
The example above enables PWM output channel 1 (P12). The PWM output will begin immediately with the frequency and duty cycle as set with the "Mn" command." And gives the table Control/Status Byte Definitions Table. If you convert that Binary number to a decimal number you get 16.
How do you use the numbers in the table to translate to a status byte to send to the PWMPAL?
4.If you wanted to put PWM output channel 1 (P12) to hardware control, how would you set control channel 1 (P8) high?
Post Edited (Casey_SCU) : 7/10/2006 10:33:27 PM GMT