Advertisement
Guest User

Untitled

a guest
Nov 12th, 2022
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.05 KB | None | 0 0
  1. git diff
  2. strip jbc
  3. root@rpi4:~/jbc# sync
  4. root@rpi4:~/jbc# git diff
  5. diff --git a/jbc.c b/jbc.c
  6. index 1d4b2fb..6ff68ee 100644
  7. --- a/jbc.c
  8. +++ b/jbc.c
  9. @@ -76,7 +76,7 @@
  10. #define JBC_CAUTION_TEMP 350
  11. #define ZEROCROSS_GPIO 17
  12. #define MOSFET_GPIO 27
  13. -#define READ_SAMPLES 2
  14. +#define READ_SAMPLES 1
  15.  
  16. #define USEFONT "/tmp/Roboto-Regular.ttf"
  17.  
  18. @@ -5088,8 +5088,8 @@ int main(int argc, char *argv[])
  19. */
  20. BSC0_DLEN = 3;
  21. BSC0_FIFO = 1; // config register
  22. - BSC0_FIFO = 0b11000011; // start conversion, AIN0 and GND, FSR=4.096,single shot mode
  23. - BSC0_FIFO = 0b10000011; // 128 SPS, Traditional comparator, alert pin active low, nonlatching comparator, disable comparator, alert pin high impedance
  24. + BSC0_FIFO = 0b11000101; // start conversion, AIN0 and GND, FSR=2.048, single shot mode
  25. + BSC0_FIFO = 0b10100011; // 250 SPS, Traditional comparator, alert pin active low, nonlatching comparator, disable comparator, alert pin high impedance
  26. BSC0_S = CLEAR_STATUS;
  27. BSC0_C = START_WRITE;
  28. if (!wait_i2c_done())
  29. @@ -5138,26 +5138,22 @@ int main(int argc, char *argv[])
  30. buf[0] = BSC0_FIFO;
  31. buf[1] = BSC0_FIFO;
  32.  
  33. - /* temperatura = (VOUT - VREF)/(5 mV/ C) */
  34. -
  35. - // ads1115 single ended rezolucija je 0x7fff = 32767
  36. - //konfig registar 1/2 = 11000011; // start conversion, AIN0 and GND, FSR=4.096,single shot mode
  37. - //konfig registar 2/2 = 10000011; // 128 SPS, Traditional comparator, alert pin active low, Nonlatching comparator, disable comparator and alert pin is high impedance
  38. - // Pola_rezolucije_adc = 16384.0 = 500 celzijusa
  39. - // ((((neki_adc_broj * VCC) / adc_rezolucija) - VREF) / 5mV)
  40. - // ((((16384.0 * 5.0) / 32767.0) - 0) / 0.005) = 500 celzijusa
  41. + // temperatura = (VOUT - VREF)/(5 mV/ C)
  42. + // LSB = FSR / 32767;
  43. + // temperatura = ((advalue * LSB) - VREF) / 0.005
  44.  
  45. /* convert output and display results */
  46. val = buf[0] << 8 | buf[1]; // Combine the two bytes of readBuf into a single 16 bit result
  47. - temperature = (float)((((val * 5.0) / 32767.0) - 0) / 0.005);
  48. +
  49. + temperature = (float)(((val * (2.048 / 32767.0)) + ((val * 0.75) / 32767.0)) / 0.005);
  50.  
  51. //if (!daemon_mode)
  52. // LOG("Conversion: buf[0]=0x%02x buf[1]=0x%02x combined=0x%04x time=%.2f mS result=%f temperature=%.2f\n",
  53. // buf[0],
  54. // buf[1],
  55. // val,
  56. - // (float)((gpiotick() - prev_tick) / 1000.0),
  57. - // (float)((val * 4.096) / 32768.0),
  58. + // (float)((gpioTick() - prev_tick) / 1000.0),
  59. + // (float)(val * (2.048 / 32767.0)),
  60. // temperature);
  61.  
  62. jbc_temperature += round(temperature);
  63. r
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement