[Vm-dev] linux systems startup stuff for a servo controller daemon

David T. Lewis lewis at mail.msen.com
Fri Jan 12 00:15:40 UTC 2018


On Thu, Jan 11, 2018 at 12:44:35PM -0800, tim Rowledge wrote:
>  
> 
> > On 10-01-2018, at 7:53 PM, David T. Lewis <lewis at mail.msen.com> wrote:
> > 
> > From looking at the Makefile, I would say that the init script is being
> > installed but it has not been wired into the system boot processing.
> > Possibly the person who wrote the makefile left that part as an "exercise
> > for the reader???.
> 
> The odd thing is that it does appear to try to start on boot (but inevitably fails because pigpiod is not autostarted) and I see 
> 
> systemctl status pca9685servo
> ??? pca9685servo.service - LSB: Start/stop pca9685servod.
>    Loaded: loaded (/etc/init.d/pca9685servo; generated; vendor preset: enabled)
>    Active: inactive (dead)
> 

I'm pretty much shooting in the dark here, but it sounds like your pca9685servod
daemon depends on the pigpiod daemon, and maybe the former fails to start cleanly
if the latter has not previously been started. 

Maybe you just need to make sure that pigpiod is autostarted at boot time. Here
is a link that might help:

  https://www.raspberrypi.org/forums/viewtopic.php?f=32&t=103752

Dave


> 
> > 
> > Give this a try and see if it works: Reboot the Pi, at which point the servo
> > will not be working. Then run this command (possibly with sudo in front if
> > it if you are not root):
> > 
> > # /etc/init.d/pca9685servo start
> 
> This gets a bit odder seeming to me - 
> 
> pi at PiCamera-1:~ $ sudo /etc/init.d/pca9685servo start
> Device address = 0x40
> Requested servo cycle time:          20000.000us
> Pulse increment step size:    5.000us
> Setting prescale value to: 121
> Actual frequency:   50.029
> Actual cycle time: 19988.480us
> Minimum width value:        500.000us (100)
> Maximum width value:       2500.000us (500)
> 
> Setting prescale value to: 121
> pi at PiCamera-1:~ $ echo  0=70% > /dev/pca9685servo
> Raw width input = 70.000000
> % specified -> 0.700000
> set servo[0]=70.000000 %
> servo on: 0 off: 389
> 
> ??? but the servo doesn???t move.
> Another status check - 
> pi at PiCamera-1:~ $ systemctl status pca9685servo
> ??? pca9685servo.service - LSB: Start/stop pca9685servod.
>    Loaded: loaded (/etc/init.d/pca9685servo; generated; vendor preset: enabled)
>    Active: inactive (dead)
> 
> ps aux says there is only one pca daemon running.
> So let???s try stopping it ??? ok, no pca running anymore. Run it completely manually -
> pi at PiCamera-1:~ $ sudo /usr/local/sbin/pca9685servod Device address = 0x40
> Requested servo cycle time:          20000.000us
> Pulse increment step size:    5.000us
> Setting prescale value to: 121
> Actual frequency:   50.029
> Actual cycle time: 19988.480us
> Minimum width value:        500.000us (100)
> Maximum width value:       2500.000us (500)
> 
> Setting prescale value to: 121
> pi at PiCamera-1:~ $ echo  0=70% > /dev/pca9685servo
> Raw width input = 70.000000
> % specified -> 0.700000
> set servo[0]=70.000000 %
> servo on: 0 off: 389
> 
> .. servo moves as expected. Gronk?
> 
> If i completely remove the /etc/init.d/pca9685servo script to make sure it can???t autostart and reboot then I do actually get to restart from clean.
> pi at PiCamera-1:~ $ ps aux | grep pca
> pi        1195  0.0  0.0   4380   576 pts/0    S+   12:21   0:00 grep --color=auto pca
> 
> And to make life still more annoying manually starting the daemon results in no servo motion.
> 
> Reboot once more; no pigpiod nor pca runnig.
> start pigpiod
> start pca
> ps says both running
> try to move servo - nope. 
> 
> pi at PiCamera-1:~ $ systemctl status pca9685servo
> ??? pca9685servo.service - LSB: Start/stop pca9685servod.
>    Loaded: loaded (/etc/init.d/pca9685servo; generated; vendor preset: enabled)
>    Active: active (running) since Thu 2018-01-11 12:30:16 PST; 3min 21s ago
>      Docs: man:systemd-sysv-generator(8)
>   Process: 1231 ExecStart=/etc/init.d/pca9685servo start (code=exited, status=0/
>    CGroup: /system.slice/pca9685servo.service
>            ??????1238 /usr/local/sbin/pca9685servod
> 
> Jan 11 12:30:16 PiCamera-1 systemd[1]: Started LSB: Start/stop pca9685servod..
> Jan 11 12:30:34 PiCamera-1 pca9685servo[1231]: Raw width input = 70.000000
> Jan 11 12:30:34 PiCamera-1 pca9685servo[1231]: % specified -> 0.700000
> Jan 11 12:30:34 PiCamera-1 pca9685servo[1231]: set servo[0]=70.000000 %
> Jan 11 12:30:34 PiCamera-1 pca9685servo[1231]: servo on: 0 off: 389
> Jan 11 12:30:40 PiCamera-1 pca9685servo[1231]: Raw width input = 10.000000
> Jan 11 12:30:40 PiCamera-1 pca9685servo[1231]: Add 0.100000 to 0.700000 = 0.8000
> Jan 11 12:30:40 PiCamera-1 pca9685servo[1231]: % specified -> 0.800000
> Jan 11 12:30:40 PiCamera-1 pca9685servo[1231]: set servo[0]=80.000000 %
> Jan 11 12:30:40 PiCamera-1 pca9685servo[1231]: servo on: 0 off: 430
> 
> So clearly it is running and receiving commands but failing at something. If I kill that incarnation and manually start with 
> pi at PiCamera-1:~ $ sudo /usr/local/sbin/pca9685servod 
> then my servo moves.
> 
> Is everyone else as baffled as me?
> 
> tim
> --
> tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
> Strange OpCodes: D: Detonate
> 
> 


More information about the Vm-dev mailing list