Sending data from Mango to Arduino board (Modbus)
-
So far I have created a datasource, modbus serial which runs over COM4. I have 2 points (slave 1 and 2), both holding registers with 2 byte unsigned integers, one of which is settable.
On my watch list I can see the values coming in from the Adruino which are point 1. Point 2 says "Point value may not be reliable", possibly because no values are coming in under that channel.
In my Arduino program, the input data that I make is transmitted under regs[MB_REG0], and I assume regs[MB_REG1] should contain the data that comes from mango to the Arduino.
Does this sound right? I still haven't been able to recieve data on the Arduino.
-
This might be a slightly simpler way to ask my question:
How can I transmit 2 data streams on a single channel from Modbus to Mango? I can do one at a time, (after first calling init_mb_slave() and start_mb_slave() ) by writing to regs[MB_REG0]=value, but it doesn't seem to work for another if I use regs[MB_REG1]=value2.
I havent been able to use both these values in Mango, I am under the impression that they are under the same data source, same slave ID, so I do not know what differentiates between the two.
-
I'll try to help you.
So far I have created a datasource, modbus serial which runs over COM4. I have 2 points (slave 1 and 2), both holding registers with 2 byte unsigned integers, one of which is settable.
If you have 2 slaves then you have 2 arduinos. Is that true? Have you got one arduino with two registers?
If you have one arduino with two register you must add two data points. First with offset 0, second with offset 1. But the two data points must belong to one slave (usually slave 1).
On my watch list I can see the values coming in from the Adruino which are point 1. Point 2 says "Point value may not be reliable", possibly because no values are coming in under that channel.
Here you have the clue. Point 2 is not working because you don't have a slave 2. Try to change slave to 1 and offset to 1.
The structure is:
Modbus data source-COMX
-slave id 1
--offset 0
--offset 1...
-slave id m
--offset 0
--offset 1...To send data to arduino:
make data point 2 settable
write a condition in arduino like: if regs[MB_REG1]<5 digitalWrite(13,1)What library are you using for modbus?
-
Thanks, I just figured it out. I was confusing slave/offset terminology, now I have 1 slave, 1 data point with offset 0 and 1 data point with offset 1 (settable) and it seems to work fine.
FYI I am using ModbusSlave.h which is included with the Arduino program files.
Thanks again for the help. My company is starting a new project using Arduino boards and Mango, I can tell this forum will be very useful.
-
have tried to send float values?
-
@jose francisco said:
have tried to send float values?
Yes, I can send values from Mango > Arduino and Arduino > Mango, haven't tested it thoroughly but I believe it works fine.
-
I'm using jpmzometa's library and it works very well but only with integers.
Are you sure that floats works right? -
@jose francisco said:
I'm using jpmzometa's library and it works very well but only with integers.
Are you sure that floats works right?Yes I believe you are right, values are always converted to integers which is fine for me right now. Have you tried changing the point details (under Mango) from 2 byte unsigned integer to a float?
-
the problem is not mango. the library can't handle 4 byte types.