REXYGEN Community Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Login
    1. Home
    2. Jan Reitinger
    3. Best
    J
    • Profile
    • Following 0
    • Followers 0
    • Topics 3
    • Posts 78
    • Best 2
    • Controversial 0
    • Groups 1

    Best posts made by Jan Reitinger

    • RE: Problems Sequential reading channels ADC MCP3424 via I2C

      Hi everyone,

      @AlexanderH solved his MCP3424 multi-channel reading issue! Here's the key takeaway:

      The Problem

      When reading multiple channels sequentially from MCP3424, conversion time must be respected. Each configuration byte starts a new conversion:

      • 12-bit: ~5ms (1/240 s)
      • 18-bit: ~267ms (1/3.75 s)

      Table 4.3 from MCP3424 datasheet lists all data rates by resolution.

      The Solution

      One-shot mode + proper timing between configure/read operations:

      For 12-bit (2 channels):

      // Channel 1 - configure + convert + read
      i2c_bufTx[0] = 0x80; // CH1, one-shot, 12-bit, gain x1  
      i2c_write_count = 1;
      i2c_read_count = 0;
      i2c_ret_fun = I2C(i2c_bus_handle, i2c_chip_address, i2c_bufTx, i2c_write_count, i2c_bufRx, i2c_read_count);
      
      Sleep(0.01); // wait for 10 ms before reading the first channel 
                   // Data rate: 12bit = 240 SPS, 14bit = 60 SPS, 16bit = 15 SPS, 18bit = 3.75 SPS
      
      i2c_write_count = 0;
      i2c_read_count = 3;
      i2c_ret_fun = I2C(i2c_bus_handle, i2c_chip_address, i2c_bufTx, i2c_write_count, i2c_bufRx, i2c_read_count);
      // i2c_bufRx[2] contains configuration byte
      channel1 = ((i2c_bufRx[0]<<8) + i2c_bufRx[1])/2;
      
      i2c_bufTx[0] = 0xA0; // channel 2, one-shot, 12bit, gain 1 (see MCP3424 datasheet)
      i2c_write_count = 1;
      i2c_read_count = 0;
      i2c_ret_fun = I2C(i2c_bus_handle, i2c_chip_address, i2c_bufTx, i2c_write_count, i2c_bufRx, i2c_read_count);
        
      Sleep(0.01); // wait for 10 ms before reading the second channel 
                   // Data rate: 12bit = 240 SPS, 14bit = 60 SPS, 16bit = 15 SPS, 18bit = 3.75 SPS
        
      i2c_write_count = 0;
      i2c_read_count = 3;
      i2c_ret_fun = I2C(i2c_bus_handle, i2c_chip_address, i2c_bufTx, i2c_write_count, i2c_bufRx, i2c_read_count);
      channel2 = ((i2c_bufRx[0]<<8) + i2c_bufRx[1])/2;
      

      Important Notes

      Sleep time scales with resolution - 10ms works for 12-bit, 270ms needed for 18-bit

      Original MCP3422 example worked because it read only 1 channel (no channel switching). The message from the previous tick was probably returned as a response.

      Example Update

      REXYGEN example library will be extended with:

      • read_mcp3424_12bit.c - 2 channels, 12-bit
      • read_mcp3424_18bit.c - 2 channels, 18-bit

      Big thanks to Alexander for the thorough debugging, testing different timing scenarios, and sharing his working scripts!

      Cheers,
      Jan

      posted in Communication (RS232
      J
      Jan Reitinger
    • RE: RPi internet issues with REXYGEN 3.0

      @MikeyH Hi Mike,
      We found out that there were changes to systemd in Bookworm. On the clean image, there is a problem in DNS after installing DWM. We will adjust the DWM installation accordingly so that everything works on Bookworm and older distributions. We'll let you know when we have a solution.

      Cheers,
      Jan

      posted in REXYGEN Studio
      J
      Jan Reitinger