PWM Input
Hi
I am working on my first basic stamp project. I am using a BS2. I want to conect the servo outputs on my R/C radio reciever to my basic stamp read the
signal and and save the PWM servo signal to a variable and then send it back out through a different pin.
How would you do this.
Thanks in advanced
I am working on my first basic stamp project. I am using a BS2. I want to conect the servo outputs on my R/C radio reciever to my basic stamp read the
signal and and save the PWM servo signal to a variable and then send it back out through a different pin.
How would you do this.
Thanks in advanced
![yeah.gif](http://forums.parallax.com/images/smilies/yeah.gif)
Comments
-Martin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Martin Hebel
StampPlot - Graphical Data Acquisition and Control
AppBee -·2.4GHz Wireless Adapters & transceivers·for the BASIC Stamp & Other controllers·
So... you can do a PULSIN on the pin(s) connected to the receiver and you'll then have a Word sized value. You may need to scale that value for PULSOUT, using * or / or */. PULSOUT also has it's own units for depending on which Stamp you are using.
Is this helpful?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
So, you use PULSIN on the 'reciever' to measure the width of the command pulse. The result is a 16-bit integer "number of ticks" -- when the "number of ticks" varies depending on which BS2 family you're using. The 'plain' BS2 uses 2 uS for it's 'tick' size.
You then use PULSOUT to send a command pulse of the same size out to the servo. I believe the 'tick' size for both PULSIN and PULSOUT are the same -- both being 2 uSec for the 'plain' BS2.
You should probably start by going through the "What's a Microcontroller?" text...it's free and fun and provides a good foundation in basic digital electronics, the Stamp, and in ways to look at design challenges.
If all you really want to do is look at a single servo command and echo it back out, then my crystal ball is on the fritz again, and you can just follow Zoot's suggestions...
Time for caffeine...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Truly Understand the Fundamentals and the Path will be so much easier...
Post Edited (Tom Walker) : 1/11/2007 3:09:33 PM GMT
1. Recieve reciever inputs and save as variable.
2. Input ultrasonic data.
3. If ultrasonic shows object infront goto sub Auto control
else send reciever pulses to Motor Controller Outs.
The idea is that if you try to drive the robot into a wall or object with the controller the robot will go into auto mode
and turn arround once it has turned arround it will go back to manual mode.
Post Edited (computer guy) : 1/12/2007 6:35:24 AM GMT
With some external logic, you could make this happen. A quad NAND gate would do it. You would have two pins on the Stamp, one would let the servo pulses through if HIGH, inhibit them if LOW. The other would be idle if HIGH and would make a servo pulse if LOW (inverted pulses). The Stamp could just do the PINGs and inhibit the incoming servo control if the PING sensed something. The Stamp would have complete override control of the servos.
Both gates are NAND. The top input is the servo pass through control. The next down is the servo input. The next is the inverted servo override and the output is to the servo itself. A typical gate package would be the 74HC00. You'd need a total of 4 Stamp pins and two pairs of gates (one quad gate in package).
Post Edited (Mike Green) : 1/12/2007 7:12:01 AM GMT
although the speed of the basic stamp 2 might cause problems i am willing to lose a bit of accuracy by adjusting pauses between ping commands and things like that.
Post Edited (computer guy) : 1/12/2007 8:37:43 AM GMT
When you want the user to have control, make the stamp pins INPUTS. When an object is detected, make the stamp pins OUTPUTs and drive them to control the motors (this will override the R/C receiver signals).
Note that the R/C receiver outputs do not go into the stamp at all. If you want/need to monitor the signals they can be sensed on the motor control pins (as long as they are INPUTs).
In your diagram above you would:
··disconnect the line going to P0 and connect it to P5 through a 1K resistor.
· disconnect the line going to P1 and connect it to P6 through a 1K resistor.
And the code would go something like:
· 1) Make P5 and P6 inputs
· 2)·Measure PING distance
· 3) If distance is > limit then goto step 2
· 4) Make P5 and/or P6 OUTPUTs
· 5) Send pulses to P5 and/or P6 to auto control robot
· 6) Measure PING distance
· 7) If distance is < limit then goto step 5
· 8) goto step 1
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap used 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
SX-Video Display Modules www.sxvm.com
Stuff I'm selling on ebay http://search.ebay.com/_W0QQsassZhittconsultingQQhtZ-1
"USA Today has come out with a new survey - apparently, three out of every four people make up 75% of the population." - David Letterman
Post Edited (Bean (Hitt Consulting)) : 1/12/2007 12:51:21 PM GMT
I = 1
MAIN:
IF I = 1 THEN
PULSIN Chan1Pin, Chan1Val ' This will take up to 20 mSec
I = 0
ELSE
PULSIN Chan2Pin, Chan2Val ' This will take up to 20 mSec
I = 1
ENDIF
' OK, when here, we've gotten either Chan1Val or Chan2Val updated
' AND, we've waited our 20 mSec. So, go ahead and send
PULSOUT Serv1Pin, Chan1Val ' We update both every 20 mSec to hold positions.
PULSOUT Serv2Pin, Chan2Val
GOTO MAIN
What you describe has been done using HB-25 Motor Controllers (which we manufacture). I have checked to see what the refresh rate is to the controllers though. The HB-25 does not require refreshing like a servo even though it uses servo pulses.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
So far the robot has cost me about AU$700 and i havent built the chassis so yea about 2 - 3 years.
Thank you
If you are investing that much time and money, your should seriously consider switching over the Propeller. The BASIC Stamp is nice, but you are going to hit task limitations pretty quickly and I think you'd enjoy the power and the flexibility of the Propeller much more.
My 2 cents,
martin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Martin Hebel
StampPlot - Graphical Data Acquisition and Control
AppBee -·2.4GHz Wireless Adapters & transceivers·for the BASIC Stamp & Other controllers·
Thank you for your recomendation Martin
P.S because of the propeller logo i couldn't take it seriously. It just looks to kiddy.
Perhaps parallax will develop a propeller Board of education type board to replace the Propeller Education Kit that uses a bread board for the whole thing. ( www.parallax.com/detail.asp?product_id=32305 ).
Well, you'll need to get over your 'kiddy' impression of the logo.· Parallax is very playful, but extremely competent.· To many in industry, the BASIC Stamp is the kiddy, whereas the propeller is being seen as the powerful controller it truly is.
Soon a protoboard for the propeller is due to be released, and while it is solderboard, you can slap a couple small breadboards, like the BOE ones, or solder directly for a firm connection needed in robotics.· They board is expected to be around $25, plus another $29 for the programming interface, and it has an area for servo headers.
Don't get me wrong, I love the Stamp, but I know its limitations too, especially in the area of real time control.
-Martin
·
Thank you for pointing out the power of the propeller chip will definately use it in future projects.
I look forward to the release of the development board for it.