Command line access for servo control?


 

Steve_M

TVWBB Guru
I wanted to demo the servo control to some friends and co-workers. Rather than using the button on the HM to step the servo in 5% increments, I was wondering if it was possible to control the servo from the command line where I could use a for loop to continuously go from 0% to 100% and back to 0% in a smooth fashion.
 
You can just use the manual mode setpoint command: /sp=-X
Code:
/sp=-0
/sp=-1
/sp=-2
/sp=-3
/sp=-4
etc
Is that what you're looking for?
 
Here's my script

Code:
# cat ./updown.sh
#!/bin/sh
for i in `seq 0 2 100` ; do lmclient LMST,sp,-$i ; sleep 1 ; done
for j in `seq 100 -2 0` ; do lmclient LMST,sp,-$j ; sleep 1 ; done

The busybox version of sleep doesn't support tenths of a second.
 
You could always do it in LUA if you want sub-second delays
Code:
#!/usr/bin/lua

local nixio = require "nixio"

require "lmclient"
local lm = LmClient()

for i=0,100,2 do
  lm:query("$LMST,sp,-"..i, true)
  nixio.nanosleep(0, 500000000) -- delay 500ms
end

for i=100,0,-2 do
  lm:query("$LMST,sp,-"..i, true)
  nixio.nanosleep(0, 500000000) -- delay 500ms
end

lm:close()
 
Turns out about 500ms is the fastest the fan/servo will respond.

I was trying to get a nice smooth 0 to 100 and back to 0 in about 15 seconds, kind of like what might be considered to be the HM in "demo mode".
 
Set the pit temp so the servo/fan is at 100% then disconnect the pit probe, she will shoot from 100% to 0%, plug the pit probe back in and she will shoot back to 100%. I know that's not exactly what you wanted but the movement will happen fast and smoothly....
 
Yeah now that you mention it, Steve, internally I think it just queues the output change for the next period. Periods only happen every second so that's probably why you're seeing that behavior.

If you changed GrillPid::setPidOutput() to include the line commitPidOutput() at the end it would take effect immediately although that would shorten the blower "long pid" (pulsed on and off) function.
 
Set the pit temp so the servo/fan is at 100% then disconnect the pit probe, she will shoot from 100% to 0%, plug the pit probe back in and she will shoot back to 100%. I know that's not exactly what you wanted but the movement will happen fast and smoothly....

I can already control that type of movement remotely.
 

 

Back
Top