BS2 with SSC32 and 74hc165... servos jumpy
kleekru
Posts: 32
Hello,
I have a BS2, a 74HC165 and an SSC 32 to control 12 servos·with·6 pedals that will actuate·up to 6 out of the 12 servos depending on how 24 switches are·flipped.· The good news is that I have·the BS2,·SSC32 and the Input register·attached and I have 4·servos·actuating based on my inputs.· The problem is that the servos are not actuating smoothly.· They seem to jump and jitter each time through the loop and it seems to be because I'm checking the inputs on the Input shift register.· I know there has to be a way to do what I want to do without the jumpiness but I'm at a loss on what I'm doing wrong.··· Also, the pins on the 74HC165 do not stay consistently on/off when there is no·switch attached... they bounce on and off randomly and that seems to cause the jumpiness on the servos.· I have not tried to attach a switch to each pin yet to see if that helps but I·suspect there is somethign else wrong.·
Can anyone provide some insight???· Help would be greatly appreciated.
·Here's the code I'm using (plagerized from several different locations):
' {$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.
'
[noparse][[/noparse] I/O Definitions ]
Clock PIN 0 ' shift clock (74HC165.2)
SerData PIN 1 ' serial data (74HC165.7)
Load PIN 2 ' output latch (74HC165.1)
'
[noparse][[/noparse] Constants ]
DelayTime CON 100
'
[noparse][[/noparse] Variables ]
switches VAR Byte ' switch data
'
[noparse][[/noparse] Initialization ]
Reset:
HIGH Load ' make output and high
DEBUG CLS,
"Switches 76543210", CR,
"
", CR,
"Status ........"
'
[noparse][[/noparse] 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,[noparse][[/noparse]"#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,[noparse][[/noparse]"#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,[noparse][[/noparse]"#0 P500 #1 P1400 #2 P1600 #3 P1400",13]
HIGH 13
HIGH 14
HIGH 12
ELSE
SEROUT 15,6,[noparse][[/noparse]"#0 P750 #1 P1500 #2 P1500 #3 P1500",13]
LOW 13
LOW 14
LOW 12
ENDIF
PAUSE DelayTime ' pad the loop a bit
LOOP
'
[noparse][[/noparse] Subroutines ]
Get_165:
PULSOUT Load, 1 ' load switch inputs
SHIFTIN SerData, Clock, MSBPRE, [noparse][[/noparse]switches] ' shift them in
RETURN
·
I have a BS2, a 74HC165 and an SSC 32 to control 12 servos·with·6 pedals that will actuate·up to 6 out of the 12 servos depending on how 24 switches are·flipped.· The good news is that I have·the BS2,·SSC32 and the Input register·attached and I have 4·servos·actuating based on my inputs.· The problem is that the servos are not actuating smoothly.· They seem to jump and jitter each time through the loop and it seems to be because I'm checking the inputs on the Input shift register.· I know there has to be a way to do what I want to do without the jumpiness but I'm at a loss on what I'm doing wrong.··· Also, the pins on the 74HC165 do not stay consistently on/off when there is no·switch attached... they bounce on and off randomly and that seems to cause the jumpiness on the servos.· I have not tried to attach a switch to each pin yet to see if that helps but I·suspect there is somethign else wrong.·
Can anyone provide some insight???· Help would be greatly appreciated.
·Here's the code I'm using (plagerized from several different locations):
' {$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.
'
[noparse][[/noparse] I/O Definitions ]
Clock PIN 0 ' shift clock (74HC165.2)
SerData PIN 1 ' serial data (74HC165.7)
Load PIN 2 ' output latch (74HC165.1)
'
[noparse][[/noparse] Constants ]
DelayTime CON 100
'
[noparse][[/noparse] Variables ]
switches VAR Byte ' switch data
'
[noparse][[/noparse] Initialization ]
Reset:
HIGH Load ' make output and high
DEBUG CLS,
"Switches 76543210", CR,
"
", CR,
"Status ........"
'
[noparse][[/noparse] 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,[noparse][[/noparse]"#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,[noparse][[/noparse]"#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,[noparse][[/noparse]"#0 P500 #1 P1400 #2 P1600 #3 P1400",13]
HIGH 13
HIGH 14
HIGH 12
ELSE
SEROUT 15,6,[noparse][[/noparse]"#0 P750 #1 P1500 #2 P1500 #3 P1500",13]
LOW 13
LOW 14
LOW 12
ENDIF
PAUSE DelayTime ' pad the loop a bit
LOOP
'
[noparse][[/noparse] Subroutines ]
Get_165:
PULSOUT Load, 1 ' load switch inputs
SHIFTIN SerData, Clock, MSBPRE, [noparse][[/noparse]switches] ' shift them in
RETURN
·
Comments
Can you post a schematic?
Rich H
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Servo Boss, a 12 channel servo tester kit from Gadget Gangster.
One of the switches (on pin 11) is a pedal.· The other switches are toggle on/off switches.· Therefore, when·push the pedal, depending on the position of the switches, the servos should actuate differently.· However, they seem to "pulse" to their position with the rhthym of the do loop that checks for the shift register inputs.· I'm hoping that this is not a limitation of shifting in the inputs from the 74HC165...· and I'm hoping more likely I'm making some rookie mistake somewhere.·
Any thoughts are greatly appreciated!
Thanks,
Kevin
First I was thinking that your inputs may be floating but I see you have pull ups on all the switches.
What you describe sounds like the servos are not getting a continuous 50 hz stream of pulses.
If the schematic accurately represents how you are powering both of the boards and the four servos then I think it is a good bet that you are browning out. As soon as the servos start to move they draw too much current, which causes the voltage to drop and the SSC to reset.
A 9v battery is not adequate for driving even a single servo under load, let alone four of them, and a micro-controller. You'll need to get a 6 volt power supply for the servos, the current capability of the power supply needs to be greater than the servos can draw. One amp per servo may be good enough but it depends on the servos and the loads they are under. I prefer to use a 5 cell battery pack made up of sub-c cells.
More than six volts to the servo will reduce their life, especially if they are under a load.
If you use a separate supply for the servos be sure to tie the grounds together. You'll want to move your 9v leads to VL and remove the jumper between VS1 and VL.
Rich H
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Servo Boss, a 12 channel servo tester kit from Gadget Gangster.
Post Edited (W9GFO) : 9/10/2009 8:15:24 AM GMT
Or, if I wanted to ensure a little more torque for the servos, would it be ok to use a voltage higher than 6.0?....
Thanks again! I hope this works.
Kevin
There are those who think 7.2 volts is fine. For light loads, maybe so. For regular or heavy loads I think you will significantly reduce the life and reliability if you run more volts than the servo is designed for.
Consider getting a good charger that can cycle and will tell you how much you put into the battery - something like this. You'll also need connectors, I use Deans.
Oh, you would also need a power supply.
Rich H
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Servo Boss, a 12 channel servo tester kit from Gadget Gangster.
Post Edited (W9GFO) : 9/11/2009 5:15:32 AM GMT