Hi all,
maybe is a late reply to this topic but I havea similar problem. I am trying to adjust the temperature of my 3d printer extruder. For this I have LinuxCNC and the Mesa 7i76.
I have set the first 4 pins of the GPIO to analog inputs and I have plugged in my 100k thermocouple in one of them. Besides I have one digital output connected to a controller like
this
In other thread I was recommended to use the lincurve command to convert the voltage to °C, so I did and it works great.
The problem comes now with the PID and PWM parameters. I know that setting up a PID takes time but I think there are some other parameters that must be first set like maxerror, maxoutput, pwm.freq, pwm.scale, etc.
I have set the PID output to PWM value and I know depending on "value" the duty cycle is calculated. One example problem that I have is I set pwm.scale and pid.maxoutput to 255 and this occurs:
- When warming up there is a moment when feedback is bigger than command (Overshoot) –> negative error!
Negative error leads to negative output –> pwm.value = 0 –> dc = 0 –> pin is closed
This is acceptable I guess, but:
- Although pin is closed, feedback from sensor is rising for a while until reached a certain value, so that the error reach negative maxoutput in the end (-255)
- The temperature starts decreasing and output value is bigger but still negative, so when the extruder should be warmed up it is not, and temperature continues decreasing until reaching a difference around 20°C
- By this time pid output is positive and extruder starts to warm up again
My .hal file looks like this:
Code:
loadrt lincurve count=1 personality=16
loadrt pwmgen output_type=0,0
addf lincurve.0 servo-thread
addf extruder-pid.do-pid-calcs servo-thread
addf pwmgen.make-pulses servo-thread
addf pwmgen.update servo-thread
# Link analog inputs from 7i76 card to lincurve.0 input
net extruder-sensor-raw lincurve.0.in <= hm2_5i25.0.7i76.0.0.analogin0
#*******************
# EXTRUDER SETTINGS
#*******************
setp lincurve.0.x-val-00 0.65
setp lincurve.0.y-val-00 0
setp lincurve.0.x-val-01 1.54
setp lincurve.0.y-val-01 20
setp lincurve.0.x-val-02 1.83
setp lincurve.0.y-val-02 25
setp lincurve.0.x-val-03 3.06
setp lincurve.0.y-val-03 40
setp lincurve.0.x-val-04 5.11
setp lincurve.0.y-val-04 60
setp lincurve.0.x-val-05 7.17
setp lincurve.0.y-val-05 80
setp lincurve.0.x-val-06 8.84
setp lincurve.0.y-val-06 100
setp lincurve.0.x-val-07 9.99
setp lincurve.0.y-val-07 120
setp lincurve.0.x-val-08 10.73
setp lincurve.0.y-val-08 140
setp lincurve.0.x-val-09 11.18
setp lincurve.0.y-val-09 160
setp lincurve.0.x-val-10 11.46
setp lincurve.0.y-val-10 180
setp lincurve.0.x-val-11 11.64
setp lincurve.0.y-val-11 200
setp lincurve.0.x-val-12 11.75
setp lincurve.0.y-val-12 220
setp lincurve.0.x-val-13 11.82
setp lincurve.0.y-val-13 240
setp lincurve.0.x-val-14 11.87
setp lincurve.0.y-val-14 260
setp lincurve.0.x-val-15 11.9
setp lincurve.0.y-val-15 280
setp extruder-pid.enable 1
setp extruder-pid.Pgain 1
setp extruder-pid.Igain 0
setp extruder-pid.Dgain 0
setp extruder-pid.maxoutput 255
setp extruder-pid.maxerror 255
setp extruder-pid.command 180
setp extruder-pid.FF0 0
setp extruder-pid.FF1 0
setp extruder-pid.FF2 0
setp pwmgen.0.enable 1
setp pwmgen.0.scale 255
setp pwmgen.0.pwm-freq 8
net extruder-sensor-interp lincurve.0.out => extruder-pid.feedback pyvcp.extruder-sensor
#*************************
# EXTRUDER VALUES PYVCP
#*************************
net extruder-sensor-raw => pyvcp.extruder-voltage
net extruder-pwm extruder-pid.output => pwmgen.0.value pyvcp.extruder-output
net extruder-error extruder-pid.error => pyvcp.extruder-error
net extruder-heater pwmgen.0.pwm => hm2_5i25.0.7i76.0.0.output-05