summaryrefslogtreecommitdiff
path: root/configs/by_interface/pico/ppmc_vel/ppmc_load.hal
blob: 4a53cb45cfcbe47b8e293d1279abc375bdd5730a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# sample file pulls all load commands into a single file
# when emc2 starts it loads iocontrol
# this file enables encoder velocity timestamping
# it will only work on PPMC encoder boards with
# rev 4 or later firmware.  In addition to the timestamp
# feature, rev 4 and above boards also have the ability to
# select the encoder digital filter frequeincy.  Append
# enc_clock="n" to the loadrt hal_ppmc line.  N can be
# 1, 2, 5 or 10 for 1, 2 5 or 10 MHz frequency.  Any other
# value will default to the standard 1 MHz.
# it is best to use the lowest rate that allows your encoders
# to be read, as this gives the greatest suppression of
# electrical noise on the encoder inputs.

# kinematics
loadrt trivkins

#motion controller, get name and thread periods from ini file
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES

# next load the PID module, for four PID loops
loadrt pid num_chan=4

# install Universal PWM Controller driver
loadrt hal_ppmc timestamp="0x00"

# make some signals for the scope for tuning.
loadrt ddt count=4
loadrt estop_latch count=1
loadrt and2 count=1

# set up the realtime thread
# read inputs first
addf ppmc.0.read servo-thread
# then run the motion controller
addf motion-command-handler servo-thread
addf and2.0 servo-thread
addf estop-latch.0 servo-thread
addf motion-controller servo-thread
# then the PID loops
addf pid.0.do-pid-calcs servo-thread
addf pid.1.do-pid-calcs servo-thread
addf pid.2.do-pid-calcs servo-thread
addf pid.3.do-pid-calcs servo-thread
# write outputs last
addf ppmc.0.write servo-thread