# HAL config file for Pico Systems UPC board
#

# set the PWM frequency to suit Pico's PWM amps (50KHz)
# users with other amps may need to change this
setp ppmc.0.pwm.00-03.freq 50000
# turn on bootstrapping for the MOSFET drivers
# this also depends on the amplifiers
setp ppmc.0.pwm.00.bootstrap TRUE
setp ppmc.0.pwm.01.bootstrap TRUE
setp ppmc.0.pwm.02.bootstrap TRUE
setp ppmc.0.pwm.03.bootstrap TRUE
# set max duty cycle to 95% for the MOSFET drives
# at 50KHz this corresponds to 1 us
setp ppmc.0.pwm.00.max-dc 0.95
setp ppmc.0.pwm.01.max-dc 0.95
setp ppmc.0.pwm.02.max-dc 0.95
setp ppmc.0.pwm.03.max-dc 0.95

# connect position feedback signals to encoders
net Xpos-fb <= ppmc.0.encoder.00.position
net Ypos-fb <= ppmc.0.encoder.01.position
net Zpos-fb <= ppmc.0.encoder.02.position
net Apos-fb <= ppmc.0.encoder.03.position

# get feedback scaling from ini file
setp ppmc.0.encoder.00.scale [JOINT_0]INPUT_SCALE
setp ppmc.0.encoder.01.scale [JOINT_1]INPUT_SCALE
setp ppmc.0.encoder.02.scale [JOINT_2]INPUT_SCALE
setp ppmc.0.encoder.03.scale [JOINT_3]INPUT_SCALE

# connect PID output signals to step generators
net Xoutput => ppmc.0.pwm.00.value
net Youtput => ppmc.0.pwm.01.value
net Zoutput => ppmc.0.pwm.02.value
net Aoutput => ppmc.0.pwm.03.value

# connect axis enables to step generators
net Xenable => ppmc.0.pwm.00.enable
net Yenable => ppmc.0.pwm.01.enable
net Zenable => ppmc.0.pwm.02.enable
net Aenable => ppmc.0.pwm.03.enable

# set output scaling from ini file
setp ppmc.0.pwm.00.scale [JOINT_0]OUTPUT_SCALE
setp ppmc.0.pwm.01.scale [JOINT_1]OUTPUT_SCALE
setp ppmc.0.pwm.02.scale [JOINT_2]OUTPUT_SCALE
setp ppmc.0.pwm.03.scale [JOINT_3]OUTPUT_SCALE

# add a couple of tuning test links
# if these are useful will want to add them to the other axes as well
# or make these setup with the tuning script
net Xoutput ddt.0.in
net Xpos-fb ddt.1.in

