Go Down

### Topic: Relais and Temperture (Read 7095 times)previous topic - next topic

#### Midway

##### Sep 22, 2013, 12:12 am
Hi all,

I have the following question:

i have a Temperture controlled relais.
When my Bias_Switch = HIGH and the temperture are below <50 Celsius the relais are switches to HIGH (on).
When the temperture reached >50 the Bias_Relais must switches to LOW.

The problem i have is howto get the Bias_Relais LOW until i have maual switch the Bias_Switch to LOW and then back to HIGH.

Code: [Select]
`Bias = digitalRead(Bias_Switch);                                         // read the value DUMMY.      Bias = digitalRead(Bias_Switch);                                         // read the value from the Bias_Switch.      if (tempC<50  &&  Bias == HIGH)                                          // read two status.         Bias = HIGH;                                                           // PA is switched ON.      digitalWrite(Bias_Relais, Bias);       if (tempC>50  &&  Bias == HIGH)                                          // read two status.         Bias = LOW;                                                            // PA is switched OFF cozz of HIGH Temperture.       digitalWrite(Bias_Relais, Bias);`

#### MAS3

#1
##### Sep 22, 2013, 12:20 am
Hi.

That can't be your entire code, you need to post all for someone else to find mistakes.

If your question is about how to prepare, you'd do that in the function void.setup().
There you can preset a defined value before it is actually read by the loop function.

Have a look at "blink without delay".
Did you connect the grounds ?
Je kunt hier ook in het Nederlands terecht: http://arduino.cc/forum/index.php/board,77.0.html

#### PaulS

#2
##### Sep 22, 2013, 12:22 am
Quote
The problem i have is howto get the Bias_Relais LOW until i have maual switch the Bias_Switch to LOW and then back to HIGH.

Set a boolean flag, beenLow to false. When the switch is LOW, set the flag to true.

When the switch BECOMES HIGH, set another flag to true, indicating that the relays can now be triggered.

You might explain why this is necessary, though.

#### Midway

#3
##### Sep 22, 2013, 12:34 am

i will try this tomorrow.

Quote
You might explain why this is necessary, though.

I just want to build a safety that it cannot destroy my expansive ATV RF Power Module.
If it reach this very high temp>100 , the problem are the FAN to cool down the RF Power Module.

#### PaulS

#4
##### Sep 22, 2013, 12:41 am
Quote
I just want to build a safety that it cannot destroy my expansive ATV RF Power Module.
If it reach this very high temp>100 , the problem are the FAN to cool down the RF Power Module.

So, unless you toggle the switch to LOW and then HIGH, it's OK to burn up the power module? I don't get it.

#### Midway

#5
##### Sep 22, 2013, 12:59 am
Hi PaulS

This is part of a Amateur Television repeater controller, located on top of a building.

Dont worry, i know what Im doing or creating with electronics.

Half year ago, i have found the Arduino and this is really nice to create projects for my hobby.

It is sometimes only hard to understand how to write some code, but I am doing well so far and most projects are very nice working.

Thats why i have asked here some help, so i can understand how to do.

Any examples are offcourse welcome.

regards,
Ed.

#### Midway

#6
##### Sep 22, 2013, 01:34 pmLast Edit: Sep 22, 2013, 01:39 pm by Midway Reason: 1
Quote
Set a boolean flag, beenLow to false. When the switch is LOW, set the flag to true.

is this what u mean ?

Code: [Select]
` const int Bias_Switch = A5;                                              // the number of the Bias switch analog input pin A5.     const int Bias_Relais = 2;                                               // the number of the Bias_Relais digital output pin 2.boolean mySet = false;boolean Bias;void setup() {  pinMode(Bias_Switch, INPUT);                                           // sets analog pin 5 for input.  digitalWrite(Bias_Switch, LOW);                                        // turn on pullup resistors  pinMode(Bias_Relais, OUTPUT);                                          // set the digital pin as output.}void loop() {  Bias = digitalRead(Bias_Switch);                                       // read the value DUMMY.  Bias = digitalRead(Bias_Switch);                                       // read the value from the Bias_Switch.  if (Bias==true) mySet = true;                                          // set bolean to true       else     mySet=false;  digitalWrite(Bias_Relais, mySet); }`

#### Midway

#7
##### Sep 22, 2013, 01:45 pm
I have only to add the safety protection in the code

Code: [Select]
`tempC>100`

then it must switch off and stay off until i toggle the switch.

but how?

#### PaulS

