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.
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);
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.
Hope that answers your question.
If not, please post your entire sketch.
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.
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.
Set a boolean flag, beenLow to false. When the switch is LOW, set the flag to true.
is this what u mean ?
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);
}
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.
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.
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?
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
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.
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);
}
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.
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
and want to switch on with the code a relais. this is not the issue, toggle the relais on and off.
i just want to switch the relais (digital output pin 5) automatic off and stay off when the temperture reach the >100 celsius. this can only happend when there a problem with the cooling fan.
it must never switch on again unless we manual the switch first off and then back on afther we have repaired the cooling fan. The fan has it's own control in the code, using for example the LM35 and has nothing to do with this relais issue.
i wanna thank u for the help so far. i hope u still can.
if u want i can send u by email the complete project.
The picture shows a double pole, double throw switch. That is hardly a "simple on/off switch".
A schematic would be good.
i just want to switch the relais automatic off and stay off when there is a problem.
it must never switch on again unless we manual the switch first off and then back on afther we have repaired the cooling fan.
In the else block, you need to detect a transition from not pressed to pressed to turn the relay on, and a transition from pressed to not pressed to clear the aProblemOccurred flag.
You really must keep track of the previous state of the switch, in order to detect the transitions.
How do you detect that a problem occurred? Is that when the temperature rises over 100 degrees?
Is the fan supposed to be turned on when the temperature is above 50? Is it to be turned off when the temperature is below 50?
The reason that you're getting so many questions is that you have a clear idea of what your hardware is and what you need. We really didn't. I'm still curious about why the system has to stay off once it overheats. Normally, I'd expect to turn it on again when it cools down.
Normally, I'd expect to turn it on again when it cools down.
I think that the idea is that someone goes and looks at the site, to try to determine what caused the system to overheat, before the system is turned back on.