Mesa modbus and pktUart

More
19 Jan 2025 18:33 - 19 Jan 2025 18:55 #319395 by PCW
Replied by PCW on topic Mesa modbus and pktUart
HAL_BIT type definitely works as this tested, working configuration:


static const hm2_modbus_chan_descriptor_t channels = {
/*  {TYPE,    FUNC, ADDR,   COUNT, pin_name} */
    {HAL_BIT, 1,  0x0000, 8,     "state"},
    {HAL_BIT, 2,  0x0000, 8,     "input"},
    {HAL_BIT, 5,  0x0000, 1,     "relay-0"},
    {HAL_BIT, 5,  0x0001, 1,     "relay-1"},
    {HAL_BIT, 5,  0x0002, 1,     "relay-2"},
    {HAL_BIT, 5,  0x0003, 1,     "relay-3"},
};

Can you post your .mod file?

The inverted enable pin may not be recognized by 2.9.3 but it
should still work.
 
Last edit: 19 Jan 2025 18:55 by PCW.

Please Log in or Create an account to join the conversation.

  • vre
  • Away
  • Platinum Member
  • Platinum Member
More
20 Jan 2025 02:19 - 20 Jan 2025 02:33 #319431 by vre
Replied by vre on topic Mesa modbus and pktUart
#define MAX_MSG_LEN 16 // may be increased if necessary to max 251
#define DEBUG 2

static const hm2_modbus_chan_descriptor_t channels = {
/* {TYPE, FUNC, ADDR, COUNT, pin_name} */
{HAL_BIT, 3, 130, 8, "in"},
{HAL_U32, 16, 1, 8, "out"},
};

compilation : sudo modcompile file.mod

this is a working mb2hal configuration for my modbus module
[TRANSACTION_00]
LINK_TYPE=serial
SERIAL_PORT=/dev/ttyS0
SERIAL_BAUD=9600
SERIAL_BITS=8
SERIAL_PARITY=none
SERIAL_STOP=1
SERIAL_DELAY_MS=5
MB_SLAVE_ID=1
FIRST_ELEMENT=129
PIN_NAMES=01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16
HAL_TX_NAME=in
MB_TX_CODE=fnct_03_read_holding_registers

[TRANSACTION_01]
PIN_NAMES=01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16
MB_TX_CODE=fnct_16_write_multiple_registers
FIRST_ELEMENT=1
HAL_TX_NAME=out
MAX_UPDATE_RATE=0.0
Last edit: 20 Jan 2025 02:33 by vre.

Please Log in or Create an account to join the conversation.

More
20 Jan 2025 03:16 #319436 by PCW
Replied by PCW on topic Mesa modbus and pktUart
I don't think:

HAL_BIT, 3, 130, 8, "in"

makes logical sense

Because unlike function 2 which returns a
number of bits, function 3 returns a number
of bytes.

I think you need to use u32

Please Log in or Create an account to join the conversation.

  • vre
  • Away
  • Platinum Member
  • Platinum Member
More
20 Jan 2025 04:20 - 20 Jan 2025 04:34 #319438 by vre
Replied by vre on topic Mesa modbus and pktUart
I have used u32 and works but
SCFFIFO error remains
hm2: hm2_7i80.0.pktuart.0: SCFFIFO error
Modbus error response function 128 error Illegal Data Value
hm2: hm2_7i80.0.pktuart.0: SCFFIFO error

Modbus error response function 128 error Illegal Data Value
Last edit: 20 Jan 2025 04:34 by vre.

Please Log in or Create an account to join the conversation.

More
20 Jan 2025 05:00 - 20 Jan 2025 05:02 #319439 by PCW
Replied by PCW on topic Mesa modbus and pktUart
The SCFFIFO error is just a warning so should be harmless.
Andy probably need to look at that.

What is you current .mod file?
I think the only valid byte count on the function 3 read is likely 2
(because holding registers are 16 bits)
Last edit: 20 Jan 2025 05:02 by PCW.
The following user(s) said Thank You: vre

Please Log in or Create an account to join the conversation.

  • vre
  • Away
  • Platinum Member
  • Platinum Member
More
20 Jan 2025 10:28 #319448 by vre
Replied by vre on topic Mesa modbus and pktUart
This config works but displays a ton of errors at startup of linuxcnc like these
task: main loop took 0.105362 seconds
Modbus error response function 128 error Illegal Data Value

Modbus error response function 128 error Illegal Data Value

task: main loop took 0.100015 seconds
Modbus error response function 128 error Illegal Data Value

task: main loop took 0.100069 seconds
Modbus error response function 128 error Illegal Data Value

#define MAX_MSG_LEN 16   // may be increased if necessary to max 251
#define DEBUG 1

