![]() ![]() ModbusRTU master #include /* Usage of CONTROLLINO library allows you to use CONTROLLINO_xx aliases in your sketch. These pins are located at the PORTJ and on the pins PIN6(DE) and PIN5(RE). It was necessary to modify setting of the PORTJ for pins DE and RE control. Modbus Master-Slave library for Arduino (ModbusRtu.h) was taken from the website: ![]() To easily evaluate this example you need a second CONTROLLINO as Modbus slave running DemoModbusRTUSlave example sketch. Modbus master device periodically writes and toggles Modbus 16bit registers: Modbus master device periodically reads Modbus 16bit registers (provided by the slave) and prints the current state to the debug Serial:Ġ – analog CONTROLLINO_A0 value (0 – 1024) The sketch is relevant only for CONTROLLINO variants MAXI and MEGA (because of necessity of RS485 interface)! 2 seconds apart sending messages with 3 types of different settings.Ĭheck the function comment for more infromation */Īfter successful test of your CONTROLLINOs you can proceed with communication between devices via RS485 with utilization the ModbusRTU protocol. In this example the CONTROLLINOs are used as the Modbus master and slave!įor more information about the Modbus protocol visit the website: * Use only one of the two functions, either send or recieve */ * This will initialize Controllino RS485 pins */ * Here we initialize RS485 serial at 9600 baudrate for communication */ * Here we initialize USB serial at 9600 baudrate for reporting */ * This function enters loop and waits for any incoming data on serial 3.*/ Serial.println ("Sending test message, not expected to be sended ") * digitalWrite (CONTROLLINO_RS485_RE, HIGH) ĭigitalWrite (CONTROLLINO_RS485_DE, LOW) */ Serial.println ("Sending test message, not expected to return ") *digitalWrite (CONTROLLINO_RS485_RE, LOW) Serial3.print("UUUUU Controllino RS485 test Message.UUUUU") Serial.println ("Sending test message, expected to return ") *digitalWrite (CONTROLLINO_RS485_RE, HIGH) ĭigitalWrite (CONTROLLINO_RS485_DE, HIGH) */ #include /* Usage of CONTROLLINO library allows you to use CONTROLLINO_xx aliases in your sketch. After programming them, connect the Controllinos according to the previous picture and turn on Serial Monitor on receiving Controllino. ![]() Upload first code on CONTROLLINO sending device and the second code on CONTROLLINO receiving device. This example code is for testing your RS485 interface. Voltage levels over 5.5V can damage the Controllino permanently. (Please, refer to if you do not see the CONTROLLINOs in the Arduino IDE menu Tools->Board.) Hardware Required Please, select proper target board in Tools->Board->Controllino MINI/MAXI/MEGA before Upload to your CONTROLLINO. In these files, you can easily see all internal wiring indications between clamps and the microcontroller. You can download a “PINOUT-table” for MAXI here. The RS485 driver module is connected to the UART3 (TxD3 / RxD3) of the ATMEGA2560. There is a large number of different components on the market that have an RS485 interface – they can communicate with the CONTROLLINO PLCs. It can carry signals up to about 1.200 metres with 32 subscribers. Connection to the interface is possible via screw terminals. The RS485 is an interface-standard for digital, line-connected and differential serial data transmission. ![]() The CONTROLLINO PLCs MAXI and MEGA have an RS485 interface type SN65HVD08, which allows it to communicate with other RS485 devices. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |