chi239
Newbie level 6
I am a novice in Arduino. I am working on a temperature controller for a hot plate. I have a PT100 as sensor which is being driven by a 1mA constant current source. As the resulting output voltage is quite low, I am using an OpAmp for a gain of 11. The output of the OpAmp is connected to pin A4 of the Arduino.
The desired temperature is set by means of a potentiometer, the output of which (0-5V) is connected to pin A1 on the Arduino.
The PWM output for the heater is from Pin 9 and is fed to an opto-isolator (the output of which is connected to a Triac, which in turn controls the power to the heater element).
All this works quite well, except for a bug that I have not been able to find:
On switching on, the PWM output is zero. It activates only when the potentiometer setting is brought quite low. After that, the setting can be changed as desired and everything works well. For example, if the potentiometer setting is for say, 150 degrees, the system will work just fine as long as it is not switched off (or if the power is not disrupted). In case of switching off (or power failure), followed by a subsequent switching on, the PWM output remains zero. It is only on bringing the potentiometer to a relatively lower setting that the PWM output gets reactivated. Once it does, then the potentiometer can safely be brought back to the original (or any other desired setting) and everything works just fine.
Can anyone help me in finding the bug? I want that on switching on, the system should start working right away and control the heater (PWM) so as to attain the temperature as set by the potentiometer.
My sketch is as below:
The desired temperature is set by means of a potentiometer, the output of which (0-5V) is connected to pin A1 on the Arduino.
The PWM output for the heater is from Pin 9 and is fed to an opto-isolator (the output of which is connected to a Triac, which in turn controls the power to the heater element).
All this works quite well, except for a bug that I have not been able to find:
On switching on, the PWM output is zero. It activates only when the potentiometer setting is brought quite low. After that, the setting can be changed as desired and everything works well. For example, if the potentiometer setting is for say, 150 degrees, the system will work just fine as long as it is not switched off (or if the power is not disrupted). In case of switching off (or power failure), followed by a subsequent switching on, the PWM output remains zero. It is only on bringing the potentiometer to a relatively lower setting that the PWM output gets reactivated. Once it does, then the potentiometer can safely be brought back to the original (or any other desired setting) and everything works just fine.
Can anyone help me in finding the bug? I want that on switching on, the system should start working right away and control the heater (PWM) so as to attain the temperature as set by the potentiometer.
My sketch is as below:
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 // Heater Controller int heatingInPin = A1;// Heating pot slider connects here int sensorPin = A4;// Temp Sensor output (amplified) connects here int heaterPin = 9;// PWM heater output is available here int tempDiff; int sensorCount;// this holds the value of the Temperature Sensor after amplification int heatSetCount;// this holds the value of the Temperature Control Pot int pulseWidth; void setup(){ pinMode(heaterPin, OUTPUT); } void loop() { sensorCount = analogRead(sensorPin); sensorCount = (sensorCount - 247);// apply offsetvalue heatSetCount = analogRead(heatingInPin); heatSetCount = map(heatSetCount, 31,1023,0,440);// This gives a maximum temp of 400 degrees if (sensorCount >= heatSetCount) { analogWrite(heaterPin,0); } else { tempDiff = (heatSetCount - sensorCount); if (tempDiff >= 25) { pulseWidth == 255;// heater is full ON } else { pulseWidth = (10 * tempDiff); } analogWrite (heaterPin,pulseWidth); } delay (10); }
Last edited by a moderator: