Shop OBEX P1 Docs P2 Docs Learn Events
Servo Pulse counter — Parallax Forums

Servo Pulse counter

Bob ABob A Posts: 10
edited 2005-09-17 22:35 in General Discussion
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

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-09-16 13:28
    Can't you do that is software?· Something like this (timing for BS2):

    · 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
  • Bob ABob A Posts: 10
    edited 2005-09-16 14:21
    I am absolutly not a computer person. The stamp is on a ship in the middle of a pond and is reachable only by radio control. also I need a servo pulse counter. Bob A
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-09-16 18:06
    I'm slow ... and just don't understand what you're asking so I'll try again.

    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
  • Bob ABob A Posts: 10
    edited 2005-09-16 20:14
    My Question is : if my ship is on the water and the board of education switch is·in #1 position how do I turn it·to step 2·so the stamp will do what it is supposed to do?·I physically need to·move the switch position with a servo. And then I need to be able to shut this switch off with a servo. ·The second question is a servo either produces a pulses or reads pulses , how do I measure the pulses ?···· Bob A
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-09-16 21:59
    I doubt you could move that switch with a small servo; better to remove the switch (kills your board warranty, so be careful) and replace it with something that you can move.

    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
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-09-16 22:28
    Bob,

    ·· 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
  • Bob ABob A Posts: 10
    edited 2005-09-17 02:34
    Here is the jist of what I am doing . I Have a battleship. It's 65" long 10" wide. This ship is a combat ship. Designed to shoot at and sink other ships. When I leave port the Boe is in the#1 position (standby)·so thet my right joy stick on the R/C is controling a spy camera on top of the fore coning tower. this camera can swing·left or right and aquire a target. upon aquiring the target I switch to #2 position ,·this is the alighn position which causes all cannon turrets to alighn on the same bearing as the camera. the camera trachs the target and the turrets follow the camera bearing while I shoot. ···after the engagement the switch is put bach into #1 (standby) the turrets return to nuteral position and I can still scan the pond for targets. If the battel is over I switch to the off position so nothing fires , nothing turns· and the camera is locked stright forward.· as for the servo setup my direction finder (camera) is set to turn 150 deg left and right on a servo direct. the servos driving the turrets are continous turn belt drive witg a 4" magazine turned by a 3/4" timing wheel on the servo . the servo controller needs to count pulses to alighn the turrets with the camera (gun director).········ Bob A
  • Ken GraceyKen Gracey Posts: 7,401
    edited 2005-09-17 03:39
    Bob,

    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.
  • Bob ABob A Posts: 10
    edited 2005-09-17 11:45
    In position 1 the camera is the only thing that moves so I am able to scan the area for targets. I do not want the cannons to follow all movements of the camera at this point. When I aquire a target I wish to go to positiom 2 and have all cannons alighn on this target that can alighn on it. there are 2 forward cannon turrets belted togeather, two rear turrets belted togeather, these turrets can only swing 155 deg port or starboard.·Here i am using continous drive servos. ·there are 6 smaller turrets , 3 on each side , 2 on each side faceing forward and 1 faceing aft. the smaller turrets are 2" in diam. and are belt driven by continous drive servos with .625 timing pully. these turrets can only turn one direction 155 deg. and then return to rest position. these turrets also should not turn unless there is a target in there cone of fire.· My biggest problem is to turn on and off the switch or move it from position 1 to 2 or from 2 to 1 or off.·After I have this problem resolved ,then on to bigger fish.············ Bob A
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-09-17 13:52
    Bob, I think you are making this out to be more difficult than it needs to be. For one question, as Chris pointed out, if you are driving the servo to switch the BOE switch, and that servo is being supplied by that switch, the servo has no power when the switch is in position 1 and hence cannot operate the switch. You are thinking about this mechanically when you should either be thinking electrically or software.

    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
  • Ken GraceyKen Gracey Posts: 7,401
    edited 2005-09-17 14:00
    Bob,

    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.

  • Bob ABob A Posts: 10
    edited 2005-09-17 14:10
    No to all . I already have a program wirtten by a programer ( for now) on servo control. I have a transmitter and a receiver. I have a 3 position switch on my transmitter to signel the receiver to turn on the 3 position switch on the boe. i flip the switch on the transmitter to 1 and it is supposed to activate a servo in the ship to turn on the boe switch . How do I make the physical connection between the servo and the boe switch. a mechanical link not a programming link. simple. The switch is to small for a person with parkensons to work with. Bob A
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-09-17 14:12
    Ken, am I reading his post correctly that the turret "continuous drive servos" are "continuous rotation servos"? If so the servo cannot be positioned by the standard pulse width method, he'd have to switch to standard servos to use your algorithm.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-09-17 14:31
    I am asuming by your discussion that the servo to activate the BOE switch is powered by the RC receiver.

    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
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-09-17 14:39
    Also I would use the electrical switch as a signal to the BOE rather than actually switching the servos on or off, when the BOE sees the switch is on, it knows to drive the servos in ganged mode, when the switch is off it returns them to the default position. With your mechanical setup (or RC switch controlling servo power), the servos will stop in thier last position, assumably the position of last firing, because once the power is cut to the turret servos, they stop, there is no way it can return to its forward position. But if the BOE was in control of the servos rather than the switch, it can direct the servos to point forwards once the switch is off.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10
  • Ken GraceyKen Gracey Posts: 7,401
    edited 2005-09-17 14:58
    Paul,

    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
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-09-17 15:13
    Yeah, there arent any prebuilt linkages for this type of control that Im aware of, all the RC people talk about using a servo with a microswitch, and microswitches require much less force to activate than the BOE switch will. Perhaps a heavy duty servo will be required for this ap.

    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
  • Washer MedicWasher Medic Posts: 39
    edited 2005-09-17 22:35
    I don’t know if this will help this is made by Du-Bro but it’s for a much larger switch then the boe has
    · DUB207.jpg
    It should be available through your local hobby shop you might also need
    DUB120.jpg

    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
Sign In or Register to comment.