Temperature Control

More
8 years 7 months ago #107492 by Hawkeye
Replied by Hawkeye on topic Temperature Control
Hello Andy,

which frequency would you propose?

What do you think about the PID values, I guess they are totally rubbish.
Any suggestion on that? At the moment, the heating overshoots with more than 10% of the target temperature.
While 3D printing, temperature control seems to be crucial.

Regards,
Ben

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

More
8 years 7 months ago #107493 by Hawkeye
Replied by Hawkeye on topic Temperature Control
What I missed so far:
For reading the temperature, I am using an Arduino UNO board which was on already on my electronic scrap bin.
This working better than expected.

Wiring and temperature-read-routine:
www.derpade.de/tutorial-arduino-cactus-n...k-temperatur-sensor/

Configuration on operationg system level (run as user "root"):
adduser {YOUR_USERNAME_HERE} dialout
apt-get install gcc-avr avr-libc avrdude
apt-get install python-pip python python-serial
python -c 'import serial'

Merge this to your {machine-name}.ini:
[RS274NGC]
PARAMETER_FILE = linuxcnc.var
SUBROUTINE_PATH = {FOLDERNAME_HERE}/SUBROUTINES/
USER_M_PATH = {FOLDERNAME_HERE}/CUSTOM/

HAL-Code (not very nice yet! Filename="USB-Thermometer.py" define script as executable:
Code:
LinuxCNC HAL: #!/usr/bin/python import serial import hal import sys import time PORT = "/dev/ttyACM0" ser = serial.Serial(PORT, 115200, timeout=15) c = hal.component("usb-thermometer") c.newpin("t0-cmd", hal.HAL_FLOAT, hal.HAL_IN) c.newpin("t0", hal.HAL_FLOAT, hal.HAL_OUT) time.sleep(1) c.ready() t0cmd = c['t0-cmd'] t0cmdOld = 0; try: while 1: time.sleep(0.25) t0cmd = c['t0-cmd'] if t0cmd != t0cmdOld: t0cmdOld = t0cmd; ser.write("T0"); while ser.inWaiting(): line = ser.readline(); if(line[:3] == "T0="): c['t0'] = float(line[3:]) except KeyboardInterrupt: ser.write("-P;"); raise SystemExit

Try to activate Arduino-Module now within {MACHINE_NAME}.ini :
###########################################################
# Arduino Temperature
###########################################################
loadusr -i ./USB-Thermometer.py

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

More
8 years 7 months ago #107508 by andypugh
Replied by andypugh on topic Temperature Control

Hawkeye wrote: which frequency would you propose?

I would kind-of expect to be turning a heater on and off about 10x per second.
Which isn't to say that 1000Hz won't work. But (for example) furnace controllers seem to cycle between full-on and full-off every few seconds.

What do you think about the PID values, I guess they are totally rubbish.


A little odd. I am not sure why you have a 0.0001 max output and a 0.0001 scale. Why not let both run from 0 to 1 or even 0 to 100(%)?

You might be seeing I-term wind-up, I would try seeing how close you can get with just P.

Also, why such a tiny max duty cycle?

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

More
8 years 7 months ago - 8 years 7 months ago #107618 by B9T
Replied by B9T on topic Temperature Control
That looks good and is kind of what I was thinking of, thank you. One option I was thinking of was loading any one of the 3d printer firmwares (probably Marlin) onto an Arduino and let it directly control the heater and temperature sensor. Marlin does ~8Hz control on the heaters if I remember that correctly and does offer PID tuning for the heaters.

Is there a straight forward way to pause the gcode interpretation in linuxcnc in order to implement a behavior similar to M109, i.e. setting the temperature and then waiting for it to be reached?
Last edit: 8 years 7 months ago by B9T.

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

More
8 years 7 months ago #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
8 years 7 months ago #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.

Time to create page: 0.108 seconds
Powered by Kunena Forum