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
KOGNA RS485 SLAVE ID
Moderators: TomKerekes, dynomotion
Re: KOGNA RS485 SLAVE ID
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 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.
JP12 PIN7 connected to RM782M RS485 A
JP12 PIN8 connected to RM782M RS485 B
JP12 PIN40 connected to RM782M RS485 GND 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.
- TomKerekes
- Posts: 2676
- Joined: Mon Dec 04, 2017 1:49 am
Re: KOGNA RS485 SLAVE ID
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
These functions move the ModBus Register data to/from Kogna Virtual Bits
To aid in debugging you might connect the device directly to the PC and use this modpoll utility to verify the commands.
HTH
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
};
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
}
HTH
- Attachments
-
- ModbusMaster.h
- (562 Bytes) Downloaded 2 times
-
- ModbusMasterVer3 RM782MB.c
- (17.46 KiB) Downloaded 2 times
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.