Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Diy duvaljka, jbc lemilica, led svetlo, mikroskop
Mislis da ja ne radim nekoliko sampla i da ne razumem o cemu pricas? Evo samo jedan detalj u vezi ads1115 pa zakljuci sam

Code:
            for (i=0; i < READ_SAMPLES; ++i)
            {
                prev_tick = gpioTick();

                // ADS1115 I2C Device Address
                BSC0_A = 0x48;

                // set config register and start conversion
                // AIN0 and GND, 4.096v, 128sps
                BSC0_DLEN = 3;
                BSC0_FIFO = 1;
                BSC0_FIFO = 0xc3;    // single shot mode
                //BSC0_FIFO = 0x42;    // continuous mode
                BSC0_FIFO = 0x83;    
                BSC0_S = CLEAR_STATUS;
                BSC0_C = START_WRITE;    
                wait_i2c_done();

                timeout = 50;
                // wait for conversion complete
                do {        
                    BSC0_DLEN = 2;
                    BSC0_S = CLEAR_STATUS; // Reset status bits
                    BSC0_C = START_READ; // Start Read after clearing FIFO
                    wait_i2c_done();
                    buf[0] = BSC0_FIFO;
                    buf[1] = BSC0_FIFO;
                } while ((0x0000 == ((buf[0] << 8 | buf[1]) & 0x8000)) && --timeout);

                // read conversion register
                BSC0_DLEN = 1;
                BSC0_FIFO = 0;   // conversion register is 0    
                BSC0_S = CLEAR_STATUS;
                BSC0_C = START_WRITE;    
                wait_i2c_done();
                BSC0_DLEN = 2;
                BSC0_S = CLEAR_STATUS; // Reset status bits
                BSC0_C = START_READ; // Start Read after clearing FIFO
                wait_i2c_done();    
                buf[0] = BSC0_FIFO;
                buf[1] = BSC0_FIFO;

                // temperature = (VOUT - VREF)/(5 mV/ C)

                // convert output and display results
                //val = (int16_t)buf[0]*256 + (uint16_t)buf[1];
                val = buf[0] << 8 | buf[1];    // Combine the two bytes of readBuf into a single 16 bit result
                temperature = (float)((((val * 4.096) / 32768.0) - 1.33) / 0.005);
                //printf("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),
                //         temperature);

                jbc_temperature += round(temperature);
            }

            jbc_temperature /= i;
        }

Ali sam shvatio da nije potrebno da radim vise samplova jer onda gubim na brzini grejanja a zakljucio sam i da je ads1115 dovoljno precizan da bukvalno ni nema razlike ako je 5 samplova u pitanju ili je jedan sampl u pitanju pa sam ipak definisao READ_SAMPLES = 1

Podsetio sam se i zasto sam stavio u formuli 4.096, tako sam podesio registar u ads1115 mada sad tek vidim da je to pogresno kako sam uradio, ispravicu i doci cu do resenja na kraju.
Reply


Messages In This Thread
RE: Diy duvaljka, jbc lemilica, led svetlo, mokroskop - by savan - 11-10-2022, 10:07 PM

Forum Jump:


Users browsing this thread: 26 Guest(s)