Is this new to any one!

oldNovice

Member
Join Date
May 2005
Location
San Jose, California
Posts
13
I have, what I believe is, a unique application that I need to develop over the next few weeks.

I need to make an ASCII text interpreter! This involves parsing a text file of limited vocabulary and having the PLC turn on or off indicated outputs, load and wait for timers to expire, and wait for sensors to change state.

For example, the word “PROCESS” is followed by the word “TRIM” and the application does nothing more than move the word “TRIM” to a specific tag name location (so that it can be accessed by OPC). At another time, “PROCESS” may be followed by “LOADING PARTS.”

Other words, such as “WATER” can be followed by either “OPEN” or “CLOSE” which tell the PLC to open or close the water valve. While “WAIT” and “5000” tells the PLC to wait for 5 seconds.

I think that you can from these examples the task is fairly straight forward and, if carried out correctly, the PLC program will never come into question since it is just following the text instructions from the “programmer.”

My main concern is can this be done with ladder logic?
Please provide any comments as soon as possible!


Best Regards,
oldNovice


[font=&quot][/font]
 
Interesting idea... Although it sounds doable, it might be frustrating to attempt straight through the COM port in a PLC. Sounds more like an easy job for a BASIC coprocessor... :nodi:

🍻

-Eric
 
So as I see it you have to write a program in ladder with several actions which can be executed. In the ladder program there is also a communication part which receives commands from a host for example "WATER OPEN" after you received a command you have to interpret is and execute the action which you already have programmed. I am not so familiar with ladder programming but there are PLCs which can handle strings. Look for ‘vector’ functions.

Best regards,
Henry
 
What type of plc are you going to use. Some have a nice selection of "ascii" commands. You can extract data starting at a certain point in a string move it to another string file and just do a lookup table comparing the 2.

Some can convert strings to integers depending on how many variations of strings this may be the easiest , between that conversion and the original string length it shouldn't be to difficult.

If only a handfull of different strings the proc should handle it fine. But if there is alot (as already stated ) a basic processor to take care of the ascii to output conversion should probably be the way to go to keep that ladder required relativly small.

What are you using that gives commands like that?

Is there any feedback to what gives the commands to ensure data integrity? ( plc gets "valve ope" what will the plc do? If there is feedback the operator can see the command did not work and re-issue or can it be set to re-issue the command upon a feedback signalling bad data?)

If you will be doing a lot of messaging another thing to watch out for is most plc proc run comms servicing outside scanning the ladder so your scan times can be greatly affected.

Drewcrew6
 
oldNovice,

Certainly it can be done and done correctly with a PLC. It may only take a small low end job to do the processing that you decscribed. Without knowing HOW MANY ASCII commands you wish to process, I cannot give a specific answer.

About 3 years ago, I used a Direct Logic DL-06 (Automation Direct brand, about $400 US) to process a set of 15 different ASCII input commands. The strings were read directly into the PLC's commm port from the 9-pin serial port of a desktop computer. The strings were of varying length, but all contained specific data. The program was done strictly in ladder logic, using the ASCII commands built into the processor. Basically, I used a COMPARE function to compare each part of the string with a list of words. When a certain word match is found, then the program branches to a routine that carrys out the necessary action.

If you are interested, I can post a sample of this ladder logic.
 
I did something very similar a few years ago (probably about 10), except that it was on a VME system and I was programming in C.

However, I believe that it can be done adequately in Ladder. If your PLC supports ST type languages the implementation could be considerably easier.

Have you considered writing an editor using VB in your HMI, or even Word or Excel and have it generate a numeric OP code file, which would then be downloaded into the PLC? Then the PLC is only looking for mumeric OP codes and paramters for those codes. The text would be much simpler to parse in VB.

A couple of years ago I did a vacuum furnace app which needed to be configured from 1 to 30 steps, which could occur in various orders. I created a VB form in the HMI using 30 drop down combo boxes paired with 30 numeric entry boxes for which the opertor would select the function and then enter the paramter for the function (such as EVACUTE TO ?, or BACKFILL TO ?, or HEAT PROGRAM ?). If you have a limted set of functions that method would also have a more modern look and feel to it than parsing a text file. Its not too bad if you have a limted number of steps, but if you have 100 or more then that might get tedious.
 
Last edited:
It sounds *looks* like you are going to convert an Adatec or now GE Fanuc State Logic program to ladder... been there - done that.
You will be better off getting a good Sequence of Operations and starting from there, pretend that the State Logic program does not exsist. Unless of course it is so well written that it can be used as the SeOp. In that case why convert it to LD, just update to the latest GE Fanuc State Logic.
If I am wrong, please disregard this.
 
RussB,

Obviously you have had more experience in this area than I have since I don't know what Adatec/GE Fanuc State Logic programs are.

