Page 1 of 1

KOGNA RS485 SLAVE ID

Posted: Thu Nov 28, 2024 11:22 am
by kizilkaya
I have RM782MB I/O mudule, baud rate 34800 , slave ID:10 please give me
example for read inputs code, I don't found any solution for this module...

https://www.valduino.com/wp-content/upl ... M782MB.pdf

Re: KOGNA RS485 SLAVE ID

Posted: Thu Nov 28, 2024 8:27 pm
by kizilkaya
Kmotion 5.3.6 ver.
JP12 PIN7 connected to RM782M RS485 A
JP12 PIN8 connected to RM782M RS485 B
JP12 PIN40 connected to RM782M RS485 GND
RM782.png
This VALDUİNO connection software a section source code , I open the Valduino software , select 38400 baudrate - Slave ID 10 and connected, no any problem.
RM782MB_COMM_SOFT.txt
(110.45 KiB) Downloaded 2 times
val.png

Re: KOGNA RS485 SLAVE ID

Posted: Sat Nov 30, 2024 5:39 pm
by TomKerekes
Hi kizilkaya,

Attached is an example that should read the 8 Inputs to Kogna Virtual Bits 48-55 and write Virtual Bits 56-63 to the outputs Using Kogna's RS485 Port. It is untested. Your example doesn't help much because the library functions weren't provided or documented.

This table defines the ModBus Commands

Code: Select all

ModbusMaster_Cmds ModbusMaster_MonitorList[] = {
	// string is "dev,cmd,adrhi,adrlo,lenhi,lenlo" bytes of modbus command. bytelen, data, and checksum are added as necessary.
	{"\x0A\x03\x9C\x61\x00\x08", 6, 0},	//ID=10, Read Holding Registers as inputs to MBRegisters[0-7] starting Modbus address 40033 decimal
	{"\x0A\x10\x9C\x51\x00\x08", 6, 8},	//ID=10, Write MBRegisters[8-15] to Output Holding Registers starting Modbus Address 40017 decimal
	{0, 0, 0}					// end flag
};

These functions move the ModBus Register data to/from Kogna Virtual Bits

Code: Select all

// marshal and move values read from PLC/Slave into MBRegisters to KFlop memory
void ModbusMaster_RegUnload()
{
	// Move 8 PLC inputs to virtual bits via MBRegisters[0]
	// Note use SetStateBit which is Atomic and Thread Safe

	int i;

	for (i = 0; i < 8; i++)
		SetStateBit(48 + i, MBRegisters[i] & 1);	// 8 input bits
}

// marshal and move values to be sent to PLC/Slave into MBRegisters
void ModbusMaster_RegLoad()
{
	// Move 8 virtual bits to PLC outputs via MBRegisters[1]
	int i;

	for (i = 0; i < 8; i++)
		MBRegisters[8+i] = ReadBit(48 + 8 + i);	// the 8 output bits after the 8 input bits
}
To aid in debugging you might connect the device directly to the PC and use this modpoll utility to verify the commands.

HTH