help on converting a string to a number in rslogix 5000

gkinslow

Member
Join Date
Jun 2006
Location
the heartland
Posts
26
Long story short, the operator inputs a code that is always two letters and a single number for a process. I need to take that in rslogix5000 and convert it to a number to use in the plc. I'm looking at the STOR instruction, but I have never converted a string in a plc program before. PLEASE help.
 
Well, it's part of the recipe table. I've used these before, but always sending numbers to tags, never a letter. Because of what I'm doing, the data type being sent to the tag is 2 letters and a number. For example, if the operator runs recipe1 then the data sent to associated tags is as follows, (pm1)for tag one, (pm3) for tag two, and (pm2) for tag three. This list is a little longer than that and the operator needs to have the ability to switch them around.
 
For example, out of your pm1 are you wishing to strip out the pm and only use the 1. If so you might get by using a MID function and then converting the result to an integer.
 
Why don't you create a string file in your rslogix 5000 call it "recipe" and add enough elements to handle all of your recipes plus extras for future recipes.

Have your PV+ send your desired recipe entered by the operator to recipe[0].
Then if you have all of your current recipe's in seperate strings as below all you should have to do is a string compare using the "ASR" instruction in your ladder.
If recipe[0] is equal to recipe[1] the move a "1" into a integer lets call it "mixture" as a tag name for example.
If recipe[0] is equal to recipe[2] the move a "2" into the integer "mixture" and so on.

Now you have a different number that can be used numerous ways in your ladder.

recipe[1] pm1
recipe[2] pm2
recipe[3] pm3
recipe[4] pm4
recipe[5] pm5
recipe[6] pm6
and so on...



Another option is if your number that is paired with the two letters is always different, then the PV+ can send the string to the Recipe[0] tag in the controller. All you have to do is use the "AEX" instruction to strip the number from the string and put into a unused string call recipe[50] or what ever one you wish to use as the destination.
The next rung will copy to the "ACI" instruction which which moves the source "recipe[50] to the destination integer of "mixture".
Now the number in mixture can be used however you want in the ladder.

Either way will get you to the same place.
 
I saw the STOR AND STOD instructions and was looking at using one of them, but I was unfamiliar. How did you convert this to a 1? I believe this is more what I'm looking for.
 
Source is your string, "Dest" will be where your number is stored.

stod.jpg
 
This is what I want, and I understand the source and destination. I guess what I'm asking is how do I know what number is going to be produced in the destination tag so that in my plc program development I can use the number without having to wait until I can load the program to the plc and run it? Also, two of the posible units in the recipe do not have a number such as (pm1) but they are only two or three letters such as (di) and (hot di).

Just so you all know, I REALLY! appreciate all the help.
 
The RSLogix5000 help file will answer your last question:

The STOD instruction converts the Source to an integer and places the result in the Destination.

§ The instruction converts positive and negative numbers.

§ If the Source string contains non-numeric characters, the STOD converts the first set of contiguous numbers:

The instruction skips any initial control or non-numeric characters (except the minus sign in front of a number).
If the string contains multiple groups of numbers that are separated by delimiters (e.g., /), the instruction converts only the first group of numbers.
 
You mention entering lettered values (di, hot di). Are any lettered entries possible or only certain ones? If there is a limited set of lettered entries then each of these can be an entry in a list type control. Each of these would be tied to a specific number (the control variable for the list.) it's hard to give advice without a lot more information concernig these entries.
 

Similar Topics

Hello nice to meet you, im new in here, I'm currently trying to convert code written in STL for a S7-400 to SCL for an S7-1500, because when i run...
Replies
5
Views
268
Hi! I am working on a project were we will be replacing an 300 CPU with a 1500 CPU and we are working on migrating / converting code. There is a...
Replies
9
Views
1,026
Hi! I need help converting an old MicroLogix 1100 project to Micro 820. Project Details I have an old MicroLogix 1100 program that has been in...
Replies
0
Views
454
Hope someone is really bored this late on Memorial day!!! I have spent the last 5 hours researching this and trying everything I could find on...
Replies
9
Views
3,244
I am needing to convert the low DWORD of a timestamp into a LREAL. The DWORD is a 32bit unsigned number. In TwinCat2, I keep getting a negative...
Replies
3
Views
1,648
Back
Top Bottom