• Problems Sequential reading channels ADC MCP3424 via I2C

    7
    0 Votes
    7 Posts
    790 Views
    J

    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

  • Problems reading from PCF8574A

    6
    1 Votes
    6 Posts
    933 Views
    J

    @AlexanderH Hi,
    I'm sorry. For some reason I didn't get an email notifying me that you had replied. I'm glad you finally resolved the issue.

    Cheers,
    Jan

  • Bluetooth sensor with rexygen

    2
    0 Votes
    2 Posts
    525 Views
    cechuratC

    @har Hi Har,

    I'm sorry, but we are not able to debug third-party Python code for you.

    If you made it work under plain Python, then you can send the data to REXYGEN using the REST API. Have a look at "0302-03 REST API Python Bash etc", which sends data to REXYGEN using Python.

    Kind regards,
    Tomas

  • SPI comms for MCP41X

    1
    0 Votes
    1 Posts
    293 Views
    No one has replied
  • Connection Problem

    2
    0 Votes
    2 Posts
    542 Views
    J

    Hi har,
    Check if RexCore is running. I see that you are solving the Python code in another thread. It is possible that your code is not only causing the error, but also causing the entire RexCore to crash. Try connecting to the Raspberry via SSH and enter the command:

    systemctl status rexcore

    Cheers,
    Jan

  • Modbus Tcp/IP communication Rpi(Rexygen)<->PC(Matlab)

    7
    0 Votes
    7 Posts
    2k Views
    J

    @stepan-ozana Thanks for sharing your solution! Unfortunately, I don't have the required toolboxes to run the script on my computer. However, the code is well-documented and well-organized, which should make it easy for anyone with the necessary Matlab toolboxes to use it without any issues.

    'modbus' requires one of the following: Industrial Communication Toolbox MATLAB Coder Support Package for NVIDIA Jetson and NVIDIA DRIVE Platforms Error in example_ModbusTcpIP_Comm_RpiToPC (line 9) m = modbus('tcpip', IP_ADDR,MODBUS_PORT) %establish communication with the server (client)

    Cheers,
    Jan

  • REST API communication example

    5
    0 Votes
    5 Posts
    1k Views
    J

    @stepan-ozana
    Thank you for confirmation. I will update the example. Unfortunately, quite large changes occur across Matlab versions, and there are situations where a script from older versions stops working in newer ones.

    Cheers,
    Jan

  • Raspbiian Bookworm

    2
    0 Votes
    2 Posts
    785 Views
    J

    @BailP Hello,
    yes, there are REXYGEN packages (version 3) for Bookworm. Details are described here.

    Cheers,
    Jan

  • HW PWM on RPi?

    2
    1 Votes
    2 Posts
    798 Views
    J

    @stepan-ozana Hello, yes PWM flags should work as HW PWM on GPIO12, GPIO13, GPIO18, GPIO19 pins. The functionality should be the same as described here: https://www.raspberrypi.com/documentation/computers/raspberry-pi.html
    https://www.electronicwings.com/raspberry-pi/raspberry-pi-pwm-generation-using-python-and-c

    Best regards,
    Jan

  • ASCII Commands Over RS485

    19
    1 Votes
    19 Posts
    6k Views
    J

    @georgedumitru I think the best documentation is this thread here on the forum. Byte array reading from communication is also discussed there.

    Another helpful tool is definitely the example located at C:\Program Files\REX Controls\REXYGEN 2.50.12.14711\Examples\0203_Function_Blocks_REXLANG.

  • Communication with USBRLY82

    2
    0 Votes
    2 Posts
    919 Views
    cechuratC

    Hi George,

    Thanks for your question. You need to create a kind of state machine which basically does the following (one line = one task period):

    Write() - send a read request to the device Read() - save received data and length into a global buffer/variable and distinguish if the received message is complete Retry and repeat Read() if the previously received message was not complete

    You will need to introduce a timeout - it can happen that you lost some data so there should be some timeout when you say "Message incomplete, resend the read request".

    Cheers,
    Tomas

  • REXduino and TSC2007

    4
    1 Votes
    4 Posts
    1k Views
    cechuratC

    @hrabalo Hi,

    Thanks for getting back to us. I'm glad it works for you now.

    Good luck with your project.

    Cheers, Tomas

  • This topic is deleted!

    1
    0 Votes
    1 Posts
    2 Views
    No one has replied
  • This topic is deleted!

    1
    0 Votes
    1 Posts
    5 Views
    No one has replied
  • VSD single wire Modbus

    1
    0 Votes
    1 Posts
    784 Views
    No one has replied
  • eBUS

    2
    0 Votes
    2 Posts
    1k Views
    J

    @pancirm
    Hello Michal,
    as far as we know, no one implemented the eBUS in REXYGEN. However, implementation should be possible, for example, via eBUS <-> USB converter and REXLANG or Python programming block.

    Cheers,
    Jan

  • This topic is deleted!

    1
    0 Votes
    1 Posts
    14 Views
    No one has replied
  • I2C EZO component

    Solved
    20
    0 Votes
    20 Posts
    6k Views
    R

    @belgacom You are welcome 🙂

  • Can driver

    Solved
    9
    0 Votes
    9 Posts
    3k Views
    R

    Hi Toni,
    FilterIdMask can be used for filtering messages from more devices. In your case, there is only one device, so you can set FilterIdMask as 0xfff. For message decomposing, use the INTSM blocks (www.rexygen.com/doc/ENGLISH/MANUALS/BRef/INTSM.html). The basic example of using INTSM block can be found in this thread: https://forum.rexygen.com/topic/174/reading-and-writing-4-byte-floating-point-from-modbus?_=1609251284153
    For decomposing a byte value into bits can be used block BDOCT(www.rexygen.com/doc/ENGLISH/MANUALS/BRef/BDOCT.html).

    Cheers,
    Jan

  • I2C with REXDuino

    2
    0 Votes
    2 Posts
    966 Views
    S

    Me and my colleague finally implemented some functional solution. We make it public if anyone is interested. Many thanks to Ing. Tomáš Dočekal!
    MCP4725_REXDuino_2_50_10.zip