Red Lion CSMSTR

Ramric

Member
Join Date
Jan 2012
Location
Australia
Posts
5
Hi all! Thank you for the opportunity to be in this forum. I’m hoping for some feedback on programming a Red Lion CSMSTR that’s connected to a sensing device. The output of the sensing device is largely unformatted string of parameters and their values and requires an input txt (i.e. GO followed by a carriage return) from the CSMSTR to trigger the sensing device output.
The sensing device output is as follows
output voltage 11.56 V
output current 4.74 A
operation time 112 h
output energy 12657.2 Wh
sensor level above or below
If there is a simple method (using Crimson 3 software) of reading the unformatted string of data and truncating or removing the unwanted strings of data, leaving only values (i.e. 4.74, 112, above) then writing these values to the remote CSMSTR would be helpful. Grateful for any constructive feedback.
 
Yes is the short answer but you are really loking for a how.

You will need to create 2 programs and in that program you will need to read the string. Below is an example of how I do it on a weight controller to a G3 HMI. First I transmit using a PortPrint function. THis tells the WC what I want to do. In the Receive program I use a PortInput function. This puts the entire string from my weight controller into my G3. I then use Mid function to extract parts of the string I want to use. You can find more details about these functions in the Reference manual. The other part you are going to need to figure out is how you will trigger your programs to run. In my case I use the tick functions so I update my weight values once a second.

Transmit from G3 Program:

// clear out input buffer

while(PortRead(2, 0) != -1) {}

// send out poll


if ((Auto_Bits.Tare_Req_to_HMI == true)&& ( Progrm_Data.TX.HMI_TareCmd ==false))
{PortPrint(2,"T");
Progrm_Data.TX.HMI_TareCmd := true ;
}







if ( (Auto_Bits.Tare_Req_to_HMI == false)||( Progrm_Data.TX.HMI_TareCmd == true))
{ PortPrint(2,"P");
Progrm_Data.TX.HMI_TareCmd := false ;
}


Receive from Weight controller Program:
cstring P2data;

// increase counter
Progrm_Data.TX.Reads ++;

if (Progrm_Data.TX.Reads ==10000) {Progrm_Data.TX.Reads := 0 ;
}

P2data := PortInput(2,0x20,0x4E,1500,0);

Progrm_Data.TX.WC_Raw_Data := P2data;

if (P2data==""){P2data=" -9999LB -9999LB T -9999LB";
Progrm_Data.TX.NoResponse++;}

if (Progrm_Data.TX.NoResponse== 10000) { Progrm_Data.TX.NoResponse := 0 ;
}

// increase var2 if there is no data
//else

Progrm_Data.TX.ST_GTN_WT:= P2data; // Get String From WC to HMI


Progrm_Data.TX.ST_Gross := Mid(Progrm_Data.TX.ST_GTN_WT,3,5); // Extract Gross Weight as a String

Progrm_Data.TX.ST_Tare := Mid (Progrm_Data.TX.ST_GTN_WT,17,5); // Extract Tare Weight as a String

Progrm_Data.TX.ST_Net := Mid (Progrm_Data.TX.ST_GTN_WT,34,5); // Extract Net Weight as a String

Progrm_Data.TX.R_Gross := TextToFloat(Progrm_Data.TX.ST_Gross); // Convert Gross Weight String to Float

Progrm_Data.TX.R_Tare := TextToFloat(Progrm_Data.TX.ST_Tare); // Convert Tare Weight String to Float

Progrm_Data.TX.R_Net := TextToFloat(Progrm_Data.TX.ST_Net); // Convert Net Weight String to Float
 
Thanks Clay B. for the info.

I've written my program with some variation including using the Find to calculate the position of the values. But I'm not getting any data using the PortInput. I've set up the RS232 comms port as raw serial, mode master, update Program1(), baud rate 9600, data bits 8, stop bits one, parity none. Tips anyone?
 
First thing is to make sure the Sensor is responding to the input.

I would do this by setting up hyper terminal on a computer and send your comand string and make sure you get a response.

Pay attention how you need to wire the serail comms between the computer and the device. Remember RS232 has transmit and receive. The transmit on one side has to be connected to the receive on the other. When I do my setup I know I have a 50/50 shot getting it right the first time, if it does not work I switch the Tx and RX and off it goes.

Once you know exactly how to make it work with Hyper terminal I would check my Red Lion program. Make sure your program is being triggered. This is as simple as putting the following line in your program:

programruntest++ ;

Then throw this tag up on a screen and see if it counts up. If it does then you know you are running your program.

Now once that is done you need to check your code.

I use PrintInput because I want the string to be a certain way:

Lets look at how I used it so you understand why mine is the way it is.


P2data := PortInput(2,0x20,0x4E,1500,0);


