Crimson 2 C-Syntax help

erock21

Member
Join Date
May 2022
Location
florida
Posts
4
Hello all, first time poster here!

I have a toggle button "REVERSE_ENABLE_BUTTON" on our HMI's that disables our "bad product rejections" by simply preventing a conveyor from going in reverse.

I added my program Vision() to run OnTick to look for when the button is toggled off. When toggled off it looks for 3 lanes to have good product and adds +1 to a counter. when my counter hits 10 i want to toggle the button "REVERSE_ENABLE_BUTTON" to re-enable our "Rejection System" automatically.

MY program works properly except for 1 thing. The tags im using so see good product (LANE_A_PASSED...) are latched for a few seconds in the plc to display an image for a few seconds, and what im seeing is that when:
(LANE_A_PASSED) && (LANE_B_PASSED) && (LANE_C_PASSED) are all true,
ALLPASS continues to count while by tags are latched, but i only want ALLPASS to increse by 1 despite however long my tags are latched in.

Any help is greatly appreciated, here is my code:

if (REVERSE_ENABLE_BUTTON == 0)

{

if ( (LANE_A_PASSED) && (LANE_B_PASSED) && (LANE_C_PASSED) ) ALLPASS++ ;

if ( (LANE_A_FAILED) || (LANE_B_FAILED) || (LANE_C_FAILED) ) ALLPASS = 0;

if (ALLPASS >= 50)
{

REVERSE_ENABLE_BUTTON = 1;
ALLPASS = 0;
};


};
 
Welcome to the forum!

Maybe move the REVERSE_ENABLE_BUTTON = 1; statement to outside the if (ALLPASS >= 50) {... } clause?

That way, it will only count on falling edges of REVERSE_ENABLE_BUTTON, which falling edge will be caused by something external?

If
REVERSE_ENABLE_BUTTON is not controlled by something else, then you will need to do something else e.g. make a one-shot of the ((LANE_A_PASSED) && (LANE_B_PASSED) && (LANE_C_PASSED)) result.

e.g.

Code:
if    ((LANE_A_PASSED) && (LANE_B_PASSED) && (LANE_C_PASSED) )
{
    if (NOT_ALL_PASSED_LAST_TIME)
    {
        ALLPASS++ ;
    }
    NOT_ALL_PASSED_LAST_TIME := 0;
}
else
{
    NOT_ALL_PASSED_LAST_TIME := 1;
}
 
Thanks for the input. I’m afraid I’m still lost.
I believe since my program is running ‘OnTick’ under ‘pages’ and my ‘LANE_A_PASSED’ tags are latched in the plc for a few seconds, ALLPASS counts up each second that LANE_A_PASSED is latched in.

Even though LANE_A_PASSED & LANE_B_PASSED & LANE_C_PASSED are latched in for a few seconds, I want my ALLPASS variable to only increase by 1, not increase each second they are latched in.

Other than my counter issue, my script is working good.
And more ideas are greatly appreciated!!
 
so on each OnTick event, you want to increment ALLPASS if and only if

  • BOTH all of LANE_A_PASSED, LANE_B_PASSED, and LANE_C_PASSED are True,
  • AND none, some, but not all, of LANE_A_PASSED, LANE_B_PASSED, and LANE_C_PASSED were True on the previous OnTick event.
Is that correct?
 
I am hoping that Crimson 2 and 3 are similar enough so that what I do here in Crimson 3 still applies to Crimson 2. I am too lazy to download and install Crimson 2 :)

There is an alternative to using the 'On Tick' method, which instead uses a 'Trigger' value in an All On tag. In the attached I added an All On tag, look at its source on the Data tab, and also look at the Tiggers tab. You can run it in simulation and see that the counter only counts up by one, and only buy one, when all Lanes are ON and Reverse Enable is OFF. To invert the Reverse Enable tag I used a !. I haven't done the whole job for, you can't afford my rates :)
 

Similar Topics

Can anyone help me with proper code syntax for setting or stuffing the value of one tag into another (PLC = HMI tag). I have FactoryTalk SE...
Replies
7
Views
2,694
Hi, I have a Red Lion E3 io counting output from weld cells, connected to a PTV station for the visuals. Our number of weld cells is set to...
Replies
2
Views
1,563
OK, I am feeling a little stupid. I can't figure out the syntax for an (IF, OR) statement in Crimson 3. Maybe because It's Sunday and I am still...
Replies
2
Views
2,368
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
125
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
5
Views
261
Back
Top Bottom