Completed Ardunio Contoller: Few Problems, Help Needed

Hi friends,
I have completed my arduino controller with power module and lights using I2C mainly.

But i am having this issue:

When i Turn OFF or ON any of the High Load Switches in the power moduleThe Arduino goes into Freeze mode and the LCD blanks and the keyboard becomes inactive.

I have made this Aquarium controller for my aquarium. Written the code with a help of a few members in the Arduino forum and all seems to work perfectly

I am mainly using I2C to control my devices.

The main layout is :
arduino%20layout.jpg


The Display of the controller : have another display also attached to the system for secondary viewing.
DSC03205_resize.JPG


The controller with the I2C, Clock and with the back of the LCD panel and the Keyboard
DSC03145_resize.JPG


The power Module, using ULN 2003 and Relays. The Power module is Connected to the Controller using a 25Pin DB Wire.
DSC03161_resize.JPG


The Outlook of the power Module
DSC03162_resize.JPG


These are the problems: (I think they are related)

1. When the power module is not connected to the main system, the system works perfectly. There is a mode called FEEDMode, when i am into that mode by press of a key in the keypad, a few of the power modules are to TURN OFF for a period of time and then TURN ON again after that period, this works perfectly when the power Module is not connected to the system.
But when i connect the power Module to the system, and go into that FEED MODE it TURNS OFF the devices, goes through the Count and then TURNS on the DEVICES but the moment it turns ON The Devices the LCD goes BLANK with just a display of "1" in the SCREEN and KeyPad is FROZEN.. .so i need to restart the Arduino by powering it down and then ON it again.

2. Some times when there is a power Outtage, and when the System turns on again, i go into the Blank Screen Mode and Frozen keypad. But all the other controls in the Power Module are WORKING...

I even put diodes across the Relays to protect them, but no USE.

The Arduino Goes into FREEZE Mode when it handles the Power Module that is done using UNL2003/2004 ICs and Relays. The ULNs drive the Relays (+5v) and Relays Output (230vac) control the Motors and Pumps.

People on ardunio forum suggested it is de-coupling and i need to add capacitors to the pwr supply. and i added 100uF to the two power inputs (one to the Arduino and One to the Power Panel +5v PWR Supply) but that still had no effect. But creates another problem, the Arduino Freezes more often than before. Without the Capacitors, my system runs perfectly if i dont go into FEEDMODE.

Did you come across any such problem? or can you help me?
 
Last edited:
Double check that you are not accidently using 1 pin output on the Arduino for multiple functions. I did that once with an LCD and Ethernet shield. Everything would work find but as soon as It would send me an alert VIA email and the Ethernet shield started using the pin my LCD would blank out untill I manually reset the Arduino. Once I moved the pin outputs of the LCD to its own pin it never happened again. I was not using I2C I had the LCD and Ethernet shield directly atached to the Arduino.
 
I have two power supplies:
1. 5V/3A - this powers the Relay Coils basically the + of this PWR is connected to one end of the Relay coil, and the other end is from the ULN 2003. The ULN 2003 is powered by this power supply. The outputs of the I2C Port Expander from the Arduino is connected to the ULN2003 via the 25pinDb Cable. Hence, when i send a BYTE to the I2C Port Expander, it sends out 8 outputs to the ULN 2003 and that in turn TURNS on or OFF The Relay.
2. a 12V/2A Power supply connected to the Power Supply IN of the Arduino. This powers the Arduino, 6 I2C Port expanders (PCF8574), 1 Sparkun Clock module, 1 I2C EEPROM Memory Module and 3 DS18B20 Temperature Sensors.

Both the Power Supplies are basically Power Adapaters and are of SMPS Mode similar to that of a Laptop.

The GROUND of the 5V, and 12V are connected together in the Circuit even though both the plugs of these adapters are connected to the same A/c power source.

Gilweb, Actually i am using the 1 pin output only I2C for all these functions. If you say you didnt use I2C, then what do you mean by 1 Pin output? i didnt understand that, sorry.
 
Oh ok. i am actually using only the following PINS:

For I2C - analog pin 4 and 5
Temp Sensor = pin 11
GND and +5V Pins of the Arduino.

Thats all. No other pins are used.

Can i try this, use a 12V/4A Adapater, just 1, and power the Arduino though pin GND and VIN in the board? instead of using it through the Power Plug IN of the Arduino? and power the Relays with the SAME Adapter? Will this solve the problem?
 
