I am making an autonomous car and wanted to be able to switch it to RC easily.· Is there a way·I can skip the RC radio entirely and program the BS2 to pick up signals and interpret them for the ESC and servo?
No, the BASIC Stamp is a microcontroller, not a radio receiver. You need the RC radio·reciever to decode the RF signals from your transmitter. You can use PULSIN to decode the receiver outputs.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ Jon Williams
Applications Engineer, Parallax
Dallas Office
If your RC controller has toggle switches and a joy stick (a la airplane controlers), you can pulse in one of the switches and the radio control for direction. This way, you could check for the switch, and determine each iteration if your doing a programmed set of instructions or if your doing something from the remote. This does mean that you can't interupt the "program" except at the top of each loop....
psuedo code (C++ style) for what I'm talking about would be
The PBasic code would be a lot longer, as you'd have to read the "switch" pin (which would probably be a pulsin), decide if the remote is "on" or if the bot should execute coded actions, pulsin the joystick and pulsout the results. I'm currently looking at doing something similar to what is above, I just need the proper connector for the rc remote (female, female three pin (servo style) conectors). Unfortunatly I haven't had time to go to the hobby shop or Radio Shack. keep me updated.
This is exactly what we do with our R/C airplane autopilots. We use the landing gear switch which outputs a 1-2 ms pulse depending on how it is switched. If it is on, then the Stamp reads the 2-axis accelerometer and flies the plane. If it is off, the signals are passed through the Stamp directly to the servos.
Circuit is the following:
R/C receiver => BS2-IC => All servos
but is also this:
Accelerometer => BS2-IC => All servos
The primary portion of code that switches between the two types of control is:
PULSIN Pin, gearInput
IF gearInput < 1200 THEN autonomous
IF gearInput > 1200 THEN manual
The manual section is simply a series of PULSIN and PULSOUT commands. As I recall, it was quite straightforward to read each of the many R/C airplane channels consecutively, either because the pulses were staggerred or missing every other one had minimal consequences.
It's really just a problem of getting the right connectors. The code is quite minimal.
I it seems the pulsin is always giving me zero on the data line... I'm reading using pulsin 10, 1000, joy1
and joy 1 is always equal to zero. The Black line (-) is tied to Vdd as I was avidesed to in an earlier thread, The red line (+) is not tied to anything and is unused. So, I commected the data line to an led, and the signal appears to never go high (no matter what I do with the stick.
Any idaes as to why the data line has no plse on it?
Your second parameter is wrong -- it should be 1 (for high pulse), not 1000. The BASIC Stamp is probably interpreting your command as 0 since bit zero of that value is not set.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ Jon Williams
Applications Engineer, Parallax
Dallas Office
The 'red' wire is supposed to power a Servo from the RC reciever. Since there is no actual
servo involved, the BS2 does not need a connection to this wire. It does need the signal
wire, of course, and the black wire to provide a ground reference for the signal wire.
I'll try that today, I though the second argument was how long to look... I've never needed to pulsin data before.
The question then becomes why didn't hooking it to an LED work? I exptected to see it "strob" the pulses from the remote. Maybe I also have a problem with my connection???
Since the signal is on-high for 1 mSec to 2 mSec, repeated every 20 to 50 mSec, you aren't going to be able to see an LED flash that short.
From experiments, you really need a flash of 50 mSec at LEAST to activate the receptors in your eye. I use 100 mSec if I want to see a brief flash. 2 mSec is way below your threshold of sight. A Logic Probe would stretch the pulse so you could see it on the Logic Probe's LED.
The LED probably is flashing, in reality. If you had a light sensor (probably not a CdS, I think they are too slow, too) looking at the LED, and looked at the output of the cell with an oscilloscope, you'd probably see the signal.
AHHhhh! Blimy... So, I fixed the code problem and played arround a bit, and it seems my connection isn't very tight but my debug code works. So, I think I need to look for wires with the proper connection at the ends instead of the make-shif juper wire I've kluged together.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
psuedo code (C++ style) for what I'm talking about would be
for(;[noparse];)[/noparse]
{
while(switch)
{
do(getJoystick());
}
f(); //some programed actions
}
The PBasic code would be a lot longer, as you'd have to read the "switch" pin (which would probably be a pulsin), decide if the remote is "on" or if the bot should execute coded actions, pulsin the joystick and pulsout the results. I'm currently looking at doing something similar to what is above, I just need the proper connector for the rc remote (female, female three pin (servo style) conectors). Unfortunatly I haven't had time to go to the hobby shop or Radio Shack. keep me updated.
This is exactly what we do with our R/C airplane autopilots. We use the landing gear switch which outputs a 1-2 ms pulse depending on how it is switched. If it is on, then the Stamp reads the 2-axis accelerometer and flies the plane. If it is off, the signals are passed through the Stamp directly to the servos.
Circuit is the following:
R/C receiver => BS2-IC => All servos
but is also this:
Accelerometer => BS2-IC => All servos
The primary portion of code that switches between the two types of control is:
PULSIN Pin, gearInput
IF gearInput < 1200 THEN autonomous
IF gearInput > 1200 THEN manual
The manual section is simply a series of PULSIN and PULSOUT commands. As I recall, it was quite straightforward to read each of the many R/C airplane channels consecutively, either because the pulses were staggerred or missing every other one had minimal consequences.
It's really just a problem of getting the right connectors. The code is quite minimal.
By the way, you can see a bit more of our R/C airplane projects including this one at: http://www.parallax.com/html_pages/resources/videolibrary/resources_product_videos.asp - scroll down in the page to the red airplane.
Ken Gracey
Parallax, Inc.
I it seems the pulsin is always giving me zero on the data line... I'm reading using pulsin 10, 1000, joy1
and joy 1 is always equal to zero. The Black line (-) is tied to Vdd as I was avidesed to in an earlier thread, The red line (+) is not tied to anything and is unused. So, I commected the data line to an led, and the signal appears to never go high (no matter what I do with the stick.
Any idaes as to why the data line has no plse on it?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
Terry
No -- the receiver has its own power supply; he just needs the pulse pin and a ground reference.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
The 'red' wire is supposed to power a Servo from the RC reciever. Since there is no actual
servo involved, the BS2 does not need a connection to this wire. It does need the signal
wire, of course, and the black wire to provide a ground reference for the signal wire.
The question then becomes why didn't hooking it to an LED work? I exptected to see it "strob" the pulses from the remote. Maybe I also have a problem with my connection???
From experiments, you really need a flash of 50 mSec at LEAST to activate the receptors in your eye. I use 100 mSec if I want to see a brief flash. 2 mSec is way below your threshold of sight. A Logic Probe would stretch the pulse so you could see it on the Logic Probe's LED.
The LED probably is flashing, in reality. If you had a light sensor (probably not a CdS, I think they are too slow, too) looking at the LED, and looked at the output of the cell with an oscilloscope, you'd probably see the signal.