/Modules/PowerSupply/LION1CELL01B/SW/PIC16F887/setting/LED_BAT7/main.bak
0,0 → 1,153
 
#include "main.h"
#define EEPROM_SDA PIN_B0
#define EEPROM_SCL PIN_B1
#use i2c(master, sda=EEPROM_SDA, scl=EEPROM_SCL)
#use rs232(baud=9600,parity=N,xmit=PIN_B3,rcv=PIN_B2,bits=8) //rcv TXD xmit RXD
 
 
void main()
{
 
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_CLOCK_DIV_2);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_ccp1(CCP_OFF);
setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
 
printf("Simple Thermomether \r\n",);
unsigned int8 STAV1,STAV2;
 
unsigned int16 SOUCET, SOUCET1;
unsigned int8 LSB=0,ZK,k=0;
//unsigned int8
while(TRUE)
{
 
 
i2c_start(); //blockdatacontrol
I2C_Write(0xAA);
I2C_write(0x61);
i2c_start();
I2C_Write(0xAA);
i2c_write(0x00);
i2c_stop();
delay_ms (1);
 
 
i2c_start();//dataflashclass
I2C_Write(0xAA);
I2C_write(0x3e);
i2c_start();
I2C_Write(0xAA);
i2c_write(0x40);
i2c_stop();
delay_ms (1);
i2c_start();//dataflashblock
I2C_Write(0xAA);
I2C_write(0x3f);
i2c_start();
I2C_Write(0xAA);
I2C_write(0x00);
i2c_stop();
delay_ms (1);
i2c_start();//blockdata
I2C_Write(0xAA);
I2C_write(0x44);
i2c_start();
I2C_Write(0xAB);
ZK=I2C_read(0);
i2c_stop();
delay_ms (1);
printf("LED %lX \r\n", ZK);
 
if(ZK==0x73)
{
LSB=LSB-1;
printf("Vysledne LSB %lX \r\n", LSB);
while(TRUE)
{
}
}
 
else
{
i2c_start();//blockdata
I2C_Write(0xAA);
I2C_write(0x44);
i2c_start();
I2C_Write(0xAA);
I2C_write(0x73); //pro 5LED 0x53 pro 7led 0x73
i2c_stop();
 
int i=64;
SOUCET=0;
SOUCET1=0;
 
/*
for (i=64;i<96;++i)
{
printf("%u\r\n",i);
i2c_stop();
i2c_start();//blockdata
I2C_Write(0xAA);
I2C_write(i);
i2c_start();
I2C_Write(0xAB);
STAV1=I2C_read(0);
i2c_stop();
printf("STAV %lX \r\n", STAV1);
SOUCET=SOUCET+STAV1;
}
printf("SOUCET: %lX (procenta)\r\n", SOUCET);
SOUCET1=SOUCET;
SOUCET1=SOUCET1>>8;
printf("Deleno 256: %lX (procenta)\r\n", SOUCET1);
SOUCET1=SOUCET-SOUCET1;
printf("Soucet - soucet/256: %lX \r\n", SOUCET1);
LSB=(unsigned int8)SOUCET1;
printf("LSB: %lX\r\n", LSB);
//printf("Stav: %X (procenta)\r\n", STAV2);
*/
 
i2c_start();//blockdata
I2C_Write(0xAA);
I2C_write(0x60);
i2c_start();
I2C_Write(0xAA);
I2C_write(LSB);
i2c_stop();
 
}
 
LSB=LSB+1;
 
delay_ms (100);
}
}
/Modules/PowerSupply/LION1CELL01B/SW/PIC16F887/setting/Min_V_cl/main.bak
0,0 → 1,154
#include "C:\Users\Honza\Documents\pic\I2C_bat_pam\Min_V_cl\main.h"
 
 
 
#define EEPROM_SDA PIN_B0
#define EEPROM_SCL PIN_B1
#use i2c(master, sda=EEPROM_SDA, scl=EEPROM_SCL)
#use rs232(baud=9600,parity=N,xmit=PIN_B3,rcv=PIN_B2,bits=8) //rcv TXD xmit RXD
 
 
void main()
{
 
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_CLOCK_DIV_2);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_ccp1(CCP_OFF);
setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
 
printf("Simple Thermomether \r\n",);
unsigned int8 STAV1,STAV2;
 
