KOGNA RS485 SLAVE ID

Moderators: TomKerekes, dynomotion

Post Reply
kizilkaya
Posts: 7
Joined: Mon Sep 25, 2023 6:01 pm
Location: TURKIYE

KOGNA RS485 SLAVE ID

Post by kizilkaya » Thu Nov 28, 2024 11:22 am

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

kizilkaya
Posts: 7
Joined: Mon Sep 25, 2023 6:01 pm
Location: TURKIYE

Re: KOGNA RS485 SLAVE ID

Post by kizilkaya » Thu Nov 28, 2024 8:27 pm

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

User avatar
TomKerekes
Posts: 2676
Joined: Mon Dec 04, 2017 1:49 am

Re: KOGNA RS485 SLAVE ID

Post by TomKerekes » Sat Nov 30, 2024 5:39 pm

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
Attachments
ModbusMaster.h
(562 Bytes) Downloaded 2 times
ModbusMasterVer3 RM782MB.c
(17.46 KiB) Downloaded 2 times
Regards,

Tom Kerekes
Dynomotion, Inc.

Post Reply