Hello all,
Well, it has been a little while but I have the SSC32 and I have a 74HC165 for my inputs. Thanks for the grid/matrix suggestion. I haven’t looked at it too closely because I seem to be set up with the input register chip. However,
I seem to be having 2 key problems.
- On the input register (74HC165)I do not yet have all of my switches installed so the lines without switches seem to jump on/off randomly. As long as I have a switch on the pin, it seems to work ok but could this be indicative of a problem?
- Although the logic seems sound (pushing a pedal is in fact actuating my servos differently depending on the switch settings attached through the 74HC165)… the servos are jumping and very jerky each time through the loop? My programming must not be right. How can I continue to check the status of my inputs yet only try to move the servos the first time? Anyway, here is my code (well, a good chunk of it is plagerized from various forums and websites… I’m not a programmer, can you tell?). The high and low calls directly to the BS2 inputs are for LED’s I’m using just to make sure the logic is sound:
’ {$STAMP BS2}
’ {$PBASIC 2.5}
’ This program demonstrates a simple method of turning three BASIC Stamp
’ I/O pins into eight digital inputs with a 74HC165 shift register.
’ ----- I/O Definitions ]-------------------------------------------------
Clock PIN 0 ’ shift clock (74HC165.2)
SerData PIN 1 ’ serial data (74HC165.7)
Load PIN 2 ’ output latch (74HC165.1)
’ ----- Constants ]-------------------------------------------------------
DelayTime CON 100
’ ----- Variables ]-------------------------------------------------------
switches VAR Byte ’ switch data
’ ----- Initialization ]--------------------------------------------------
Reset:
HIGH Load ’ make output and high
DEBUG CLS,
“Switches 76543210”, CR,
“-------- --------”, CR,
“Status …”
’ ----- Program Code ]----------------------------------------------------
Main:
DO
GOSUB Get_165 ’ get switch inputs
DEBUG CRSRXY, 9, 2, BIN8 switches ’ display current status
IF switches.BIT0 = 1 AND switches.BIT1=0 AND switches.BIT5=1 THEN
SEROUT 15,6,"#0 P850 #1 P1500 #2 P1500 #3 P1500",13]
LOW 13
LOW 14
HIGH 12
PAUSE 10
LOW 12
’ PAUSE 50
ELSEIF switches.BIT0 = 0 AND switches.BIT1=1 AND switches.BIT5=1 THEN
SEROUT 15,6,"#0 P750 #1 P1500 #2 P1500",13]
LOW 12
HIGH 14
HIGH 13
PAUSE 50
LOW 14
LOW 13
ELSEIF switches.BIT0=1 AND switches.BIT1=1 AND switches.BIT5=1 THEN
SEROUT 15,6,"#0 P500 #1 P1400 #2 P1600 #3 P1400",13]
HIGH 13
HIGH 14
HIGH 12
ELSE
SEROUT 15,6,"#0 P750 #1 P1500 #2 P1500 #3 P1500",13]
LOW 13
LOW 14
LOW 12
ENDIF
PAUSE DelayTime ' pad the loop a bit
LOOP
’ ----- Subroutines ]-----------------------------------------------------
Get_165:
PULSOUT Load, 1 ’ load switch inputs
SHIFTIN SerData, Clock, MSBPRE, [switches] ’ shift them in
RETURN
What do I need to do to keep my servos smooth without losing the ability to change reaction to my inputs quickly?
Any thoughts are helpful.