5V/3A - this powers the Relay Coils basically the + of this PWR is connected to one end of the Relay coil, and the other end is from the ULN 2003.

That strikes me as an oversimplified circuit. What sort of load do those relays draw? What can the ULN2003 handle? Most relay driving circuits I've seen have a transistor between the IC and the relay and/or some kind of isolation. Check out the schematics for relays here:

http://www.arduino.cc/playground/Main/InterfacingWithHardware

EDIT - never mind, I just discovered that the ULN2003 is a darlington array. I thought it was an I2C port expander. What are you using to control the darlington array?

Oh ok. i am actually using only the following PINS:

For I2C - analog pin 4 and 5
Temp Sensor = pin 11
GND and +5V Pins of the Arduino.

Thats all. No other pins are used.

What temp sensor are you using? I've seen interference on I2C with some One-Wire temp sensors. Or is it just a passive sensor?

You also have an RTC in the block diagram in your fist post - is that running on I2C?

Maybe I'm just not wrapping my head around your project, but in the photos above, it looks like A TON of wiring for how simple you're describing the system. Is the I2C port expander you're using for the relays in the main box, or in the relay box? In your photo of the relay box it looks like there are 16 relays, but only 4 electrical outlets?

Can i try this, use a 12V/4A Adapater, just 1, and power the Arduino though pin GND and VIN in the board? instead of using it through the Power Plug IN of the Arduino? and power the Relays with the SAME Adapter? Will this solve the problem?

Can your relays take 12v? Above you said you were powering them with 5v. Also, which Arduino board are you using? Different clones have different power circuits.
 
That strikes me as an oversimplified circuit. What sort of load do those relays draw? What can the ULN2003 handle? Most relay driving circuits I've seen have a transistor between the IC and the relay and/or some kind of isolation. Check out the schematics for relays here:

http://www.arduino.cc/playground/Main/InterfacingWithHardware

EDIT - never mind, I just discovered that the ULN2003 is a darlington array. I thought it was an I2C port expander. What are you using to control the darlington array?

Actually the circuit is pretty complicated.. i made it so!!!

Using the outputs of the I2C to contol my ULN2003. And the relays draw approximately 70mA each.. i have 16 Relays in that circuit.

That circuit in Arduino is for driving ONE Relay. and i didnt want to many transistors in my circuit so went with the Relay Driver ULN2003.

What temp sensor are you using? I've seen interference on I2C with some One-Wire temp sensors. Or is it just a passive sensor?

You also have an RTC in the block diagram in your fist post - is that running on I2C?

I am using a Dallas Ds18B20 Temperature Sensor for the system. that draws nearly Zero Current.

Yes it is an RTC, that i got from Sparkfun. It is under I2C Topp


Maybe I'm just not wrapping my head around your project, but in the photos above, it looks like A TON of wiring for how simple you're describing the system. Is the I2C port expander you're using for the relays in the main box, or in the relay box? In your photo of the relay box it looks like there are 16 relays, but only 4 electrical outlets?

Yes the tons of wiring is because i am trying to control 2 Tanks with one Controller and it worked. So 25 wires needs to goto one tank (to the Relay Modue) through the 25 Pin DB Cable.

The system is simple actually speaking, as i worked with the system i realized i needed more ground and +5 V pins, so then came in the extra wires soldered to the system.. the extras went to control my Ds18B20 and the secondary unit - this is only the display - this display the parameters of my second tank. Currently i am not using this

Can your relays take 12v? Above you said you were powering them with 5v. Also, which Arduino board are you using? Different clones have different power circuits.

Actually the relays is a 6V Relay. and i have used it with 12V too. So was thinking i can use the 12 volt to get it going with ONE power supply to minimize my ground issues.


CAN I use Opto-Isolaters? between my 25 Pin DB and the ULN 2003? will this work?
 
Do you have a schematic? Without a schematic it will be hard to help you.

Here are some things to answer and/or think about:

  1. Are you using the ULN2003 to SOURCE or SINK current?
    • It should be used as a current sink
    • The negative sides of the relay coils should be attached to the ULN output pins. The ULN common pin should be tied to power ground.
    • The positive side of the relay could should be connected to your relay power supply. NOT the microcontroller's power supply.
  2. The Relays MUST have their OWN power supply (see above)
  3. Opto isolation would be on the INPUT side of the ULN driver to protect the microcontroller pins.
  4. You MUST have protection diodes on the relay coils. The inductive kick produced during turn-off can easily damage your driver and/or micro, especially if they are sharing a common postive rail or ground.
 
