Servo Pulse counter
Bob A
Posts: 10
Where do I obtain such a item ? and the cost.·next I wish to make the·off/1/2·switch on my board of education·to turn on with a servo. do I have to change the switch or is there a simpler way? this is in a R/C warship.··············· Bob A····
Comments
· SELECT state
·· ·CASE 0················· ' off -·servo left
··· · PULSOUT Servo, 500
·· ·CASE 1················· ' position 1 - servo center
··· · PUSLOUT Servo, 750
·· ·CASE 2················· ' position 2 - servo right
···· ·PULSOUT Servo, 1000
·· ·CASE ELSE
···· ·PULSOUT Servo, 500
· ENDSELECT
Of course, you need to run through this code every 20 milliseconds to refresh the servo (unless it's digital and remembers the last command).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Do you want to monitor a servo signal and do something with that?· You can -- use PULSIN.· Using BS2 timing, you could do something like this:
· PULSIN ServoChan, pWidth
· LOOKDOWN pWidth <[noparse][[/noparse]625, 875, $FFFF], switch
After this switch will hold 0, 1, or 2 depending on the servo pulse width (left, center, right).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Servos look for a pulse and move based on the width of that pulse. You can measure the control pulse coming from an RC receiver using PULSIN.
I strongly recommend you read our "What's A Microcontroller?" text (download the PDF from our web site) before you continue.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
·· There is possibly a logical flaw in your question, so I thought I would ask to confirm...Normally if you want to move the switch on the BOE from position 1 to position 2 it's because you want to enable power to your servos, which aren't energized in position one if they're plugged into the servo headers.· But if the servos aren't energized, how are you going to move the switch position from 1 to 2?· The only way would be a separately connected servo, but then what of the off position?· Can you please clarify?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
It sounds like you have a camera connected directly to your R/C receiver. And, you want the other servos to mimic the camera by rotating the same direction. I think you have a couple of fundamental issues to understand first, which would cause you to rethink the entire switch 1 / switch 2 position "problem". The switch can remain in position 2 depending on how you decide to program the BASIC Stamp.
I don't think you need to count any servo pulses, either. That's not going to do anything for you. All servos are receiving the same number of pulses, but the WIDTH of the pulse will vary between 1 and 2 ms. The width of the servo pulse determines the servo position. You will need to program the BASIC Stamp to generate pulses for the gun turrets, based on an input from the R/C receiver. In other words, the BASIC Stamp will sit between the R/C receiver and the turret servos.
First, can you explain the "turret" mechanics? Are you using continuous rotation servos on the belt drive? Can the guns move all the way around, or only 180 degrees?
Ken Gracey
Parallax, Inc.
Here is a primer on servos: servos have a position feedback in the system, using varying pulse widths the servo will move until it reaches the position corresponding to the pulse width. If the pulse width is 1ms the servo will be far left (or right depending on servo "handedness"), 1.5ms centered, 2ms far right (left). So knowing what the width of the pulse is all that is nessesary to gang multiple servos. Now here is your problem, continuous rotation servos are normal servos whose feedback loop has been cut. This means there is no way of knowing where the servo is unless you use and external mechanism such as an encoder, likewise you have no way of knowing what the ganged servo (turrets) position is either. You basically asking a bunch of blind gunners to do your shooting (and they are deaf too because they cannot communicate where they are pointing). This is a fundamental flaw to your setup, you either need to use standard servos, stepper motors, or an encoder on every servo. This must be addressed to get a system functional for your intended application.
There is more than one way to switch a servo on and off, one way is to override the signal sent to the servo. If you want them to be at a default centered position (this is assuming you use a standard servo instead of the continuous rotation servo you are presently using) you just need to send it a 1.5ms pulse every 20ms, this is the software approach. The electrical approach would be to install a electrically controlled switch (analog switch, mosfet, bjt, etc) to cut the power to the servo when not in use, this switch would be installed inline to the servo cable, same effect as what you are trying to do only it is a direct effect situation instead of the electrical->mechanical->electrical situation you've described.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
The way you explain the application I have concluded it is not about switching the BoE's switch between 0, 1 and 2. You need to program the BASIC Stamp on the BoE to make the decisions about where and when the turrets will be pointed.
If you want to achieve this project, you will need to read the servo control chapter in our What's a Microcontroller text. This will take an evening or two. I'll try to·describe how the project would be accomplished.
You need two channels from the R/C reciever to be connected to the BASIC Stamp as inputs. One channel is the camera servo, the other is a "trigger" such as CH5 or 6 (do you have one of those switches on the transmitter for landing gear, or something equivalent?). Four/five·additional pins on the BASIC Stamp will be connected to your servos. No servos will·be directly connected to your reeiver.
The BASIC Stamp would be programmed as follows.
Measure pulse for camera servo channel on I/O pin 1
Measure pulse for trigger channel on I/O pin 2
Relay camera servo pulse to camera servo on I/O pin 3
Pause for 15-20 ms
If the pulse of trigger channel is greater than 1.5 ms, continue in this program, else go to the top and start over
Send the camera servo pulse to turret 1 on I/O pin 4
Send the camera servo pulse to turret·2 on I/O pin 5
Send the camera servo pulse to turret·3 on I/O pin 6
<if the turrets are not aligned, do some math on the servo pulse value to make them aligned with target>
Goto start and do this all over again
Jon's code up top is a good start as a template, too.
Each of these lines of psuedo code is one to three lines of PBASIC. The program largely consists of using the PULSIN and PULSOUT commands. And your BoE will always be powered in position 2, where power is provided to servos and the BASIC Stamp at all times. This program isn't about switching the power switch, as best as I can tell.
Does that help?
Ken Gracey
Parallax, Inc.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
Your mechanical method is problematic all around, first your going to have problems designing a reliable mechanical linkage, second the throwing of the switch will require a fair amount of torque, basically the servo will have the same problems switching it as someone with parkinsons.
I think I undertsand the basic setup you are trying to accomplish, and I still think an electrical switch is best suited for this application. Just google "RC switch" and you'll get quite a few links to circuits that will turn off or on depending on a servo pulse signal.
Here are a few links I turned up:
http://www.rcgroups.com/forums/showthread.php?t=252543······················· 3rd post by PDK looks good.
http://www.tuug.fi/~isaarine/electronics/rc-switch/
http://www.rc-flysoft.com/··································································· Click on RC switch
http://www.teamdelta.com/products/prod2.htm
http://www.uoguelph.ca/~antoon/gadgets/rc-sw.htm
and the list goes on and on...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
By "continuous" I'm pretty sure he means the pulses are continuous. When he said the turret rotates 180 degrees, I felt he had standard servos. I don't think this will turn into a programming project for Bob, even if we wrote and debugged the code on this forum and he downloaded it to the Stamp.
He wants to switch the power switch with a servo, I guess. If that's the way it'll be, I'd drill a hole in the switch plastic and put a mini pull-rod into the middle of it.
Ken
As far as the mechanical switch is concerned, I would carefully drill a small hole in the BOE switch then affix a rod in the hole which passes through a hole in the servo horn, by correctly placing the servo, you may be able to switch the BOE switch. Modification to the hole in the servo horn may be required since the horn will move the rod in an arc, by elongating the hole in the servo horn, the rod will slide along the hole so that the arc motion is translated into a linear one. ·Though this will take a hugh amount of tweaking since the servo will need to start and stop at a certain angle and he has no control over what the actual pulses sent by the reciever are (and hence what those angles will be). I wish you luck in this adventure Bob, and I hope you can get it to work.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
Post Edited (Paul Baker) : 9/17/2005 3:16:53 PM GMT
·
It should be available through your local hobby shop you might also need
This is an override if your radio doesn’t have end point adjustments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
There's nothing a good wack with a hammer won't fix
Darn I let the white smoke out again