Decoding ASCII input to a RedLion G303

averytc

Member
Join Date
Jul 2002
Posts
114
I have a RedLion G303 that I’m feeding ASCII string data from a weight scale.

String is: <STX><Signed DATA><sp><lb/kg><CR>

<STX> = Start of String, decimal valve of 2

<Signed DATA> = 8 characters right justified, space padded, including a decimal point and polarity sign. Polarity is a ‘+’ or ‘–‘ to the immediate left of the most significant digit.

<sp> = Space Decimal value 32.

<lb/kg> = Two characters indicating pounds or kilograms.

<CR> = Carriage Return, decimal value of 13.


I want to pass this data to a SLC 5/05 via Ethernet. I am able to communicate with the plc and read/write data in both directions. I can connect the Scale (GSE 350) to my computer and read the data feed there, but I have not been able to see it in the G303. I have some minimal experience in C, and have gone as far as I can. Has anyone done this before?

Thanks,
Charlie
 
Here is the text from a user program that you can use to parse the input string. This program should be called by the On Update property of the Raw Port which is connected to the weight scale. It will also require 2 tags, Weight, which is a real, and Lbs, which is a flag. These tags can both be mapped to where ever in the PLC that you please, or they can be left internal and Gateway blocks could be used to transfer the data to the PLC. The later method will not rely on the PLC connection for the serial data to work. If the Weight and LBs tags are mapped to the PLC, the PLC will need to be connected in order to view the values.
**********************************************************************

// Declare local variables in, amount, and type
// in is the string between the <STX> and CR from the serial buffer, this is set
// using the PortInput function
// amount is the first 8 characters of in
// type is the last 2 characters, IE lb or kg

cstring in = PortInput(2, 2, 13, 1000, 0), amount, type;

// If the PortInput function returns something other than nothing, it will be parsed
if(in != "")
{
// Grab the left most 8 characters
amount = Left(in, 8);
// Convert the string to a floating point number
Weight = TextToFloat(amount);

// Grab the right most 2 characters
type = Right(in, 2);
// Check if they are lb, if so set the lbs tag to 1
if(type == "lb")
Lbs = 1;
// If they are not lb, then assume that it is kg
else Lbs = 0;
}
**********************************************************************

Feel free to call with any questions, 1-800-677-7880.

Regards,

(Edit: the quick reply did not keep my formatting, and still does not allow the lines to be tabbed in)
 
Last edited:
ASCII data to SLC

Good morning! I have numerous customers who are doing the same that you have explained - bringing ASCII serial data into a SLC via Ethernet/IP using a product we manufacture called a DeviceMaster UP. Please contact me. I would be more than happy to extend to you an evaluation unit at no charge for testing.
 
Dan,

Thank you for the help. My code was similar, but I was looking at the wrong port. I counted over 3 from the first port (PRGM), and not down in the com editor... What can I say?

With such a good product, why would I want to look elsewhere?

Thanks again for your help!
Charlie
 
The port number also shows up in the status bar of the configuration software when you have the port selected. Glad you like the product! :)
 

Similar Topics

I have a Red Lion G315C That I am feeding Ascii String data from a Weight Scale. String is:<sp>G{GWT}<sp>{UN}<CR><LF>{EOS} <sp> = Space, decimal...
Replies
2
Views
4,396
Hello, I was wondering if anyone has a ControlLogix block or routine for encoding and decoding base64. I figured I would ask before diving into...
Replies
1
Views
261
Hello All, I hope we are all doing great and have a healthy and happy 2023!! I was wondering if anyone could help me decode this Motor Name...
Replies
15
Views
5,307
Hi, I'm using Studio 5000 PE V24. I would like to encode a Real Float so that it my be transmitted serially and stored to an RFID tag occupying...
Replies
2
Views
1,462
I've been helping out a contractor friend who has picked up several customers who use Direct Logic PLC's talking over spread spectrum radio via...
Replies
0
Views
2,046
Back
Top Bottom