Group Details

administrators

  • 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
  • RE: Rexygen Runtime installation after 31st January 2026

    @martinpies Dear Martin,
    Thank you for pointing this out. Everything should be working now. The command

    sudo wget https://download.rexcontrols.com/rexygen.gpg -O /etc/apt/trusted.gpg.d/rexygen.gpg
    

    will now download the new version of the certificate, which is supported even under the new licensing policy.

    Cheers,
    Jan

    posted in Bug reports
  • RE: Rexygen Runtime installation after 31st January 2026

    @martinpies
    Hello Martin,
    I apologize for the complications. This issue is on the REXYGEN side, and I have already reported it to the developers. I hope it will be resolved soon.

    In the meantime, I recommend using our pre-installed Bookworm image according to the instructions in chapter 2.2 Monarco HAT: https://www.rexygen.com/doc/ENGLISH/MANUALS/RexCore_Installation/RexCore_Installation_ENG.html#x1-60002.2

    Alternatively, you can install REXYGEN from Studio using the Quick bootstrapping guide in chapter 3.1: https://www.rexygen.com/doc/ENGLISH/MANUALS/RexCore_Installation/RexCore_Installation_ENG.html#x1-90003

    Cheers,
    Jan

    posted in Bug reports
  • RE: Problems Sequential reading channels ADC MCP3424 via I2C

    @AlexanderH Hi Alexander,

    we discussed the I2C communication details with the developers and both continuous reading and using multiple I2C commands within a single task cycle should be possible in your use case.

    Unfortunately, there is no MCP342x device available on my side right now, but I will try to get one so the behavior can be reproduced and tested. In the meantime, could you please send a minimal version of your project, either here on the forum or to support@rexygen.com? That will make it much easier to see what is going on in your specific setup and suggest a concrete solution.

    Cheers,
    Jan

    posted in Communication (RS232
  • RE: Problems Sequential reading channels ADC MCP3424 via I2C

    @AlexanderH Hi Alexander,

    Great to see you experimenting with REXYGEN and getting good results so far! It’s nice that you started from the example library — that’s definitely the right approach. The I2C function in REXYGEN works a bit differently compared to Arduino or other low-level implementations. Since REXYGEN tasks usually don’t run with very short cycle times, a single I2C call performs both write and read operations within one cycle. This command takes care of sending the message, waiting briefly, and then reading the response. That means you don’t need to manually handle the NAK or stop condition — the function itself takes care of it.

    I looked through your code and have a few notes that might help:

    • I noticed that right after calculating channel1, you have a return 0;. Because of that, the code for channel2 never runs — I guess that’s just for debugging, but it’s worth pointing out.
    • In each REXYGEN cycle, you currently configure the converter for continuous read mode. This might not behave as you expect, and it’s probably unnecessary. Try switching to one-shot mode first and see what kind of values you get. Later, you can set continuous mode once, and then in your main() you can just read the data by setting i2c_write_count = 0. That way, the I2C function won’t send any configuration bytes, it will only read — according to the documentation, that should work.
    • You can use the Trace() function to print out the value of i2c_ret_fun for debugging. Keep in mind that you need to enable these messages in the system log:
      Go to TargetDiagnostic messages, tick Information in Function block messages, and make sure Enable logging is checked in the Options tab of the block properties dialog. Only then you’ll see the messages in the System log.
    • And finally, double-check the I2C address of the MCP3424 — it’s configurable, so make sure it matches your hardware setup.

    Hope this helps you move forward! Please let us know how it goes — it’s always interesting to see REXLANG + I2C projects in action.

    Cheers,
    Jan

    posted in Communication (RS232
  • RE: Vector demultiplexer VTOR+Python processing

    Hello @stepan-ozana,
    The main point from our developer's explanation is that the problem occurs because the Python script assigns outputs from inputs only during the initialization phase (init). However, while the CNR block sets its output directly in init (based on its parameter), the VTOR block likely receives its output settings only after the first run of its main function.

    Generally, blocks should not process inputs from other blocks during init. During init, each block should manage itself: check parameter settings and initialize its own outputs to starting values. Any processing of inputs and outputs involving other blocks should happen in the main runtime phase.

    In this case, CNR correctly sets its output in init according to its parameter, which is acceptable. VTOR must read its inputs to set outputs, so it does this later in the main function, which is also correct.

    Thus, the VTOR output being zero initially can happen because it does not update outputs until the main function runs, unlike CNR which sets fixed output at init. This explains the observed behavior with the VTOR1 showing zeros at first while sharing the same Python script with another block

    posted in REXYGEN Studio
  • RE: REXYGEN - DWM interface for Debian Trixie

    @gninaus Hi Guenther,

    DWM is not ready for Trixie yet. We are working on it. I will keep you posted when Trixie is supported.

    Cheers,
    Tomas

    posted in General discussion
  • RE: Core Error "Configuration requires higher license than available on the target device"

    In this specific case, the error message "Configuration requires higher license than available on the target device" indicates that RexCore did not find the new version of the license. If an older license version is present on the device and is sufficient concerning the scope of the project, this information should appear in the log and the project should run normally. In such a case, please ignore the error message.

    This error message will be revised in future versions of REXYGEN.

    posted in General discussion
  • RE: Core Error "Configuration requires higher license than available on the target device"

    Hi @gninaus,

    With version 3.0, REXYGEN introduced a new licensing policy. You can find the details here:
    https://eshop.rexcontrols.com/pages/licensing-policy

    Could you please send us your license information at support@rexygen.com?
    You can find the license info via REXYGEN Studio by using the menu Target -> Connect and then again Target -> Licensing.

    Also, please attach the REXYGEN Studio Compiler output related to licensing. Here’s an example:
    a7569447-a9d3-42b7-8544-5ebedf7652cf-image.png

    This will help us identify what part of the configuration requires a higher license and provide further guidance.

    Cheers,
    Jan

    posted in General discussion
  • RE: error on Modbus driver

    @MikeyH Hi Mike,

    It's a duplicate of this one: https://forum.rexygen.com/post/1707 - check the project timing.

    Cheers,
    Tomas

    posted in Modbus RTU