Red Lion Strings from Integer Array

Old No. 7

Member
Join Date
Jun 2010
Location
Ohio
Posts
173
Anyone know if it is possible to read an integer array and display it as the ascii character string?

In other words, I want to copy a string (ST, length 10) into five integers in the ML1400 PLC, so each (N) integer has the integer value for two characters. I'd like to read the integer array in the G306, but display the characters.

Yes, I know its much easier to just read the string directly, but I'm saving space in the PLC due to memory limitations. :mad:
 
I have some experience with what you're trying to do (using scripting in Crimson... not sure if it can be done with data tags alone).

From the Crimson 2 manual:
You may also use the addition operator to add an integer to a string, in which case a single character equal to the ASCII code represented by the integer is appended to the data in the string.
This implies that if I had a string tag defined, I could write:
Code:
StrTag := "";
StrTag := StrTag + [PLC.N0007:0000];
StrTag := StrTag + [PLC.N0007:0001];
to combine the ASCII equivalents of the integers in N7:0 and N7:1 into a single string. However, this code will not compile. I discovered (with the help of tech support) that you have to write it this way:
Code:
StrTag := "";
StrTag += [PLC.N0007:0000];
StrTag += [PLC.N0007:0001];
Your situation is a little more complicated because you have two characters stored in a single integer register. I'm not sure if the "+=" operator would recognize that. A little extra code may be required to first unpack the bits.
 
Anyone know if it is possible to read an integer array and display it as the ascii character string?

In other words, I want to copy a string (ST, length 10) into five integers in the ML1400 PLC, so each (N) integer has the integer value for two characters. I'd like to read the integer array in the G306, but display the characters.

Yes, I know its much easier to just read the string directly, but I'm saving space in the PLC due to memory limitations. :mad:

Nor sure I understand how you're saving space. What you're doing requires 5 extra integers as opposed to reading the ST element directly with the G3.
 
Unless I'm mistaken, in the ML1400 each string takes up 82 words even if you only use 10 characters where the integers will only use 5 words. In my case the string gets passed around several places and is viewed but not modified. So I could end up saving 77 words per string, x 3 intermediate views per string, x 8 different strings = 1848 words saved.
 
Anyone know if it is possible to read an integer array and display it as the ascii character string?

In other words, I want to copy a string (ST, length 10) into five integers in the ML1400 PLC, so each (N) integer has the integer value for two characters. I'd like to read the integer array in the G306, but display the characters.

Yes, I know its much easier to just read the string directly, but I'm saving space in the PLC due to memory limitations. :mad:

I did this a while ago

you'll need to run it through a C2/C3 program ideally

Convert integer into string
Strip out the components of the string that you require
Convert new strings to integer

Haven't got crimson here, but there are string stripping commands left summin , mid summin, right summin ?? from memory :unsure:
 
See Function DataToText

This function might work, if by int and element they mean 8 bit integer. If they are using one 16 bit integer for each ascii character, then you would have to add manipulation at one end or the other (I would do it in Crimson 3.0).

It should be easy to test though, just make a numeric tag array of 5 with the source pointed at your first N register, then make a string tag with Complex code and the function:

return DataToText(Your_N_Tag[0],5);

I think, that since a cstring is 16 characters, that their example in the manual (with a length of 8 elements) will do it. I would emulate this, but this laptop is running Win7 64 bit, so no emulator.
 
Last edited:
This may help

Dan at Red Lion was nice enough to send this to me awhile back. Under programs you will see a folder named FuncLib. In this you will find a program called IntToChar. This is basically what you need to do. In Dan's example he declares the string locally in his program you can declare that string globally in your tags list and display it.

This program covers alot. One thing that has really helped me alot lately is "C++ for Dummies" 6 th edition.The programing you do on the G3 resembles this alot.
 
Dan at Red Lion was nice enough to send this to me awhile back. Under programs you will see a folder named FuncLib. In this you will find a program called IntToChar. This is basically what you need to do. In Dan's example he declares the string locally in his program you can declare that string globally in your tags list and display it.

This program covers alot. One thing that has really helped me alot lately is "C++ for Dummies" 6 th edition.The programing you do on the G3 resembles this alot.

Very nice. I haven't had the chance to dig around in all the examples, but this looks very valuable.
 
Very nice. I haven't had the chance to dig around in all the examples, but this looks very valuable.

I owe Dan serveral beers for that program. Ironic part is he sent it to me when I was asking how to extract time and date data for a project I was working on. The best thing for me has been looking at how he forms his code. I have more experience writing Ladder Code so this helps alot.
 
Thanks for the help guys. It turns out we were able to make a string tag (array) in the Red Lion and give it a N address and it will convert each two characters into a integer word. Unfortunately, the while the Micrologix 1400 allows Ascii (A) files you can't copy or move them into integers (or move integers into Ascii). I wasn't able to get rid of all of the strings, but I got rid of a few. Hopefully it will be enough to squeeze the program into the processor.
 

Similar Topics

Hey all, is there a way with Crimson where I can Concat 3 different string tags into a new tag. Something like: Filename = (partnumber +...
Replies
6
Views
3,433
I have been tasked with bringing in ascii string data from some scales in our plant, onto the RL for display as well as utilization. My code...
Replies
3
Views
2,896
From the Red Lion website, after some customer enquiries in the last week or so... Rev. March 25, 2024 [18:30] Just thought it might help a...
Replies
9
Views
247
How do you install update on Red Lion Crimson ver 3.1. Do I just need to run the exe file on the host server?
Replies
1
Views
94
Hello All, I need the ability to remotely reboot a Red Lion CR3000 HMI. Due to some graphics issues when the database is updated the HMI must be...
Replies
4
Views
198
Back
Top Bottom