Temperature Control

More
20 Mar 2018 17:22 #107629 by andypugh
Replied by andypugh on topic Temperature Control
M109 is in the range of user-M codes so you could create it.

Without using an _actual_ M109 you would typically use an M66 "wait on input"
linuxcnc.org/docs/2.7/html/gcode/m-code.html#mcode:m66

I am not 100% sure what an M66 with an analogue input actually does. I think I would set up a comparator in HAL (looking at the PID error output pin) to judge when the setpoint was hit.

Please Log in or Create an account to join the conversation.

More
20 Mar 2018 17:36 #107630 by B9T
Replied by B9T on topic Temperature Control
M109 is just what I know the "set and wait for temperature" command from 3D printing as. I don't care if I'll either replace it inline with a set of other codes or write a quick pre/postprocessor between the slicer and linuxcnc

That link says:
"Mode 0: IMMEDIATE - no waiting, returns immediately. The current value of the input is stored in parameter #5399"
and
"Mode 0 is the only one permitted for an analog input. "

So I don't think directly waiting for an analog signal is the way to go, especially because that value will require a mapping between value and the actual temperature...

Though it should be "trivially" possible to create a temperature reached signal, output that onto an I/O pin and feed back that I/O into an input pin for which to wait for with M66 and an proportionately long timeout. Or maybe even without using actual pins by just connecting the right signals?

Thanks for pointing me towards this.

Please Log in or Create an account to join the conversation.

More
20 Mar 2018 17:43 #107631 by andypugh
Replied by andypugh on topic Temperature Control
You can do something like this in G-code
#1 = 220
O100 DO
M66 E0 
G4 P1
O100 WHILE [ #5399 LT #1]

linuxcnc.org/docs/2.7/html/gcode/o-code.html#ocode:looping

Please Log in or Create an account to join the conversation.

More
20 Mar 2018 22:14 #107643 by rodw
Replied by rodw on topic Temperature Control
Just a thought.

Nothing moves in LinuxCNC until the spindle is at speed.
Consider using the motion.spindle-at-speed pin to tell the system when the print head is at temperature
It might be easier to use spindle S commands to set the temperature which you could read on motion.spindle-speed-out

Please Log in or Create an account to join the conversation.

More
21 Mar 2018 12:21 #107654 by B9T
Replied by B9T on topic Temperature Control
Both of those options look interesting, I'll have to experiment with them. Thank you

Please Log in or Create an account to join the conversation.

More
22 Jul 2019 12:38 #140169 by superman
Replied by superman on topic Temperature Control
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:
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

Please Log in or Create an account to join the conversation.

More
23 Jul 2019 11:51 #140284 by andypugh
Replied by andypugh on topic Temperature Control
You have a system where a negative PWM has no meaning (you don't have active cooling)
I am slightly surprised to find that there is no way to force the PID to be single-sided built in to the component.

So, the answer is probably to add a limit HAL component between the PID output and the PID input..
You might need to limit the I error in the PID to prevent wind-up in the I term when over setpoint.

Please Log in or Create an account to join the conversation.

More
02 Apr 2024 20:23 #297461 by lkavan
Replied by lkavan on topic Temperature Control
Hallo,
I have similar problem with temperature control and I would like to ask if you have found a solution. I need to control selective soldering wave. I have used 7I96S to control machine and 7I87 to measure temperature with thermocouple to voltage amplifier. I have used hal components pid and pwmgen to control the heater. Well, it works somehow. But I have the same problem with negative output from pid. I think, limit between pid out and pwm in will not solve it. Have anybody found better solution? It seems there is still not pid component with positive output only. And the second problem - I would like to have a signal, that temperature is OK, to block the tin pump (connected as a spindle) when tin temperature is too low and it is not liquid.
Thanx a lot.

Please Log in or Create an account to join the conversation.

More
02 Apr 2024 21:13 #297469 by PCW
Replied by PCW on topic Temperature Control
Yes, it would be nice to have a single ended PID comp or PID mode.

Maybe better would be a  more temperature control friendly comp
that implements MPC or similar.

You could use the "near"  or "comp" components to enable your pump.
 
The following user(s) said Thank You: lkavan

Please Log in or Create an account to join the conversation.

More
02 Apr 2024 21:53 #297472 by andypugh
Replied by andypugh on topic Temperature Control
You could also use wcomp or comp to disable the PID when the temperature was above setpoint. I am not sure how elegantly that would work, though.

If the problem is integral wind-up when over-temperataure then one solution might be to set up a second lincurve component that sets the I-gain to zero when the error is negative.

I used to tune vehicle idle speed controllers, and those used this idea, except that P, I and D gains were all 8x8 maps agains error and coolant temperature.

Please Log in or Create an account to join the conversation.

Time to create page: 0.316 seconds
Powered by Kunena Forum