Arduino Development Thread

Australia & New Zealand Homebrewing Forum

Help Support Australia & New Zealand Homebrewing Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.
If anyone has the dealextreme LED and an 18B20 around I found a nice bit of code at:
http://www3.zansstuff.com/sous-vide
Only single channel but some nicely documented code. Changed the pins to match my setup and it ran first time too which is pretty good.
2012_03_13.jpg
 
Just ordered a LCD-09363 LCD shield plus some stackable headers as the next step in my development. Got the Netduino reading temps, but not much point without being able to display them as well. :)

Has anyone had a look at the FEZ Spider Starter Kit? Also uses the MS .Net MF. Comes with a heap of goodies and the hardware blows the NetDuino away (also arduino). 16MB on -board RAM, 72MHz ARM7 processor, built-in real time clock, etc, etc. Mainboard twice the price of the Netduino though. The kit is $290 although that comes with a fair bit of cool stuff as well..

http://www.ghielectronics.com/catalog/product/297
 
well I have had some time to work on the code in the last couple of days, this is it, the manual mode is complete now to work on the auto mode and the setup.


//libraries
#include<EEPROM.h>
#include<LiquidCrystal.h>
#include<OneWire.h>
#include<PID_v1.h>
OneWire ds(11);
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
//pushbuttons
constint Button_up = A3;
constint Button_dn = A2;
constint Button_prev = A1;
constint Button_nxt = A0;
//outputs
constint Heat = 9;
constint Pump = 8;
//variables
int WindowSize = 5000;
unsigned long windowStartTime;
double Setpoint, Input, Output;
boolean autoLoop = false;
boolean manuLoop = false;
boolean waterAdd = false;
boolean Conv_start = false;
boolean mpump = false;
boolean mheat = false;
boolean wtBtn = false;
float mset_temp = 35;
float Temp_c;
int temp;
byte mainMenu = 0;
byte setupMenu = 0;
byte pidMenu = 0;
byte autoMenu = 0;
byte stepTime;
byte pumpTime;
byte data[2];
byte i;
byte Busy = 0;
//Specifythelinksandinitialtuningparameters
PID myPID(&Input, &Output, &Setpoint,200,5,3, DIRECT);
void setup()
{
// Start up the library
lcd.begin(16,2);
pinMode (Button_up,INPUT);
pinMode (Button_dn,INPUT);
pinMode (Button_prev,INPUT);
pinMode (Button_nxt,INPUT);
pinMode (Heat,OUTPUT);
pinMode (Pump,OUTPUT);
windowStartTime=millis();
//tell the PID to range between 0 and the full window size
myPID.SetOutputLimits(0, WindowSize);
myPID.SetMode(AUTOMATIC);
}

