Kegconnection Complete Starter Kit and More Giveaway!


Home Brew Forums > Home Brewing Beer > Automated Brewing Forum > Yet another option for PID control...

Reply
 
LinkBack Thread Tools
Old 08-30-2012, 04:21 AM   #1
chuckjaxfl
Feedback Score: 1 reviews
Recipes 
 
Join Date: Feb 2010
Location: Jacksonville, FL
Posts: 327
Liked 18 Times on 11 Posts
Likes Given: 23

Default 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!
__________________
chuckjaxfl is offline
 
Reply With Quote Quick reply to this message
Old 08-31-2012, 08:09 PM   #2
Rbeckett
HBT_SUPPORTER.png
Feedback Score: 0 reviews
 
Rbeckett's Avatar
Recipes 
 
Join Date: Dec 2011
Location: Bronson, Fl
Posts: 984
Liked 63 Times on 46 Posts
Likes Given: 29

Default

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

__________________

What do you mean "no Kidneys"???, WTF now I gotta drink less beer...
Join the Automation sub forum in Electric brewing for a discussion of components and control systems. I did!!!!

Rbeckett is offline
 
Reply With Quote Quick reply to this message
Old 08-31-2012, 10:07 PM   #3
FastTalker
Member
HBT_SUPPORTER.png
Feedback Score: 0 reviews
 
FastTalker's Avatar
Recipes 
 
Join Date: Sep 2011
Location: Nashville, TN
Posts: 103
Liked 1 Times on 1 Posts
Likes Given: 2

Default

Quote:
Originally Posted by chuckjaxfl View Post
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! If you really want to learn something write you code in assembly.
__________________
FastTalker is offline
 
Reply With Quote Quick reply to this message
Old 08-31-2012, 10:11 PM   #4
FastTalker
Member
HBT_SUPPORTER.png
Feedback Score: 0 reviews
 
FastTalker's Avatar
Recipes 
 
Join Date: Sep 2011
Location: Nashville, TN
Posts: 103
Liked 1 Times on 1 Posts
Likes Given: 2

Default

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.

__________________
FastTalker is offline
 
Reply With Quote Quick reply to this message
Old 09-01-2012, 02:28 PM   #5
chuckjaxfl
Feedback Score: 1 reviews
Recipes 
 
Join Date: Feb 2010
Location: Jacksonville, FL
Posts: 327
Liked 18 Times on 11 Posts
Likes Given: 23

Default

Quote:
Originally Posted by FastTalker View Post
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 View Post
If you are doing it to learn something, GREAT! 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 is offline
 
Reply With Quote Quick reply to this message
Old 09-01-2012, 03:36 PM   #6
chuckjaxfl
Feedback Score: 1 reviews
Recipes 
 
Join Date: Feb 2010
Location: Jacksonville, FL
Posts: 327
Liked 18 Times on 11 Posts
Likes Given: 23

Default

Quote:
Originally Posted by Rbeckett View Post
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.
__________________
chuckjaxfl is offline
 
Reply With Quote Quick reply to this message
Old 09-01-2012, 05:13 PM   #7
Larso
Feedback Score: 0 reviews
Recipes 
 
Join Date: May 2011
Location: Dublin, Meath
Posts: 217
Liked 9 Times on 6 Posts
Likes Given: 5

Default

Quote:
Originally Posted by chuckjaxfl View Post
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
__________________
Larso is offline
 
Reply With Quote Quick reply to this message
Reply


Quick Reply
Message:
Options
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ignition Control Help lgoolsby Automated Brewing Forum 0 08-21-2012 03:41 AM
Control Advice Theologia14 Automated Brewing Forum 2 08-02-2012 03:24 AM
Burner Temp Control Like ToP rwinzing Automated Brewing Forum 1 07-25-2012 09:19 PM
Software to control brewing process btbonser Automated Brewing Forum 18 07-08-2012 05:42 AM