unsigned int16 SOUCET, SOUCET1;
unsigned int8 LSB=0,ZK,k=0,VH,VL;
//unsigned int8
while(TRUE)
{
 
 
i2c_start(); //blockdatacontrol
I2C_Write(0xAA);
I2C_write(0x61);
i2c_start();
I2C_Write(0xAA);
i2c_write(0x00);
i2c_stop();
delay_ms (1);
 
 
i2c_start();//dataflashclass
I2C_Write(0xAA);
I2C_write(0x3e);
i2c_start();
I2C_Write(0xAA);
i2c_write(0x50);
i2c_stop();
delay_ms (1);
i2c_start();//dataflashblock
I2C_Write(0xAA);
I2C_write(0x3f);
i2c_start();
I2C_Write(0xAA);
I2C_write(0x02);
i2c_stop();
delay_ms (1);
i2c_start();//blockdata horni bit
I2C_Write(0xAA);
I2C_write(0x43);
i2c_start();
I2C_Write(0xAB);
VH=I2C_read(0);
i2c_stop();
i2c_start();//blockdata
I2C_Write(0xAA);
I2C_write(0x44);
i2c_start();
I2C_Write(0xAB);
VL=I2C_read(0);
i2c_stop();
delay_ms (1);
printf("VL %lX \r\n", VL);
printf("LH %lX \r\n", VH);
 
 
 
if(VH==0x0A)
{
LSB=LSB-1;
printf("Vysledne LSB %lX \r\n", LSB);
while(TRUE)
{
}
}
 
else
{
i2c_start();//blockdata
I2C_Write(0xAA);
I2C_write(0x43);
i2c_start();
I2C_Write(0xAA);
I2C_write(0x0A);
i2c_stop();
 
i2c_start();//blockdata
I2C_Write(0xAA);
I2C_write(0x44);
i2c_start();
I2C_Write(0xAA);
I2C_write(0x5A);
i2c_stop();
 
 
}
 
i2c_start();//blockdata
I2C_Write(0xAA);
I2C_write(0x60);
i2c_start();
I2C_Write(0xAA);
I2C_write(LSB);
i2c_stop();
 
LSB=LSB+1;
 
delay_ms (100);
 
}
 
}
/Modules/PowerSupply/LION1CELL01B/SW/PIC16F887/setting/Q_MAX/main.bak
0,0 → 1,156
#include "C:\Users\Honza\Documents\pic\I2C_bat_pam\Q_MAX\main.h"
 
 
 
#define EEPROM_SDA PIN_B0
#define EEPROM_SCL PIN_B1
#use i2c(master, sda=EEPROM_SDA, scl=EEPROM_SCL)
#use rs232(baud=9600,parity=N,xmit=PIN_B3,rcv=PIN_B2,bits=8) //rcv TXD xmit RXD
 
 
void main()
{
 
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_CLOCK_DIV_2);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_ccp1(CCP_OFF);
setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
 
printf("Simple Thermomether \r\n",);
unsigned int8 STAV1,STAV2;
 
unsigned int16 SOUCET, SOUCET1;
unsigned int8 LSB=0,ZK,k=0,VH,VL;
//unsigned int8
while(TRUE)
{
 
 
i2c_start(); //blockdatacontrol
I2C_Write(0xAA);
I2C_write(0x61);
i2c_start();
I2C_Write(0xAA);
i2c_write(0x00);
i2c_stop();
delay_ms (1);
 
 
i2c_start();//dataflashclass
I2C_Write(0xAA);
I2C_write(0x3e);
i2c_start();
I2C_Write(0xAA);
i2c_write(0x52);
i2c_stop();
delay_ms (1);
i2c_start();//dataflashblock
I2C_Write(0xAA);
I2C_write(0x3f);
i2c_start();
I2C_Write(0xAA);
I2C_write(0x00);
i2c_stop();
delay_ms (1);
i2c_start();//blockdata
I2C_Write(0xAA);
I2C_write(0x40);
i2c_start();
I2C_Write(0xAB);
VH=I2C_read(0);
i2c_stop();
i2c_start();//blockdata
I2C_Write(0xAA);
I2C_write(0x41);
i2c_start();
I2C_Write(0xAB);
VL=I2C_read(0);
i2c_stop();
delay_ms (10);
printf("VL %lX \r\n", VL);
printf("LH %lX \r\n", VH);
if(VL==0x48)
{
LSB=LSB-1;
printf("Vysledne LSB %lX \r\n", LSB);
while(TRUE)
{
}
}
 
else
{
i2c_start();//blockdata
I2C_Write(0xAA);
I2C_write(0x40);
i2c_start();
I2C_Write(0xAA);
I2C_write(0x0D);
i2c_stop();
i2c_start();//blockdata
I2C_Write(0xAA);
I2C_write(0x41);
i2c_start();
I2C_Write(0xAA);
I2C_write(0x48);
i2c_stop();
 
 
 
 
}
 
i2c_start();//blockdata
I2C_Write(0xAA);
I2C_write(0x60);
i2c_start();
I2C_Write(0xAA);
I2C_write(LSB);
i2c_stop();
 
LSB=LSB+1;
 
delay_ms (100);
 
 
 
 
 
 
}
 
}
 
