Offline
Jr. Member
Karma: 0
Posts: 53
|
 |
« Reply #15 on: August 23, 2011, 11:01:07 pm » |
The SSR definitely works with anything else. Will the ones I ordered from China be better suited for the application? Should I just wait and test those?
Edit: The SSR has a little red LED on it so I know when it turns off and on, and I have used it for other applications in the past and it has worked perfectly. It must be the inductive load like you said.
The relay modules you purchased use electro-mechanical relays, not a SSR. So your relays use simple mechanical switch contacts to turn on and off the external circuit, just like a standard wall light switch might. SSRs use internal semiconductor parts, a back to back SCR type devices called a triac to do the switching. Lefty Oh I didn't realize they were electro mechanical. Makes sense. Thanks for all the fast replies. You have been amazingly helpful.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 53
|
 |
« Reply #16 on: August 24, 2011, 04:03:22 pm » |
So, do you see any problems with my super ghetto MS paint Schematic attached?
|
|
|
|
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15293
Measurement changes behavior
|
 |
« Reply #17 on: August 24, 2011, 04:50:30 pm » |
Looks good to me.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 53
|
 |
« Reply #18 on: September 22, 2011, 11:43:31 am » |
Ok,
So I have everything wired up and working, however I am having some issues with my temperaure sensors. I have attached a full wiring schematic which looks pretty much exactly like my actual panel.
Red = Hot Black = Signal Green = Neutral/Ground
Like I said, everything works, however I am getting some strange noise in my temp sensors.
They work perfectly fine in the begining, all of them reading like 68 degrees.
Now there are two times when things go bad.
1) When I trip a relay and a Valve is opened. If I unhook the vavles, things remain ok.
2) when I let it sit for a long time doing nothing. Everything starts out fine, temp sensors reading true temps, then after a random amount of time, any where from 5 minutes to 4 hours, temp readings are all over the place.
So when things go bad, the sensors just start reading crazy temps anywhere from like 40 to 110 degrees in ambient air (appox. 68 degrees). After things go crazy, they never go back to normal until I unplug the arduino. When I plug it back in the sensors read correct temps, until I either open a valve or after some random amount of time goes by.
Other things of interest: Temp Sensors are LM34CAZ and I have check the voltages from power supplys and they are dead stable.
Any help is highly appreciated.
Thanks, Craig
|
|
|
|
« Last Edit: September 22, 2011, 11:46:55 am by Cruelkix »
|
Logged
|
|
|
|
|
New Jersey
Offline
Edison Member
Karma: 24
Posts: 2345
|
 |
« Reply #19 on: September 22, 2011, 05:38:42 pm » |
1 has the faint smell of power issues, but hard to be sure - does the system settle down if you turn the solenoid off again? 2 says software. Please post your code.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 53
|
 |
