Shop OBEX P1 Docs P2 Docs Learn Events
Digital Servos with Servo32 Library Problem — Parallax Forums

Digital Servos with Servo32 Library Problem

kaliatechkaliatech Posts: 5
edited 2008-12-08 00:32 in Propeller 1
I have an issue that I can not figure out, and as unlikely as it seems, I think it's related to differences between analog and digital servos. I'm using the following simple program below as the most basic test that still results in the issue. When this program is run with an analog servo connected it works as expected. (It moves servo back and forth every 3 seconds). However, when I connect a digital servo it severely stutters, often moving one or two ticks every few seconds...though randomly it jumps to much larger values. I can see no repeatable pattern except that it's simply not working as it should.

This test program is very similar to the Servo32v3_demo.spin included with the Servo32v3 library. The Servo32v2_demo program works fine with both types of servos. The main difference is that my test program sets a position and then waits and expects the server32 library to handle moving the servo to that position as fast as possible. The demo program loops through the range of positions for the servo (resulting in a controlled speed). From what I know of servos and can discern from the Servo32v2 library though, the test program should work fine, and it does with an analog servo.

CON
  _clkmode = xtal1 + pll16x                           
  _xinfreq = 5_000_000

  servoPin = 10

VAR

OBJ
  servoLib : "servo32v3"
  
PUB servoLibMoveAppMain

  
    servoLib.Set(servoPin, 1500)            
    servoLib.Start

    repeat

      waitcnt((clkfreq / 1_000 * 3000) + cnt)  ' 3 seconds
      servoLib.Set(servoPin, 1000)

      waitcnt((clkfreq / 1_000 * 3000) + cnt)  ' 3 seconds
      servoLib.Set(servoPin, 2000)




I have a more complex program that uses the same approach but with initialization and other routines. It's interesting that there seems to be a "delay" after initialization of the digital servos before they will start accepting positional values that I'm giving. (The same delay is not evident in the demo program though. I'm assuming it's the same thing... it doesn't work when a "far away" position is requested, but does start working when the position requests are more sequential? This is just a guess though.)

If anyone has ideas I'd be most appreciative.

(Fwiw, I'm attempting to build a higher level servo library in Spin that handle arbitrary acceleration/deacceleration periods for the servo movements. It's generally working, but the issue above is causing some unexpected problems with the digital servos.)

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-07 15:48
    I went through the servo32v3 code and I couldn't see anything that would explain what you're seeing. How are you powering the servos? I'm sure the current requirement pattern over time of a digital servo is different from an analog servo. Maybe that's contributing to the problem.
  • John R.John R. Posts: 1,376
    edited 2008-12-07 17:25
    FWIW:

    I have found that with my HiTech Digital Servos (HSR-5995-TG), as they come programmed from the factory (I do not have a programmer for them) the servos "ignore" pulse widths at either end of the range. In my case, the pulse must be between 1105 and 1895 mSec. (1000 and 2000 is "spec").

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John R.
    Click here to see my Nomad Build Log
  • kaliatechkaliatech Posts: 5
    edited 2008-12-07 17:38
    Mike Green said...
    How are you powering the servos?
    I had written out a reply explaining my power setup and how I was pretty sure it wasn't power related, especially since the demo program worked (as did mine when ramping positions up/down.) But then thought I better just double check things one more time because I knew power issues could cause all sorts unexpected wierdness. Lo and behold, my servo power line was showing 3.3v. I had connected the servo power to the 3.3v rail by mistake at some point rather than the intended 5v rail. Fixed that, and now everything works as expected. I can't tell you how much time I've spent trying to debug that. Thanks for suggesting I check power. I knew from reading a thousand posts like mine that servo problems are almost always power related. ...another lesson learned. blush.gif
    John R. said...
    I have found that with my HiTech Digital Servos...
    Great suggestion, though I ran in to that already and was aware of the shorter range. I've been wondering if it's possible reprogram the servos without buying the Hitec HMI programmer, but I haven't looked in to it yet myself. Not yet sure if I need the extended range yet, though would be nice to know it's an (inexpensive) option.
  • JasonDorieJasonDorie Posts: 1,930
    edited 2008-12-07 17:38
    Be aware that digital servos also draw more current than analog ones, so make sure you have a good power source, preferably one that is seperate from what's powering the prop. The demo app moving at a slower speed would draw much less juice, though I'm inclined to believe it's the pulse range problem.

    Jason
  • Capt. QuirkCapt. Quirk Posts: 872
    edited 2008-12-08 00:26
    Have you tried changing your "width" variable?, less may be better. Is there any serial devices?
  • kaliatechkaliatech Posts: 5
    edited 2008-12-08 00:32
    Just to clarify, I have resolved my problem per my last post above. It was a power issue. I was unknowingly and wrongly powering the servo with 3.3v instead of the intended 5v. After fixing that, everything is working as expected. Thanks for the response though.
Sign In or Register to comment.