void loop()
{
switch (mainMenu){
case (0):
Temperature();
lcd.setCursor(0,0);
lcd.print("The Brauduino");
lcd.setCursor(0,1);
lcd.print("Temp=");
lcd.setCursor(6,1);
lcd.print(Temp_c);
//read the buttons for menu selection

if (digitalRead(Button_dn)==0){
delay(1000);
if (digitalRead(Button_dn)==0){
lcd.setCursor(0,0);
lcd.print(" Manual ");
lcd.setCursor(0,1);
lcd.print(" ");
mainMenu=1;
while(digitalRead(Button_dn)==0){
}
}
}
if (digitalRead(Button_prev)==0){
delay(1000);
if (digitalRead(Button_prev)==0){
lcd.setCursor(0,0);
lcd.print(" Auto ");
lcd.setCursor(0,1);
lcd.print(" ");
mainMenu=2;
while(digitalRead(Button_prev)==0){
}
}
}
if (digitalRead(Button_nxt)==0){
delay(1000);
if (digitalRead(Button_nxt)==0){
lcd.setCursor(0,0);
lcd.print(" Setup ");
lcd.setCursor(0,1);
lcd.print(" ");
mainMenu=3;
while(digitalRead(Button_nxt)==0){
}
}
}
break;

case(1): //manual mode
delay(1000);
lcd.setCursor(0,0);
lcd.print(" Water added? ");
lcd.setCursor(0,1);
lcd.print(" Yes Quit");
wtBtn=true;
while (wtBtn){
if (digitalRead(Button_prev)==0){
manuLoop=true;
wtBtn=false;
while(digitalRead(Button_prev)==0){
}
}
if (digitalRead(Button_nxt)==0){
mainMenu=0;
wtBtn=false;
while(digitalRead(Button_nxt)==0){
}
}
}
while (manuLoop){
Temperature();
Setpoint=mset_temp*16;
Input=Temp_c*16;
lcd.setCursor(0,0);
lcd.print(" Manual Mode ");
lcd.setCursor(0,1);
lcd.print("ST=");
lcd.print(mset_temp);
lcd.setCursor(8,1);
lcd.print("AT=");
lcd.print(Temp_c);
if (digitalRead(Button_up)==0){
delay(200);
if (digitalRead(Button_dn)==0){
digitalWrite(Heat,LOW);
digitalWrite(Pump,LOW);
mainMenu=0;
manuLoop=false;
lcd.clear();
}
else{
mset_temp=mset_temp+0.25;
}
while (digitalRead(Button_up)==0){
}
}
if (digitalRead(Button_dn)==0)
{
delay(200);
if (digitalRead(Button_up)==0){
digitalWrite(Heat,LOW);
digitalWrite(Pump,LOW);
mainMenu=0;
manuLoop=false;
lcd.clear();
}
else{
mset_temp=mset_temp-0.25;
}
while (digitalRead(Button_dn)==0){
}
}
//turns heat on or off
if (digitalRead(Button_prev)==0){
while(digitalRead(Button_prev)==0){
}
if (mheat==false){
mheat=true;
}
else{
mheat=false;
digitalWrite(Heat,LOW);
}
}

//turns the pump on or off
if (digitalRead(Button_nxt)==0){
if (mpump == false){
mpump=true;
digitalWrite(Pump,HIGH);
}
else{
mpump=false;
digitalWrite(Pump,LOW);
}
while(digitalRead(Button_nxt)==0){
}
}
if (mheat){
PID_HEAT();
}
}
break;
case(2):
if (digitalRead(Button_up)==0){
delay(100);
if (digitalRead(Button_dn)==0){
mainMenu=0;
while ( digitalRead(Button_dn)==0){
}
}
}
break;
case(3):
if (digitalRead(Button_up)==0){
delay(100);
if (digitalRead(Button_dn)==0){
mainMenu=0;
while ( digitalRead(Button_dn)==0){
}
}
}
break;
}
}
void Temperature(void)
{
ds.reset();
ds.skip();
// start conversion and return
if (!(Conv_start)){
ds.write(0x44,0);
Conv_start=true;
return;
}
// check for conversion if it isn't complete return if it is then convert to decimal
if (Conv_start){
Busy=ds.read_bit();
if (Busy == 0){
return;
}
ds.reset();
ds.skip();
ds.write(0xBE);
for ( i = 0; i < 2; i++) { // we need 2 bytes
data=ds.read();
}
unsigned int raw = (data[1] << 8) + data[0];
Temp_c=(raw&0xFFFC)*0.0625;
Conv_start=false;
return;
}
return;
}
void PID_HEAT (void){
myPID.Compute();
/************************************************
*turntheoutputpinon/offbasedonpidoutput
************************************************/
unsigned long now = millis();
if(now - windowStartTime>WindowSize)
{//time to shift the Relay Window
windowStartTime+=WindowSize;
}
if(Output > now - windowStartTime) digitalWrite(Heat,HIGH);
else digitalWrite(Heat,LOW);

return;


}
 
its getting close, today i have sorted out the menus now just get the auto function written and it will be done.
I have been thinking about the setup menu, it has 2 sub menus "brauduino setup" which adjusts the PID settings and the 'Auto settings' which is where you adjust the stage times and temps, what I'm thinking about is in the brauduino setup allowing the users to change the number of stages from 2 to 7 so when the user goes into the Auto setup menu only the number of stages that they want appears and they don't have to scroll through unwanted stages.

