Shop OBEX P1 Docs P2 Docs Learn Events
HB-25 controller via IR Help!! — Parallax Forums

HB-25 controller via IR Help!!

alpineralpiner Posts: 2
edited 2010-06-25 14:21 in Robotics
Hello everyone, pleased to meet you all, i'm a little newbie...and i'm a little stuck...and need some help, here it goes:
I little car, with 2 motors and a ball in front as third wheel. all good i used 2 HB-25 motor controllers for my 2 motors all good is working great. Down below is my program.
' {$STAMP BS2}
' {$PBASIC 2.5}
' -----[noparse][[/noparse] I/O Definitions ]-------------------------------------------------
HB25 PIN 15 ' I/O Pin For HB-25
' -----[noparse][[/noparse] Variables ]-------------------------------------------------------
index VAR Word ' Counter For Ramping
' -----[noparse][[/noparse] Initialization ]--------------------------------------------------
DO : LOOP UNTIL HB25 = 1 ' Wait For HB-25 Power Up
LOW HB25 ' Make I/O Pin Output/Low
PAUSE 5 ' Wait For HB-25 To Initialize
PULSOUT HB25, 750 ' Stop Motor 1
PAUSE 1 ' 1 mS Delay
PULSOUT HB25, 750 ' Stop Motor 2 (If Connected)
' The Above 2 Lines May Be Removed
' If You Are Using Single Mode
' -----[noparse][[/noparse] Program Code ]-------------------------------------------------
GOSUB Front
PAUSE 500
GOSUB Right
PAUSE 500
END

Front:
PAUSE 20 ' Wait 20 mS Before Ramping
FOR index = 0 TO 300 ' Ramp Up To Full Speed
PULSOUT HB25, 750 + index ' Motor 1 Forward
PAUSE 1 ' 1 mS Delay For Motor 2 Pulse
PULSOUT HB25, 750 - index ' Motor 2 Reverse
PAUSE 20 ' 20 mS Smoothing Delay
NEXT
PAUSE 1000 ' Wait 3 Seconds
FOR index = 300 TO 0 ' Ramp Back Down
PULSOUT HB25, 750 + index ' Motor 1 Forward Slowing
PAUSE 1 ' 1 mS Delay For Motor 2
PULSOUT HB25, 750 - index ' Motor 2 Reverse Slowing
PAUSE 20 ' 20 mS Smoothing Delay
NEXT
RETURN

Right:
PAUSE 20 ' Wait 20 mS Before Ramping
FOR index = 0 TO 0  ' Ramp Up To Full Speed
PULSOUT HB25, 0 + index ' Motor 1 Forward
PAUSE 1 ' 1 mS Delay For Motor 2 Pulse
PULSOUT HB25, 750 - index ' Motor 2 Reverse
PAUSE 20 ' 20 mS Smoothing Delay
NEXT
PAUSE 1000 ' Wait 3 Seconds
FOR index = 300 TO 0 ' Ramp Back Down
PULSOUT HB25, 0 + index ' Motor 1 Forward Slowing
PAUSE 1 ' 1 mS Delay For Motor 2
PULSOUT HB25, 750 - index ' Motor 2 Reverse Slowing
PAUSE 20 ' 20 mS Smoothing Delay
NEXT
RETURN



All good and fine....The problem is now, i put an IR and i'm trying make it work via IR. All good i made the circuit i runed a program and it works, but i want to make it like this: when i push the remotes button i want the motors to work as long as i keep the button pushed, not just push the button and work for 5 mS and stop and i have to push the button again. I would like to just keep the button pushed and as long as is pushed to just go in front for example, and when i take my finger off the button, the car to just stop.Down below is the program i used, if someone can tell me what to modify, or what to add, pls take yout time. Thanks.

'{$STAMP BS2}
'{$PBASIC 2.5}
time
VAR
Word(2)
' SONY TV remote variables.
DEBUG "Press and hold a digit key (1-4) or CH+/- and VOL+/-..."
FREQOUT 4, 2000, 3000 ' Start/reset indicator.
DO ' Beginning of main loop.
DO
' Wait for rest between messages.
PULSIN 9, 1, time(0)
LOOP UNTIL time(0) > 1000
PULSIN 9, 0, time(0)
PULSIN 9, 0, time(1)
' Measure/store data pulses.
' Decide which maneuver to execute depending on the combination
' of pulse durations stored in the first two pulse measurem
IF (time(1) < 500) AND (time(0) < 500) THEN
GOSUB Front
ELSEIF (time(1) < 500) AND (time(0) > 500) THEN
GOSUB Right
ENDIF
LOOP



