BS2 Lock up
kelly@ncwcom.com
Posts: 3
Hi
I have made a simple glue machine that just spins the part and turns the glue on and applies it to the piece as it rotates. It works fine except it locks up randomly. The system is quite simple, you press the button and it sends a series of pulses to a stepper controller to spin the part while at the same time it sends a pulse to strat the glue head. The speed and glue time can be adjusted be 2 front mounted push button variable resistors. Below is the code I use.
Any help on the lock ups would be greatly appreciated.
Kelly.
' {$STAMP BS2e}
'stepper test beta 1
Reset:
factor CON 2 'Pot -> speed factor
steps VAR Word 'number of steps per revolution
relay VAR Word 'glue head relay
POT VAR Word 'Result of RCTIME
speed VAR Word 'Calculated speed value
btnwrk VAR Byte
relay1 VAR Word 'adjusted glue relay
OUTPUT 11 'set step direction
HIGH 11
INPUT 10 'switch input
HIGH 10
OUTPUT 5 'stepper speed
LOW 5
OUTPUT 4 'relay output
LOW 4
Main:
HIGH 9 'Charge cap
PAUSE 1 'Discharge cap for 1ms
RCTIME 9,1,relay 'Measure discharge on P9
relay1 = relay / 1 'Adjust relay range
HIGH 2 'Charge cap
PAUSE 1 'Discharge cap for 1ms
RCTIME 2,1,POT 'Measure discharge on P2
PAUSE 1
speed = POT / 5 'adjusted motor speed
BUTTON 10,0,50,20,btnwrk,0,SKIP1 'Check button state and jump acordingly
HIGH 4 'turn the relay on
FOR steps = 0 TO 210 'start stepping count
PULSOUT 5, 4 'send step pulse out
PAUSE speed 'pause for variable miliseconds
IF relay1 >= steps THEN GoOn 'check step and relay count and jump accordingly
LOW 4 'turn relay off
GoOn:
NEXT 'count
'LOW 4 'turn relay off
GOTO Reset 'attempt to reset unit and avoid lockups. (didn't work)
SKIP1: 'main loop
GOTO Main 'loop
I have made a simple glue machine that just spins the part and turns the glue on and applies it to the piece as it rotates. It works fine except it locks up randomly. The system is quite simple, you press the button and it sends a series of pulses to a stepper controller to spin the part while at the same time it sends a pulse to strat the glue head. The speed and glue time can be adjusted be 2 front mounted push button variable resistors. Below is the code I use.
Any help on the lock ups would be greatly appreciated.
Kelly.
' {$STAMP BS2e}
'stepper test beta 1
Reset:
factor CON 2 'Pot -> speed factor
steps VAR Word 'number of steps per revolution
relay VAR Word 'glue head relay
POT VAR Word 'Result of RCTIME
speed VAR Word 'Calculated speed value
btnwrk VAR Byte
relay1 VAR Word 'adjusted glue relay
OUTPUT 11 'set step direction
HIGH 11
INPUT 10 'switch input
HIGH 10
OUTPUT 5 'stepper speed
LOW 5
OUTPUT 4 'relay output
LOW 4
Main:
HIGH 9 'Charge cap
PAUSE 1 'Discharge cap for 1ms
RCTIME 9,1,relay 'Measure discharge on P9
relay1 = relay / 1 'Adjust relay range
HIGH 2 'Charge cap
PAUSE 1 'Discharge cap for 1ms
RCTIME 2,1,POT 'Measure discharge on P2
PAUSE 1
speed = POT / 5 'adjusted motor speed
BUTTON 10,0,50,20,btnwrk,0,SKIP1 'Check button state and jump acordingly
HIGH 4 'turn the relay on
FOR steps = 0 TO 210 'start stepping count
PULSOUT 5, 4 'send step pulse out
PAUSE speed 'pause for variable miliseconds
IF relay1 >= steps THEN GoOn 'check step and relay count and jump accordingly
LOW 4 'turn relay off
GoOn:
NEXT 'count
'LOW 4 'turn relay off
GOTO Reset 'attempt to reset unit and avoid lockups. (didn't work)
SKIP1: 'main loop
GOTO Main 'loop
Comments
Hope this helps.
Kelly
What Mike said about the filtering is the issue. The PS is probably fine, but driving the relays directly from the stamp is dangerous to the stamp because of the back emf from the field collapse of the relay coil(s).
Take a look at this:
http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/vol1/col/nv6.pdf
(Stamp on Steroids)
You really need a driver of some kind and a diode to protect the stamp. Personally, I would stop using it until you add the driver circuit. You could smoke the stamp, instead of just locking it up.
Hope that helps,
Lloyd
Sorry, I didn't look to see if the super carrier board has relay drivers built in. If it does, forget what I said.
Lloyd
If you're using the 24V supply and a 7812 regulator, there will be a lot of heat produced in the 7812. Make sure you have an adequate heatsink. The glue relay will draw about 30mA. The Stamp will draw maybe 10-20mA more. The regulator will need to dissipate somewhere between 1/2 and 1W of heat, not a huge amount unless there's no heatsink.
Thanks
Kelly