I am using AB SoftLogix and I do have a choice of four different languages. Structured Text was ruled out since it had no string compare functions, SFC's I am not that familiar with that as yet, Function Blocks need yet to be investigated, but I know that the LL can do string comparisions.

The last time I did this was on a WinPLC from AutomationDirect using flowcharts. I did the entire application in three hours! Even surprised me on how well that really worked.

If you have any suggestion for me, starting from scratch, I would surely appreciate it.

Thanks, for you input to date!
oldNovice
 
I agree with Alaric about using a program such as VB to do your parsing, all of the old text games where based on these type commands. "OPEN WINDOW", CLOSE DOOR, KISS GIRL". It's just a simple matter of parsing the expression and sending it to the PLC in the form of an integer data.

About 5 years back, I experimented with using voice commands and then parsing them as mentioned above and send them to a SLC504. I got outputs to turn on and off but that was as far as I ever took this project.

Instead of parsing your commands, could you put the commands in 2 different input boxes. This will eliminate the parsing and then it is only a matter of using EQUAL statments to figure out the command. As far as integer values "WAIT 5000", I might even put that one "5000" in its on input box. Use another button "SEND COMMAND" to trigger a bit in the processor to get things started. If the command is unreconized in the processor, trigger an error message.

Now, as far at this application being practical, I don't know. Will the operators soon grow tired of having to type commands instead of pressing a button(s). Another thought and this does happen, can your operators read and write?

Good luck on the project and let us know your progress.
 
oldNovice said:
I am using AB SoftLogix and I do have a choice of four different languages. Structured Text was ruled out since it had no string compare functions....

Actually, it does have string compare instructions. Please refer to the online documentation of RSLogix 5000 again. The CMP, NEQ, and EQU instruction will all work on strings in Logix 5000 and they are available is ST. If you need a compare that ignores case you can write a For-Next loop in ST that indexes down the string and compares character by character. That was the reason I suggested using ST.
 
Here are some suggestions for using ST in the Logix 5800 soft PLC


//Convert a string to uppercase
//Use the UPPER instruction, or you could do it with a For loop like this:
For I:= 0 to (CommandLine.Len-1) DO
If CommandLine.Data > 96 then
CommandLine.Data := CommandLine.Data - 32;
End_if;
End_For;

//Find the delimiter and then use MID to break the string into two parts.
//Find the location of a space delimiter in a string
Find(CommandLine,Delimiter,0,DelimiterPos)
//Or you could use a For loop to walk down the string looking for delimtiers as you would do in C.

//Then use MID to extract the two strings
Mid(CommandLine, 0, DelimiterPosition, CommandString);
MID(CommandLine, CommandLine.Len-Result,DelimiterPosition,CommandParamter);

//Use STOD to convert a string to an integer.
//You can compare strings directly using the following:
If String1 = String2 then

//put your code here, be sure to convert to uppercase
//first because "ABC" does not equal "abc"

End_if;

// Since the number of commands is limtied, you could use a case statement to
// speed up the comparrison by only checking the first character
Case CommandLine.Data[0] of
65, 97: //ascii value of A,a
//put needed code here

66, 98: //ascii value of B,b
//put needed code here
End_Case;



This should be fairly simple in ST for anyone with any Basic, VB, C, or other non-ladder programming experience.
 
Last edited:
I am curious.

Actually, it does have string compare instructions. Please refer to the online documentation of RSLogix 5000 again. The CMP, NEQ, and EQU instruction will all work on strings in Logix 5000 and they are available is ST.
According to the online help file there are no instructions available in ST for CMP, NEQ and EQU. There are instructions that allow you to extract from the strings then you could use any of the compare functions...I think.

I am curious though, why the need to use ASCII? The examples "imply" operator input, arent there more prudent methods available? Seems to me that using ASCII for an operator interface with RSL5K and Softlogix is a step backwards.

I am not debating the use of ladder or ST. I just think that there are more features and options available with the system that are not being considered.
 
Alaric said:
Have you considered writing an editor using VB in your HMI, or even Word or Excel and have it generate a numeric OP code file, which would then be downloaded into the PLC? Then the PLC is only looking for mumeric OP codes and paramters for those codes. The text would be much simpler to parse in VB.


That is the way that I would do it. Is there anything that prevents this approach?

Marc
 
rsdoran said:
According to the online help file there are no instructions available in ST for CMP, NEQ and EQU.....


According to the online help those insrtuctions in ST are written as:
= Equal
<> Not equal
> Greater than
< Less than
>= Greater than or equal
<= Less than or equal

You have to follow the online help liks and it expalins it all.

IF String1 <> String2 then...

or

If String1 = String2 then...
 
Why convert text? You could do this numerically.

You're going to build a table of text values anyway. You could assign decimal values to each acceptable string. Instead of having the PLC interpret the text, you select the text from your HMI. The table of text values would be hosted in the HMI, rather than the PLC.

Just a thought.

AK
 
Back
Top Bottom