so what do people think?

cheers steve
 
its getting close, today i have sorted out the menus now just get the auto function written and it will be done.
I have been thinking about the setup menu, it has 2 sub menus "brauduino setup" which adjusts the PID settings and the 'Auto settings' which is where you adjust the stage times and temps, what I'm thinking about is in the brauduino setup allowing the users to change the number of stages from 2 to 7 so when the user goes into the Auto setup menu only the number of stages that they want appears and they don't have to scroll through unwanted stages.

so what do people think?

cheers steve
Sounds like a good idea, but is there any thing else in the setup menu? It seems a waste to have a menu of one entity.

I am interested to see how you implemented the stages with their timing. What happens if you have a power glitch. Does it recover? This is important to me.

Am I right to guess that this is going on the braumiser? It seems as though we cross threads a lot... :)
 
Sounds like a good idea, but is there any thing else in the setup menu? It seems a waste to have a menu of one entity.

I am interested to see how you implemented the stages with their timing. What happens if you have a power glitch. Does it recover? This is important to me.

Am I right to guess that this is going on the braumiser? It seems as though we cross threads a lot... :)

the setup menu also includes the PID multipliers and the PID window size, so adding a few more sub menus would probably make it more worthwhile.
As for brownouts and loss of power I have been thinking about this, what I could do is make it so that there is a 'auto started' byte in the eeprom that is set every time the 'auto' process is started, when the stage is entered it is recorded in the eeprom, the time left is recorded at set intervals, if the process finishes with out a glitch then the 'auto started' byte is cleared. Before the 'auto' process is entered the 'auto started' byte is read and if it is set then it will ask you if you want to continue with the last process, it can then read the stage and time from the last session and continue from there. This will also let people to exit the process and change a setting and then pick up from where they left off.

Yeah this is for the braumiser, I was asked to supply the braumiser controller so I have decided to develope it for the arduino and make up a sheild for it, this will make it easier for people to modify the code to suit their system.

cheers steve
 
the setup menu also includes the PID multipliers and the PID window size, so adding a few more sub menus would probably make it more worthwhile.
As for brownouts and loss of power I have been thinking about this, what I could do is make it so that there is a 'auto started' byte in the eeprom that is set every time the 'auto' process is started, when the stage is entered it is recorded in the eeprom, the time left is recorded at set intervals, if the process finishes with out a glitch then the 'auto started' byte is cleared. Before the 'auto' process is entered the 'auto started' byte is read and if it is set then it will ask you if you want to continue with the last process, it can then read the stage and time from the last session and continue from there. This will also let people to exit the process and change a setting and then pick up from where they left off.

Yeah this is for the braumiser, I was asked to supply the braumiser controller so I have decided to develope it for the arduino and make up a sheild for it, this will make it easier for people to modify the code to suit their system.

cheers steve

You really are a champ for doing that for other people :)
When you are done, send your code my way and I will have a look through as a once-over if you want.

