Control DC motor speed via joystick
Woei Wen
Posts: 5
I am using the BS2SX controller and have a variable resistor joystick. I like to use the voltage output from the joystick to control the motor speed and direction of a wheel chair. I wonder if I need to gather any hardwares to faciliate the operation. In addition, I wonder if this could be done or I need another controller chip.
Comments
You can use the RCTIME command (see the Help file in the programming environment) to read the joystick directly. Or you can add an A-to-D converter and read the joystick position that way.
You will also need some sort of motor controller (perhaps the HB25 or another DC motor driver) to allow the Stamp to control the motor. You may also be able to use the PWM capabilities of the Stamp to drive the motors via a high current transistor.
Cheers,
Make R5 the joystick pot. and make R4 and R6 the same value as the joystick pot. Feed the output into the motor driver.
Or you can make the BS2 control a digipot as R5
Slide 1 and 2 shows different value when shift from centre to left.
Slide 3 shows correct value when shift from centre to right.
Or, measure the resistance of the joystick pot from center terminal to left and right terminals while the stick is in known positions.
From the code, it looks like you've got WORD variables, so that should be ok.
Temporarily modifiy your code to read the a/d and put the results on a DEBUG screen. Let us know what you see.
Also, we are puzzled that the result0 binary data is not the same though there are the same variable in Slide 1. Apparently, the last 7 values are removed.
You don't say what a/d you're using, but I assume you have checked that the configuration nibble is right as you switch from ch0 to ch1.
Run the a/d reading loop and show only result0, result1 in DEC, when the stick is centered, half-way left, half way right, full left and full right. Don't add or subtract or manipulate anything, just show the raw values.
Let me know if if I am right about this
What you may need to do is have result0,result1,result2,result3
I have had to this if you want to hold a value
You should also you a different channel for each half of the pot this should work find ( | ) = pins
pot control
channel0>|^|<2.5 volts>|^| <channel1
I hope this help