/Modules/PowerSupply/LION1CELL01B/SW/PIC16F887/setting/V_MAX/main.bak
0,0 → 1,153
#include "C:\Users\Honza\Documents\pic\I2C_bat_pam\V_MAX\main.h"
 
 
#define EEPROM_SDA PIN_B0
#define EEPROM_SCL PIN_B1
#use i2c(master, sda=EEPROM_SDA, scl=EEPROM_SCL)
#use rs232(baud=9600,parity=N,xmit=PIN_B3,rcv=PIN_B2,bits=8) //rcv TXD xmit RXD
 
 
void main()
{
 
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_CLOCK_DIV_2);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_ccp1(CCP_OFF);
setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
 
printf("Simple Thermomether \r\n",);
unsigned int8 STAV1,STAV2;
 
unsigned int16 SOUCET, SOUCET1;
unsigned int8 LSB=0,ZK,k=0,VH,VL;
//unsigned int8
while(TRUE)
{
 
 
i2c_start(); //blockdatacontrol
I2C_Write(0xAA);
I2C_write(0x61);
i2c_start();
I2C_Write(0xAA);
i2c_write(0x00);
i2c_stop();
delay_ms (1);
 
 
i2c_start();//dataflashclass
I2C_Write(0xAA);
I2C_write(0x3e);
i2c_start();
I2C_Write(0xAA);
i2c_write(0x52);
i2c_stop();
delay_ms (1);
i2c_start();//dataflashblock
I2C_Write(0xAA);
I2C_write(0x3f);
i2c_start();
I2C_Write(0xAA);
I2C_write(0x00);
i2c_stop();
delay_ms (1);
i2c_start();//blockdata
I2C_Write(0xAA);
I2C_write(0x45);
i2c_start();
I2C_Write(0xAB);
VH=I2C_read(0);
i2c_stop();
i2c_start();//blockdata
I2C_Write(0xAA);
I2C_write(0x46);
i2c_start();
I2C_Write(0xAB);
VL=I2C_read(0);
i2c_stop();
delay_ms (1);
printf("VL %lX \r\n", VL);
printf("LH %lX \r\n", VH);
 
 
 
if(VL==0x10)
{
LSB=LSB-1;
printf("Vysledne LSB %lX \r\n", LSB);
while(TRUE)
{
}
}
 
else
{
i2c_start();//blockdata
I2C_Write(0xAA);
I2C_write(0x45);
i2c_start();
I2C_Write(0xAA);
I2C_write(0x68);
i2c_stop();
i2c_start();//blockdata
I2C_Write(0xAA);
I2C_write(0x46);
i2c_start();
I2C_Write(0xAA);
I2C_write(0x10);
i2c_stop();
 
 
 
 
}
 
i2c_start();//blockdata
I2C_Write(0xAA);
I2C_write(0x60);
i2c_start();
I2C_Write(0xAA);
I2C_write(LSB);
i2c_stop();
 
LSB=LSB+1;
 
delay_ms (100);
 
}
 
}
/Modules/PowerSupply/LION1CELL01B/SW/PIC16F887/setting/LED_BAT/main.bak
0,0 → 1,152
//#include "C:\Users\Honza\Documents\pic\I2C_bat_pam\main.h"
#define EEPROM_SDA PIN_B0
#define EEPROM_SCL PIN_B1
#use i2c(master, sda=EEPROM_SDA, scl=EEPROM_SCL)
#use rs232(baud=9600,parity=N,xmit=PIN_B3,rcv=PIN_B2,bits=8) //rcv TXD xmit RXD
#include "main.h"
 
void main()
{
 
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_CLOCK_DIV_2);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_ccp1(CCP_OFF);
setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
 