Personally, to attack the brownout problem on my upcoming system (looks like I won't be going the braumiser route) I will have a real time clock in there. This means when the "job" is started it will save the steps and associated time stamps into the EEPROM. When it wakes from a brownout, it reads the current time and compares it to the saved steps and continues on its merry way.

I have not started this project but have been thinking about it in thorough detail. Are you also using the PID Library?

My plan:
Seeduino Stalker
5V power supply
DS18B20 probes (there are some with thermowells on the evilbay, which may be suitable)
25A relays (for any heating elements and the March pumps)
Wireless programming via Xbee so I don't have to bring PC to the garage or the controller into the house.
panel mount power outlets (like the ones I used on the fridge controller)
Serial (I2C) LCD (only 2x16 which I already have)
4x buttons for menu system.

I am trying to keep this as simple as possible.
Perhaps I could even go for the dealextreme display/buttons again, I really like that piece of kit...
 
My plan:
Seeduino Stalker
5V power supply
DS18B20 probes (there are some with thermowells on the evilbay, which may be suitable)
25A relays (for any heating elements and the March pumps)
Wireless programming via Xbee so I don't have to bring PC to the garage or the controller into the house.
panel mount power outlets (like the ones I used on the fridge controller)
Serial (I2C) LCD (only 2x16 which I already have)
4x buttons for menu system.


Hey mate, what's the 5V power supply for? I used to think you needed a 5V adapter to power the arduino, but apparently that's not the case: http://arduino.cc/playground/Learning/WhatAdapter . That is unless you have a really well regulated supply and put it straight on the +5V pin. If you're using the 2.1mm dc jack, you'll need a bit more voltage I think.
 
Hey mate, what's the 5V power supply for? I used to think you needed a 5V adapter to power the arduino, but apparently that's not the case: http://arduino.cc/playground/Learning/WhatAdapter . That is unless you have a really well regulated supply and put it straight on the +5V pin. If you're using the 2.1mm dc jack, you'll need a bit more voltage I think.
Yes, you can bypass the onboard regulator and supply 5V directly to the 5V pin. The voltage required on the DC jack depends on the regulator used, but should be between approximately 7V and 12V. The higher the voltage you supply, the more heat the regulator has to dissipate, so the lower the better. 9V is a good compromise.
 
Hey mate, what's the 5V power supply for? I used to think you needed a 5V adapter to power the arduino, but apparently that's not the case: http://arduino.cc/playground/Learning/WhatAdapter . That is unless you have a really well regulated supply and put it straight on the +5V pin. If you're using the 2.1mm dc jack, you'll need a bit more voltage I think.
Yes but I am using a seeeduino stalker, which runs from 5v and regulates down to 3.3v with a back up lipo battery.

I bypassed the 5V regulator on the fridge set up, it's easier than sourcing a 9V supply... I have mountain loads of 5v and 12v supplies and no 9V, so I chose the lesser of two evils.
 
Also, now that I mention seeed products, I am totally keen to test the dragrove from them too. Look into it...
 
When you are done, send your code my way and I will have a look through as a once-over if you want.

when I'm finished I'm planning on posting the whole code so more experienced coders can review it and fix things up if needed.

cheers
 
I have finished with the code, I'm fairly happy with it, all up its about 17k in size so there is room to expand, I'll post the schematics and code after I have tested it a bit more

cheers steve
 
I have finished with the code, I'm fairly happy with it, all up its about 17k in size so there is room to expand, I'll post the schematics and code after I have tested it a bit more

cheers steve
Nice work metho! Now we've just gotta get the shield finished and printed and we can all start testing it.
 
Learn some git and chuck it up on https://github.com/ so we can track your changes.

All my brewbot code and other temp controllers and stuff is up there.

https://github.com/Zizzle

that looks cool I'll will do that zizzle

Nice work metho! Now we've just gotta get the shield finished and printed and we can all start testing it.

yeah mate we will, I already have 10 lcd on the way, there are a couple of part that I want to get to see if they are correct before I order the PCB, I think I should order all the parts and print out the PCB on paper to make sure all the parts go together correctly.

cheers steve
 
I think I should order all the parts and print out the PCB on paper to make sure all the parts go together correctly.
Yeah that's a really good idea. It's a good way to avoid component clearance issues.
 
that looks cool I'll will do that zizzle



yeah mate we will, I already have 10 lcd on the way, there are a couple of part that I want to get to see if they are correct before I order the PCB, I think I should order all the parts and print out the PCB on paper to make sure all the parts go together correctly.

cheers steve
Where did you get your boards made up matho?
I am very keen to use the seeedstudio service, very cheap for what you get.
 
Where did you get your boards made up matho?
I am very keen to use the seeedstudio service, very cheap for what you get.
Edak, The Seeeduino Fusion PCB service is what I used for my bonjuino and HERMS boards. The quality seems pretty decent and the price is great. I have been doing 10 board orders. They take about 3 weeks from order to your door.
 
Back
Top