best way to do temperature pid with linuxcnc

More
30 Mar 2016 04:49 #72363 by sleepybishop
hello *, trying to add 3d printing to my mill.
im using gantry style machine with g540 running the motors and 7i76 for extra io and extruder motor control via A4988 driver.

ive read through the forums and found a few insightful posts. but i havent found a concrete example to figure out what do to.

in this thread it seems an arduino is reading value but how to then interface arduino to linuxcnc, also how to set up temperature pid
forum.linuxcnc.org/forum/30-cnc-machines/29874-laser-engraving

this thread outlines someone building a custom circuit based on ne555, but im curious whether its accurate given non linearity of thermistors
forum.linuxcnc.org/forum/46-francais/296...e-temperature-hotend

this thread is trying to something similar except for the print bed instead of the hot end, but still unclear to to setup temperature pid
forum.linuxcnc.org/forum/39-pncconf/2933...or-3d-printer-heater

both the last two threads have suggestions on using an external pid controller like rex-c100 or inkbird, like the ones used for diy reflow ovens, but im unsure as to what would be more robust.

i imagine using an external controller would be the easiest, but im rather curious what it would take to something arduino/max31855 based with linuxcnc doing the pid logic.

any pointers or tips would be most appreciated.

thanks

--joe

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

More
30 Mar 2016 09:24 #72371 by andypugh
What hardware are you using? These are good if you have an SPI channel:

uk.rs-online.com/web/p/instrumentation-amplifiers/7861017/

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

More
30 Mar 2016 17:40 #72406 by sleepybishop
hi andy, thanks for the reply.

im running a mesa 6i25 with one port configured for a g540 and the other for a 7i76, running on an asrock q1900m.

i thought the max31855 might be a nice way to go, but i dont have any spi inputs, ive google around and found some anecdotes about using a microcontroller to read the spi value and encode it as frequency so that i could read it via the mesa the same way you would spindle rpm but i havent found any details of how best to accomplish that.

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

More
30 Mar 2016 19:46 #72411 by andypugh

im running a mesa 6i25 with one port configured for a g540 and the other for a 7i76, running on an asrock q1900m.
i thought the max31855 might be a nice way to go, but i dont have any spi inputs,


It might be possible to get a custom firmware that puts a Hostmot2 BSPI component on some pins of the 7i76. (not that straightforward, as most of the GPIO on the card is serially-addressed.)

Alternatively, bit-banging the SPI format ought to work if the device will work with a 1kHz clock. It will still get around 30 updates per second.

ive google around and found some anecdotes about using a microcontroller to read the spi value and encode it as frequency so that i could read it via the mesa the same way you would spindle rpm but i havent found any details of how best to accomplish that.

It is pretty easy with an Arduino, I even have some circuit boards for 6 x 31855 + Arduino Nano. But you still need an interface from Arduino to HAL, so I am not sure you win much. A MAX31855-specific HAL component is probably not all that hard.

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

More
30 Mar 2016 20:40 #72414 by Sparky961
Perhaps I'm missing something and oversimplifying, but couldn't you just use a spare input pin to read voltage from a temperature sensor?

From the manual:

All field input pins are capable of reading the input voltage. These are not highly
accurate or high resolution but can be useful for things like potentiometer inputs. Input
resolution is 8 bits and input full scale value is 36.3V. Accuracy is +-5%. Software process
data modes 1 and 2 allow reading the analog voltage on inputs 0 through 3, in addition to
the 32 digital bit inputs.


I'm thinking that should provide sufficient resolution for most temperature controllers. You may be able to directly connect the output from a temperature sensor, or may have to translate the voltage using a microcontroller or discrete circuit.

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

More
31 Mar 2016 00:00 #72426 by sleepybishop
thanks andy, i think max31855 is the way to go, i emailed mesa and pcw replied that i can use spare pins as bspi interaface, waiting to hear back to see how to best modify my pin vhd file.

are there any resources out there that i could use to learn how to create a hal component once i have the spi pins configured?

im still not very familiar with the guts on linuxcnc so i very much appreciate the guidance.

thanks
--joe

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

More
31 Mar 2016 09:25 #72445 by andypugh

thare there any resources out there that i could use to learn how to create a hal component once i have the spi pins configured?


BSPI isn't the most convenient component to use. I would like to make it easier, I know how but haven't found the time.

To write a HAL component you use halcompile:
linuxcnc.org/docs/2.7/html/hal/comp.html

There is an example of a bspi HAL component here:
github.com/LinuxCNC/linuxcnc/blob/master...ivers/mesa_7i65.comp

Yours would be similar, but rather simpler.

That comp uses a number of calls to the hostmot2 API that are documented at the bottom of this page
linuxcnc.org/docs/2.7/html/
Which is basically the best starting point for all LinuxCNC documentation.

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

More
31 Mar 2016 15:24 #72481 by sleepybishop
ok thanks, that aught to keep me busy for a while.

as an alternative, i found and old thread where you discussed integrating a DS18B20 one wire temp sensor, did you ever get it work?

if so, is one-wire easier to integrate? the DS18B20 wont do for my application but maxim has another chip the MAX31850, thats like the 31855 but one wire output instead of spi.

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

More
31 Mar 2016 15:32 #72482 by andypugh
I never got one-wire to work, it needs a different type of input to what parport pis are, if I recall the problem correctly.

I do actually think that a bit-banged SPI on GPIO would work, but I don't have the time to work on it. (I am busy with a lathe conversion)

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

More
08 Apr 2016 21:08 - 08 Apr 2016 21:10 #72977 by sleepybishop
andy, ive followed your advice and created a hal component for the max31855 based on the mesa_7i65 driver.

does it look reasonable?
github.com/sleepybishop/linuxcnc-mirror/...s/max31855_bspi.comp

ive compiled and installed it, i tested hardcoding the 32 bit value from the sensor to a known 32 bit value and the expected temperature shows up on the new pin.

however i cant get it to work with actual sensor data, its always 0, even with the thermocouple disconnected which should trigger a fault and NAN as the pin value, which leads me to believe theres something really wrong somewhere.

i put together this pin file from info gathered from google and the forums and some info from pcw
github.com/sleepybishop/platform/blob/ma...in/PIN_G540_BSPI.vhd, i hope its right.

i included two cs pins in case i want to add a second sensor..

ive installed this firmware and the channel shows up when loading the hal modules, theres no errors, just no data coming through.
i have the cs pin wired to stepgen2-step, the clk pin wired to stepgen3-step and d0 wired to qcount idx

i want to verify the actual sensor works so i just ordered an arduino to play with, i would still like to get this to work but at the end of the day i might have to resort to your original solution of using arduino to read the sensors and write a hal component to read from arduino.

if the sensor works on arduino maybe ill try bitbanging spi via a gpio pin as well.
Last edit: 08 Apr 2016 21:10 by sleepybishop.

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

Time to create page: 0.084 seconds
Powered by Kunena Forum