Do you have a schematic? Without a schematic it will be hard to help you.

Here are some things to answer and/or think about:

  1. Are you using the ULN2003 to SOURCE or SINK current?
    • It should be used as a current sink
    • The negative sides of the relay coils should be attached to the ULN output pins. The ULN common pin should be tied to power ground.
    • The positive side of the relay could should be connected to your relay power supply. NOT the microcontroller's power supply.
  2. The Relays MUST have their OWN power supply (see above)
  3. Opto isolation would be on the INPUT side of the ULN driver to protect the microcontroller pins.
  4. You MUST have protection diodes on the relay coils. The inductive kick produced during turn-off can easily damage your driver and/or micro, especially if they are sharing a common postive rail or ground.

I dont have a schematic, but have the PCB.
The Output (Negative) is connected to the Relays Coil. The Other end of the coil is connected to the + of the Power Source.
All Relays have a Seperate power Supply, the 5V.
Not done opto isolation, but will that help solve the situation?
There are protection diodes across the Relay Coil.
 
How did you build a project without a schematic?

Are the protection diodes properly installed? They should be in reverse polarity to the relay coil as close to the coil as possible.

Do you have an inductor on the power supply for the microcontroller and proper power filtering (both LARGE electrolytics and small ceramic bypass caps)?

What have you done with unused pins? Are they left floating or have they been tied to ground? Either set them as input and enable the internal pullups or set them to output and use external 1K load resistors.

Did you breadboard this before you built it?
 
Are using delay in your standby mode, I found that things would hang up with the delays used during the countdown, I fixed by using this code, try using this instead:
You will need to declare standbymillis in your initialization and set to 0. By using 1000millis interval instead of the 1 sec delay, it should do the same thing.

Code:
void standby (){
                  int interval = 1000;
                  lcd.clear();
                     lcd.setCursor(0,0); lcd.print("Feed mode active !");
                      digitalWrite(heater, LOW);
                      digitalWrite(coolingfans, LOW);
                      //digitalWrite(ph_1, LOW);
                      //digitalWrite(ph_2, LOW);
                      digitalWrite(sump, LOW); 
                  lcd.setCursor(0, 1); lcd.print("Time left: ");
                      counter_delay = feed_time * 60; // Number of seconds for feed mode
                      while(counter_delay >= 0){
                            lcd.setCursor(12,1);
                            minute = counter_delay / 60;
                            second = counter_delay % 60;
                            lcd.print(minute,DEC); delay(keypad_delay);
                            lcd.print(":");
                            if(second < 10) { lcd.print("0"); delay(keypad_delay);}
                            lcd.print(second,DEC);
                            if (millis() - stndbyMillis > interval) {
                                 stndbyMillis = millis();  
                                 counter_delay = counter_delay -1; }           
                            if (detectKey() == 3) {break;}
                            }
                    counter_delay = 0; lcd.clear();
                  }
 
Last edited:
Code:
[INDENT][COLOR=blue]void standby ()[/COLOR]
[COLOR=blue]    {[/COLOR]
[COLOR=blue]    int interval = 1000;[/COLOR]
[COLOR=blue]    lcd.clear();[/COLOR]
[COLOR=blue]    lcd.setCursor(0,0);[/COLOR]
[COLOR=blue]    lcd.print("Feed mode active !");[/COLOR]
[COLOR=blue]    digitalWrite(heater, LOW);[/COLOR]
[COLOR=blue]    digitalWrite(coolingfans, LOW);[/COLOR]
[COLOR=seagreen]    //digitalWrite(ph_1, LOW);[/COLOR]
[COLOR=seagreen]    //digitalWrite(ph_2, LOW);[/COLOR]
[COLOR=blue]    digitalWrite(sump, LOW); [/COLOR]
[COLOR=blue]    lcd.setCursor(0, 1); [/COLOR]
[COLOR=blue]    lcd.print("Time left: ");[/COLOR]
[COLOR=#0000ff]    counter_delay = feed_time * 60; [/COLOR][COLOR=seagreen]// Number of seconds for feed mode[/COLOR]
[COLOR=blue]    while(counter_delay >= 0)[/COLOR]
[COLOR=blue]         {[/COLOR]
[COLOR=blue]         lcd.setCursor(12,1);[/COLOR]
[COLOR=blue]         minute = counter_delay / 60;[/COLOR]
[COLOR=blue]         second = counter_delay % 60;[/COLOR]
[COLOR=blue]         lcd.print(minute,DEC); [/COLOR]
[COLOR=blue]         delay(keypad_delay);[/COLOR]
[COLOR=blue]         lcd.print(":");[/COLOR]
[COLOR=blue]         if(second < 10) [/COLOR]
[COLOR=blue]              { [/COLOR]
[COLOR=blue]              lcd.print("0"); [/COLOR]
[COLOR=blue]              delay(keypad_delay);[/COLOR]
[COLOR=blue]              }[/COLOR]
[COLOR=blue]         lcd.print(second,DEC);[/COLOR]
[COLOR=blue]         if (millis() - stndbyMillis > interval) [/COLOR]
[COLOR=blue]              {[/COLOR]
[COLOR=blue]              stndbyMillis = millis(); [/COLOR]
[COLOR=blue]              counter_delay = counter_delay -1;[/COLOR]
[COLOR=blue]              } [/COLOR]
[COLOR=blue]         if (detectKey() == 3) [/COLOR]
[COLOR=blue]              {[/COLOR]
[COLOR=blue]              break;[/COLOR]
[COLOR=blue]              }[/COLOR]
[COLOR=blue]    }[/COLOR]
[COLOR=blue]    counter_delay = 0; lcd.clear();[/COLOR]
[COLOR=blue]}  [/COLOR]
[/INDENT]

Sorry....

sloppy code formatting drives me out of my mind.
 
Last edited:
Not sure what you mean, BEAN? Not sure why it pasted the way it did, but it looks like what you just posted on my end, how do you get it to keep its format when putting onto a forum??
 
Not sure what you mean, BEAN? Not sure why it pasted the way it did, but it looks like what you just posted on my end, how do you get it to keep its format when putting onto a forum??

Was honestly not meant as an insult.

You can use CODE /CODE tags just like you would for other VB tags. That way you can format with spaces where needed.

I also took the code block brackets and placed them on their own lines and along with moving multiple statemenst to their own lines. It makes the code easier to read for novices... (even if it gets a good chuckle out of true C nerds)

99.999% of C coders (C, C++ Java, PHP, and any other C like language) learn to write "sloppy" formatted code... I think the term they use is "elegant" to describe code that is barely readable but stable.
 
Bean,
I did it without a schematic as the circuit was pretty simple. Just set the Address pins on the PCF8574 and take the outputs to the 8 pin connectors. Do this for the remaining I2Cs and from there i take the wires to the 25 DB Pin.

The Protection Diode is installed properly. If not installed properly, either the relay will NEVER turn ON or will Always TURN ON Right? Yes, This is how :
GND =>|= + of the PWR Supply.

Yes I did Bread board this before i did the circuit. And NO i dont have any Inductors or Capacitors at the Power Supply. I had 100uF at both the power Supplies, but still then the problem was persisting.

The Unused pins of the Arduino are Left Floating, I Believe it shouldnt be a problem.

The Whole Basis is, The Circuit And the Program WORKS PERFECTLY when the power Module is NOT Connected. But when the POWER MODULE is connected the Problem of Freezing arrives Randomly. I think it happens only when it turns on or Off the CHILLER. But It also Happens RANDOMLY when i Turn ON or OFF a switch in the Power Module. So the problem is the POWER MODULE.

Thanks SMORROW will try that code in my Delay. and See.. but Still even When not in FEED MODE the system Freezes now and Then!!!

Is there any capacitor value that i should try?
 
Power Supply:
Your power supply circuits need to have proper filtering, both large electros and smaller ceramic bypass caps. The inductor will also help. Will it fix the problem? I don't know.

Schematic:
You MUST have a schematic for a project like this. It is the only way that people can help to troubleshoot problems like you are hacving.

PCB layout:
Do you have a layout for the PCB? Poorly routed traces can act like antenae

Floating Pins:
Set the pins to INPUT and enable the internal pullups via code. Otherwise they may be acting like antenas and contributing to your problems.
 
Power Supply: What will be the Capacitor values that are required? Even if i have inductors what value is required? Do you have a schematic that i use?

Schematic:
Will get one done soon and post it now

PCB: Yes i have the PCB Layout, will post the pictures soon.

Floating Pins: Will Change all the floating pins to INPUTS. To minimize the Antenna problems. Shouldnt this be OUTPUT?
 
Back
Top