-
Notifications
You must be signed in to change notification settings - Fork 0
/
temperature.hal
86 lines (68 loc) · 2.02 KB
/
temperature.hal
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
## load modules
loadrt encoder num_chan=1
loadrt frequency2temperature count=1
loadrt pid num_chan=1
loadrt pwmgen output_type=0
loadrt mux2
loadrt mux2bool
## add functions
addf encoder.capture-position servo-thread
addf encoder.update-counters base-thread
addf frequency2temperature.0 servo-thread
addf pid.0.do-pid-calcs servo-thread
addf pwmgen.make-pulses base-thread
addf pwmgen.update servo-thread
addf mux2.0 servo-thread
addf mux2bool.0 servo-thread
## frequency read in
net temp_pin parport.0.pin-10-in
net temp_pin encoder.0.phase-A
setp encoder.0.counter-mode 1
net temp_freq encoder.0.velocity
net temp_freq pyvcp.temp-freq
## freq to temp conversion
net temp_freq frequency2temperature.0.frequency-in
net temp_degrees frequency2temperature.0.temperature-out
net temp_degrees pyvcp.temp-degrees
## PID
net temp_degrees pid.0.feedback
net pid_out pid.0.output
net pid_out pyvcp.pid-out
net temp_setpoint pid.0.command
net temp_setpoint mux2.0.out
net temp_setpoint pyvcp.temp-set
net temp_setpoint_mcode mux2.0.in0
net temp_setpoint_gui pyvcp.temp-setpoint-f
net temp_setpoint_gui mux2.0.in1
net temp_mux_sel pyvcp.man-temp-control mux2.0.sel
setp pid.0.Pgain 0.3
setp pid.0.Igain 0.0
setp pid.0.Dgain 0.0
#setp pid.0.maxoutput 30
#net pgain pyvcp.pgain pid.0.Pgain
#net igain pyvcp.igain pid.0.Igain
#net dgain pyvcp.dgain pid.0.Dgain
## PWMgen
net pid_out pwmgen.0.value
net pwm_out pwmgen.0.pwm
net pwm_out parport.0.pin-14-out
net pwm_dutycycle pwmgen.0.curr-dc
net pwm_dutycycle pyvcp.dutycycle
#setp pwmgen.0.scale 30
setp pwmgen.0.pwm-freq 1000
setp pwmgen.0.dither-pwm 0
setp pwmgen.0.max-dc 0.5
setp pwmgen.0.min-dc 0.0
## enable switch for pid and pwm
net pid_en pid.0.enable
net pid_en pwmgen.0.enable
net pid_en mux2bool.0.out
net pid_en_mcode mux2bool.0.in0
net pid_en_gui mux2bool.0.in1
net pid_en_gui pyvcp.pid-en
net temp_mux_sel mux2bool.0.sel
## for pid tuning
loadrt passthru count=1
addf passthru.0 servo-thread
net p-gain-in <= pyvcp.Pgain => passthru.0.in
net p-gain-out <= passthru.0.out => pid.0.Pgain