Dear all,
I'm a beginner of Arduino, so my question could be stupid. and Thanks every reply in advance.
I'm trying to use Arduino Uno board to control and read the Mass Flow Controller (MFC) which only has the RS485 interface. So I brought a RS485 shield (DFROBOT RS485 shield V1.0) for the Uno and plan to send the command and read the return value through the Uno's USB on my PC monitor.
As shown on the pin definition of the shield, I connected my MFC to the standard RS485 interface on the shield, mounted the shield on the Uno board, and connected the Uno to my PC by USB. However, the problem is that I could not find any sample code to support me. Some of them sending command through the digital pins connected to another RS485 module (https://arduino-info.wikispaces.com/RS485-Modules) which is different from mine. Some are like the sample code of DFROBOT RS485 shield V1.0 (Arduino_RS485_Shield_SKU__DFR0259-DFRobot), it still need a RS485-USB converter to communicate with PC. All these make me confusing a lot!
There must be something wrong with my thinking. Did I buy a wrong board, or my connection is wrong? Please guide me.
Hi,
it still need a RS485-USB converter to communicate with PC.
No you don't that is in a list of similar products.
You can use the USB programming connection you have to the UNO to communicate with your PC.
Can you tell us your electronics, programming, Arduino, hardware experience?
Can you post link to specs/info on your MFC?
Tom... ![]()
You can use the USB programming connection you have to the UNO to communicate with your PC.
No, he can't because the RS-485 shield connects to the hardware serial interface and the same pins are used for the communication to the PC by USB.
The best option for the OP is to get a Leonardo to be used with that shield. This has an USB interface built into the microcontroller so the hardware serial interface is free to be used for the RS-485 communication. Just take care to use the Serial object for the communication to the PC but the Serial1 object for the communication with the RS-485 bus.
pylon:
No, he can't because the RS-485 shield connects to the hardware serial interface and the same pins are used for the communication to the PC by USB.The best option for the OP is to get a Leonardo to be used with that shield. This has an USB interface built into the microcontroller so the hardware serial interface is free to be used for the RS-485 communication. Just take care to use the Serial object for the communication to the PC but the Serial1 object for the communication with the RS-485 bus.
Or just use softwareserial.h with a UART to USB converter. Much easier than converting to a different board.
Or just use softwareserial.h with a UART to USB converter. Much easier than converting to a different board.
That's OK for debugging but you would not want to have SoftwareSerial in any productive installation.
pylon:
That's OK for debugging but you would not want to have SoftwareSerial in any productive installation.
What do you mean by that? Why not?
What do you mean by that? Why not?
SoftwareSerial is blocking (including all interrupts) the complete processor during the sending or reception of a complete byte. So there are many chances for race conditions that you barely detect without a lot of time for investigations. Just one example in this context: if the OP uses the Arduino just as simple forwarder device and use SoftwareSerial for the PC side chances are high to loose some bytes of the RS-485 stream if the RS-485 device is sending almost continously. The first byte is received from the RS-485 line and sent out the SoftwareSerial. Now the processor is just doing that transfer and will miss the interrupt for the next byte on the RS-485 stream. After sending is finished the interrupt gets handled but half of the next byte is read already. The code will send that byte too and for another byte length the complete system is blocked for that task. After a few bytes the two serials will be out of sync and a complete byte is received while the system still waits for a moment where it can fire the interrupt to read the last byte from the UART register. This is even worse if the PC starts transmitting while the Arduino is still sending some data. In this case you loose data for sure.
Hi,
I also have a similar problem getting this shield working.
My project is making an arduino uno (actually using a sparkfun red board which should be the same) into a MODBUS RTU slave.
I have the uno talking fine to a PC running some MODBUS master software via the uno USB port.
Now the next part of my project is to add the RS485 shield (also using the DFrobot DFR0259) and communicate via RS485.
My problem is that I cant get the RS485 shield communicating at all.
I am using the sample code and following the instructions exactly per the link:
The only difference with my arrangement is my USB to RS485 converter (digitech) only has the four RS485 connectors for R-,R+,T-,T+. My converter has no GND connection so am leaving this unconnected.
Per the DFrobot example I am connecting A,B on the shield to T-, T+ on the converter.
Can anyone advise if the GND connection here is necessary, as with my previous RS485 experience I have only ever used the two wires? I have also tried adding terminating resistors (100ohm) to each end as this is normal with RS485 even though none are shown in the dfrobot example.
If I can get the the sample project per the dfrobot link working then I know I can get my project running.
Any ideas would be appreciated. In the meantime I have ordered another USB to RS485 converter the same as shown in the dfrobot example just in case.
Thanks in advance
The only difference with my arrangement is my USB to RS485 converter (digitech) only has the four RS485 connectors for R-,R+,T-,T+. My converter has no GND connection so am leaving this unconnected.
Per the DFrobot example I am connecting A,B on the shield to T-, T+ on the converter.
It seems that your USB2RS485 converter is for full-duplex RS-485 while the shield is for half-duplex. You cannot mix the two.
Can anyone advise if the GND connection here is necessary, as with my previous RS485 experience I have only ever used the two wires? I have also tried adding terminating resistors (100ohm) to each end as this is normal with RS485 even though none are shown in the dfrobot example.
The GND connection is not necessary as the signal transmission is differential. You only need the A and B signals.
Terminating resistors are strongly recommended as you might get reflections on the bus otherwise.
Pylon,
Thanks for the response. I received my DTECH RS485 converter, the exact one used in the dfrobot tutorial and tried again. Still can not get correct communication.
I modified the sketch to just print OK every second and I receive this on the serial monitor ok.
But with the original sketch, when i enter "V", nothing. All the Tx and Rx leds seem to flicker correctly.
Any other suggestions or recommendation for another RS485 shield would be appreciated.
take a step back.
you want to connect a device, something we know nothing about, no data sheet, no notes of the data stream.
you connect the MFS to the RS-485
you connect the RS-458 to your UNO,
you should be able to have the UNO output values to the serial monitor .
what are you getting ?
read the sticky on the top of every forum about how to use this forum and read about code tags. then post your code.
my guess is that you are not talking to the MFS, yet.
if that is the case, you will need to post a link to the data sheet and your device, and maybe a link to where you got it if there is not enough information.
as a side note, anytime you want to connect a thing, google the thing name and arduino. see if anyone has written something on how to use it.
I modified the sketch to just print OK every second and I receive this on the serial monitor ok.
That doesn't sound like no correct communication to me.
But with the original sketch, when i enter "V", nothing. All the Tx and Rx leds seem to flicker correctly.
Which of the two sketches did you use and what position was that switch on the shield?
You should definitely start to post the code you use so we know what exactly you are using.