Go Down

Topic: Arduino Bar Project (Read 998 times) previous topic - next topic

mouseonmar

Hello!

The project im working on is a bar in a VW T3 Van.

With an Android App - or a rotary phone encoder you can select your drink and in the Van there are 7 metal-bottles with    
solenoid valves, that are connected to relays with are controlled by a arduino duemilanove.

The project is already working - the problem is the arduino gets resetted everytime when there are 2 relays to switch.
There is also a second relay modul connected for other things.

I already tried to use different power sources - to make sure that there is enough power for the relays/ the arduino.

Here i s the code i used:
And the relay modules i used:

http://www.ebay.at/itm/8-Kanal-5V-Relay-Relais-Module-Modul-Arduino-AVR-PIC-/270961218745?pt=Elektromechanische_Bauelemente&hash=item3f168c14b9
http://www.ebay.at/itm/4-Kanal-5V-Relay-Relais-Module-Modul-Arduino-TTL-Logik-/170828696163?pt=Elektromechanische_Bauelemente&hash=item27c62f0a63

If you have any ideas for solving my problem, please let me know!
Thank you very much in advance -
greetings
markus


Code: [Select]

/*
Mobile Bar Steuerung LEIDER GEIL vers 1.0

*/

/*-----( Import needed libraries )-----*/

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include "MeetAndroid.h"


// Zeugs für TelefonCotnroller

int needToPrint = 0;
int tel_count;

// wählscheibe angeschlossen an pin 1 und an masse

int tel_in = 7;
int lastState = LOW;
int trueState = LOW;
long lastStateChangeTime = 0;
int tel_cleared = 0;

// constants

int drinks_gesamt;

int dialHasFinishedRotatingAfterMs = 100;
int debounceDelay = 15;


// Zeugs für Telefon Controller

/*-----( Declare objects )-----*/

MeetAndroid meetAndroid;

LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27




/*-----( Getränke aufrufen )-----*/

void weiss_wein(){

 digitalWrite(8, LOW);  
 delay(3900);
 digitalWrite(8, HIGH);
 
 lcd.clear();
 lcd.print(" *** Mobile Bar *** Weisswein");
 
 //pause einlegen
 delay(500);
 //drinks_gesamt++;
 
 //klingel ansteuern
 digitalWrite(3, LOW);  
 delay(30);
 digitalWrite(3, HIGH);
 
 //pause einlegen
 delay(500);
}


void captain_cola(){
 
 /*
 //cola einschenken
 digitalWrite(6, LOW);  
 delay(1000);
 digitalWrite(6, HIGH);

 
 //captain einschenken
 digitalWrite(10, LOW);  
 delay(300);
 digitalWrite(10, HIGH);
 */
 
 lcd.clear();
 lcd.print(" *** Mobile Bar *** Captain Cola");
 
 //drinks_gesamt++;
 
 //klingel ansteuern
 digitalWrite(3, LOW);  
 delay(30);
 digitalWrite(3, HIGH);
}




//...



/*-----( restl Verbraucher aufrufen )-----*/


byte red_bull_state = HIGH;      // Red Bull Sign deklarieren - am start: aus


void red_bull_sign(){
 
 //toggle our switch (if off make it on and vice-versa)
 if (red_bull_state == LOW){
   red_bull_state = HIGH;
 } else {
   red_bull_state = LOW;
 }
 
 //PIN 4 - red bull sign bekommt wert von red_bull_sign zugewiesen
 digitalWrite(6, red_bull_state);
 
 lcd.clear();
 lcd.print(" *** Mobile Bar *** Red Bull Sign");

}


void bim_klingel(){

 //klingeln telefon
 digitalWrite(3, LOW);  
 delay(300);
 digitalWrite(3, HIGH);
 delay(150);
 digitalWrite(3, LOW);  
 delay(300);
 digitalWrite(3, HIGH);
 
 lcd.clear();
 lcd.print(" *** Mobile Bar *** ring ring ");

}

/*-----( Relay aufrufen Ende )-----*/




/*-----( MeetAndroid Funktion übergeben )-----*/

