Saturday, June 21, 2014

PWM based temperature controller using ATmega16A

Abstract: In this project we are going to design an embedded system that controls the temperature using a PWM signal, generated by a ATmega16A controller. 

Here we assume that our required temperature is 145 degrees C' and the bandwidth is ∆T= 20 degrees C. And also assume that it takes 10sec to heat up to 145 degrees C(this is not true in all cases). With  ∆T= 20 degrees C maximum temperature is 155 degrees C and minimum temperature would be 145 degrees C. Duty cycle can be calculated using the following formula..
                                                     T_duty =1- (T_sensor – T0)/∆T
                                                      here T0=145 degrees C
                                                     and T_sensor is the temperature sensor output
If you want to control higher temperatures, say above 150 degree C, then you have to use Thermistors instead of LM35. Here 10*T_duty gives the ON time duration and 10*(1-T_duty) gives the OFF time duration.

Operation:- The temperature sensor will sense the temperature of the device/chamber and a Nichrome wire used as a Heating element. Here LM35 is connected to the internal ADC0 pin of ATmega16A controller. ADC output will be the T_sensor value and is used to calculate the T_duty cycle period. PD0 pin carries the PWM signal, is connected to the Nichrome wire. If there is a change in temperature T_duty will change and the PWM will change. Example, if the temperature is higher than the required then the T_duty (ON time) will be reduced and OFF time will be increased to cool down the temperature. If the temperature is lower than the required then the T_duty (ON time) will be increased and OFF time will be reduced to increase the temperature.   
When the temperature is 144 degrees C 
                                       T_duty = 1-(144 - 135)/20 = 0.55*10=5.5sec = ON time
                                       1-T_duty = 1-0.55= 10*0.45=4.5sec = OFF time
 When the temperature is 150 degrees C 
                                       T_duty = 1-(150 - 135)/20 = 0.2*10=2.5sec = ON time
                                       1-T_duty = 1-0.25= 10*0.7=7.5sec = OFF time

Flow chart:-   to download the source code

NOTE: The time required to heat up to a required temperature will depend on the type of heating material used. Calculate the time required and use it to generate PWM. 


Saturday, June 14, 2014

Wheatstone bridge application using ATmega16A

Abstract: In this project we are going to build a circuit that calculates the unknown resistance in a Wheatstone bridge using voltage subtractor and Internal ADC of a ATmega16A.

Wheatstone bridge is used to calculate the unknown resistance in a circuit. Here we are using OpAmp based subtractor circuit to calculate the voltage 'Vg', which is used to calculate the unknown resistance. The two buffer amplifiers are used to provide virtual isolation between the wheatstone bridge and the subtractor. Below circuit shows the working of a subtractor,



NOTE: In case of ATmega16A we don't need to use external subtractor because ATmega16A is having differential input mode.

Here we selected external ADC reference voltage 5V. So, the output of a ADC value is multiplied with its resolution to get input voltage, 5/1024. This voltage is given as 'Vg' in wheatstone bridge equation to calculate the resistance, remaining three resistors are set to 1k ohm.

Here's the program flow


  to download the code

Working images of the total circuit



Click here to see the working video.