Home Brew Forums

Home Brew Forums (http://www.homebrewtalk.com/forum.php)
-   Automated Brewing Forum (http://www.homebrewtalk.com/f235/)
-   -   Yet another option for PID control... (http://www.homebrewtalk.com/f235/yet-another-option-pid-control-350979/)

chuckjaxfl 08-30-2012 04:21 AM

AVR221: Discrete PID controller on tinyAVR and megaAVR devices
 
I think I want to teach myself to code AVR's outside of the Arduino environment. So far, I can read a button and blink and LED (deja vu).

While looking at the Atmel site for some tutorials or beginner projects to get myself started, I came across this:
AVR221: Discrete PID controller on tinyAVR and megaAVR devices
(file size: 97986, 10 pages, revision A, updated: 05/2006)
This application note describes a simple implementation of a discrete Proportional-Integral-Derivative (PID) controller on tinyAVR and megaAVR devices.
There is an application note, and a zip file with the main.c and everything. I don't (yet) have the skills to implement it. It looks to me like the skeleton of PID program, you'll have to add your own code to read whatever sensor you're using, your LCD or whatever, etc, etc.

Seems like a great starting point if you don't want to just use Arduino to do it. Especially since it looks like it will run on just about any AVR, not just the ones that have cores written for Arduino. The ATtiny44's are $1.16 on Digikey in quantities of 1!

Rbeckett 08-31-2012 08:09 PM

Chuck,
I have been self learning C to program PicMicrochips,. I am using the 16f877A 40 pin chip to do everything. So far no issues with memory, size or execution. I'm still a babe in the woods with C, so I am taking my time and building the code a block at a time, then verifying it works correctly before I integrate it into the main program on a diferent chip. I bought a bunch of 16f877A's on Ebay for pretty cheap, but had to wait two weeks for them to arrive from China. Have a look at C, because apparently that is what everybody is using to develop code for intergrated systems and chips. Hope this helps.
Bob

FastTalker 08-31-2012 10:07 PM

Quote:

Originally Posted by chuckjaxfl (Post 4372987)
Seems like a great starting point if you don't want to just use Arduino to do it. Especially since it looks like it will run on just about any AVR, not just the ones that have cores written for Arduino. The ATtiny44's are $1.16 on Digikey in quantities of 1!

The Arduino processor is a standard AVR microcontroller and isn't made specifically for Arduino. Arduino is just a prototyping platform to develop AVR applications. Arduino is essentially a programmer, bootloader, and some additional libraries that make things like I/O simpler. Arduino code is still C. It still uses the AVR compiler.

Plus, you will have to build all the additional electronics just to use it: power, a means to program it, oscillator, etc. Once you buy all those things and build it you are nearly back to the Arduino.

Unless you plan on mass production, there isn't much advantage to taking that route.

If you are doing it to learn something, GREAT! :rockin: If you really want to learn something write you code in assembly.

FastTalker 08-31-2012 10:11 PM

Tell Atmel you are a student and ask them for one of their AVR prototyping boards for free. I got Intel to send me a nice 68HC12 prototyping boards when I was in school.

chuckjaxfl 09-01-2012 02:28 PM

Quote:

Originally Posted by FastTalker (Post 4377718)
The Arduino processor is a standard AVR microcontroller and isn't made specifically for Arduino. Arduino is just a prototyping platform to develop AVR applications. Arduino is essentially a programmer, bootloader, and some additional libraries that make things like I/O simpler. Arduino code is still C. It still uses the AVR compiler.

Plus, you will have to build all the additional electronics just to use it: power, a means to program it, oscillator, etc. Once you buy all those things and build it you are nearly back to the Arduino.

Which is pretty much exactly what I did here, except my power supply is off of the board, and I was programming the chip by swapping it in and out of the Arduino. I've learned some since then. If I were doing it again today, I'd use the TQFP instead, put a LM1117 & caps on the board, add a 6 pin ICSP header, and program it with my USBtiny (and, like you said, just end up with pretty much the same thing as an Arduino pro mini).

Quote:

Originally Posted by FastTalker (Post 4377718)
If you are doing it to learn something, GREAT! :rockin: If you really want to learn something write you code in assembly.

Yes, exactly that. As far as I know, there's nothing I can do outside of the Arduino environment that I can't do from within it, programming wise. I do think it would be neat to have access to AVR's for which no one has yet written cores. I.E., I'm not aware of a means to use Arduino's IDE to program an ATtiny10, or ATxmega128A3U.

Plus, am I mistaken that C/C++ is the same for everything? I.E., shouldn't I also then be able to work with ARM, Pic, etc?

This seems like the step from extract brewing to all-grain brewing. They both can result in the same end product, one method is just much more "hands-on".

chuckjaxfl 09-01-2012 03:36 PM

Quote:

Originally Posted by Rbeckett (Post 4377409)
I bought a bunch of 16f877A's on Ebay for pretty cheap, but had to wait two weeks for them to arrive from China.

That's been my solution for pretty much everything as well, patience pays.
Although, now that I'm soldering SMD components on home-etched boards, Digikey is a lot more competitive.

Larso 09-01-2012 05:13 PM

Quote:

Originally Posted by chuckjaxfl (Post 4379012)
This seems like the step from extract brewing to all-grain brewing. They both can result in the same end product, one method is just much more "hands-on".

I'm with Chuck on this. Have had the PICKIT2 for along time and just need to get round to figuring it out.
One point about PID control is that its referred to a lot when temp controlling fermentation fridges. I have yet to see true PID control for this purpose. You actually just want simple on/off control. Too hot >turn on cooler, too cold> turn on heater.(Heater and cooler never on at same time)
To try and write code for PID control is waaay overkill. I'm guessing the same applies to mash temp control systems but dont know much about whats out there(I BIAB).

Thanks

L


All times are GMT. The time now is 04:31 AM.

Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.