void android_weiss_wein(byte flag, byte numOfValues){
weiss_wein();
}

void android_captain_cola(byte flag, byte numOfValues){
captain_cola();
}

void android_red_bull_sign(byte flag, byte numOfValues){
red_bull_sign();
}

void android_bim_klingel(byte flag, byte numOfValues){
bim_klingel();
}

/*-----( MeetAndroid Funktion übergeben ENDE )-----*/


void setup() {

 //Serial.begin(115200);
 Serial.begin(57600);
 
 Serial.print("drinks_gesamt = ");
 Serial.print(drinks_gesamt);
 
 //Zeugs für Telefon Controller
 //pinMode(2, INPUT);
 pinMode(tel_in, INPUT);
 
 
 // register callback functions, which will be called when an associated event occurs.
 meetAndroid.registerFunction(android_weiss_wein, 'f');
 meetAndroid.registerFunction(android_bim_klingel, 'b');
 meetAndroid.registerFunction(android_red_bull_sign, 'l');
 meetAndroid.registerFunction(android_red_bull_sign, 'r');


 /*-----( ports definieren )-----*/
 
 
 // ausgänge definieren

 pinMode(3, OUTPUT);
 pinMode(4, OUTPUT);
 pinMode(5, OUTPUT);
 pinMode(6, OUTPUT);
 
 //telefon pin auf input ??
 pinMode(7, INPUT);
 
 pinMode(8, OUTPUT);
 pinMode(9, OUTPUT);
 pinMode(10, OUTPUT);
 pinMode(11, OUTPUT);
 pinMode(12, OUTPUT);
 pinMode(13, OUTPUT);



 digitalWrite(3, HIGH);
 digitalWrite(4, HIGH);  
 digitalWrite(5, HIGH);  
 digitalWrite(6, HIGH);
 
 digitalWrite(7, HIGH);  
 
 digitalWrite(8, HIGH);  
 digitalWrite(9, HIGH);
 digitalWrite(10, HIGH);
 digitalWrite(11, HIGH);  
 digitalWrite(12, HIGH);  
 digitalWrite(13, HIGH);


 
 /*-----( LCD initalisieren )-----*/
 

 lcd.init(); // initialize the lcd
 lcd.backlight();

 
 // Print a message to the LCD.
 //lcd.setCursor(0, 1);
 
 lcd.clear();
 lcd.print(" *** Mobile Bar *** leider geil!");


}

void loop() {
 
 
 /*-----( Telefoncontroller auslesen )-----*/
 
int reading = digitalRead(tel_in);

if ((millis() - lastStateChangeTime) > dialHasFinishedRotatingAfterMs) {
// the dial isn't being dialed, or has just finished being dialed.
if (needToPrint) {
// if it's only just finished being dialed, we need to send the number down the serial
// line and reset the count. We mod the count by 10 because '0' will send 10 pulses.
//Serial.print(tel_count % 10, DEC);

// auswertung tel_count
if (tel_count == 1){
 
 lcd.clear();
 lcd.print(" *** Mobile Bar *** tel_1");
 
 captain_cola();
 
}


else if (tel_count == 2){
 
 lcd.clear();
 lcd.print(" *** Mobile Bar *** tel_2");
 
 havanna_cola();
}


else if (tel_count == 3){
 
 lcd.clear();
 lcd.print(" *** Mobile Bar *** tel_3");
 
 wodka_weiss_bull();
}


else if (tel_count == 4){
 
 lcd.clear();
 lcd.print(" *** Mobile Bar *** tel_4");
 
 wodka_rot_bull();
 
}


else if (tel_count == 5){
 
 lcd.clear();
 lcd.print(" *** Mobile Bar *** tel_5");
 
 weiss_wein();

 
}


else if (tel_count == 6){
 
 lcd.clear();
 lcd.print(" *** Mobile Bar *** tel_6");
 
 cola();
 
}


else if (tel_count == 7){
 
 lcd.clear();
 lcd.print(" *** Mobile Bar *** tel_7");
 
 red_bull();
 
}


else if (tel_count == 8){
 
 lcd.clear();
 lcd.print(" *** Mobile Bar *** tel_8");
 
 wodka_weiss();
 
}


else if (tel_count == 9){
 
 lcd.clear();
 lcd.print(" *** Mobile Bar *** tel_9");
 
 bim_klingel();
 
}


else if (tel_count == 10){
 
 lcd.clear();
 lcd.print(" *** Mobile Bar *** tel_10");
 
 red_bull_sign();
 
}

needToPrint = 0;
tel_count = 0;
tel_cleared = 0;
}
}

if (reading != lastState) {
lastStateChangeTime = millis();
}
if ((millis() - lastStateChangeTime) > debounceDelay) {
// debounce - this happens once it's stablized
if (reading != trueState) {
// this means that the switch has either just gone from closed->open or vice versa.
trueState = reading;
if (trueState == HIGH) {
// increment the count of pulses if it's gone high.
tel_count++;
needToPrint = 1; // we'll need to print this number (once the dial has finished rotating)
}
}
}
lastState = reading;



 /*-----( Telefoncontroller ENDE )-----*/

 
  meetAndroid.receive(); // you need to keep this in your loop() to receive events
 
 
 /*-----( Alle Ventile sicherheitshalber zumachen )-----*/
 
 /*
 
 digitalWrite(3, HIGH);
 //digitalWrite(4, HIGH);  //red bull sign behält status
 digitalWrite(5, HIGH);  
 digitalWrite(6, HIGH);
 digitalWrite(7, HIGH);  
 digitalWrite(8, HIGH);  
 digitalWrite(9, HIGH);
 digitalWrite(10, HIGH);
 digitalWrite(11, HIGH);  
 digitalWrite(12, HIGH);  
 digitalWrite(13, HIGH);
 
 */
 

}

