Help - Search - Members - Calendar
Full Version: ML1500 needs to receive ASCII stream
Forums.MrPLC.com > PLCs and Supporting Devices > Allen Bradley
ECSI
I have a ML1500 LRP and I need to receive a continuous ASCII stream from an electronic scale. The scale sends out the gross weight and the units followed by a CR/LF. I have the channel 1 port set up as DF1 with CR/LF append characters (not sure if that matters). So, if I use the ARL - ASCII read Line instruction to read the buffer and store the string, what happens to the buffer? Do I need to clear it somehow or is it continually overwritten with the streaming data? I'm not sure how to go about this. Or can I just continuously enable the ARL instruction maybe once every second? The data stream from the scale is sent about every 0.5 seconds.

Any suggestions would be appreciated.

Thanks!
pcmccartney1
Here is an example of an ML1100 talking ASCII to a Mettler-Toledo IND560. In this case, the data is bidirectional. I need to get the weight into the ML1100 and send back a couple integers as ASCII strings.
I chose to fill the buffer and then test for the CR/LF and then parse out the weight data and convert to INT. Going in the other direction I formatted the data string using concatenation and included the CR before doing the write.
In the serial port setup, I used "/d" for the first AWA append character and "/a" for the second AWA append character.
Hope you find this helpful.
Doug-P
QUOTE (ECSI @ Oct 27 2009, 01:45 PM) *
I have the channel 1 port set up as DF1 with CR/LF append characters (not sure if that matters).
I'm pretty sure the port needs to set up as "USER ASCII". DF1 protocol is for RSLogix to communicate with the processor for programming, etc.
ECSI
QUOTE (pcmccartney1 @ Oct 27 2009, 05:30 PM) *
Here is an example of an ML1100 talking ASCII to a Mettler-Toledo IND560. In this case, the data is bidirectional. I need to get the weight into the ML1100 and send back a couple integers as ASCII strings.
I chose to fill the buffer and then test for the CR/LF and then parse out the weight data and convert to INT. Going in the other direction I formatted the data string using concatenation and included the CR before doing the write.
In the serial port setup, I used "/d" for the first AWA append character and "/a" for the second AWA append character.
Hope you find this helpful.

I couldn't open your file. I get a file corrupt message. Maybe my RSLogix500 v6.2 is older than what you are using. I could set the scale up for polling, but I thought the continuous stream would be easier since I only have to monitor gross weight.

Another side question, when I convert the string to ASCII will it pick up a decimal point in the string? For Example, if the scale sends out 02450.4KG and I use the ACI(String to Integer) instruction will it return 02450 only? I would like to have the 1 decimal point accuracy if possible.


QUOTE (Doug-P @ Oct 27 2009, 05:49 PM) *
QUOTE (ECSI @ Oct 27 2009, 01:45 PM) *
I have the channel 1 port set up as DF1 with CR/LF append characters (not sure if that matters).
I'm pretty sure the port needs to set up as "USER ASCII". DF1 protocol is for RSLogix to communicate with the processor for programming, etc.


You're probably right. I thought I read somewhere that I could leave the port on DF1 but now I'm not sure where I read it.

Thanks for the help! I'll get to try this stuff out online to the PLC tomorrow.
ECSI
Well I have it working. I set the port up for ASCII. Then I use the following steps:

- I use the ACL(ASCII Clear Buffers) instruction to clear the receive buffer
- I use the ARL(ASCII Read Line) instruction to read the next string in the receive buffer and store it in ST9:0.
- Now I use the ACI(String to Integer) instruction to pull the value to the left of the decimal from the string and store it in N7:0.
- Next is the AEX(String Extract) instruction to extract all of the string data to the right of the decimal and store it in a new string ST9:1
- Use the ACI(String to Integer) instruction to pull the decimal value out to N7:1
- Do the math ((N7:0*10)+N7:1))/10, store it in F8:0. F8:0 is the final destination of my gross weight from the scale.

Job complete. It all went pretty smooth. thumbsupsmileyanim.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.