The aim of the project is to switch on and off a heater and a vakuum pump. The reason behind this is to completely dry transformer oil before use. With a potentiometer I can set a target temperature and the temperature probe does read the current temperature. I use solid state relais to switch on on off the heater and the vacuum pump.
However I am currently strugling with something as simple as the ds18b20 temperature sensor.
It took me a long time to trace down the problem to the ds16b20...
This is the function where I get the temperature...
If I bypass the temperature read there are no hangups - the entire sketch runs as it should...
(but I do not have the temperature )
// Temperatur vom Sensor auslesen.
double get_temp() {
//sensors.requestTemperatures();
//double value = sensors.getTempCByIndex(0);
return 10;
//return value;
}
Now this will cause hangups and reboots after a few seconds or a few minutes...
// Temperatur vom Sensor auslesen.
double get_temp() {
sensors.requestTemperatures();
double value = sensors.getTempCByIndex(0);
//return 10;
return value;
}
I have done a whole load of experiments to rule out other reasons I can think of:
Try with other power supply.
Use a different ds16b20.
Add 100 µF paralel to the supply of the sensor.
Add 2000 µF paralel to 5V of the entite arduino uno.
Drive the SSR not directly, use transistors to drive them...
Are you sure the DS18B20 is wired the right way round?
Does it get hot?
Is the 4K7 resistor really a 4k7?
How long, and what sort, is the cable?
As for the code, everybody else uses float, not double. I understand this is because double takes more time and more memory for no purpose, i.e. it is not properly supported. I don't think using double is the cause of your problem, but I note the dummy
a. Add 0.1uF capacitor at the sensor end between Vcc and Gnd
Have dont it already - does not solve the problem.
b. Try running the examples from Arduino-Temperature-Control-Library e.g. ‘single’
In my code, I have deactivated everything except the temperature part and the lcd part to show the temperature. It works - no hangups… So the problems must be something with the temperature part and the rest of the code… memory???
Are you sure the DS18B20 is wired the right way round?
Yes - otherwise it would not deliver any data I thin… But it does…
Does it get hot?
No.
Is the 4K7 resistor really a 4k7?
Yes.
How long, and what sort, is the cable?
1 meter.
As for the code, everybody else uses float, not double. I understand this is because double takes more time and more memory for no purpose, i.e. it is not properly supported. I don’t think using double is the cause of your problem, but I note the dummy
Have changed it to float - still same issue with hangups…
@gvfavo:
I have, check the first post.
@outsider:
See if this helps:
have done so - does not help…
Slowly I think it meight be connected to some memory issue…
Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
When you designed this, did the breadboard prototype do this?
If you unplug the SSRs does the problem occur?
Does the problem occur when a change in output state happens or when everything is stable and no state change is occuring?
Andreas1984:
Next thing I am going to try is to get rid of all float / double and use int only…
No… there is no point.
In any case there is no difference between float and double on an Arduino UNO. they are different names for the same thing.
What may well make a LOT of difference is using String.
it is well known for eating memory and can eventually cause hangups… I didn’t spot it til now.
Change your hysteresis marker to be a single char ‘a’ instead of “a” like:
// Gibt auskunft über den momentanen Stand der Hysterese.
// a = unterhalb der Hysterese.
// b = innerhalb der Hysterese steigend.
// c = überhalb der Hysterese.
// d = innerhalb der Hysterese fallend.
char hysterese_marker = 'a';
and change:
// Logik für die Hysterese.
void hysteresis() {
// Wenn die momentane Temperatur kleiner ist als die Hysterese.
if (current_temperature < hysteresis_low) {
general_heating_status = true;
hysterese_marker = 'a';
}
... and so on