
adccommunitymod (AutomationDirect) asked a question.
RS-485 ASCII communication
Created Date: July 06,2009
Created By: scrawford
**** This post has been imported from our legacy forum. Information in this post may be outdated and links contained in the post may no longer work.****
I am attempting to communicate to a slave device using rs485. According to the manual, I am required to write an ascii command to it and it will send the information I require back. I am new to ascii and I would love some suggestions on how to make this work.
Created Date: July 06,2009
Created by: dacordrey
How you do it depends on the master device that you want to communicate to the slave device. Is the master a PC, PLC or something else?
Created Date: July 06,2009
Created by: scrawford
I am using the 205 base with a 260 CPU.
Created Date: July 06,2009
Created by: dacordrey
You can use the DL260 port 2 for RS-485. Set up port 2 for Non-sequence protocol, baud rate parity etc using Directsoft PLC/Setup menu. Use the PRINT or PRINTV instruction to send your command to the slave device. Use the AIN instruction to read the response. There are other ASCII instructions that allow you to parse the received string and convert from text to hex/bcd (See the AFIND, AEX, SWAPB, ATH instructions).
You could also get a Basic CoProcessor Module and write some Basic language code to handle all of the serial communications, parsing and conversion and then transfer the result to V memory. The F2-CP128 module has three serial ports, two of which can be set up to for RS-485. This may be a better choice if the commands and responses are complicated or need to include error checking check sums.
Good luck with your application.
Created Date: July 17,2009
Created by: scrawford
I am still having trouble getting this to work. I have the comm port set up correctly (38400, 8bit data, 1 stop bit, no parity, extended timeout and non-sequence only). I am printing the value i want (01c) out to the V memory location that i am sending out of the com port with the PRINTV command. i wait 1 sec and turn on my AIN. All i get is first char. timeout error. Any more suggestions or should i start looking into the slave device itself.
Thanks again for the help.
Scott
Created Date: July 23,2009
Created by: stimpsonjcat
The ADC literature is pretty clear that they do not intend the ASCII instructions (PRINT and AIN) to be used as bi-directional master-slave setups.
What I mean is that the instructions are listed as PRINT *OR* AIN, not both.
The problem you have is that there is no buffer for the return data, so even if it works for a very fast program, it will eventually fail as scan time increases and the first character(s) start getting lost in the response.
Get the coprocessor.
Created Date: July 23,2009
Created by: bcarlton
The key is to have the slave device, if possible , wait a certain amount of time after receiving the request before it starts transmitting the information. BETWEEN the time you send the request and the slave device starts transmitting the reply you must start the AIN.
For example - The slave has a 1 second wait time before responding.
Send request (PRINT)
Delay 1/2 second
Start AIN with a 1 second first character timeout setting
1/2 second later the AIN command begins receiving the data.
Created Date: July 06,2009
Created by: scrawford
I am attempting to communicate to a slave device using rs485. According to the manual, I am required to write an ascii command to it and it will send the information I require back. I am new to ascii and I would love some suggestions on how to make this work.