Shop OBEX P1 Docs P2 Docs Learn Events
Another Motor Control problem — Parallax Forums

Another Motor Control problem

DrewDrew Posts: 9
edited 2004-12-08 21:36 in BASIC Stamp
Im using the L298 motor controller hoping to program a minesweeping robot.· Im in the beginning·phases, so im trying to get simple things like 'motion of my wheels' working.··I can get my wheels to move both forward and·backwards, but in attempting to·have them 'stop' after a given amount of time,·doesnt seem to work.· The wheels·keep moving.· I was using the source code given on the robotics v20 guide (page 111), and i edited it to match my motor controller configuration.·

FOR counter = 1 TO 122 ' Clockwise just under 3 seconds.
PULSOUT 12, 650 'Pin 12 connected to forward on motor controller
PAUSE 20
NEXT
FOR counter = 1 TO 40 ' Stop one second.
PULSOUT 12, 750
PAUSE 20
NEXT
FOR counter = 1 TO 122 ' Counterclockwise three seconds.
PULSOUT 13,·650 'Pin 13·connected to Backwards on motor controller
PAUSE 20
NEXT
END

Should i use the robotics v20 as an outline for my robot, or is their another guide i should use.


Here is a link to my motor controller:
http://www.hvwtech.com/downloads/manuals/L298%20Kit%20Manual%20v31.pdf

And here is the link to the robotics guide ive been using.·
http://www.parallax.com/dl/docs/books/edu/RoboticsV20.pdf

Regards,

Drew

·

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-11-10 14:43
    I think the problem is that you're trying to use code intended to control servos to drive DC motors -- this won't work. You can get an idea about driving a DC motor from our NX-1000-24/40 documentation (you'll have to adapt the code though).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • mikeslaneymikeslaney Posts: 17
    edited 2004-12-08 20:20
    I'm not sure what you mean by adapt the code. Where is the code actually controlling the speed on pages 17 - 19?. Are there different commands for the nx1000?. Is there a cross reference to BS2sx? The code in the manual just confuses me.
    Is there an argument in PWM to keep it constant?
  • mikeslaneymikeslaney Posts: 17
    edited 2004-12-08 21:36
    Here's something I found on another site. http://members.tripod.com/~divelec/pwm1mtr.html
    I had to debug line by line just to get what I wanted. Here's what I cut out just to control one motor. It will PWM a motor and enable one to adjust the speed. Pretty neat.
    I still don't understand though, that is the real issue.

    NOW, what I want to do is control it with a pot. RCTIME perhaps?

    ' {$STAMP BS2sx}
    '
    Define Constants & Variables
    pwmpin5 CON 5

    cycles VAR Byte: cycles = 10
    neutral VAR Byte: neutral = 180 'pwm value for 3.0V out
    full_fwd VAR Byte: full_fwd = 180 'pwm value for 3.5V out
    x VAR Byte: x = 0 'counter variable
    pause_time VAR Word: pause_time = 250 'pause between counter increments


    PWM pwmpin5,neutral,cycles 'bring voltage up to 3.0V (neutral)
    runmotor:
    FOR x = neutral TO full_fwd
    DEBUG ?x
    PWM pwmpin5,x,cycles
    PAUSE pause_time
    NEXT
    RETURN
Sign In or Register to comment.