#8
##### Sep 22, 2013, 01:57 pm
Code: [Select]
`  Bias = digitalRead(Bias_Switch);                                       // read the value DUMMY.  Bias = digitalRead(Bias_Switch); `
Why are you reading the switch twice? Since so little time elapses between readings, the odds are you are going to always get the same value. Does it matter if the readings are different, since the first value is overwritten?

You may be thinking of analogRead(), where, depending on the impedance of the connected device, it may be necessary to read twice, and discard the first value.

Reading a digital device twice, and discarding the first value is never necessary.

Code: [Select]
`  if (Bias==true) mySet = true;                                          // set bolean to true     `
The digitalRead() function returns HIGH or LOW, not true or false.

No, that is not how I was thinking of using mySet. If the switch becomes HIGH, and mySet is false, ignore the switch. If the switch becomes LOW, and mySet is false, set mySet to true. If the switch becomes HIGH, and mySet is true, then you want to read the temperature and toggle the relay as needed.

Of course, in order to determine that the switch becomes something, rather than is something, you need to keep track of the previous state. Look at the state change detection example.

#### wildbill

#9
##### Sep 22, 2013, 01:59 pm
It sounds like what you want to do is pretty simple, but from the foregoing explanations, I'm not able to understand the requirement. Can you give a bit more detail about what you're switching and why? I'm guessing its a power supply and equipment that heats up and can stay on until the temp is 50 degrees. If 100 degrees is reached (how? because it was turned off at 50) a fan comes on and everything else must be off?

#### Midway

#10
##### Sep 22, 2013, 02:16 pmLast Edit: Sep 22, 2013, 02:21 pm by Midway Reason: 1
@wildbill
Quote
If 100 degrees is reached (how? because it was turned off at 50) a fan comes on and everything else must be off?

the code i had written was >50 and must be original >100 celsius. u right i made a type mistake.

again the explanation where i want to use this for.
I just want to build a safety that it cannot destroy my expansive Amateur TV RF Power Module.
If it reach this very high temp>100 , the problem are the FAN to cool down the RF Power Module.
This is part of a Amateur Television repeater controller, located on top of a building. and not at home.

@ paulS
Quote
Why are you reading the switch twice?

i have read more values in my project, when i do not double readings it affecting the actual reading from other inputs / sensors.

ok, i ll now try to change some code to get this protection work.

#### Midway

#11
##### Sep 22, 2013, 02:48 pmLast Edit: Sep 22, 2013, 02:54 pm by Midway Reason: 1
like this ?

Code: [Select]
`  Bias = digitalRead(Bias_Switch);                                       // read the value DUMMY.  Bias = digitalRead(Bias_Switch);                                       // read the value from the Bias_Switch.  if (Bias==HIGH) mySet = false;                                          // set bolean to  else      mySet=true;  digitalWrite(Bias_Relais, mySet);    if (Bias==LOW) mySet = false;                                          // set bolean to  else      mySet=false;  digitalWrite(Bias_Relais, mySet);    if (Bias==HIGH) mySet = true && tempC>100;                                          // set bolean to        mySet = false;      digitalWrite(Bias_Relais, mySet);}`

#### PaulS

#12
##### Sep 22, 2013, 02:56 pm
Quote
like this ?

Not even close.

You keep saying that the purpose behind this code is to turn a relay, that controls a fan, on when the power supply gets too warm. Fine. But what is this switch for? Why do you want to turn the relay on, to cool off the power supply, only if this switch has been slid back and forth. That's the part I don't understand. That is not any kind of safety.

#### wildbill

#13
##### Sep 22, 2013, 03:05 pm
Does the relay control the "expansive Amateur TV RF Power Module" or does it control the fan?

#### Midway

#14
##### Sep 22, 2013, 03:16 pmLast Edit: Sep 22, 2013, 03:22 pm by Midway Reason: 1
ok, Im sorry. i try to explain.

This project i am working on is a Hamradio, Amateur Television Transmitter "Radio Frequency Power moduul" that transmit TV signals so people (Hamradio users) can receive it from a large distance.

The equipement are to far away from our hand to control it.
So, to put the device operational it has a switch to turn it on (the relais turn the power on, on the RF moduul). now this part of the equipement is operational. we go home now.

Afther a few day's  it seems that the Fan to cool down the RF module, is not working anymore, maybe we have buy a cheap one,,
This Fan is cooling the RF module from the transmitter. When this module is to high temperture it will be destroyed.

1, the on/off switch outside the 19" cabinet must toggle the relais on
2, the fan has it's own control in the code, using for example the LM35

is this clear for u?

Go Up