/Designs/MRAKOMER3/SW/irmrak3.c
13,24 → 13,6
char VER[4]=VERSION;
char REV[50]=ID;
 
int8 heat;
 
#INT_RDA
rs232_handler()
{
char ch;
 
if (getc()=='h')
{
heat=0; // Need warmer
}
else
{
heat=MAXHEAT; // Stop heating
}
}
 
 
unsigned char PEC_calculation(unsigned char pec[]) // CRC calculation
{
unsigned char crc[6];
107,7 → 89,6
int8 crc; // Readed CRC
int16 temp; // Readed temperature
 
disable_interrupts(GLOBAL);
i2c_stop();
i2c_start();
i2c_write(addr);
119,7 → 100,6
temp=MAKE16(arr[1],arr[2]);
crc=i2c_read(0); //crc
i2c_stop();
enable_interrupts(GLOBAL);
 
arr[5]=addr;
arr[4]=RAM_Access|select;
134,6 → 114,7
{
unsigned int16 n, temp, tempa;
signed int16 ta, to;
int8 i;
 
output_low(HEATING); // Heating off
setup_wdt(WDT_2304MS); // Setup Watch Dog
153,15 → 134,17
temp=ReadTemp(SA, RAM_Tobj1);
 
n=0;
heat=MAXHEAT;
i=MAXHEAT;
enable_interrupts(GLOBAL);
enable_interrupts(INT_RDA);
 
while(TRUE)
{
n++;
 
if (kbhit()) // Would you like warmer?
{
getc(); i=0;
}
 
tempa=ReadTemp(SA, RAM_Tamb); // Read temperatures from sensor
temp=ReadTemp(SA, RAM_Tobj1);
 
176,7 → 159,7
ta=(signed int16)(tempa*2-27315)/100;
 
printf("%Lu;ta:%Ld;ts:%Ld;sta:",n,ta,to);
if (heat>=MAXHEAT)
if (i>=MAXHEAT)
{
printf("0\n\r");
output_low(HEATING);
185,7 → 168,7
{
printf("1\n\r");
output_high(HEATING);
heat++;
i++;
}
};
restart_wdt();
/Designs/MRAKOMER3/SW/irmrak3.h
15,6 → 15,6
#FUSES NOIESO //Internal External Switch Over mode disabled
 
#use delay(clock=4000000)
#use rs232(baud=2400,parity=N,xmit=PIN_B5,rcv=PIN_B2,bits=8)//,FORCE_SW)
#use rs232(baud=2400,parity=N,xmit=PIN_B5,rcv=PIN_B2,bits=8,FORCE_SW)
#use i2c(MASTER,SLOW,sda=PIN_B1,scl=PIN_B4,SMBUS)
 
/Designs/MRAKOMER3/SW/irmrak3.PJT
34,8 → 34,7
1=C:\Users\locadmin\Documents\MLAB\Designs\MRAKOMER3\SW\irmrak3.c
2=C:\Users\locadmin\Documents\MLAB\Designs\MRAKOMER3\SW\irmrak3.h
3=C:\Program Files\PICC\devices\16F88.h
4=C:\Users\locadmin\Documents\MLAB\Designs\MRAKOMER3\SW\irmrak3.lst
5=
4=
[Units]
Count=1
1=C:\Users\locadmin\Documents\MLAB\Designs\MRAKOMER3\SW\irmrak3.c (main)