P2data: is where I want my string to go once I have it
2: is the port I am using (go to your Comms page and highlight the port you configured for Raw and in the lower left hand corner of your screen you will see the port number
0x20: is the character I am looking for 0x mean 20 is a hex number and 20 stands for ASCII sp (space). In my case I get a sp symbol first so I know that is where I want to start reading my string
0x4E: is the last character I am looking for in my string because my strings always end with the capital N character.
1500: is the timeout. I set this so that I can close the port and try again if I do not get anything back.
0: this number can be used if you know the specific length in characters you expect your string to be. I do not need this so I do not use it.

Hope this helps.
Clay
 
Clay I did a Count++ last night my program wasn't running. I forgot to call it.

Nice breakdown of sending and receiving.
 
Clay I did a Count++ last night my program wasn't running. I forgot to call it.

Nice breakdown of sending and receiving.

This is where I screw up the most. I try to get "creative" with my triggers and hose things.

If you noticed in the program I posted I have 2 counters. One is showing the program reading and the other is when the program gets nothing back.

It is a great tool for trouble shooting over the phone because I can look at each counter and tell what kind of problem I have.

In our machines we use NTEP certified weight controllers that error out if Gross goes below zero. This is usually caused by a forklift running over the machine so we get this one alot. So the response counter is a really good troubleshooting tool.
 
Nice I like the counter idea. I looked at it but thought you just stuck it in for design time troubleshooting and left it in.
Where do I send the royalties check to when I use that bit of code?

Next time your around my way let me know.
 
All I know is of sell enough machines to Mom&Pop companies you really learn the importance of fault handling and how to troubleshoot over the phone.

As far as the counter trick feel free to use it. I do take it a step further.

In your PLC you can monitor the counter (NonResponse in my case) for change and when the change reaches a certain value trigger an alarm to shut down the process.

I use the Read counter to let my PLC know when I have completed the start up routine and it can do its first system check after a power up.

A lot of our machines are mobile so they get moved around our customers plant so we like to check everything before we go into a run mode.
 
Thanks Clay B.
I’ve setup a hyperterminal and sent the command string and I get back the required response from the device. i.e. expected strings of data.
I’ve checked my Red Lion program and I have added a counter Reading_Data. I can see the counter counting in the watch window but not the Display Pages that I’ve added as a Tag.
I still cannot get the output I desire. My understanding is PortInput returns the string specified excluding the start and end bytes or characters. I have used 0x62 to represent char “b” as start char, and 0x3E to represent char “> “ of the string. Like
Device_Data:=PortInput(2,0x62,0x3E,1500,0);
I have tried setting the properties of the program to various combinations of same as caller, background when referenced, read always, read when executed and also tried the Read Anway.
I have also tried 2 separate programs under the navigation pane as one for the write program (that requests for data from device) and another for the read program (gets the data from the port and processes it) rather than the 1 combined program of read and write but I’m still not getting any success. Am I missing something?
 
I would make use of the hyper terminal.

This time connect it to the G3 in place of the sensor. Then I would just run my transmit program to make sure it is sending out. Once this is confirmed try writing some data on the hyper terminal and see if it comes back.

One thing to note: make the tag that displays your string is formatted as a string and has a max length larger than what you are wanting to send. Also it needs to be a global tag not just one created in the program. If you notice in my program I place the string in the instant tag I create with my program and then move it to a global tag.

FYI...Stuff like this is always a PITA... Thats why only crazy people do this for a living.
 
so what are you calling me and you?

Mentally disturbed... bit off center... unhinged... unbalanced... pick your adjective

Will say that for me Comms is generally the most annoying part of the project and you have to be a bit bent to have the patients to work it out.

Working on one now where my data turns to garbage whenever a couple of VFD's are fired up. Panel worked fine in the shop but is not doing so well on site.

Best part, customer is in Texas and I am in North Carolina so no laying eyes on it other than thru the local guys.
 
Thanks Clay B.
I don’t have a G3 to use in place of the sensor.
I suspect the command for the device to send data is not being received. So probably the device cannot respond to output the data. I have used both PortPrint(2, “Go”) and PortWrite (2,0x0D) for the carriage return as the output command consecutively.
I’m looking at getting a patch panel (an extra accessory for the sensor device) so I can send the command with a pc via hyper-terminal and receive in the same port (port 2 – RS232) that the red lion is connected to. But this is another cost in time and $.
I have made a global tag that displays the whole string of data as string format and at twice the length. This i've assigned this to the PortInput instruction. I still have no desired output.
I've also checked and tested the cable terminations between the sensor device and efoy as per manuals and they're all correct.
What else it there???
Thanks for the stating the obvious! :)
 
Have you tried going in both directions with Hyperterminal? I mean, you know you can send strings with it, but can you read the output of the Red Lion with Hyperterminal? And does it exactly match the syntax you are sending that is successful?
 

Similar Topics

Hi, I am trying to write a program to read Tank Inventory from an Incon TS-750 fuel system that has an RS-232 output with Veeder Root. I have...
Replies
1
Views
1,947
While they came up quickly with a fix for the alarm date issue quickly I will have to drive around for a week or so, burning up a lot of fuel...
Replies
4
Views
265
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
279
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
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
219
Back
Top Bottom