potentiometer throttle
FRC2370
Posts: 128
On my go-kart robot thingy (don't have a name yet) I'm trying to have a foot operated throttle pedal to drive the motors. How would I have a potentiometer rigged up to a pedal?
Comments
Here are two methods.
http://www.arcade-museum.com/manuals-videogames/P/Pole_Position_TM218_7th_Printing.pdf
http://www.arcade-museum.com/manuals-videogames/G/GrandChampion.pdf
I also thought I saw one of these type of things at MPJA. I'll look around and try to find a link.
Here's a Roland pedal. There are more on Google.
Here are some more options:
http://www.amazon.com/SE-Switch-Flexible-Grinder-972FSG/dp/B000VV4SDS/ref=sr_1_5?ie=UTF8&qid=1356927781&sr=8-5&keywords=pedal+switch
http://www.amazon.com/HDE®-Video-Game-Racing-Foot-Pedal/dp/B0098PLPOI/ref=sr_1_12?ie=UTF8&qid=1356927781&sr=8-12&keywords=pedal+switch
http://www.amazon.com/Sewing-Machine-Control-Pedal-J00360051/dp/B0038RGE9S/ref=sr_1_16?ie=UTF8&qid=1356927781&sr=8-16&keywords=pedal+switch
Perhaps a COTS " Pot Box " is safe way to go ?
Curtis makes them for EV conversions and are about 50 USD if you look around.
http://images.search.yahoo.com/search/images;_ylt=A0oGdUPOFuFQTjEAJxNXNyoA?p=curtis+potbox&fr=moz35&fr2=piv-web
http://www.electroauto.com/catalog/potbox.shtml
( curtis also makes all in one foot pedles too that you can just mount and wire .
Like this one.
http://www.amazon.com/HDE®-Video-Game-Racing-Foot-Pedal/dp/B0098PLPOI/ref=sr_1_12?ie=UTF8&qid=1356927781&sr=8-12&keywords=pedal+switch
Of course anything can be made to have a USB connection by adding a microcontroller with a USB interface.
I'm pretty sure any USB2 port will read a USB1 device.
IIRC, the PS/2 to USB adapters are only electrical, not programatical. So, they only work on devices that have built in support for the USB protocol (which older and custom devices are not likely to have).
Short answer no.
The mice and keyboards that can use those adapters (generally USB to PS/2) detect which type of signal they're connected and make the change in protocol internally.
You could make a PS/2 to USB adaptor but it would have enough brains to convert the protocols. I'm counting on others to correct me if I'm wrong. Not too hard if you can get by with a serial connection through a FTDI adapter.
I don't know if a Basic Stamp would be able to read the PS/2 signal but a Propeller could do this. One of the many Propeller boards with a USB connection should be able to be used as a converter. I thin a QuickStart would be your least expensive option. The new Propeller project board would also be a good choice.
You won't know until you try it out.
A QuickStart costs $25. You'll proably want a PS/2 connector if you don't want to cut the pedal's wire. You might be able to salvage a PS/2 connector from an old PC or you could buy the connector from Parallax, SparkFun, etc. You'll also need a couple of resistors for the PS/2 bus.
You can power the QuickStart with 5V and my guess is it will draw around 50mA. I don't know how much current your pedals will draw but they probably need 5V power.
I'd start with a keyboard demo to see how to read the PS/2 line. I'm not sure, but I think there's a keyboard demo that displays to a serial terminal. (Edit: The demo uses a TV object. I'll attach a serial version in a soon to be made post.) You'll need both a PS/2 object and a serial object (such as Parallax Serial Terminal (PST) or FullDuplexSerial (there are lots of others)). You'd use this same serial object to send your data to the PC in your final program.
I think the main unknown is what kind of data the pedals send. You could just print (I'd use the hexadecimal value ("hex" method in the serial objects)) whatever data comes out of them to the terminal to see what the codes are.
The Propeller is a great (IMO best) microcontroller for robotics. This would be a great reason to start learning how to use it. People are really helpful on the Propeller forum so you can easily get help if you have trouble.
It was very simple to change it to use the object "Parallax Serial Terminal".
I also added a "$" to the hexidecimal displayed and added a constant "CODES_PER_LINE" to let you easily change how many codes to display on a line.
Here's the code:
Warning, I haven't tested this code myself. I'll do so once I find my PS/2 keyboard (probably tomorrow).
The code example sends the PS/2 data to the PC. Instead of having it displayed in a terminal program you could have your control program receive it and take appropriate action based on the incoming code.
You might want the Propeller to add some additional formatting aids and delimiters to make it easier for the PC program to use the data. For example, you may want to add carriage returns to the end of a transmission or add commas or tabs between data fields.
I lot will depend on how the PC program whats the data formatted.
#include <SPI.h>
#include <Ethernet.h>
#include <RobotOpen.h>
/* I/O Setup */
USBJoystick usb1('0'); // Assign the logitech USBJoystick object to bundle 0
void setup()
{
/* Initiate comms */
RobotOpen.begin();
}
/* This is your primary robot loop - all of your code
* should live here that allows the robot to operate
*/
void enabled() {
// Constantly update PWM values with joystick values
int leftDrive = usb1.makePWM(ANALOG_RIGHTY, INVERT) - (127 - usb1.makePWM(ANALOG_RIGHTX, NORMAL));
int rightDrive = usb1.makePWM(ANALOG_RIGHTY, INVERT) + (127 - usb1.makePWM(ANALOG_RIGHTX, NORMAL));
if (leftDrive > 255)
leftDrive = 255;
else if (leftDrive < 0)
leftDrive = 0;
if (rightDrive > 255)
rightDrive = 255;
else if (rightDrive < 0)
rightDrive = 0;
RobotOpen.setPWM(SIDECAR_PWM1, 255 - leftDrive);
RobotOpen.setPWM(SIDECAR_PWM2, rightDrive);
}
/* This is called while the robot is disabled
* You must make sure to set all of your outputs
* to safe/disable values here
*/
void disabled() {
// PWMs are automatically disabled
}
/* This loop ALWAYS runs - only place code here that can run during a disabled state
* This is also a good spot to put driver station publish code
* You can use either publishAnalog, publishDigital, publishByte, publishShort, or publishLong
* Specify a bundle ID with a single character (a-z, A-Z, 0-9) - Just make sure not to use the same twice!
*/
void timedtasks() {
RobotOpen.publishAnalog(ANALOG0, 'A'); // Bundle A
RobotOpen.publishAnalog(ANALOG1, 'B'); // Bundle B
RobotOpen.publishAnalog(ANALOG2, 'C'); // Bundle C
RobotOpen.publishAnalog(ANALOG3, 'D'); // Bundle D
RobotOpen.publishAnalog(ANALOG4, 'E'); // Bundle E
RobotOpen.publishAnalog(ANALOG5, 'F'); // Bundle F
}
/* This is the main program loop that keeps comms operational
* There's no need to touch anything here!!!
*/
void loop() {
RobotOpen.pollDS();
if (RobotOpen.enabled())
enabled();
else
disabled();
timedtasks();
RobotOpen.outgoingDS();
}
And the driver station application waits for a signal from the USB port. So all I need the Propeller to do is translate the PS/2 protocol to USB. Thats do-able right? And its being sent to the USB on an Android based device if that helps