Crimson 3.1

gimli

Member
Join Date
Nov 2014
Location
nowhere
Posts
34
Hi yas,


Pretty new at this...



Looking for some advice on how to get string data in Red Lion HMI via Modbus.


I am bringing ascii data into the redlion via modbus using an integer array.


On the red lion side there is a function called "datatotext" which says its supposed to covert an array to text.



So far im only able to get the first data point to convert...


from description:

data int The first element in an array.
limit int The number of characters to process



string = DataToText(Data[0], 8)


Based on their example shown above, the string should equal the first 8 elements in the data array.


when using this in a program im only getting the value of the first element (0).



Any help would be appreciated.



thanks much
 
What are the contents of the Data[0] through Data[7] elements in decimal format?

According the the Crimson 3.1 help topic, if the DataToText instructions encounter a null character, it will stop.

EDIT: I just ran a test and it appears that the help file is a little bit misleading. It appears that it will get two characters from a 16 bit integer and will get up to four characters from a 32 bit integer, but does not appear to move through more than one element of an integer array tag.

Here's a program that may do what you want:
Code:
Str :=
DataToText(Data[0],4) + 
DataToText(Data[1],4) +
DataToText(Data[2],4) +
DataToText(Data[3],4);

If you have more than 4 integers, you will need to extend that code to how ever many lines you need. Stick that code in a program and call it when your Modbus data changes. I just stuck a button on the emulator screen (using Crimson 3.0) to run that program for my test.

I assumed 32 bit integers for Data[n] and Str is my cstring tag. I plugged in the value 6,381,922 Which is: ((97 * 256 + 97) * 256) + 98) into the first two elements and that program returned "baabaa", which means that the order of the characters might be backwards too. So, you may have to insert some code to swap the characters around if that is not the correct order from your device.
 
Last edited:
Code worked perfect! Thanks so much! Basically Im breaking down the string on the transmitting side to one integer per ascii character. So on the red lion side your code worked great for me. :)
 
Hi [FONT=&quot]OkiePC,[/FONT]
[FONT=&quot]
[/FONT]
[FONT=&quot]Im back..wondering if you could help out with this..[/FONT]
[FONT=&quot]Trying to covert a string to and integer using the redlion[/FONT]
[FONT=&quot]function TexttoInt. Name being the string...[/FONT]
[FONT=&quot] if name has the first letter = A the integer value should be 65..im getting 0.[/FONT]
[FONT=&quot]If i use the base of 128 im getting 10...thinking base 10 should work?
[/FONT]
[FONT=&quot]any help would be great :)
[/FONT]
[FONT=&quot]
[/FONT]
[FONT=&quot]
[/FONT]
Code:
Name_Ascii[0]:=
TextToInt(Mid(Name,1,1),10);
 
It sounds like what you need to do is convert an alphabetic character to its ASCII numeric code. There is another related question fresh on the forum that has prompted me to look for the Red Lion sample code that has some ASCII functions in it, but so far I have not tracked down that sample database.
 
Any luck find the ASCII to int type methods

I was just handed this project, no one in the company knows anything about Crimson.
My string coming in has a <LF> and or a <CR> at the end. So I need to look for them as well as some "," & "T" characters.

I thought I could find some ASCII_to_int type functions. These are all single byte characters.

I was also hoping to see a "split" function that would break a "," delimited string into parts, but I do not see that either.

When I place the <LF> on the screen I see a "?".

Thanks for any suggestions.
 
In the attached that I have been given by RedLion or found on the web from RedLion:
Look in G308 Recipe Examples file, and look at the Read Recipes program, it shows you how to go through a 'comma delimited' file.
In the FuncLib and Widgets you will be able to see how to find a String in a String. You don't need to convert ASCII in to anything else for the searching and separating, once things are separated then you can convert values in to their final format.
 

Similar Topics

Hey guys, hoping someone here could give me a little advice. I'm working with a CR1000-04000 in Crimson 3.1 and I was interested in adding the...
Replies
4
Views
115
Hi, I'm having an issue in crimson 3.0 when I create a programme using a case statement referencing a fault word that each bit needs to change the...
Replies
4
Views
191
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
107
Has anyone found a way to convert/replace/update the firmware on old Parker TS80xx series HMIs (i.e. TS8010, TS8006, etc) to accept Crimson...
Replies
0
Views
91
Has anyone setup communications with Red Lion 3.0 MODBUS to Baker Hughes Centrilift GCS VFD? Thanks
Replies
0
Views
89
Back
Top Bottom