Place servotest.hal, servotest.xml, and optionally, autosave.halscope into a directory such as:
/home/my_user_name/emc2/configs/RCservotestThe application can be started by making the above directory the current directory:
cd ~/emc2/configs/RCservotest/Then invoke with:
halrun -I servotest.halWhich should give you something like this:
##### RC Servo Test Configuration - servotest.hal #####
loadrt threads name1=fast period1=10000 name2=slow period2=1000000 # fast period of
# 10000 gives 1 degree per period, or 1 degree resolution, but many PC's may
# crash with this setting. 20000 gives 2 degrees per fast period, or 2 degree resolution.
loadrt hal_parport cfg="0x0378" # Change as needed
loadrt pwmgen output_type=0
#loadusr -Wn mypanel pyvcp -g 250x500+800+0 -c mypanel mypanel.xml # Sample from doc's
loadusr -Wn servopyvcp pyvcp -g 700x80+50+50 -c servopyvcp servotest.xml
# FUNCTIONS #########################################
addf parport.0.read fast
addf pwmgen.update slow
addf pwmgen.make-pulses fast
addf parport.0.write fast
# CONNECTIONS #######################################
setp pwmgen.0.min-dc 0.06 #float rw, -90 degrees at .6 ms (center - .9ms),
# tries to keep the servo output shaft off of the hardware limit stop
setp pwmgen.0.max-dc 0.24 #float rw, 90 degrees at 2.4 ms, (center + .9ms),
# tries to keep the servo output shaft off of the hardware limit stop
#setp pwmgen.0.offset 0.15 #float rw, center position at 1.5ms
setp pwmgen.0.offset 0.153 #float rw, center position at 1.53ms, this line is
# tweaked but servo should be adjusted to center on 1.5ms
#setp pwmgen.0.scale 1000.00 #float rw
setp pwmgen.0.scale 1120.00 #float rw, tweaked a little for a particular servo
setp pwmgen.0.pwm-freq 100.00 #float rw, frequency can be changed as needed,
# but affects other parameters
setp pwmgen.0.enable TRUE # could be connected to a pyVCP button
net PWMcmd servopyvcp.anaout-f pwmgen.0.value #float
net PWMout pwmgen.0.pwm parport.0.pin-16-out #bit
#########################################
# start real-time threads
start
# start HALscope
loadusr halscope
<!-- servotest.xml -->
<pyvcp>
<vbox>
<scale>
<font>("Helvetica",14)</font><width>"40"</width><halpin>"anaout"</halpin>
<resolution>0.1</resolution><orient>HORIZONTAL</orient>
<initval>0</initval><min_>-90</min_><max_>90</max_>
</scale>
<!-- Commented out because scale works better
<dial>
<size>200</size><cpr>100</cpr><min_>-90</min_><max_>90</max_><text>"Dial"</text>
<initval>0</initval><resolution>0.1</resolution><halpin>"anaout"</halpin>
<dialcolor>"yellow"</dialcolor><edgecolor>"green"</edgecolor><dotcolor>"black"</dotcolor>
</dial> -->
</vbox>
</pyvcp>
THREAD fast MAXCHAN 4 HMULT 1 HZOOM 2 HPOS 7.007245e-01 CHAN 1 PIN parport.0.pin-16-out VSCALE -1 VPOS 0.300971 VOFF 0.000000e+00 CHAN 2 PIN servopyvcp.anaout-f VSCALE 5 VPOS 0.699029 VOFF 0.000000e+00 TSOURCE 1 TLEVEL 0.500000 TPOS 0.500000 TPOLAR 1 TMODE 0 RMODE 1