counter reset on startup (1734-VHSC24)

einnh

Lifetime Supporting Member
Join Date
Mar 2014
Location
New England
Posts
275
I am trying to figure out a way to reset the count of this module on power-up back to what it was before the power cycle.

The module resets to zero every power cycle.

This obviously isn't working:

2015-06-11 15_21_28-Logix Designer - count_testing in count_testing_01.ACD [1769-L18ER-BB1B 26.1.jpg
 
These modules actually have to be inhibited and then un-inhibited before they will apply that C.Preset value based on your output O.CounterPreset bit command.

The reason is that the Configuration Assembly data is only sent to the module during the module setup process.

In addition, a one-shot probably won't allow the Output bit to be seen by the module; you need to hold that bit until you see that it's taken effect and the Present Value has changed from zero.


There's an example in the RA Knowledgebase:

https://rockwellautomation.custhelp.com/app/answers/detail/a_id/543243

Edit: An alternative to inhibiting and un-inhibiting the module is to send a Module Reconfigure message to the module using a MSG instruction. That has the same basic effect.
 
I'll try that.. I tried the same setup as I posted in ladder (I'm more familiar with ladder) and couldn't get it to work either.

2015-06-11 16_15_11-Logix Designer - count_testing in count_testing_01.ACD [1769-L18ER-BB1B 26.1.jpg
 
These modules actually have to be inhibited and then un-inhibited before they will apply that C.Preset value based on your output O.CounterPreset bit command.

The reason is that the Configuration Assembly data is only sent to the module during the module setup process.

In addition, a one-shot probably won't allow the Output bit to be seen by the module; you need to hold that bit until you see that it's taken effect and the Present Value has changed from zero.


There's an example in the RA Knowledgebase:

https://rockwellautomation.custhelp.com/app/answers/detail/a_id/543243

Edit: An alternative to inhibiting and un-inhibiting the module is to send a Module Reconfigure message to the module using a MSG instruction. That has the same basic effect.

Well that didn't work. I'm going to try the message route.

2015-06-11 16_54_06-Logix Designer - count_testing in count_testing_01.ACD [1769-L18ER-BB1B 26.1.jpg
 
Edit: An alternative to inhibiting and un-inhibiting the module is to send a Module Reconfigure message to the module using a MSG instruction. That has the same basic effect.

Any idea where in the sequence you would do this? I tried putting it before the toggling of the preset and after. Neither seemed to work.
 
Well re-reading the KB article there is a comment about putting in a delay, that seemed to work. This seems way over complicated, come on AB!

Code:
// setup
    Local:2:C.Preset := preset_value; // (DINT) the preset value.
    present_count := Local:2:I.PresentData; // (DINT) the preset count.
    Local:2:O.CounterPreset := preset_toggle; // (BOOL)toggle the preset value to set.
    inhibit_module := 4; // (INT) inhibit module.
    uninhibit_module := 0; // (INT) un-inhibit module.
    delay_timer1.PRE := 1000; // set the timer to 1000ms (1s).
    delay_timer2.PRE := 1000; // set the timer to 1000ms (1s).
    delay_timer3.PRE := 1000; // set the timer to 1000ms (1s).
    delay_timer4.PRE := 1000; // set the timer to 1000ms (1s).
    operator_preset_value := 1000; // operatore reset value.

    if s:fs then // reset sequence on first scan.
        sequence [:=] 0; // (DINT)
    end_if;

// begin program
    // begin startup routine.
    if present_count = 0 then
        if sequence = 0 then
            preset_value := stored_count; // set the preset to the stored value.
            if preset_value = stored_count then // if completed, move to next step.
                sequence [:=] 1;
            end_if;
        end_if;
        if sequence = 1 then
            ssv(module,counter,mode,inhibit_module); // inhibit the counter module.
            gsv(module,counter,mode,status_module); // (INT) check the status of the module.
            if status_module = 4 then // if completed, move to next step.
                sequence [:=] 2;
            end_if;
        end_if;
        if sequence = 2 then
            delay_timer1.TimerEnable [:=] 1; // start timer.
            tonr(delay_timer1); // call timing function.
            if delay_timer1.DN then // if completed, move to next step.
                sequence [:=] 3;
            end_if;
        end_if;
        if sequence = 3 then
            ssv(module,counter,mode,uninhibit_module); // un-inhibit the counter module.
            gsv(module,counter,mode,status_module); // check the status of the module.
            if status_module = 0 then // if completed, move to next step.
                sequence [:=] 4;
            end_if;
        end_if;
        if sequence = 4 then
            delay_timer2.TimerEnable [:=] 1; // start timer.
            tonr(delay_timer2); // call timing function.
            if delay_timer2.DN then // if completed, move to next step.
                sequence [:=] 5;
            end_if;
        end_if;
        if sequence = 5 then
            preset_toggle [:=] 1; // toggle preset to present data.
            if present_count = stored_count then
                sequence [:=] 6;
            end_if;
        end_if;
        if sequence = 6 then
            error [:=] 2; // error because it should have moved to next if then.
        end_if;
    // begin normal running routine.
    elsif present_count <> 0 then
        if ((sequence = 0) or (sequence = 5) or (sequence = 6) or (sequence = 56)) then
            preset_toggle [:=] 0;
            if not preset_toggle then // call main routine.
                sequence [:=] 100; 
            end_if;
        end_if;
        if sequence = 100 then
            stored_count := present_count; // (DINT) save the count.
            if operator_reset then
                sequence [:=] 50; // call reset routine.
            end_if;
        end_if;

        // begin operator reset
        if sequence = 50 then
            preset_value := operator_preset_value; // set the preset to the stored value.
            if preset_value = operator_preset_value then // if completed, move to next step.
                sequence [:=] 51;
            end_if;
        end_if;
        if sequence = 51 then
            ssv(module,counter,mode,inhibit_module); // inhibit the counter module.
            gsv(module,counter,mode,status_module); // (INT) check the status of the module.
            if status_module = 4 then // if completed, move to next step.
                sequence [:=] 52;
            end_if;
        end_if;
        if sequence = 52 then
            delay_timer3.TimerEnable [:=] 1; // start timer.
            tonr(delay_timer3); // call timing function.
            if delay_timer3.DN then // if completed, move to next step.
                sequence [:=] 53;
            end_if;
        end_if;
        if sequence = 53 then
            ssv(module,counter,mode,uninhibit_module); // un-inhibit the counter module.
            gsv(module,counter,mode,status_module); // check the status of the module.
            if status_module = 0 then // if completed, move to next step.
                sequence [:=] 54;
            end_if;
        end_if;
        if sequence = 54 then
            delay_timer4.TimerEnable [:=] 1; // start timer.
            tonr(delay_timer4); // call timing function.
            if delay_timer4.DN then // if completed, move to next step.
                sequence [:=] 55;
            end_if;
        end_if;
        if sequence = 55 then
            preset_toggle [:=] 1; // toggle preset to present data.
            if present_count = operator_preset_value then
                sequence [:=] 56;
            end_if;
        end_if;
    else
        error [:=] 1; // error

    end_if;
 
This is one of the reasons that I never use a counter module's count directly, unless there is absolutely no other choice.

Every program scan, just read the value of the counter, subtract the value from the last scan, and add the result into a memory register.

The AB Logix platform has an instruction that makes this easy, PMUL, which allows me to mask off say the lower 10 counter bits and just use that, completely ignoring rollover and such.
 

Similar Topics

Hi Guys, I have a 1769-L24-QBFCB1 that has the OK light flashing on the embedded counter module. The manual states it is a resettable fault, but...
Replies
0
Views
16
Hi y'all Just a quick question for using Rslogix 5000 I'm using a counter up bit with an analog signal (0-10V). When 10V is measured, counter...
Replies
5
Views
206
Hello guys, I have created a program where I count the high speed inputs of a flowmeter and create pulses per second to check the flowrate. Next I...
Replies
5
Views
1,746
Hello I have a AB Compact logic 1769-L32E controller. I'm wanting to reset a counter at the end of each month. Since the months have different...
Replies
34
Views
9,338
Working on delaying running a program in Fanuc robots by a distance (encoder counter). I can delay the program using the encoder counter but there...
Replies
3
Views
1,186
Back
Top Bottom