Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- git diff
- strip jbc
- root@rpi4:~/jbc# sync
- root@rpi4:~/jbc# git diff
- diff --git a/jbc.c b/jbc.c
- index 1d4b2fb..6ff68ee 100644
- --- a/jbc.c
- +++ b/jbc.c
- @@ -76,7 +76,7 @@
- #define JBC_CAUTION_TEMP 350
- #define ZEROCROSS_GPIO 17
- #define MOSFET_GPIO 27
- -#define READ_SAMPLES 2
- +#define READ_SAMPLES 1
- #define USEFONT "/tmp/Roboto-Regular.ttf"
- @@ -5088,8 +5088,8 @@ int main(int argc, char *argv[])
- */
- BSC0_DLEN = 3;
- BSC0_FIFO = 1; // config register
- - BSC0_FIFO = 0b11000011; // start conversion, AIN0 and GND, FSR=4.096,single shot mode
- - BSC0_FIFO = 0b10000011; // 128 SPS, Traditional comparator, alert pin active low, nonlatching comparator, disable comparator, alert pin high impedance
- + BSC0_FIFO = 0b11000101; // start conversion, AIN0 and GND, FSR=2.048, single shot mode
- + BSC0_FIFO = 0b10100011; // 250 SPS, Traditional comparator, alert pin active low, nonlatching comparator, disable comparator, alert pin high impedance
- BSC0_S = CLEAR_STATUS;
- BSC0_C = START_WRITE;
- if (!wait_i2c_done())
- @@ -5138,26 +5138,22 @@ int main(int argc, char *argv[])
- buf[0] = BSC0_FIFO;
- buf[1] = BSC0_FIFO;
- - /* temperatura = (VOUT - VREF)/(5 mV/ C) */
- -
- - // ads1115 single ended rezolucija je 0x7fff = 32767
- - //konfig registar 1/2 = 11000011; // start conversion, AIN0 and GND, FSR=4.096,single shot mode
- - //konfig registar 2/2 = 10000011; // 128 SPS, Traditional comparator, alert pin active low, Nonlatching comparator, disable comparator and alert pin is high impedance
- - // Pola_rezolucije_adc = 16384.0 = 500 celzijusa
- - // ((((neki_adc_broj * VCC) / adc_rezolucija) - VREF) / 5mV)
- - // ((((16384.0 * 5.0) / 32767.0) - 0) / 0.005) = 500 celzijusa
- + // temperatura = (VOUT - VREF)/(5 mV/ C)
- + // LSB = FSR / 32767;
- + // temperatura = ((advalue * LSB) - VREF) / 0.005
- /* convert output and display results */
- val = buf[0] << 8 | buf[1]; // Combine the two bytes of readBuf into a single 16 bit result
- - temperature = (float)((((val * 5.0) / 32767.0) - 0) / 0.005);
- +
- + temperature = (float)(((val * (2.048 / 32767.0)) + ((val * 0.75) / 32767.0)) / 0.005);
- //if (!daemon_mode)
- // LOG("Conversion: buf[0]=0x%02x buf[1]=0x%02x combined=0x%04x time=%.2f mS result=%f temperature=%.2f\n",
- // buf[0],
- // buf[1],
- // val,
- - // (float)((gpiotick() - prev_tick) / 1000.0),
- - // (float)((val * 4.096) / 32768.0),
- + // (float)((gpioTick() - prev_tick) / 1000.0),
- + // (float)(val * (2.048 / 32767.0)),
- // temperature);
- jbc_temperature += round(temperature);
- r
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement