Shop OBEX P1 Docs P2 Docs Learn Events
joystick and dc motor? — Parallax Forums

joystick and dc motor?

mikeyhzmikeyhz Posts: 16
edited 2010-09-29 10:10 in BASIC Stamp
hey there,is it possible to control a dc motor through an h-bridge with an analog joystick using a bs2e and pwmpal?.if it is,how do ya do it?.i have had my motors running using push buttons,bs2e and pwmpal(slowly making progress) but really want to use a joystick.any help would be great,cheers.

Comments

  • stamptrolstamptrol Posts: 1,731
    edited 2010-09-28 04:47
    No problem. Show us what you've done so far in terms of wiring and programming and I'm sure you'll get some help.
    Basically, you could read the joystick pots with RCTIME then send the proper signals to the h-bridges.
  • mikeyhzmikeyhz Posts: 16
    edited 2010-09-28 13:35
    sorry i dont have a camera to take pics of my set up but i have two large gear motors from a mobility scooter (i think) and what i am using for an h-bridge is the osmc board http://www.robotpower.com/products/osmc_info.html[/URL]i have ahi/bhi(osmc) set high permanently during running of osmc,set disable pin(osmc) low to enable the board and alternate pwm on ali/bli pins(osmc).i have two push buttons hooked to bs2e pins 8 and 9 as hardware control for pwmpal pins 13 and 14.my code is basically the parallax example modified with what i could understand and grasp from the documentation.dont yet fully understand pwmpal but am making some progress and will continue to read.i did have a go at rctime and a joystick last night working through parallax examples but dont know how to apply my readings to h-bridges. i hope i have given enough information.
  • stamptrolstamptrol Posts: 1,731
    edited 2010-09-29 10:10
    I had a brief look at your docs. The motor controller expects the PWM signal to come from the microcontroller ( or PWMPAL, in your case).

    I've only used PWMPAL a couple of times with only mediocre results. Anyway, basically you tell the PWMPAL what output you want then it does its thing until you change the settings.

    If you're have trouble getting the whole thing to work together, I'd suggest doing it in three parts:

    Step 1: Set up a program to read the joysticks properly. Write a program to read two sticks (or both directions of a single stick, if thats what you're going to use). Just put the number on the DEBUG screen. Make a note of the numbers generated when the stick is neutral, full left, full right.

    Step two, get the Stamp to use its own PWM command to talk directly to the motor controller. This will be a short program that does not need the PWMPAL chip. See the Stamp Helpfile under PWM. Just a short loop that repeatedly puts out some level of PWM. Try a couple of settings, maybe slow, stop, fast.

    Step 3: Combine the two program pieces so when you move the joystick the motor does what you expect. Likely you'll have to multiply or divide the joystick number to get it to a range that the PWM command can send to the motor controller.

    Now that you know all parts are working try the PWMPAL chip. At this point the subroutines in the program you attached may be useful.
Sign In or Register to comment.