diff options
Diffstat (limited to 'monitor.c')
-rw-r--r-- | monitor.c | 40 |
1 files changed, 20 insertions, 20 deletions
@@ -33,18 +33,18 @@ void I2C_Setup_Monitor() LCD_clear(); LCD_write(0,0,"Nulling Current Monitor ...."); /* quiescent */ - I2C_Write(PCF8574A+Curr_Mon_MSB+channel*4,0xff); - I2C_Write(PCF8574A+Curr_Mon_LSB+channel*4,0xff); + I2C_Write(PCF8574A+Curr_Mon_MSB+channel*2,0xff); + I2C_Write(PCF8574A+Curr_Mon_LSB+channel*2,0xff); /* remove chip-select */ - I2C_Write(PCF8574A+Curr_Mon_MSB+channel*4,0xbf); + I2C_Write(PCF8574A+Curr_Mon_MSB+channel*2,0xbf); /* pulse CAL line low */ - I2C_Write(PCF8574A+Curr_Mon_MSB+channel*4,0x9f); - I2C_Write(PCF8574A+Curr_Mon_MSB+channel*4,0xbf); + I2C_Write(PCF8574A+Curr_Mon_MSB+channel*2,0x9f); + I2C_Write(PCF8574A+Curr_Mon_MSB+channel*2,0xbf); for(i=0; i<50; i++); /* quiescent */ - I2C_Write(PCF8574A+Curr_Mon_MSB+channel*4,0xff); + I2C_Write(PCF8574A+Curr_Mon_MSB+channel*2,0xff); /* wait for monitor output to become stable */ @@ -59,15 +59,15 @@ void I2C_Setup_Monitor() g_usleep(1e4); /* pulse S/H line low for initial sample of monitor */ - I2C_Write(PCF8574A+Curr_Mon_MSB+channel*4,0x7f); + I2C_Write(PCF8574A+Curr_Mon_MSB+channel*2,0x7f); for (i=0; i<100; ++i) { ; } /* quiescent */ - I2C_Write(PCF8574A+Curr_Mon_MSB+channel*4,0xff); + I2C_Write(PCF8574A+Curr_Mon_MSB+channel*2,0xff); /* inactive, weak pull-up mode */ - I2C_Read(PCF8574A+Curr_Mon_MSB+channel*4); + I2C_Read(PCF8574A+Curr_Mon_MSB+channel*2); new_os = 1.0 * I2C_Get_Monitor_Word(channel); average_os = (average_os*j+new_os) / (j+1.0); @@ -99,24 +99,24 @@ void force_monitor_cal(int channel, int do_calibration) { if (do_calibration) { /* quiescent */ - I2C_Write(PCF8574A+Curr_Mon_MSB+channel*4,0xff); - I2C_Write(PCF8574A+Curr_Mon_LSB+channel*4,0xff); + I2C_Write(PCF8574A+Curr_Mon_MSB+channel*2,0xff); + I2C_Write(PCF8574A+Curr_Mon_LSB+channel*2,0xff); /* remove chip-select */ - I2C_Write(PCF8574A+Curr_Mon_MSB+channel*4,0xbf); + I2C_Write(PCF8574A+Curr_Mon_MSB+channel*2,0xbf); /* pulse CAL line low */ - I2C_Write(PCF8574A+Curr_Mon_MSB+channel*4,0x9f); - I2C_Write(PCF8574A+Curr_Mon_MSB+channel*4,0xbf); + I2C_Write(PCF8574A+Curr_Mon_MSB+channel*2,0x9f); + I2C_Write(PCF8574A+Curr_Mon_MSB+channel*2,0xbf); g_usleep(2e3); } /* pulse trigger line low and remove chip-select to force an A/D conversion */ - I2C_Write(PCF8574A+Curr_Mon_MSB+channel*4,0x3f); + I2C_Write(PCF8574A+Curr_Mon_MSB+channel*2,0x3f); /* quiescent */ - I2C_Write(PCF8574A+Curr_Mon_MSB+channel*4,0xff); + I2C_Write(PCF8574A+Curr_Mon_MSB+channel*2,0xff); } @@ -126,13 +126,13 @@ int I2C_Get_Monitor_Word(int channel) int monitor_word; /* remove chip-select, so that the value doesn't change while read */ - I2C_Write(PCF8574A+Curr_Mon_MSB+channel*4,0xbf); + I2C_Write(PCF8574A+Curr_Mon_MSB+channel*2,0xbf); - monitor_word=((I2C_Read(PCF8574A+Curr_Mon_MSB+channel*4) & 0x1f)<<8) - + I2C_Read(PCF8574A+Curr_Mon_LSB+channel*4); + monitor_word=((I2C_Read(PCF8574A+Curr_Mon_MSB+channel*2) & 0x1f)<<8) + + I2C_Read(PCF8574A+Curr_Mon_LSB+channel*2); /* restore chip-select */ - I2C_Write(PCF8574A+Curr_Mon_MSB+channel*4,0xff); + I2C_Write(PCF8574A+Curr_Mon_MSB+channel*2,0xff); /* PCB 116B and earlier had 13-bit ADC, PCB 116C has 12 bit. */ if (globals.Flash.pcb116c_mon == 1) { |