I'm working on an Arduino project that requires a communication between Arduino and multiple pressure sensors.
The master is an Arduino UNO (or Mega 2560) that communicates to different slaves (the sensors) and sends data to a pc.
The communication will be via RS485 half duplex and the protocol will be Modbus RTU.
Could you please, indicate to me some link for the ModbusMaster library built for RS485 half duplex?
I use this library in my ModBus projects. I've chosen it mainly because it provides support for both master and slave modes and because it's quite slim.
Choose the Mega as the Arduino basis if you need the serial channel to the PC. A hardware serial interface is much more reliable than the software emulations (especially the SoftwareSerial library) in the first place but they also support parity bit setups as required by the ModBus specification (although some devices does not conform to the standard in this point).
I have written my program using SimpleModbusMasterV2rev2 library and I fixed the problem.
Now I can read the pressure value, but a question still remains.
Some garbage comes on the request message. There is a way to eliminate it and optimize the communication?
I attached the program, the hardware set-up, the serial monitor screen shoot and the pressure manual.
At present I only read the pressure value (0x0002), but in the future I would also like to read out the temperature value (0x0008)...in order to do this I have to use PACKET2, or it is enough to use PACKET1 changing the register index in the function modbus_construct ()?
Any suggestion or useful link will be really appreciated.
modbus_configure(&Serial, baud, SERIAL_8N1, timeout, polling, retry_count, TxEnablePin, packets, TOTAL_NO_OF_PACKETS,readRegsPress); // Initialize the Modbus Finite State Machine
You're using the same serial interface for the RS-485 (ModBus) as you use for the debugging information. So I'm not surprised that some information doesn't transmit as you expect it. Although the driver should be disabled during that the ModBus library expects to rule the serial interface without disturb.
My program is working now, but for my application I think it is better to keep the two communications separated (sensor-board and board-pc).So, I've decided to switch to Arduino Mega 2560, mainly to avoid collisions on data.
For the future evolution of my project , should I use the Arduino Mega to read out signals via an RS485 to 4-20mA converter?
TIA-485 is digital and 4-20mA is analogue, so you would need to specify the data protocol used on the TIA-485 side, and what are you driving the 4-20mA signal into ?
Or do you mean a 4-20mA to TIA-485 Modbus converter, where you connect a 4-20mA signal, such as sensor and then read the data using Modbus RTU from a controller or computer ?
If the above is correct, then what converter do have in mind to use and would it not be possible just to use the Arduino Mega to connect to the sensor directly ?
If your sensor is already 4-20mA, then it is not difficult at all to interface this into an analogue port of either the Arduino or better still a little ADC board, such as MCP3242 or ADS1115 type for better accuracy.
One problem I see which doesn't really effect your end goal, is that there is a lot of conversions between the analogue and digital realm, ADC and DAC.
As long as you know the details of each conversion process to know that you will have a faithful 4-20mA representation of final signal, which I guess will again go into another analogue to digital converter, such as PLC for further processing or to SCADA, correct ?
Would it not be possible to read the the sensor signal directly as analogue with as I mentioned using a quality ADC such as MCP3234 and then do all the processing you need using the Arduino board of choice or other micro-controller ?
If you are indeed sending to a device like a PLC, then why not send the processed data using digital, say, using Modbus, either Modbus TCP on Ethernet or Modbus RTU on TIA-485 or RS-232 ?
An Arduino Mega 2560 will be fine, but there is little cost difference between many of the boards.
You may be able to use a UNO style or go 1284 which is a sort of Goldilocks thing, or in fact a DUE, where you do have the on-board 12 bit ADC and DAC if you choose.
You mention multiple pressure sensors, what sort are they, do you have a part number ?
Just a few thoughts and methods I have used in the past.
In the final hardware configuration, I willMy idea is to add an RS485-to TTL module to Arduino an connect the converter.
In this case, I have to use the Arduino as a master and writing on the Modbus?
Any suggestions about the topic or link where I can collect more info, will be really appreciated.