Digital Servos with Servo32 Library Problem
kaliatech
Posts: 5
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.
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.)
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
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
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.
Jason