stamp too slow?
I'm trying to use an r/c remote and reciever to control 2 wheelchair motors. i have 2 h-bridges made from 12 volt auto relays switched by the stamp and n-channel mosfets. everything worked ok on the desk switching 1 bridge so i installed everything on the project buggy (now 2 h-bridges) and when i hold the remote stick over the activate fwd for example the relay clicks on /off. everything acts like it should except the relays dont hold they keep clicking on/off. i was wondering if the stamp is too slow to read in 2 channels and run 8 relays(need a ninth for a safety shut off). any advice would be appreciated-mike
' {$STAMP BS2}
' {$PBASIC 2.5}
channel9 VAR Word
channel10 VAR Word
channel9 = 750
channel10 = 750
main:
receiver:
HIGH 0
LOW 1 'rev off
LOW 2 'rev off
LOW 3 'fwd off
LOW 4 'fwd off
LOW 5
LOW 6
LOW 7
LOW 8
DO
PULSIN 9,1,channel9 'read output from receiver channels "9" and "10"
PULSIN 10,1,channel10
DEBUG "channel9=",DEC ? channel9,CR 'display pusles for each channel in debug terminal
DEBUG HOME 'display range+/- 550-950
DEBUG "channel10=", DEC ? channel10,CR
IF channel9<400 THEN IF channel9>1100 THEN ' pin 0 can kill power to motors if radio signal is out of normal parameters
LOW 0 '
ENDIF '
IF channel10<400 THEN IF channel10>1100 THEN '
LOW 0 '
ENDIF
IF channel9>800 THEN 'fwd motor 1
GOSUB for1
ENDIF
IF channel9<700 THEN IF channel9>401 THEN 'bwd motor 1
GOSUB back1
ENDIF
IF channel9<=770 THEN IF channel9 >= 700 THEN 'deadstick range center position
GOSUB nogo
ENDIF
IF channel10<=770 THEN IF channel9 >= 700 THEN 'deadstick range center position
GOSUB nogo
ENDIF
IF channel10<700 THEN 'bwd motor 2
GOSUB back2
ENDIF
IF channel10>770 THEN 'fwd motor 2
GOSUB for2
ENDIF
LOOP
'-----------------------------------------------------------------------------------
for1:
LOW 2 'rev off
LOW 3 ' rev off
PAUSE 250
HIGH 1 'f on
HIGH 4 'f on
RETURN
back1:
LOW 1 'fwd off
LOW 4 'fwd off
PAUSE 250
HIGH 2 'b on
HIGH 3 'b on
RETURN
back2:
LOW 5 'f off
LOW 8 'f off
PAUSE 250
HIGH 6 'b on
HIGH 7 'b on
RETURN
for2:
LOW 6 'b off
LOW 7 'b off
PAUSE 250
HIGH 5 'f on
HIGH 8 'f on
RETURN
nogo:
LOW 1 'shut off all relays
LOW 2
LOW 3
LOW 4
LOW 5
LOW 6
LOW 7
LOW 8
RETURN

Comments
' {$STAMP BS2} ' {$PBASIC 2.5} 'full fwd is around 950 'deadstick is 750 'full reverse is around 550 channel9 VAR Word channel10 VAR Word 'channel11 VAR Word 'safety relay not used yet main: receiver: HIGH 0 'kill power relay ...safety not used yet LOW 1 'rev off motor 1 LOW 2 'rev off LOW 3 'fwd off LOW 4 'fwd off LOW 5 'motor 2 LOW 6 LOW 7 LOW 8 DO 'PULSIN 11,1,channel11 'DEBUG "channel9=",DEC ? channel9,CR 'display pusles for each channel in debug terminal 'DEBUG HOME 'display range+/- 550-950 'DEBUG "channel10=", DEC ? channel10,CR 'DEBUG "channel11=", DEC ? channel11,CR PULSIN 10,1,channel10 'read r/c reciever channel IF channel10>800 THEN 'fwd motor 2 GOSUB for2 ENDIF IF channel10<700 THEN 'bwd motor 2 GOSUB back2 ENDIF IF channel10 > 699 AND channel10 < 801 THEN 'if pulsin reads deadstick range 700-800...stop motor GOSUB nogo1 ENDIF PULSIN 9,1,channel9 'read r/c receiver channel IF channel9>800 THEN 'fwd motor 1 GOSUB for1 ENDIF IF channel9<700 THEN 'bwd motor 1 GOSUB back1 ENDIF IF channel9 > 699 AND channel9 < 801 THEN 'if pulsin reads deadstick range 700-800...stop motor GOSUB nogo2 ENDIF LOOP '----------------------------------------------------------------------------------- for1: LOW 2 'rev off LOW 3 ' rev off PAUSE 250 HIGH 1 'f on HIGH 4 'f on RETURN back1: LOW 1 'fwd off LOW 4 'fwd off PAUSE 250 HIGH 2 'b on HIGH 3 'b on RETURN back2: LOW 5 'f off LOW 8 'f off PAUSE 250 HIGH 6 'b on HIGH 7 'b on RETURN for2: LOW 6 'b off LOW 7 'b off PAUSE 250 HIGH 5 'f on HIGH 8 'f on RETURN nogo1: LOW 1 'shut off motor 1 relays LOW 2 LOW 3 LOW 4 RETURN nogo2: 'shut off motor 2 relays LOW 5 LOW 6 LOW 7 LOW 8 RETURN' {$STAMP BS2} ' {$PBASIC 2.5} ' Code follows this pinout. Adjust as needed. ' Pins 0 & 1 Left motor forward ' Pins 2 & 3 Left motor backwards ' Pins 4 & 5 Right motor forwards ' Pins 6 & 7 Right motor backwards ' Pin 8 Kill power LeftChannel VAR Word RightChannel VAR Word KillChannel VAR Word Initialize: HIGH 8 ' Set power on? GOSUB AllStop Main: DO PULSIN 11, 1, KillChannel ' if KillChannel then ? PULSIN 9, 1, LeftChannel IF LeftChannel < 700 THEN GOSUB LeftBack IF LeftChannel > 699 AND LeftChannel < 801 THEN GOSUB LeftStop IF LeftChannel > 800 THEN GOSUB LeftForward PULSIN 10, 1, RightChannel IF RightChannel < 700 THEN GOSUB RightBack IF RightChannel > 699 AND RightChannel < 801 THEN GOSUB RightStop IF RightChannel > 800 THEN GOSUB RightForward LOOP AllStop: OUTL = 0 ' Set pins 0 - 7 low RETURN LeftBack: LOW 0 ' Turn left forward off LOW 1 PAUSE 250 HIGH 2 ' Turn left backward on HIGH 3 RETURN LeftStop: OUTA = 0 ' Set pins 0 - 3 low RETURN LeftForward: LOW 2 LOW 3 PAUSE 250 HIGH 0 HIGH 1 RETURN RightBack: LOW 4 ' Turn right forward off LOW 5 PAUSE 250 HIGH 6 ' Turn right backward on HIGH 7 RETURN RightStop: OUTB = 0 ' Set pins 4 - 7 low RETURN RightForward: LOW 6 LOW 7 PAUSE 250 HIGH 4 HIGH 5 RETURNwhere do you find the info for things like outa to control only pins 0-3? i looked in the manual and help section and only found them on the reserved word list, but with no info about how to use them.
thanks again i appreciate your time and help.-mike