Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[AVR] PID for Temperature control of TEC Peltier plate

Status
Not open for further replies.

Narendra1190

Member level 2
Joined
Jan 23, 2014
Messages
44
Helped
6
Reputation
12
Reaction score
6
Trophy points
1,288
Activity points
1,666
Hi Electronics Geeks!
I am working on TEC temperature controller using ATmega32 MCU. Thermistor of 10K is interfaced and the Steinhart-Hart Thermistor Equation is applied to get the temperature reading using ADC.I am getting correct reading with little Fluctuations.The other part of the project is to set the desired temperature and achieve that by heating/cooling the peltier plate(TEC12706) with below specification,

Model number: TEC1-12706
Voltage : 12V
Vmax (V) : 15.4V
Imax (A) : 6A
QMax (W) : 92W
Nominal Power : 60W
Internal resistance: 1.98 Ohm +/- 10%
Dimensions : 40mm x 40mm x 3.6mm

I have read that PID is the method to achieve the result but dont know how to implement.I can generate PWM signal to control the H-bridge voltage.
Can you help me in below part?
1)How to implement PID in ATmega32 or code?
2)H-bridge Design using MOSFET for TEC1-12706?

Thank you for reading.
 

you don't need H-bridge , only one N-MOSFET (low side) is enough.
connect
12 V to Red wire (positive)
Black wire (Negative) to MOS's drain
MOS's source to 0 V
build suitable gate driving circuit
 

1) Please refer the following thread to get a basic idea of a PID controller to be coded in C. https://www.edaboard.com/threads/98387/

2) There might not even be need to construct a H-Bridge in order to control the PWM pulses applied to the Peltier Plate. You can simply use a buck converter to control the average voltage across the Peltier Chip. Better suited for your application and power to be handled. You can refer to TI's Application Report SLVA477B. Or else you can simply chop the waveform using a single MOSFET as Ahmed has suggested.
 

Narendra needs both heating and cooling, so it will be necessary to reverse the current through the peltier cell.
A full bridge will certainly work, but I think you can do better than that...

The problem controlling peltier cells is they produce MASSIVE amounts of heat in heating mode, but really struggle to cool. This makes tuning a PID loop problematic because the gain changes so significantly between heating and cooling.

What you might like to try is grounding one side of the peltier cell, then using separate +ve and -ve supplies to power the cell via a half bridge.

The idea is to optimise the cooling side of things with whatever voltage and current is required to do that.
Then for heating use a far less powerful dc supply to match the cooling performance.

You should then have far less difficulty tuning your PID loop because it should behave pretty much the same when controlling the temperature in either direction.
 
In case of doubt, a H-bridge is the straightforward way to implement a peltier power supply. It's presumed that you have sufficient L or LC filtering to reduce the peltier current ripple to a level where it doesn't cause significant efficiency loss.

Nonlinear peltier characteristic is a point to consider. It can be either compensated in the controller or - for a static temperature controller with moderate dynamic requirements - possibly ignored. You have a linear peltier effect superimposed by a square law heater characteristic, so just switching the gain between cooling and heating is not the exact solution.
 
Its not a small difference.
For (say) 50 watts of dc input, you might see something like 5 watts of cooling and 55 watts of heating.
 

Thank you all for quick reply.
@Fvm : thanx for filter suggestion.
@warpspeed: you mean i have to set different initial gain for cooling and heating process so i can reach the desired temperature?

I got below link for PID program in C.
https://control.com/thread/996485795

can anybody help me in this code with pwm to control peltier?
 

@warpspeed: you mean i have to set different initial gain for cooling and heating process so i can reach the desired temperature?

PID loops are fascinating things, either in hardware or software. But in either case, the tuning is always limited by any fundamental faults or problems in the system you are trying to control.

If the gain or time delays drastically change from one operating point to another, or there are huge non linearities, the control loop may become unstable at one particular point, and you will need to reduce gain and increase integral time to avoid the particular instability.

This reduces overall performance of the loop to less than it might have been if the system being controlled was made more linear and predictable in its response.

Or put much more crudely, its much easier for a PID loop to control an obedient dog, than a mad dog.
 
Hi!
I found this documentation for PID.
www.atmel.com/dyn/resources/prod_documents/AVR221.zip

I have written code as below.
I am reading measured temperature as double value
Code:
#include..
..
...
..
uint16_t adc = 0;
uint16_t adchisto = 0;
int main(void) {
	char printbuff[100];
	char setbuff[100];
	char diffbuff[100];
	long l;
	double d;
	double ST = 25.0;
	int DiffTemp;
	float precision = 0.1;
	DDRD |= 0;
	DDRB |= 0xFF;
	TCCR0 |=(1<<WGM00)|(1<<WGM01)|(1<<COM00)|(1<<COM01)|(1<<CS00);
    OCR0 = 0;
	
	lcd_init(LCD_DISP_ON);

	adc_setchannel(1);
	adc_init();
	//init interrupt
	sei();
	//main loop
	while(1) 
	{
		//read adc and filter it
		adchisto = adc;
		adc = adc_read(0);
		adc = adc_emafilter(adc,adchisto);	
		//print out results
		itoa(adc,printbuff,5);
		l = adc_getresistence(adc, 10000);
		ltoa(l, printbuff, 10);

		if (bit_is_clear(PIND,5))
        {
            ST = ST - 0.1;
            _delay_ms(10);
            
        }
        if (bit_is_clear(PIND,6))
        {
            ST = ST + 0.1;
            _delay_ms(10);
		}

		dtostrf(ST, 5, 1, setbuff);
	
		#if NTCTEMP_SH == 1
		d = ntctemp_getSH(adc_getresistence(adc, 10000),(double)0.947070725e-3,(double)2.450662058e-4, (double)1.853992838e-7);		
		dtostrf(d, 5, 1, printbuff);
		lcd_gotoxy(0,0);lcd_puts("ACT TEMP=");lcd_gotoxy(9,0);lcd_puts(printbuff);
		lcd_gotoxy(0,1);lcd_puts("SET TEMP=");lcd_gotoxy(9,1);lcd_putc(setbuff);
		#endif	
		_delay_ms(100);
		
	}	
	return 0;
}

to control PWM
Code:
TCCR0 |=(1<<WGM00)|(1<<WGM01)|(1<<COM00)|(1<<COM01)|(1<<CS00);
    OCR0 = 0;
    while(1)
    {
        if (bit_is_clear(PIND,5))
        {
            if (OCR0<255)
            {
                OCR0++;    
            }        
            _delay_ms(10);
            
        }
        if (bit_is_clear(PIND,6))
        {
            if (OCR0>0)
            {
                OCR0--;
            }        
            _delay_ms(10);
        }
    }
IN ATMEL's pid code, what i have to set as input value?
can anybody help me, how can i implement code for output control with PID ?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top