printf("Simple Thermomether \r\n",);
unsigned int8 STAV1,STAV2;
 
unsigned int16 SOUCET, SOUCET1;
unsigned int8 LSB=0,ZK,k=0;
//unsigned int8
while(TRUE)
{
 
 
i2c_start(); //blockdatacontrol
I2C_Write(0xAA);
I2C_write(0x61);
i2c_start();
I2C_Write(0xAA);
i2c_write(0x00);
i2c_stop();
delay_ms (1);
 
 
i2c_start();//dataflashclass
I2C_Write(0xAA);
I2C_write(0x3e);
i2c_start();
I2C_Write(0xAA);
i2c_write(0x40);
i2c_stop();
delay_ms (1);
i2c_start();//dataflashblock
I2C_Write(0xAA);
I2C_write(0x3f);
i2c_start();
I2C_Write(0xAA);
I2C_write(0x00);
i2c_stop();
delay_ms (1);
i2c_start();//blockdata
I2C_Write(0xAA);
I2C_write(0x44);
i2c_start();
I2C_Write(0xAB);
ZK=I2C_read(0);
i2c_stop();
delay_ms (1);
printf("LED %lX \r\n", ZK);
 
if(ZK==0x73)
{
LSB=LSB-1;
printf("Vysledne LSB %lX \r\n", LSB);
while(TRUE)
{
}
}
 
else
{
i2c_start();//blockdata
I2C_Write(0xAA);
I2C_write(0x44);
i2c_start();
I2C_Write(0xAA);
I2C_write(0x73); //pro 5LED 0x53 pro 7led 0x73
i2c_stop();
 
int i=64;
SOUCET=0;
SOUCET1=0;
 
/*
for (i=64;i<96;++i)
{
printf("%u\r\n",i);
i2c_stop();
i2c_start();//blockdata
I2C_Write(0xAA);
I2C_write(i);
i2c_start();
I2C_Write(0xAB);
STAV1=I2C_read(0);
i2c_stop();
printf("STAV %lX \r\n", STAV1);
SOUCET=SOUCET+STAV1;
}
printf("SOUCET: %lX (procenta)\r\n", SOUCET);
SOUCET1=SOUCET;
SOUCET1=SOUCET1>>8;
printf("Deleno 256: %lX (procenta)\r\n", SOUCET1);
SOUCET1=SOUCET-SOUCET1;
printf("Soucet - soucet/256: %lX \r\n", SOUCET1);
LSB=(unsigned int8)SOUCET1;
printf("LSB: %lX\r\n", LSB);
//printf("Stav: %X (procenta)\r\n", STAV2);
*/
 
i2c_start();//blockdata
I2C_Write(0xAA);
I2C_write(0x60);
i2c_start();
I2C_Write(0xAA);
I2C_write(LSB);
i2c_stop();
 
}
 
LSB=LSB+1;
 
delay_ms (100);
}
}
/Modules/PowerSupply/LION1CELL01B/SW/PIC16F887/main.bak
0,0 → 1,43
//#include "C:\Users\Honza\Documents\pic\I2C_magnetometr\main.h"
#include "main.h"
#define EEPROM_SDA PIN_C4
#define EEPROM_SCL PIN_C3
#use i2c(master, sda=EEPROM_SDA, scl=EEPROM_SCL)
#use rs232(baud=9600,parity=N,xmit=PIN_C7,rcv=PIN_C6,bits=8) //rcv TXD xmit RXD
#include "BQ34Z100.h"
 
 
void main()
{
 
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_CLOCK_DIV_2);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_ccp1(CCP_OFF);
setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
 
printf("Vycitani zakladnich dat z modulu LION1CELL01B \r\n",);
printf("(c) MLAB 2013 JACHO \r\n",);
int16 data;
 
while(TRUE)
{
data=batintT();
printf("Teplota baterie: %Ld (°C)\r\n", data);
data=batNAP();
printf("Napeti clanku: %Ld (mV)\r\n", data);
data=batPROUD();
printf("Proud clankem: %Ld (mA)\r\n", data);
data=batKAPAKT();
printf("Zbyvajici kapacita: %Ld (mAh)\r\n", data);
data=batKAPMAX();
printf("Max. kapacita: %Ld (mAh)\r\n", data);
data=batSTAV();
printf("Stav baterie: %Ld (procenta)\r\n", data);
delay_ms (2000);
}
}