« Reply #20 on: September 22, 2011, 06:44:36 pm » |
1 has the faint smell of power issues, but hard to be sure - does the system settle down if you turn the solenoid off again? 2 says software. Please post your code.
1) No, the system never settles down even if I shut off the relays and solenoids, only when I complete unplug the Arduino, reset doesn't cut it. 2) I warn you I am not the best coder on the planet... I'm welcome to any changes to clean things up as well.
#include <SPI.h> #include <Ethernet.h>
#define maxLength 60
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x5A, 0xFA }; byte ip[] = { 192,168,0, 177 };
Server server(80);
String inString = String(maxLength); long previousMillis = 0; int setferm1 = 300; int setferm2 = 300; int setferm3 = 300; int setferm4 = 300; int Posa = 0; int Posb = 0; int Posc = 0; int Posd = 0; int whichTank = -1; int chillValue = 10; char tempBuff[4]; int chill = 0; int valveToOpenIdx = -1; double volts = 0.48535; int TempSensor1 =0; int TempSensor2 =0; int TempSensor3 =0; int TempSensor4 =0;
void setup() { Ethernet.begin(mac, ip); server.begin(); Serial.begin(9600); pinMode(2, OUTPUT); pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); digitalWrite(2, HIGH); digitalWrite(3, HIGH); digitalWrite(4, HIGH); digitalWrite(5, HIGH); digitalWrite(6, LOW); }
void loop() { //Get Temps off sensors analogRead(1); delay(10); TempSensor1 = 0; for (int i = 0; i < 10; i++) { TempSensor1 = TempSensor1 + round(volts*analogRead(1)); } analogRead(2); delay(10); TempSensor2 = 0; for (int i = 0; i < 10; i++) { TempSensor2 = TempSensor2 + round(volts*analogRead(2)); } analogRead(3); delay(10); TempSensor3 = 0; for (int i = 0; i < 10; i++) { TempSensor3 = TempSensor3 + round(volts*analogRead(3)); } analogRead(4); delay(10); TempSensor4 = 0; for (int i = 0; i < 10; i++) { TempSensor4 = TempSensor4 + round(volts*analogRead(4)); } TempSensor1 = round(TempSensor1/10); TempSensor2 = round(TempSensor2/10); TempSensor3 = round(TempSensor3/10); TempSensor4 = round(TempSensor4/10); // Web Interface int bufLength = 4; // listen for incoming clients Client client = server.available(); if (client) { // an http request ends with a blank line // Serial.println(client.read());
boolean currentLineIsBlank = true; while (client.connected()) { if (client.available()) { char c = client.read(); if (inString.length() < maxLength) { inString += c; } if (c == '\n' && currentLineIsBlank) { // send a standard http response header if (inString.indexOf("?") > -1) { Posa = inString.indexOf("a"); Posb = inString.indexOf("b"); Posc = inString.indexOf("c"); Posd = inString.indexOf("d"); inString.substring((Posa+2), (Posb-1)).toCharArray(tempBuff, bufLength); //transfer substring to buffer setferm1 = atoi(tempBuff); inString.substring((Posb+2), (Posc-1)).toCharArray(tempBuff, bufLength); //transfer substring to buffer setferm2 = atoi(tempBuff); inString.substring((Posc+2), (Posd-1)).toCharArray(tempBuff, bufLength); //transfer substring to buffer setferm3 = atoi(tempBuff); inString.substring((Posd+2), (Posd+5)).toCharArray(tempBuff, bufLength); //transfer substring to buffer setferm4 = atoi(tempBuff); }
client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println(); client.print("<font size=32 color=CDAD00><b><u>HGB Fermenter Control</u></b></font><br /><br /> "); // output the value of each analog input pin client.print("<font size=32>Temperature of Fermenter 1 is ");client.print(TempSensor1);client.println("</font><br />"); client.print("<font size=32>Temperature of Fermenter 2 is ");client.print(TempSensor2);client.println("</font><br />"); client.print("<font size=32>Temperature of Fermenter 3 is ");client.print(TempSensor3);client.println("</font><br />"); client.print("<font size=32>Temperature of Fermenter 4 is ");client.print(TempSensor4);client.println("</font><br />"); client.print("<br /><br /><form method=get><font size=32>"); client.print("Setpoint Fermenter 1: <input type=text style=font-size:32pt size=3 name=a value="); client.print(setferm1);client.print(" />"); if (valveToOpenIdx == 0) { client.print(" Open"); } else { client.print(" Closed"); } client.print("<br />"); client.print("Setpoint Fermenter 2: <input type=text style=font-size:32pt size=3 name=b value="); client.print(setferm2);client.print(" />"); if (valveToOpenIdx == 1) { client.print(" Open"); } else { client.print(" Closed"); } client.print("<br />"); client.print("Setpoint Fermenter 3: <input type=text style=font-size:32pt size=3 name=c value="); client.print(setferm3);client.print(" />"); if (valveToOpenIdx == 2) { client.print(" Open"); } else { client.print(" Closed"); } client.print("<br />"); client.print("Setpoint Fermenter 4: <input type=text style=font-size:32pt size=3 name=d value="); client.print(setferm4);client.print(" />"); if (valveToOpenIdx == 3) { client.print(" Open"); } else { client.print(" Closed"); } client.print("<br />"); client.println("<br />"); client.print("<input type=submit value=Update-Temps style=height:6em; width:24em />"); client.print("</font></form>"); client.println("<br />"); break; } if (c == '\n') { // you're starting a new line currentLineIsBlank = true; } else if (c != '\r') { // you've gotten a character on the current line currentLineIsBlank = false; } } } // give the web browser time to receive the data delay(1); inString = " "; // close the connection: client.stop(); } // Valve Control Logic delay(2000); Serial.println(TempSensor1); Serial.println(TempSensor2); Serial.println(TempSensor3); Serial.println(TempSensor4); Serial.println(digitalRead(6)); switch ( whichTank ) { case 0: chillValue = TempSensor1-setferm1; break; case 1: chillValue = TempSensor2-setferm2; break; case 2: chillValue = TempSensor3-setferm3; break; case 3: chillValue = TempSensor4-setferm4; break; } if (chillValue < -1 && valveToOpenIdx != -1) { digitalWrite(6, LOW); delay(1000); digitalWrite(2, HIGH); digitalWrite(3, HIGH); digitalWrite(4, HIGH); digitalWrite(5, HIGH); volts = 0.48535; delay(100); //Serial.println("Closed "); // Serial.println(valveToOpenIdx); chill = 0; } if (chill == 0) { int tankSetTemps[4] = {setferm1, setferm2, setferm3, setferm4}; int tankTemps[4] = {TempSensor1, TempSensor2, TempSensor3, TempSensor4}; int curTankDiff; int maxTankDiff = 0; valveToOpenIdx = -1; for (int i = 0; i < 4; i++) { curTankDiff = tankTemps[i] - tankSetTemps[i]; if (curTankDiff > maxTankDiff) { valveToOpenIdx = i; whichTank = i; maxTankDiff = curTankDiff; } } if (valveToOpenIdx != -1) { digitalWrite(valveToOpenIdx + 2, LOW); digitalWrite(6, HIGH); volts = 0.48535; // Serial.println("Opened "); // Serial.println(valveToOpenIdx); chill = 1; } }
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 53
|
 |
« Reply #21 on: September 22, 2011, 07:02:15 pm » |
Here's a short output of TempSensor1. You can easily see when I turn on the relay. The strange part to me is that it really only shows readings from like 52-110. Granted they are all over the place. When I read it straight off the arduino with a volt meter, I get a constant voltage across the power supply and the temp probes show steady numbers at 0.76 volts. Very confusing. Must be a coding issue?? 75 75 75 75 75 75 75 75 75 75 75 76 75 54 102 88 95 107 85 69 99 89 104 97 100 83 88 89 59 95 67 79 87 57 64 59 77 82 110 63 71 58 74 101 88 54 66 56 77 85 108 92 61 82 113 72 99 95 88 79 55 72 89 105 65 57 74 83 71 84 53 80 101 67 118 82 95 65 99 84 108 60 94 77 99 62 52 54 56 62 89 88 61 93 53 78 82 54 86 80 98 92 58 81 74 99 75 55 72 74 80 100 66 105 68 112 102 56 99 73 92 70 83 79 86 74 83 81 97 72 88 56 85 104 84 94 98 97 84 82 81 98 65 106 75 110 108 75 62 112 64 101
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 53
|
 |
« Reply #22 on: September 22, 2011, 07:32:08 pm » |
Ok, In an effort to simplify the crap out of this problem, I made the code very simplistic, and I am seeing the same issue. When I remove the power from the solenoids, no issue. Readings remain constant. This to me screams of some sort of power issue. #include <SPI.h>
double volts = 0.48535;
void setup() {
// initialize serial communications at 9600 bps: Serial.begin(9600); pinMode(2, OUTPUT); pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); digitalWrite(2, HIGH); digitalWrite(3, HIGH); digitalWrite(4, HIGH); digitalWrite(5, HIGH); digitalWrite(6, LOW); }
void loop() { //Get Temps off sensors for (int g = 0; g < 10; g++) { Serial.println(volts*analogRead(1)); Serial.println(volts*analogRead(2)); Serial.println(volts*analogRead(3)); Serial.println(volts*analogRead(4)); delay(1000); }
//Turn Relay On digitalWrite(2, LOW); delay(3000); //Turn Relay Off digitalWrite(2, HIGH); delay(3000); }
|
|
|
|
« Last Edit: September 22, 2011, 07:58:16 pm by Cruelkix »
|
Logged
|
|
|
|
|
New Jersey
Offline
Edison Member
Karma: 24
Posts: 2345
|
 |
« Reply #23 on: September 22, 2011, 07:58:03 pm » |
I don't know what the analogRead command is going to do with analogRead(1). From the documentation, it looks like it is acceptable but humour me and try analogRead(A1) instead. I've no business advising you about hardware issues, but I'd be inclined to try driving a LED (with a suitable resistor) instead of the solenoid to zero in on whether power is your issue.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 53
|
 |
« Reply #24 on: September 22, 2011, 08:06:07 pm » |
I don't know what the analogRead command is going to do with analogRead(1). From the documentation, it looks like it is acceptable but humour me and try analogRead(A1) instead. I've no business advising you about hardware issues, but I'd be inclined to try driving a LED (with a suitable resistor) instead of the solenoid to zero in on whether power is your issue.
A1 does the same thing. So lets talk crazy. I plugged in the 12 volt power supply while I had good readings going. All I had to do was plug it in, and everything went to shit. So I unplug it to see if things stable. Nope. I go to unplug the Arduino to reset it, and I touch the ethernet cat 5 jack. I get a little shock, and everything goes back to normal....... right back to good sensor readings. So somehow, Something is not grounded properly or something. The arduino is carrying some sort of stored charge. I'm so confused.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 53
|
 |
« Reply #25 on: September 22, 2011, 08:21:59 pm » |
Alight, That's messed up. I unplugged my ethernet cable.... Everything works perfectly. What the hell do I do about that?
Edit: Nevermind. That was the not the issue. There is definitely some sort of power problem tho.
|
|
|
|
« Last Edit: September 22, 2011, 08:50:09 pm by Cruelkix »
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 53
|
 |
« Reply #26 on: September 23, 2011, 03:53:58 pm » |
Ok, so to add to things that I just dont truly understand, if I plug ANYTHING into ANY of the outlets in the room, it sets the temp sensors going crazy.
Like I pluged a lamp in, comletely unrelated to the control panel, and then sensors went nuts. This is with the arduino plugged in via the USB cable ONLY. the solenoids werent even attached in any way. So weird.
I also removed teh Ethernet sheild to see if that was causing the issue. Same thing was heppening with out it.
I hope someone has a good idea, becuase I am stumped and demotivated....
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 53
|
 |
« Reply #27 on: September 26, 2011, 09:52:22 am » |
So I found a, solution, kinda...
I switched the temp sensors over to the 3.3V line and left the relays on the 5V line.
Everything appears to be working properly now. There must have been some noise coming through the relays. I ordered some DS18B20 Digital Temp sensors prior to finiding this fix. I will give them a go and see if I have more stable.
|
|
|
|
|
Logged
|
|
|
|
|
|