static const hm2_modbus_chan_descriptor_t channels[] = {
/*  {TYPE,    FUNC, ADDR,   COUNT, pin_name} */
    {HAL_U32, 3,  0x0080, 1,     "in-01"},
	{HAL_U32, 3,  0x0081, 1,     "in-02"},
    {HAL_U32, 3,  0x0082, 1,     "in-03"},
    {HAL_U32, 3,  0x0083, 1,     "in-04"},
    {HAL_U32, 3,  0x0084, 1,     "in-05"},
    {HAL_U32, 3,  0x0085, 1,     "in-06"},
    {HAL_U32, 3,  0x0086, 1,     "in-07"},
	{HAL_U32, 3,  0x0087, 1,     "in-08"},
    {HAL_U32, 3,  0x0088, 1,     "in-09"},
    {HAL_U32, 3,  0x0089, 1,     "in-10"},
    {HAL_U32, 3,  0x008A, 1,     "in-11"},
    {HAL_U32, 3,  0x008B, 1,     "in-12"},
	{HAL_U32, 3,  0x008C, 1,     "in-13"},
    {HAL_U32, 3,  0x008D, 1,     "in-14"},
    {HAL_U32, 3,  0x008E, 1,     "in-15"},
    {HAL_U32, 3,  0x008F, 1,     "in-16"},
    {HAL_U32, 3,  0x0090, 1,     "in-17"},
	{HAL_U32, 3,  0x0091, 1,     "in-18"},
    {HAL_U32, 3,  0x0092, 1,     "in-19"},
    {HAL_U32, 3,  0x0093, 1,     "in-20"},
    {HAL_U32, 3,  0x0094, 1,     "in-21"},
    {HAL_U32, 3,  0x0095, 1,     "in-22"},
    {HAL_U32, 3,  0x0096, 1,     "in-23"},
	{HAL_U32, 3,  0x0097, 1,     "in-24"},
    {HAL_U32, 3,  0x0098, 1,     "in-25"},
    {HAL_U32, 3,  0x0099, 1,     "in-26"},
    {HAL_U32, 3,  0x009A, 1,     "in-27"},
    {HAL_U32, 3,  0x009B, 1,     "in-28"},
	{HAL_U32, 3,  0x009C, 1,     "in-29"},
    {HAL_U32, 3,  0x009D, 1,     "in-30"},
    {HAL_U32, 3,  0x009E, 1,     "in-31"},
    {HAL_U32, 3,  0x009F, 1,     "in-32"},
		
    {HAL_U32, 16, 0x0000, 1,     "out-01"},
    {HAL_U32, 16, 0x0001, 1,     "out-02"},	
    {HAL_U32, 16, 0x0002, 1,     "out-03"},
    {HAL_U32, 16, 0x0003, 1,     "out-04"},
    {HAL_U32, 16, 0x0004, 1,     "out-05"},
    {HAL_U32, 16, 0x0005, 1,     "out-06"},
    {HAL_U32, 16, 0x0006, 1,     "out-07"},
    {HAL_U32, 16, 0x0007, 1,     "out-08"},
    {HAL_U32, 16, 0x0008, 1,     "out-09"},
    {HAL_U32, 16, 0x0009, 1,     "out-10"},	
    {HAL_U32, 16, 0x000A, 1,     "out-11"},
    {HAL_U32, 16, 0x000B, 1,     "out-12"},
    {HAL_U32, 16, 0x000C, 1,     "out-13"},
    {HAL_U32, 16, 0x000D, 1,     "out-14"},
    {HAL_U32, 16, 0x000E, 1,     "out-15"},
    {HAL_U32, 16, 0x000F, 1,     "out-16"},	
    {HAL_U32, 16, 0x0010, 1,     "out-17"},
    {HAL_U32, 16, 0x0011, 1,     "out-18"},	
    {HAL_U32, 16, 0x0012, 1,     "out-19"},
    {HAL_U32, 16, 0x0013, 1,     "out-20"},
    {HAL_U32, 16, 0x0014, 1,     "out-21"},
    {HAL_U32, 16, 0x0015, 1,     "out-22"},
    {HAL_U32, 16, 0x0016, 1,     "out-23"},
    {HAL_U32, 16, 0x0017, 1,     "out-24"},
    {HAL_U32, 16, 0x0018, 1,     "out-25"},
    {HAL_U32, 16, 0x0019, 1,     "out-26"},	
    {HAL_U32, 16, 0x001A, 1,     "out-27"},
    {HAL_U32, 16, 0x001B, 1,     "out-28"},
    {HAL_U32, 16, 0x001C, 1,     "out-29"},
    {HAL_U32, 16, 0x001D, 1,     "out-30"},
    {HAL_U32, 16, 0x001E, 1,     "out-31"},
    {HAL_U32, 16, 0x001F, 1,     "out-32"},

};

Please Log in or Create an account to join the conversation.

More
20 Jan 2025 15:12 - 20 Jan 2025 16:52 #319465 by PCW
Replied by PCW on topic Mesa modbus and pktUart
if this is a 16 input module, there should only be one function 3 read
(because that read reads 16 bits at once into a single U32)

Also it's a bit  strange to use function 3 to read bits
as function 2 would be the standard thing for this.
 
Last edit: 20 Jan 2025 16:52 by PCW.

Please Log in or Create an account to join the conversation.

Time to create page: 0.101 seconds
Powered by Kunena Forum