Shop OBEX P1 Docs P2 Docs Learn Events
BS2 with SSC32 and 74hc165... servos jumpy — Parallax Forums

BS2 with SSC32 and 74hc165... servos jumpy

kleekrukleekru Posts: 32
edited 2009-09-11 05:05 in BASIC Stamp
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
·

Comments

  • W9GFOW9GFO Posts: 4,010
    edited 2009-09-09 06:40
    Do you have pull up or pull down resistors on your switches?

    Can you post a schematic?

    Rich H

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Servo Boss, a 12 channel servo tester kit from Gadget Gangster.
  • kleekrukleekru Posts: 32
    edited 2009-09-10 07:24
    Thanks for the reply Rich.· Here is my best shot at a picture/schematic.
    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
  • kleekrukleekru Posts: 32
    edited 2009-09-10 07:45
    Just to add to my note above, I just added a 10k resister to the clock pin and added "LOW Clock" to my initialization (This was suggested this on a separate thread regarding the 74HC165 and this seemed to help the other guy) but that did not help my situation. I have not tried adding any resistance to the switches yet. How would that help?
  • W9GFOW9GFO Posts: 4,010
    edited 2009-09-10 07:59
    kleekru said...
    However, they seem to "pulse" to their position with the rhthym of the do loop that checks for the shift register inputs.

    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
  • kleekrukleekru Posts: 32
    edited 2009-09-11 04:44
    I figured it was probably something like this... but I was led astray by connecting 3 servos directlty to my BS2 before I had the SSC32... and they moved smoothly and had the torque and speed I needed... of course I suspected I would have a power issue after doubling the servos and received some similar advice to get a better power supply... I promise to stop ignoring good advice. [noparse]:)[/noparse] Anyway, I found a 7.2V 3300 mA RC battery pack at Radio Shack but neglected to buy a charger (duh). Ultimately I need to power 6 servos at a time out of a total 12... which assuming the 1amp per servo, would this be a good pack to go with: http://www.all-battery.com/nicd6v5000mahbatterypackforemergencelight.aspx

    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
  • W9GFOW9GFO Posts: 4,010
    edited 2009-09-11 05:05
    Myself, I would just remove one cell out of that 7.2v pack and call it good. Very few servos are designed to run on more than 6 volts. Some, you aren't even supposed to run at more than 4.8v.

    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
Sign In or Register to comment.