Tekkis vajadus kompressori järgi mis ei müriseks nagu enamiks poe omi.
Kasutatud 2x külmiku kompressoreid jadas. Jadas seepärast et 1 ei suuda käivituda kui vasturõhk üle 3Atm. Sensorina kasutasin Honywell 26pcffs2g sensorit. Temp mõõtmiseks igal kompressoril DS75. Usb on tegelt FT232 com kivike. Selle kaudu läheb soft sisse ja saab terminali kaudu seadistada ja vaadata parameetreid:
Temperatuuri limiit.
Kompressor sees väljas.
Sisselülitus limiit.
Välja lülitus limiit.
Hetke temperatuur kummagil kompressoril(toodud ka LCD peale välja)
Hetke rõhk (samuti LCD peale välja toodud)
Salvestada default parameetrid(laetakse toite peale lülitamisel)
Laadida default parameetrid.
Katsetatud sai ka vaakum pumbana, vesi tühja klaaspudelisse ja õhk välja, kees ilusti toa tempil.
Puudu veel sisend filter mis sodi sisse ei laseks, ja survepaagile alla ventiil kust saaks õhu välja lasta.
Skeem ja pildid serveris üleval antud lingil.
Kood:
Kasutatud 2x külmiku kompressoreid jadas. Jadas seepärast et 1 ei suuda käivituda kui vasturõhk üle 3Atm. Sensorina kasutasin Honywell 26pcffs2g sensorit. Temp mõõtmiseks igal kompressoril DS75. Usb on tegelt FT232 com kivike. Selle kaudu läheb soft sisse ja saab terminali kaudu seadistada ja vaadata parameetreid:
Temperatuuri limiit.
Kompressor sees väljas.
Sisselülitus limiit.
Välja lülitus limiit.
Hetke temperatuur kummagil kompressoril(toodud ka LCD peale välja)
Hetke rõhk (samuti LCD peale välja toodud)
Salvestada default parameetrid(laetakse toite peale lülitamisel)
Laadida default parameetrid.
Katsetatud sai ka vaakum pumbana, vesi tühja klaaspudelisse ja õhk välja, kees ilusti toa tempil.
Puudu veel sisend filter mis sodi sisse ei laseks, ja survepaagile alla ventiil kust saaks õhu välja lasta.
Skeem ja pildid serveris üleval antud lingil.
Kood:
Kood:
#include "LTC2482_lib.c" #include "Conv_Lib.c" #define ON 1 #define OFF 0 #define AIR(A) PORTC.F1=(A) #define COMPRESSOR(A) PORTC.F2=(A) #define AIR_Act PORTC.F1 #define COMPRESSOR_Act PORTC.F2 unsigned char Usart_Rx_FIFO[50]; unsigned char Usart_Rx_FIFO_Write_Pointer=0; union Control { unsigned char bytes [7]; struct { unsigned char Temperature1; unsigned char Temperature2; unsigned char Temperature_Lim; //Tcmd unsigned char Pressure; //Lcmd unsigned char Pressure_Max_Lim; //LUcmd unsigned char Pressure_Min_Lim; //Llcmd unsigned char Air_Control; } name; }Control ; unsigned char Load_Def=0; char txt[6]; char temp_text[14]; ////////////////////////////////////////////////////////////////////////////// void Usart_Write_Text(unsigned char *text){ while(*text) {Usart_Write(*text++);} } ////////////////////////////////////////////////////////////////////////////// void Resa (void){asm {RESET;}} ////////////////////////////////////////////////////////////////////////////// unsigned int LM75_Read(unsigned char devo){ unsigned buffer=0; unsigned char kuju; I2C_Start(); if(0==I2C_Wr(0b10010001+(devo<<1))){ buffer = I2C_Rd(0); I2C_Stop(); } else{I2C_Stop();return 0;} return buffer; } ////////////////////////////////////////////////////////////////////////////// void Update_Temperature(void){ Control.name.Temperature1=LM75_Read(0); Control.name.Temperature2=LM75_Read(1); } ////////////////////////////////////////////////////////////////////////////// void Update_Pressure(void){ double p; double r; double t; unsigned int taga; double voltage; voltage = LTC2482_Read() & 0x7FFF; if(voltage!=0){ p = (voltage * 0.003404584259033203125)*10.0; //(3279/65536)*0,068046 Control.name.Pressure=p; } } ////////////////////////////////////////////////////////////////////////////// void Save_Defaults (void){ unsigned char i; for(i=0;i<7;i++){ Eeprom_Write(i,Control.bytes[i]); } } ////////////////////////////////////////////////////////////////////////////// void Load_Defaults (void){ unsigned char i; for(i=0;i<7;i++){ Control.bytes[i]=Eeprom_Read(i); } } ////////////////////////////////////////////////////////////////////////////// void Usart_Command_Action(void){ unsigned char i; unsigned long Temp_data; switch(Usart_Rx_FIFO[0]){ case 'T' : { if(Usart_Rx_FIFO[1]=='s') { if(isdigit(Usart_Rx_FIFO[2])==1) { Control.name.Temperature_Lim=StringToLong(&Usart_Rx_FIFO[2]); } else{ Usart_Write_Text(WordToMyStr(Control.name.Temperature_Lim)); } } else{ if(Usart_Rx_FIFO[1]=='1'){ Usart_Write_Text(WordToMyStr(Control.name.Temperature1)); } if(Usart_Rx_FIFO[1]=='2'){ Usart_Write_Text(WordToMyStr(Control.name.Temperature2)); } } return;} case 'P' : { switch(Usart_Rx_FIFO[1]){ case 'h' : { if(isdigit(Usart_Rx_FIFO[2])){ Control.name.Pressure_Max_Lim=StringToLong(&Usart_Rx_FIFO[2]); } else{ Usart_Write_Text(WordToMyStr(Control.name.Pressure_Max_Lim)); } return; } case 'l' : { if(isdigit(Usart_Rx_FIFO[2])){ Control.name.Pressure_Min_Lim=StringToLong(&Usart_Rx_FIFO[2]); } else{ Usart_Write_Text(WordToMyStr(Control.name.Pressure_Min_Lim)); } return; } default : { Usart_Write_Text(WordToMyStr(Control.name.Pressure)); return; } } } case 'O' : { if(Usart_Rx_FIFO[1]=='a'){ Usart_Write_Text(WordToMyStr(COMPRESSOR_Act)); } else{ if(isdigit(Usart_Rx_FIFO[1])==1) { Control.name.Air_Control=(Usart_Rx_FIFO[1]=='0')? 0:1; } else{ Usart_Write_Text(WordToMyStr(Control.name.Air_Control)); } } return; } case 'L' : { Load_Defaults(); return;} case 'S' : { Save_Defaults(); return;} default : return; } } ////////////////////////////////////////////////////////////////////////////// void interrupt(void) { unsigned char Utemp; if(INTCON.TMR0IF){ TMR0L=0xC7; TMR0H=0xFE; TMR1=0; INTCON.TMR0IF=0; } if(Load_Def){Load_Defaults(); Load_Def=0;} if(PIR1.RCIF == 1){ // Usart interrupt T1CON=0; Utemp=Usart_Read(); if(Utemp==13){ Usart_Rx_FIFO[Usart_Rx_FIFO_Write_Pointer]=0; Usart_Write_Text("\n\r"); Usart_Command_Action(); Usart_Rx_FIFO_Write_Pointer=0; } else{ if(Utemp=='R'){Resa();} Usart_Rx_FIFO[Usart_Rx_FIFO_Write_Pointer++]=Utemp; } T1CON=0b00110011; TMR0L=0xC7; TMR0H=0xFE; TMR1=0; INTCON.TMR0IF=0; PIR1.RCIF=0; } } ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// void main (void){ char Text[8]; unsigned int temu; ADCON1=0b11111110; Usart_Init(115200); Delay_ms(500); LTC2482_Init(); I2C_Init(50000); Lcd8_Config(&PORTA, &PORTB, 2, 4, 3, 7, 6, 5, 4, 3, 2, 1, 0); TRISC.F2=0; TRISC.F1=0; AIR(OFF); COMPRESSOR(OFF); T1CON=0b00000011; Usart_Rx_FIFO[256]=0; Load_Def=1; INTCON=0b11000000; INTCON.TMR0IF=0; INTCON.TMR0IE=1; T0CON =0b10000111; PIR1.RCIF=0; PIE1.RCIE=1; Delay_ms(3000); Lcd8_Config(&PORTA, &PORTB, 2, 4, 3, 7, 6, 5, 4, 3, 2, 1, 0); while(1){ Update_Temperature(); Update_Pressure(); if(Control.name.Pressure_Max_Lim>100){Control.name.Pressure_Max_Lim=100;} if(Control.name.Pressure_Max_Lim<5){Control.name.Pressure_Max_Lim=5;} if(Control.name.Temperature_Lim>=95){Control.name.Temperature_Lim=95;} if((Control.name.Pressure_Min_Lim+5)>Control.name.Pressure_Max_Lim){ Control.name.Pressure_Min_Lim=Control.name.Pressure_Max_Lim-5; } if(!Control.name.Air_Control) { COMPRESSOR(OFF); } else{ if(Control.name.Pressure<=Control.name.Pressure_Min_Lim){ AIR(ON); Delay_ms(100); COMPRESSOR(ON); Delay_ms(2000); AIR(OFF); } if(Control.name.Pressure>=(Control.name.Pressure_Max_Lim+1)){ COMPRESSOR(OFF); } } Delay_ms(100); ByteToStr(Control.name.Pressure,Text); if(Text[1]==' '){Text[1]='0';} Text[3]=Text[2]; Text[2]='.'; Text[4]=0; Lcd8_Out(0, 1, Text); Lcd8_Out(0, 5, " Atm "); if((Control.name.Temperature1>=Control.name.Temperature_Lim)||(Control.name.Temperature2>=Control.name.Temperature_Lim)){ while(1){ Lcd8_Out(2, 1,"OVERTEMP"); Delay_ms(500); Lcd8_Out(2, 1," "); Delay_ms(500); COMPRESSOR(OFF); } } else{ ByteToStr(Control.name.Temperature1,Text); if(Text[1]==' '){Text[1]='0';} Text[0]=Text[1]; Text[1]=Text[2]; Text[2]=0; Lcd8_Out(2, 2, Text); Lcd8_Out(2, 4, "C"); ByteToStr(Control.name.Temperature2,Text); if(Text[1]==' '){Text[1]='0';} Text[0]=Text[1]; Text[1]=Text[2]; Text[2]=0; Lcd8_Out(2, 6, Text); Lcd8_Out(2, 8, "C"); } }}
Comment