Crimson 3 "Filtering" with complex code

KNeland

Member
Join Date
May 2010
Location
Boise, Idaho
Posts
87
I am working with some jumpy integers(noisy RTD inputs) and would really like to filter the numbers for a smooth display. Has anybody used the complex code functionality to accomplish this kind of filtering?
I'm using a PLC with limited functionality(GE Versamax), and instead of doing the math the old fashioned way in the logic, I am looking to use the RedLion. I'm shady at C but have found great insights from the local guru's in using the complex code capability in Crimson.


Thanks in advance...
 
The only obstacle I foresee is communication delays. You will be getting your samples at the polling rate of the channel which may be a lot slower than what is required to adequately filter them, depending on the application. Then again, the comms drivers used by Crimson 3.0 tend to be pretty zippy...

You should be able to implement something like this in Crimson pretty easily:
http://www.plctalk.net/qanda/showpost.php?p=298656&postcount=4

If you get stuck, post your code and we can pitch in and help. (zip it first.)
Paul
 
You should be able to implement something like this in Crimson pretty easily:
http://www.plctalk.net/qanda/showpost.php?p=298656&postcount=4

I think the problem will be setting up the program in Crimson to repeat continuously, and fast enough. The G3 just doesn't have a fast, accurate timebase for these kinds of applications. You could trigger the program from a bit of the display count system variable (DispCount.0 would give the fastest rate) but I think that rate varies depending on the complexity of the current screen. Might not matter in this application. It might make more sense to use an "On Update" trigger that fires every time a new value is transferred from the connected device.
 
Below is code I wrote for the Crimson 3 that runs the equation that Paul was talking about. It is an adjustable filter. In my example I use it for weights.


/// This program uses an adjustable filter FV=FVp+C(NV-FVp)
/// for the weight value on Scale 1

/// FV= Filtered Value (value used in later functions)
/// FVp= Previous filtered value (filtered valve from the last time
/// the program was scaned)
/// C = Constant value ( this multiplier between 0 and 1 controls the strength of
/// the filter)
/// NOTE: THe smaller the C value the more damping the filter is
/// NV = Raw weight values from strain guage module as a float (value that is
/// being filtered)

/// program is triggered by a value change in Scale1.Net

/// The following lines convert the Interger value from the Strain Guage module
/// to a Float value

Scales_Fltr.Scale1_GrossNV := (Scale1.Gross * 1.0);
Scales_Fltr.Scale1_NetNV := (Scale1.Net * 1.0) ;


/// The following lines run the filter function for the Gross Weight


Scales_Fltr.Scale1_GrossFV :=

(Scales_Fltr.Scale1_GrossFVp + Scales_Fltr.Scale1_C *
(Scales_Fltr.Scale1_GrossNV - Scales_Fltr.Scale1_GrossFVp)) ;

Scales_Fltr.Scale1_GrossFVp := Scales_Fltr.Scale1_GrossFV ;

/// The following lines run the filter function for the Net Weight

Scales_Fltr.Scale1_NetFV :=

(Scales_Fltr.Scale1_NetFVp + Scales_Fltr.Scale1_C *
(Scales_Fltr.Scale1_NetNV - Scales_Fltr.Scale1_NetFVp)) ;

Scales_Fltr.Scale1_NetFVp := Scales_Fltr.Scale1_NetFV ;
 
I think the problem will be setting up the program in Crimson to repeat continuously, and fast enough. The G3 just doesn't have a fast, accurate timebase for these kinds of applications. You could trigger the program from a bit of the display count system variable (DispCount.0 would give the fastest rate) but I think that rate varies depending on the complexity of the current screen. Might not matter in this application. It might make more sense to use an "On Update" trigger that fires every time a new value is transferred from the connected device.

I believe the simplest way is to roll your own trigger.
You can use the RTC of your PLC as a trigger. Just take your RTC into the G3 as an integer then under the trigger tab set it to run your filter program each time the data changes. I have never tried this with a GE but it works like a charm on AB.
 
I was thinking of using the Global Action On Update field to call the code. In my experience, it would run about twice per second this way and also be fairly repeatable timing. If it needs to be faster, then we may have a problem.
 
No problem, one of the Red Lion tech guys shared that trick with me awhile back. Works great for making flashing messages and primitives, just change the bit number to adjust the flash rate.
 
No problem, one of the Red Lion tech guys shared that trick with me awhile back. Works great for making flashing messages and primitives, just change the bit number to adjust the flash rate.
VERY handy tip! Thanks for sharing!... (y)

🍻

-Eric
 
Boom!

I believe the simplest way is to roll your own trigger.
You can use the RTC of your PLC as a trigger. Just take your RTC into the G3 as an integer then under the trigger tab set it to run your filter program each time the data changes. I have never tried this with a GE but it works like a charm on AB.

Well I can now confirm that this method works wonderfully with a GE as well..


Thank you Clay B.
 
You could trigger the program from a bit of the display count system variable (DispCount.0 would give the fastest rate)

Ok how do you use the DispCount.0? Do you create a Tag that uses DispCount.0 as its source then trigger your program whenever the whenever the flag is active on?
 
Ok how do you use the DispCount.0? Do you create a Tag that uses DispCount.0 as its source then trigger your program whenever the whenever the flag is active on?

I created a tag using DispCount as the source and pasted it on a master slide and ran it in the emulator. It incremented about ten times per second and seemed to do so at the same rate on all the various screens of the app I emulated.

You may be able to use a trigger on a change of value to run the filter code and use the whole word instead of a bit. I did not try that.
 
Ok how do you use the DispCount.0? Do you create a Tag that uses DispCount.0 as its source then trigger your program whenever the whenever the flag is active on?


You can create a tag or you can just use it as is.

For example, put the two Cool Fan images (under Blowers Etc.) in an Animated Image and use DispCount.0 as the Image Select then watch the fan turn...

Copy and paste the Animated Images and then change the copies to DispCount.0, DispCount.1, DispCount.2, etc. to see how it affects the "Fan Speed".
 
You can create a tag or you can just use it as is.

For example, put the two Cool Fan images (under Blowers Etc.) in an Animated Image and use DispCount.0 as the Image Select then watch the fan turn...

Copy and paste the Animated Images and then change the copies to DispCount.0, DispCount.1, DispCount.2, etc. to see how it affects the "Fan Speed".

Gotcha. I have to program 3 HMI's this weekend I am going to give that a whirl.

Thanks for the info.
 

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
95
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
1
Views
81
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
103
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
88
Has anyone setup communications with Red Lion 3.0 MODBUS to Baker Hughes Centrilift GCS VFD? Thanks
Replies
0
Views
86
Back
Top Bottom