Hi!
I'm working on a brew kettle using an arduino as the PID and interface, a ULWD water heater element, adafruit LCD sheild, a rotary controller, 1-wire temp probe and mostly the code from this project. I started out about a year ago building it from scratch and piecing together bits of code but since this tutorial showed up it has about 90% of the code with a few minor issues.
In essence I could use the existing code from the SousViduino with alterations for the LCD (mine isn't rgb, just backlit) if it wasn't for the rotary encoder. I need to switch up the temperature from about 150F to 212F in the process of brewing. I *could* do this with the buttons but it would take a bit to get between the two temperatures. So the encoder was intended to provide a great way to adjust temperatures and possibly bits of the PID variables.
Here's what I have specifically:
LCD http://www.adafruit.com/products/772
Encoder http://www.adafruit.com/products/377
A SSR rated for 30amps
ULWD Heating Element http://www.amazon.com/Camco-02963-Screw ... B000BPG4LI
Temp sensor http://www.adafruit.com/products/642
I'm assuming, since I'll be using the ssr, I can remove the code in the tutorial for the time proportional output. But for the encoder I want to use the library here: https://code.google.com/p/adaencoder/ as it only reads the detents or clicks, instead of every state change for the a & b pins. But it seems to run constantly, meaning if the encoder is moved while the arduino isn't in an adjustment mode, the value being adjusted jumps to match any turns while the SousVide portion was running.
My question is how can I have that library only "run" or pay attention only when I'm in a variable editing state? Or does someone know of another way to do this without that library? Again, I just want the input to increment +/- per click/detent, not per state change. For the set temp, that is 1°F. I think I can figure out the code for the rest once I have that. Most encoder code I've found wants to read every state change to increment.
Any help appreciated.
Tom
SousViduino alterations
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_bill
- Posts: 88087
- Joined: Sat Feb 07, 2009 10:11 am
Re: SousViduino alterations
No. You still want to do the TPO. You 'can' PWM the SSR, (PWM is just TPO with a higher switching frequency) but you will need to heat sink it. For most heating applications with substantial thermal mass, TPO is appropriate.I'm assuming, since I'll be using the ssr, I can remove the code in the tutorial for the time proportional output.
I'm not familiar with the encoder library you are using. But looking at the documentation, you need to monitor the rotation in your loop. If you are not in a variable editing state, then don't monitor the rotation.can I have that library only "run" or pay attention only when I'm in a variable editing state?
-
- Posts: 7
- Joined: Fri Jan 04, 2013 5:17 pm
Re: SousViduino alterations
Bill,
Thanks for the response. Using the SSR without a heatsink will be much easier design wise.
As for the code, here's what I've used as a test. It is meant to just test out the concept of the machine state between running and editing variables, using the button on the encoder to switch between the two.
When I run it, the arduino is watching the encoder in all states. In this case both in run() and adjust(). I think I'm only calling the AdaEncoder while in adjust() but if I rotate the encoder while in run() those additional clicks are immediately applied to the variable Setpoint.
Any advice?
code:
Thanks for the response. Using the SSR without a heatsink will be much easier design wise.
As for the code, here's what I've used as a test. It is meant to just test out the concept of the machine state between running and editing variables, using the button on the encoder to switch between the two.
When I run it, the arduino is watching the encoder in all states. In this case both in run() and adjust(). I think I'm only calling the AdaEncoder while in adjust() but if I rotate the encoder while in run() those additional clicks are immediately applied to the variable Setpoint.
Any advice?
code:
Code: Select all
// sketch to test code necessary to run encoder as needed
//Libraries for LCD
#include <Wire.h>
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>
//libraries for Encoder
#include <ByteBuffer.h>
#include <ooPinChangeInt.h>
#include <AdaEncoder.h>
//defining encoder pins
#define ENCA_a 9
#define ENCA_b 8
// for push button on encoder
#define PUSH 7
//tell encoder library what/where encoder is
AdaEncoder encoderA = AdaEncoder('a', ENCA_a, ENCA_b);
//set up variables for encoder checking
int clicks = 0;
int Setpoint = 200;
int buttonState = 0;
// tell rgblcd sheild library where to find some stuff
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
#define ON 0x7
void setup()
{
//set pinmode for pushbutton
pinMode(PUSH, INPUT_PULLUP);
//define size of lcd
lcd.begin(16,2);
//turn backlight on
lcd.setBacklight(ON);
}
void loop()
{
lcd.clear();
switch (opState);
{
case RUN:
run();
break;
case ADJ:
adjust();
break;
}
}
void run()
{
while (digitalRead(PUSH) == LOW)
{
//indicate we are in loop
lcd.setCursor(5,0);
lcd.print("LOOPING");
lcd.setCursor(7,1);
lcd.print(Setpoint);
}
//watch pushbutton, jump if pressed
val=digitalRead(PUSH);
if (val == HIGH) {
lcd.clear()
opState = "ADJ";
}
}
void adjust()
{
while (digitalRead(PUSH) == LOW)
{
//clear lcd
lcd.clear();
lcd.setCursor(5,0);
lcd.print("ADJUSTING");
lcd.setCursor(7,1);
lcd.print(Setpoint);
clicks=AdaEncoder::genie()->query();
if (clicks > 0) {
}
- adafruit_support_bill
- Posts: 88087
- Joined: Sat Feb 07, 2009 10:11 am
Re: SousViduino alterations
In the code posted, I don't see where Setpoint gets assigned any value at all. Is there some missing code?
Please be positive and constructive with your questions and comments.