Shop OBEX P1 Docs P2 Docs Learn Events
Bstamp with hb25 — Parallax Forums

Bstamp with hb25

joy1joy1 Posts: 32
edited 2014-01-20 22:47 in BASIC Stamp
Hello, I'm trying to hook up a linear actuator to a HB25 controller and switch....what I need is for the actuator to move out when the switch is on and in when the switch is off...the code I am putting below does not work well...when it does work it's "glichy" by not moving smoothly...and its inconsistent in when it works or doesn't (lots of time the switch is activated and nothing happens)

Any help would be appreciated

Here's the code:

' {$STAMP BS2}
' {$PBASIC 2.5}

'
[ Program Description ]

' This program works with one linear actuator hooked up to one motor controller
'The actuator moves out if "1" is seen and in if "0" is seen

'
[ I/O Definitions ]


linear PIN 1 'I/O Pin for linear actuator


'
[ Variables ]




'
[ Initialization ]

DO : LOOP UNTIL linear = 1 ' Wait For HB-25 Power Up
LOW linear ' Make I/O Pin Output/Low
PAUSE 5 ' Wait For HB-25 To Initialize
PULSOUT linear, 750 ' Stop linear actuator

'
[ Program Code ]

Main:
DO
IF (IN3 = 1) THEN

PULSOUT linear, 500 'moves linear actuator forward...linear actuator is extended.

PAUSE 400

ELSE
PULSOUT linear, 1000
PAUSE 20
ENDIF
LOOP

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-01-17 15:36
    You have a PAUSE 400 in your loop, which means that it would take the HB-25 at least 400 ms plus overhead to respond to the switch change. Depending on the speed of the actuator this could cause some issues. Also, by default the HB-25 does not require continuous pulses to keep going so really in a loop you need only test for the limit switch and any code that may cancel travel before simply sending a stop pulse. This would simplify the loop that handles this and remove any response delay.
  • joy1joy1 Posts: 32
    edited 2014-01-20 08:07
    What would this look like in code....I'm not sure what to do
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-01-20 22:47
    Does the linear actuator have one limit switch or two? There is generally one for each max range position, however you indicate only one in your existing code. Also, how are the switches wired? Active-high/low?
Sign In or Register to comment.