trouble with hb25 commands
joy1
Posts: 32
Hello,
I have hooked up one hb25 to a vacuum pump and another to a linear actuator. I'm having trouble with the code to get them to work properly
I will paste below...the issues I'm having are commented on in the code.
Any assistance would be greatly appreciated.
thanks
' =========================================================================
' File...... HB-25 Motor Test.bs2
' Purpose... Tests One Or Two HB-25's Connected To P15
' Author.... Parallax, Inc.
' E-mail.... support@parallax.com
' Updated... 01-18-2006
'
' {$STAMP BS2}
' {$PBASIC 2.5}
'
[ Program Description ]
' This program tests the HB-25 by waiting for it to power up, then pulsing
' the output to ramp the motors up in opposite directions, wait 3 seconds
' then ramp them back down to a stopped position. While the code is
' written for two HB-25/motors you can use it with just one by commenting
' out or removing the lines for the second motor, commented below. If you
' have two HB-25/motors connected, remember to remove the jumper block from
' the second HB-25.
'
[ I/O Definitions ]
pump PIN 15 ' I/O Pin For pump
linear PIN 1 'I/O Pin for linear actuator
'
[ Variables ]
index VAR Word ' Counter For Ramping
'two VAR Word
'
[ Initialization ]
DO : LOOP UNTIL pump = 1 ' Wait For HB-25 Power Up
LOW pump ' Make I/O Pin Output/Low
PAUSE 5 ' Wait For HB-25 To Initialize
PULSOUT pump, 750 ' Stop Motor 1
PAUSE 1 ' 1 mS Delay
PULSOUT linear, 750 ' Stop Motor 2 (If Connected)
' The Above 2 Lines May Be Removed
' If You Are Using Single Mode
'
[ Program Code ]
Main:
FOR index = 0 TO 100 'moves linear actuator forward
PULSOUT linear, 500 'linear actuator is extended.
PAUSE 20
NEXT
PAUSE 1000
FOR index = 0 TO 1 'Start pump **no matter what number I put for
PULSOUT pump, 1000 'duration, in this case 0 to 1, the
PAUSE 20 'outcome is the same where the pump stays on
NEXT 'until after the actuator is brought in.
PAUSE 1000 'I want to be able to control the vacuum pump so that
'what it picks up will be released when i want it to
FOR index = 0 TO 100 'bring actuator back to beginning position
PULSOUT linear, 1000
PAUSE 20
NEXT
PAUSE 1000
END
I have hooked up one hb25 to a vacuum pump and another to a linear actuator. I'm having trouble with the code to get them to work properly
I will paste below...the issues I'm having are commented on in the code.
Any assistance would be greatly appreciated.
thanks
' =========================================================================
' File...... HB-25 Motor Test.bs2
' Purpose... Tests One Or Two HB-25's Connected To P15
' Author.... Parallax, Inc.
' E-mail.... support@parallax.com
' Updated... 01-18-2006
'
' {$STAMP BS2}
' {$PBASIC 2.5}
'
[ Program Description ]
' This program tests the HB-25 by waiting for it to power up, then pulsing
' the output to ramp the motors up in opposite directions, wait 3 seconds
' then ramp them back down to a stopped position. While the code is
' written for two HB-25/motors you can use it with just one by commenting
' out or removing the lines for the second motor, commented below. If you
' have two HB-25/motors connected, remember to remove the jumper block from
' the second HB-25.
'
[ I/O Definitions ]
pump PIN 15 ' I/O Pin For pump
linear PIN 1 'I/O Pin for linear actuator
'
[ Variables ]
index VAR Word ' Counter For Ramping
'two VAR Word
'
[ Initialization ]
DO : LOOP UNTIL pump = 1 ' Wait For HB-25 Power Up
LOW pump ' Make I/O Pin Output/Low
PAUSE 5 ' Wait For HB-25 To Initialize
PULSOUT pump, 750 ' Stop Motor 1
PAUSE 1 ' 1 mS Delay
PULSOUT linear, 750 ' Stop Motor 2 (If Connected)
' The Above 2 Lines May Be Removed
' If You Are Using Single Mode
'
[ Program Code ]
Main:
FOR index = 0 TO 100 'moves linear actuator forward
PULSOUT linear, 500 'linear actuator is extended.
PAUSE 20
NEXT
PAUSE 1000
FOR index = 0 TO 1 'Start pump **no matter what number I put for
PULSOUT pump, 1000 'duration, in this case 0 to 1, the
PAUSE 20 'outcome is the same where the pump stays on
NEXT 'until after the actuator is brought in.
PAUSE 1000 'I want to be able to control the vacuum pump so that
'what it picks up will be released when i want it to
FOR index = 0 TO 100 'bring actuator back to beginning position
PULSOUT linear, 1000
PAUSE 20
NEXT
PAUSE 1000
END
Comments
Also, since the "pump" I/O is used for an input waiting for the HB25 to initialize as a logic HIGH, and then immediately your making it a logic LOW, you might want to place a current limiting resistor on the I/O pin (15 in your case) in case the HB25 and the BS2 I/O do not agree.
I've tried with anything from 1 to 100 or more in the "For index = 0 to 1"....the time the motor runs is always around 4 seconds
I will need some more time to go through the rest of your suggestions
thanks
EDIT: Have you tried them individually with any luck? Since the actuator portion works maybe comment it out to see what happens on with the pump.
The vacuum pump though, this just doesn't want to work properly...it shouldn't stay on long with a duration of 0 to1 but it does...any ideas?
yes i have...still did not change anything
From what I can see of your code this is what is happening:
1) wait for the HB-25 to turn on
2) make sure BOTH motors are OFF
3) move the actuator OUT
4) start pump
5) move actuator back in
6) End of program
Note: from what I gather, the idea is to keep the pump ON after the program stops? ... but with the current program, the pump shuts off at the end?
Note: taken from the BASIC Stamp Help for the "END" function
If the I/O pin is for the HB-25 the resistor is not needed. The HB-25 has an internal pull-up and the code is waiting for that line to go high so it knows when the HB-25 has been powered on and needs to be initialized. Making the line low won't hurt anything since the HB-25 has an input only. In fact, putting a resistor in series may cause the HB-25 not to work since it may never see a low on the input.
It looks to me like you're sending a pulse value of 1000 to start the motor and then expecting the motor to stop because you sent one pulse. But it doesn't work that way. You must send a 750 pulse to it so that the motor stops. Please let me know if this helps.
Also, ending the program can cause pulses on the I/O pins which may retrigger your HB-25. Try ending the code with a STOP or keep it in a loop.
I kinda started from the beginning and tried to make sense of everything from your suggestions; i don't know if my end code is exactly what you were telling me but, it works nicely now. I will post my code and if there is something you see that can make it better then let me know.
thanks again.
' ================================================== =======================
'Mr. C testing hb25 with pump and actuator
'
' {$STAMP BS2}
' {$PBASIC 2.5}
'
[ Program Description ]
' This program works with two hb25 controllers...one for a pump...one for a linear
'actuator. The actuator moves out, pump starts, then actuator moves back with object
'in suction cup.
'
[ I/O Definitions ]
pump PIN 15 ' I/O Pin For pump
linear PIN 1 'I/O Pin for linear actuator
'
[ Variables ]
index VAR Word ' Counter For Ramping
'two VAR Word
'
[ Initialization ]
DO : LOOP UNTIL pump = 1 ' Wait For HB-25 Power Up
LOW pump ' Make I/O Pin Output/Low
PAUSE 5 ' Wait For HB-25 To Initialize
PULSOUT pump, 750 ' Stop Motor 1
PAUSE 1 ' 1 mS Delay
PULSOUT linear, 750 ' Stop Motor 2 (If Connected)
'
[ Program Code ]
Main:
DO
IF (IN4 = 1) THEN
GOSUB move
ELSE
PULSOUT linear, 750
PULSOUT pump, 750
PAUSE 20
ENDIF
LOOP
move:
FOR index = 0 TO 100 'moves linear actuator forward
PULSOUT linear, 500 'linear actuator is extended.
PAUSE 20
NEXT
PAUSE 1000
PULSOUT pump, 1000 'Start pump
PAUSE 20
PAUSE 1000
FOR index = 0 TO 100 'bring actuator back to beginning position
PULSOUT linear, 1000
PAUSE 20
NEXT
PAUSE 1000
PULSOUT pump, 750 'Stop pump
PAUSE 20
PAUSE 1000
RETURN
As for what I suggested, yes, you now have the start and stop pulse values so the motor can stop and your code doesn't end so there are no glitches to cause the motor to become erratic.