Dear all,
I need Help in two thing Here.
1)My main project is i have 23 hallsensors with analog output. There are connected to arduino UNO analog pins using 16:1 Mux or 8:1 mux circuit. The currently i can receive data properly with proper switching. Which are floating point values.
Second stage: Now this has to communicate via MODbus protocol .(here only transmission is pending)
- Now I am in to transmission data. Here i am using basic library downloaded from
Modbus-Master-Slave-for-Arduino/examples/RS485_slave/RS485_slave.ino at master · smarmengol/Modbus-Master-Slave-for-Arduino · GitHub
Now my setup is like this
I have arduino Board. RS485 sheild and USB to RS485 converter. Qmodbus software to view data.
I have uploaded the below code.
#include <ModbusRtu.h>
// data array for modbus network sharing
uint16_t au16data[16] = {
3, 1415, 9265, 4, 2, 7182, 28182, 8, 0, 0, 0, 0, 0, 0, 1, -1 };
/**
* Modbus object declaration
* u8id : node id = 0 for master, = 1..247 for slave
* u8serno : serial port (use 0 for Serial)
* u8txenpin : 0 for RS-232 and USB-FTDI
* or any pin number > 1 for RS-485
*/
Modbus slave(1,0,0); // this is slave @1 and RS-232 or USB-FTDI
void setup() {
slave.begin( 9600 ); // baud-rate at 19200
}
void loop() {
slave.poll( au16data, 16 );
}
so i am expecting this answer if i am not wrong.
uint16_t au16data[16] = {
3, 1415, 9265, 4, 2, 7182, 28182, 8, 0, 0, 0, 0, 0, 0, 1, -1 };
But i am getting data as below.
questions:
- Whats making wrong to get below data??
2)If i want to store float values how can name uint16_t au16data[16] or changes to be made - Is there any working code ON modbus