SnJDK

Hi,
your described symptom suggest that you have problem with current sink from arduino board, can you provide schematic how you connect relay board and arduino ?

Best regards,
Dubravko Penezic

the reset is  caused by inductive fold back i suggest the following actions to correct this problem
take  +12vdc into  a separate board and construct the following circuits on the board a +12v regulated supply  using a 7812p+ 3 terminal regulator place a 4,700 uf cap between the gnd  plane and  the output and a 408uf cap between the input and ground  both caps should be rated @35volts or more use the regulated output to power the arduino and the non to power the relays also on the board  place a tip 120 darlington transistor  for each relay drive output tied through a diode wired so that current only flows toward the relay but cant flow back from it into the driver
the diode  should be in the positive lead    as  shown below
from transistor + ------|>|-------- - to relay coil + ____3333____ - to vehicle ground via system ground
also connect diodes in the  output lines from the arduino itself to  the driver as shown below
from arduino   +----|>|-------- - to base pin of tip 120

the  true and  permanent fix is however to  use the arduino to control a gate driver and use mos fets   preferably  p channel

try this  if you want ive used this a lot http://www.mouser.com/ProductDetail/STMicroelectronics/TD350E/?qs=L6eUzyzWLAvJVVLfLJPI5qS1fNsgAj%2fl
and this fet is quite robust
http://www.mouser.com/ProductDetail/Fairchild-Semiconductor/FDD6N20TM/?qs=8NSUQxcvzttK7FAUi%252b6Izw%2fkC3V5OVSl

Chagrin

He's linked to optoisolated relay boards. The simple solution is to use that capability.

With the jumper in place between VCC and JD-VCC you're powering both sides of the optoisolated circuits with the same supply. You need to remove that jumper and, with a separate 5V power source, power it on the JD-VCC and GND pins. Also, somewhat non-intuitively, remove any GND between the Arduino and the board. Leave a connection between the Arduino's VCC and the VCC on the relay board.

mouseonmar

Thank you for your fast replies!

i will separate the relay module ground from the arduino provided ground
and add a external power supply for the relay-modules.

Ill post the results here.

mouseonmar

The problem was solved with a blocking diode for every solenoid valve

We also separated the power supply from the arduino vcc  - but this did not work out.

A second battery - separated power and ground supply worked.

We considered the blocking diodes between each solenoid and a common ground as a more "elegant" solution.

Thank you for your support.

Go Up