Linux Based PID - Page 2

Need help with equipment usage or want to share your latest discovery?
napierzaza (original poster)
Posts: 221
Joined: 13 years ago

#11: Post by napierzaza (original poster) »

I realize it was just a suggestion. But since I've already come so far in this project, I was disappointed that the only comment was that I should do an entirely different project instead! :oops:

There were certainly weird issues that I had to work around. But to do an Arduino project on my way to doing a Linux one would have just been a side-line. There are about a dozen Arduino projects already.

Embedded Linux programming was what I was interested in working with. Not to mention the fact that I had a Meraki Mini lying around, this project actually cost me nothing at all. I was lucky enough to be preparing the project, and came across a bunch of thermocouples being thrown out. Asking around I was able to scrounge some SSRs.

At any rate, it's been pretty fun. Now that I'm in a position where everything is stable, I am only tweaking things and making them better. Which means I need more instruments of course. :wink:

User avatar
jknotzke
Posts: 101
Joined: 13 years ago

#12: Post by jknotzke »

I totally understand and I really didn't mean to suggest you made some horrible error that needs correcting. That really wasn't my intention. Sorry if it came off that way.

Looks pretty cool actually. What main controller did you go with ? Where is most of the logic ? Is it on the board or is it sent via a computer ? How do you upload new firmware ?

What did you use to handle turning off and on the element ? There's some pretty serious amperage going on there and I'm curious what you did to handle that part..

J

napierzaza (original poster)
Posts: 221
Joined: 13 years ago

#13: Post by napierzaza (original poster) »

It's a router running OpenWRT (atheros). I built a PCB with two chips, an ADC and a Ambient temperature sensor which are both going over the same i2c bus (MCP9800 and MCP3422). Then I also have some transistors that are used to trigger a SSR which powers the element, just like a regular PID setup.

The logic, logging, and control is all done through the router, with an integrated package I made for Openwrt. So a daemon basically runs, periodically (4 times a second) measures the temperature, runs the PID calc, and modulates the heater control.

For now I have a cron script on the system to control whether the PID is on or not. I also have uhttpd installed, so I can have a simple API for when I get my iPhone app running. For now I can SSH into the device and change the PID calculations, temperature offsets, or just see what temperature the machine is at.

I can access the router because it connects to my main wireless router (over wifi), so my espresso machine is basically a computer on my network :-)

As for the firmware, I am making custom builds of OpenWRT (though stock would work too), in the future I can even preload my package onto the firmware image if I really wanted to. But since I'm always updating the package with improvements it makes no sense to do that. For now I just ssh the new package to the router and install it via "opkg".

I actually think that the code is generic enough to work with anything running OpenWRT Backfire. You just have to find the appropriate GPIO pins for the i2c and the "heater out". I'm not aware of any other routers as "elegant" as this one since it has a nice 1.0 pitch headers with the GPIOs and power.

User avatar
jknotzke
Posts: 101
Joined: 13 years ago

#14: Post by jknotzke »

So the PCB you built was to just handle the sensors that all talk i2C. Is that correct ?

And the router you are using also happens to have an i2C port open on it..

Are you logging any data such as temperature and profiles ?

J

napierzaza (original poster)
Posts: 221
Joined: 13 years ago

#15: Post by napierzaza (original poster) »

Well it has the i2c chips and the transistors to trigger the SSR. So yes.

It doesn't so much have an i2c port, you can use GPIOs as i2c if you have the right kernel package.

I'm logging temperature so far. Timestamped temperature reading is the basic measure I have now which I have graphed.

napierzaza (original poster)
Posts: 221
Joined: 13 years ago

#16: Post by napierzaza (original poster) »

Finally got to gumption to pierce the case and put Silvia back together. The PID has been working very well over the past month or so, still tweaking the PID settings. Glad to have it together finally, though I wish that I had put the antenna on the side instead of the back, I didn't realize that it would stick out so far.

I'm looking into setting up the API for iPhone control over the settings.



cubastreet
Posts: 27
Joined: 16 years ago

#17: Post by cubastreet »

Cool, great to see something different!

Did you write your own PID code? if so, can you suggest some reading as I'm keen to write my own code and actually understand what it's doing.

napierzaza (original poster)
Posts: 221
Joined: 13 years ago

#18: Post by napierzaza (original poster) »

PID without a PHD is all you need to read. It's online and basically walks you through with pseudo code as well. Though I found that the PID constants were not working and I've had to tweak them.

Edit :

Here is the link

http://igor.chudov.com/manuals/Servo-Tu ... -a-PhD.pdf

It's really the best thing out there. It's pretty simple to create your own class or function, you run the calculations and pretty much only need to retain 2 or 3 different variables at run time. I have looked at some PID code from around the net and they are clearly coming from this.

User avatar
allon
Posts: 1639
Joined: 13 years ago

#19: Post by allon »

Not linux, but you can find an Arduino implementation of PID here:

http://www.arduino.cc/playground/Code/PIDLibrary
LMWDP #331

napierzaza (original poster)
Posts: 221
Joined: 13 years ago

#20: Post by napierzaza (original poster) »

I'm not putting down your suggestion, but I found very little of the Arduino code stuff useful. Barebones PID for instance was so generic I couldn't image it would even work.

But at any rate if anyone knows how to implement simple API communication protocols let me know.