This code is added to my first program.This second program is for boe bot and is working fine. the thing is i don't know what to add or delete from my sub to make it work. i hope you all understand. below is the all program:

'{$STAMP BS2}
'{$PBASIC 2.5}
time
VAR
Word(2)
' SONY TV remote variables.
DEBUG "Press and hold a digit key (1-4) or CH+/- and VOL+/-..."
FREQOUT 4, 2000, 3000 ' Start/reset indicator.
DO ' Beginning of main loop.
DO
' Wait for rest between messages.
PULSIN 9, 1, time(0)
LOOP UNTIL time(0) > 1000
PULSIN 9, 0, time(0)
PULSIN 9, 0, time(1)
' Measure/store data pulses.
' Decide which maneuver to execute depending on the combination
' of pulse durations stored in the first two pulse measurem
IF (time(1) < 500) AND (time(0) < 500) THEN
GOSUB Front
ELSEIF (time(1) < 500) AND (time(0) > 500) THEN
GOSUB Right
ENDIF
LOOP
' -----[noparse][[/noparse] I/O Definitions ]-------------------------------------------------
HB25 PIN 15 ' I/O Pin For HB-25
' -----[noparse][[/noparse] Variables ]-------------------------------------------------------
index VAR Word ' Counter For Ramping
' -----[noparse][[/noparse] Initialization ]--------------------------------------------------
DO : LOOP UNTIL HB25 = 1 ' Wait For HB-25 Power Up
LOW HB25 ' Make I/O Pin Output/Low
PAUSE 5 ' Wait For HB-25 To Initialize
PULSOUT HB25, 750 ' Stop Motor 1
PAUSE 1 ' 1 mS Delay
PULSOUT HB25, 750 ' Stop Motor 2 (If Connected)
' The Above 2 Lines May Be Removed
' If You Are Using Single Mode
' -----[noparse][[/noparse] Program Code ]-------------------------------------------------
GOSUB Front
PAUSE 500
GOSUB Right
PAUSE 500
END

Front:
PAUSE 20 ' Wait 20 mS Before Ramping
FOR index = 0 TO 300 ' Ramp Up To Full Speed
PULSOUT HB25, 750 + index ' Motor 1 Forward
PAUSE 1 ' 1 mS Delay For Motor 2 Pulse
PULSOUT HB25, 750 - index ' Motor 2 Reverse
PAUSE 20 ' 20 mS Smoothing Delay
NEXT
PAUSE 1000 ' Wait 3 Seconds
FOR index = 300 TO 0 ' Ramp Back Down
PULSOUT HB25, 750 + index ' Motor 1 Forward Slowing
PAUSE 1 ' 1 mS Delay For Motor 2
PULSOUT HB25, 750 - index ' Motor 2 Reverse Slowing
PAUSE 20 ' 20 mS Smoothing Delay
NEXT
RETURN

Right:
PAUSE 20 ' Wait 20 mS Before Ramping
FOR index = 0 TO 0  ' Ramp Up To Full Speed
PULSOUT HB25, 0 + index ' Motor 1 Forward
PAUSE 1 ' 1 mS Delay For Motor 2 Pulse
PULSOUT HB25, 750 - index ' Motor 2 Reverse
PAUSE 20 ' 20 mS Smoothing Delay
NEXT
PAUSE 1000 ' Wait 3 Seconds
FOR index = 300 TO 0 ' Ramp Back Down
PULSOUT HB25, 0 + index ' Motor 1 Forward Slowing
PAUSE 1 ' 1 mS Delay For Motor 2
PULSOUT HB25, 750 - index ' Motor 2 Reverse Slowing
PAUSE 20 ' 20 mS Smoothing Delay
NEXT
RETURN



I hope you can help me thanks again

Comments

  • FranklinFranklin Posts: 4,747
    edited 2010-06-25 04:19
    Depending on the ir remote it may be sending the code and then stoping after a couple of times through the code sent. This would be a function of the sending device not your code. Check out that possibility and let us know. If you have a digital camera you can look at the remote to see the IR led.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • alpineralpiner Posts: 2
    edited 2010-06-25 07:18
    the remote is from IR Remote for the Boe-Bot Parts Kit and Text
    http://www.parallax.com/StoreSearchResults/tabid/768/txtSearch/ir/List/0/SortField/4/ProductID/322/Default.aspx
    

    , and for the boe bot works good, i mean as long as i keep the button pushed it goes ahead and went i take the finger off the button it stops.
  • FranklinFranklin Posts: 4,747
    edited 2010-06-25 14:21
    I would try your boebot code and hook up the HB25s one to each pin as you do with the boebot servos.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
Sign In or Register to comment.