Communication with FTDI RS485
Hi all, I have purchased a FTDI usb to RS485 converter to talk to my industruino. However I fail to recieve and/or send data from/to the arduino. From what I understand the Serial1 should be connected to the RS485 port? And digital pin 9 should be set to high to enable the RS485 port on the industruino?
Per example from the modbus master and slave example I have removed the 560R jumpers from the industruino (slave) and have attached the 120R wires of the FTDI converter to the A and B channel.
Industruino FTDI
GND GND (RS485)
A Data+ (A) and 120R pin1
B Data- (B) and 120R pin2
Any ideas why I'm not receiving any data would be greatly apreciated!
Datasheet: http://www.ftdichip.com/Support/Documents/DataSheets/Cables/DS_USB_RS485_CABLES.pdf
Modbus master and slave example: https://industruino.com/blog/our-news-1/post/modbus-rtu-master-and-slave-14
Example:
#include <UC1701.h>
#include <Indio.h>
#include <Wire.h>
#define RS485_ENABLE_PIN 9
void setup()
{
Indio.digitalWrite(RS485_ENABLE_PIN, HIGH);
Serial1.begin(9600); //open the TX/RX port
}
void loop()
{
Serial1.write("Hello world");
if (Serial1.available())
{
int inByte = Serial1.read();
Serial1.print(inByte);
Serial.print(inByte);
}
delay(1000);
}
- Arnoud
Hi Arnoud, the pin 9 on the IND.I/O is the TxEnablePin, which means it has to be HIGH during transmission. In your above sketch, this pin stays HIGH from Setup, so in theory you won't be able to receive anything, which is the opposite of what you are reporting. Can you please double check? This reference may be useful: https://arduino-info.wikispaces.com/SoftwareSerialRS485Example (it uses software serial but the Industruino can use hardware serial1)
I have managed to receive data from the USB FTDI device, however I fail to send data from the Arduino. I have checked with my logic analyzer and there is no change on the A or B pin of the RS485 port on the industruino.
How do I enable the send mode on the MAX485?
As far as I know about RS485 chips, D9 should be high when sending and low when receiving, or viceversa. It is not a chip select pin but a direction pin. Check on a RS485 chip datasheet.
Hello,
looking at the example and at the datasheet, RS485 pin 9 is not an Indio pin, but a MCU pin.
So it should be addressed as a normal Arduino pin, I think.
Stefano is correct, the RS485 direction pin is a GPIO pin, not a field side IND.I/O pin. So it should be address in the standard Arduino way, digitalWrite NOT indio.digitalWrite.
Your answer
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
Keep Informed
About This Forum
This community is for professionals and enthusiasts of our products and services.
Read GuidelinesQuestion tools
Stats
Asked: 4/22/16, 12:32 PM |
Seen: 5383 times |
Last updated: 7/8/17, 7:19 PM |
Hi Arnoud, actually i just saw a mistake in the above code, the TxEnablePin is not an Indio pin, but a pin connected directly to the mcu, so you should use it with the standard digitalWrite (not Indio library): digitalWrite(9, HIGH); Hope this helps- Tom