Shop OBEX P1 Docs P2 Docs Learn Events
Control DC motor speed via joystick — Parallax Forums

Control DC motor speed via joystick

Woei WenWoei Wen Posts: 5
edited 2010-11-14 11:47 in BASIC Stamp
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

  • stamptrolstamptrol Posts: 1,731
    edited 2010-11-02 06:10
    You have a number of options.

    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,
  • CampeckCampeck Posts: 111
    edited 2010-11-02 12:41
    You also have the option to not use a ucontroller at all!

    attachment.php?attachmentid=74929&stc=1&d=1288726245

    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
  • ercoerco Posts: 20,244
    edited 2010-11-04 14:23
  • Woei WenWoei Wen Posts: 5
    edited 2010-11-11 02:02
    After installing the joystick to the Basic stamp, I have difficulties to gather the correct value from the readout. Attached is the Basic stamp code and its output response. When the joy stick is shift from left to right, the value gather is not linear. It is only linear from centre to right. From centre to left, the value gather seems strange. Instead of decreasing, it looks like random.
    Slide 1 and 2 shows different value when shift from centre to left.
    Slide 3 shows correct value when shift from centre to right.
  • stamptrolstamptrol Posts: 1,731
    edited 2010-11-11 09:24
    When measured with a voltmeter, do the input voltages of the a/d operate as expected?

    Or, measure the resistance of the joystick pot from center terminal to left and right terminals while the stick is in known positions.
  • Woei WenWoei Wen Posts: 5
    edited 2010-11-12 08:54
    The voltage from the multimeter shows correct voltage. When the joystick is shifted left, it shows 0 to 2.5v while towards right shows 2.5 to 5v. However, I am still unable to decode and use the data collect in the stamp code variable result0. It is 12 binary and how could I use its value to achieve my outcome. I am unable to pull the value between 0 to 2.5v and use it to activate my motor speed. For the value between 2.5 and 5v, I have not problem by substracting the value by 2.5v and then use it to set my motor speed.
  • stamptrolstamptrol Posts: 1,731
    edited 2010-11-12 11:54
    It sounds like the hardware is OK, so it has to be a software issue.

    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.
  • Woei WenWoei Wen Posts: 5
    edited 2010-11-13 05:02
    Slide 1 shows the Debug results when the joystick is towards the left while Slide 2 shows the Debug results when the joystick is push towards the right. From the same code, the reading when the joystick is push towards the right is what we like to get.

    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.
    1500 x 1200 - 174K
    1500 x 1200 - 175K
  • stamptrolstamptrol Posts: 1,731
    edited 2010-11-13 16:21
    Sorry, still not seeing the problem. The mix of BIN and DEC doesn't help.

    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.
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2010-11-14 11:47
    I think I understand what he want to is to have a value that is the same one each side of center
    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
Sign In or Register to comment.