how to declare 1 second pulse in rslogix 5000?

and then used a counter to calculate the running hours...

If you are wanting to totalize running hours then take consider using the TOT instruction.

To configure TOT to totalize hours, fix the TOT tagname.In value at 1.0. Fix the gain at 1.0 and set tagname.timebase to 2. This configures the TOT to totalize time in units of hours. Use the tagname.EN bit to start/stop time totalizing. Now you have a run hour meter.

The TOT tag contains some other useful elements named .Target and .TargetDev1 and .TargetDev2. Set Target to the time where you want to signal needed maintenance on the motor. .TargetDev1 and TargetDev2 can be set to give you advance warning that the maintenace time is approaching. .TargetFlag, .TargetDev1Flag, and .TargetDev2Flag are booleans that turn on when the TOT reaches the specified value. Once maintenance has been performed add the required time interval until the next maintenance is required to the .Target.
 
[ZOMBIE THREAD #2 - can't kill 'em!]

I'm doing some runtime montoring. The guy who started it used a timer and boy was it off. I am using a second based off the Controllogix clock now. My concern is that we're still losing time. Basically the runtime is checked, then a subroutine is entered. On the one-second tick, the time is incremented. Program scan is around 160ms; I'm afraid we're missing the tick every now and then.

Is there a good way to do this? I'm thinking of abandoning the subroutine. A scheduled task may work, but I still think we might lose a little on that.

Runtime solutions? Alaric, the TOT looks nice but I'm using discrete inputs.

EDIT TO ADD:

My one second pulse solution (no pix!):

BST GRT PLC.Clock_Read.Second Prev_Clock_Second MOV PLC.Clock_Read.Second Prev_Clock_Second NXB EQU PLC.Clock_Read.Second 0 MOV 0 Prev_Clock_Second BND ONS New_Clock_Second_ONS OTE New_Clock_Second
 
Last edited:
To simplify change to:

NEQ PLC.CLOCK_READ.SECOND PREV_CLOCK_SECOND BST MOV PLC.CLOCK_READ.SECOND PREV_CLOCK_SECOND NXB OTE NEW_CLOCK_SECOND BND

[Edit - delete "Otherwise it looks ok."]

Your code won't issue the pulse 'New_Clock_Second' on the transition from zero to one. Mine will.
 
Last edited:
Anyone knows how to declare a one second pulse in the Rslogix 5000? Is there any command for this function? It does not same like GE or other PLC where the 1s pulse is an internal bit. How to declare a bit or a tag to have this function? I am using Allen Bradley 1769-L33R controller. Appreciate for those can help. Thanks
 
For the structured text types out there...

I wanted to share some code for pulse generation. We recently purchased the ST add-on and upgraded a couple of our newer controllers to v24, so I've been converting existing Add-On-Instructions and a utility program (the performance gains aren't imaginary!).

This snippet generates one and half-second pulses using the same approach as a ladder DTR - bitwise masking and references. If you recognize the mask pattern, you can extend this to quarter, eighth, sixteenth-second pulses, and so on:
Code:
// Parse the controller's WallClockTime
GSV(WallClockTime, ,LocalDateTime, RealTimeClock.Year);

// Generate a pulse each second
IF( (RealTimeClock.Second & 16#000000FF) = RTC_Reference[0]) THEN
	OneSecPulse := 0;
ELSE
	RTC_Reference[0] := RealTimeClock.Second & 16#000000FF;
	OneSecPulse := 1;
END_IF;

// Generate a pulse each half-second
IF( (RealTimeClock.Microsecond & 16#00080000) = RTC_Reference[1]) THEN
	HalfSecPulse := 0;
ELSE
	RTC_Reference[1] := RealTimeClock.Microsecond & 16#00080000;
	HalfSecPulse := 1;
END_IF;

// End of function

Another function within the utility program accumulates the controller's running time using the above function's output:
Code:
// Reset the running time if the controller has
// just been powered on or toggled from Program
// to Run mode.
IF (S:FS) THEN
	ControllerRuntime.Second := 0;
	ControllerRuntime.Minute := 0;
	ControllerRuntime.Hour := 0;
	ControllerRuntime.Day := 0;
END_IF;

// increment running seconds
IF (NOT S:FS AND NOT OneShots[1] AND OneSecPulse) THEN
	ControllerRuntime.Second := ControllerRuntime.Second + 1;
END_IF;
OneShots[1] := OneSecPulse;

// increment running minutes
IF (ControllerRuntime.Second = 60) THEN
	ControllerRuntime.Minute := ControllerRuntime.Minute + 1;
	ControllerRuntime.Second := 0;
END_IF;

// increment running hours
IF (ControllerRuntime.Minute = 60) THEN
	ControllerRuntime.Hour := ControllerRuntime.Hour + 1;
	ControllerRuntime.Minute := 0;
END_IF;

// increment running days
IF (ControllerRuntime.Hour = 24) THEN
	ControllerRuntime.Day := ControllerRuntime.Day + 1;
	ControllerRuntime.Hour := 0;
END_IF;

edit: in addition upgrading to v24 made it easy to reference the pulses in other programs: "\Utilities.OneSecPulse" as a public parameter generally eliminates the need to write and read controller-scoped tags and keep track of what program does what at the controller scope.
 
Hello
Please any one can help me. I need this pulse generator and i did what are you mentioned above about making the task as a periodic. But it's run the output and still the output on
 
Hello
Please any one can help me. I need this pulse generator and i did what are you mentioned above about making the task as a periodic. But it's run the output and still the output on
 
this the best way, i think so...i also tried this way..and the timming not run much..and if correcting the timming using SSV with pc timmer, i thing its help much.
 
This thread was referenced from another thread today, so I'll add my comment here.

About 10 years ago, on my first major Logix 5000 project, I tested a wall clock-derived one second pulse similar to Bernie's code in post #18 against a 1000 msec repeating timer. Over time, the timer lost counts against the clock pulse. Using a 500msec periodic task to toggle a bit was not an option as we were using Version 13 redundancy which allowed only continuous tasks.

One-shot vs 500ms on/ 500ms off doesn't matter to elapsed time counter inputs. However, flow totalizers use math functions which execute on every scan where the rung is true, so they require a one-shot trigger to work properly.

Mike
 
This thread was referenced from another thread today, so I'll add my comment here.

About 10 years ago, on my first major Logix 5000 project, I tested a wall clock-derived one second pulse similar to Bernie's code in post #18 against a 1000 msec repeating timer. Over time, the timer lost counts against the clock pulse. Using a 500msec periodic task to toggle a bit was not an option as we were using Version 13 redundancy which allowed only continuous tasks.

One-shot vs 500ms on/ 500ms off doesn't matter to elapsed time counter inputs. However, flow totalizers use math functions which execute on every scan where the rung is true, so they require a one-shot trigger to work properly.

Mike

Assuming that one does have the ability to employ a periodic task, no pulse reference bit is required. An unconditional logic statement will execute once per second in a program running under a periodic task with a 1000 ms time base.

Why bother with a redundant trigger?
 
Hi Jeremy,

I'm trying to understand why you are using masking in your function. Cause if I understand it right, pulse is not exactly 500 000us but 524288 us or 475712 ms.

Code:
// Parse the controller's WallClockTime
GSV(WallClockTime, ,LocalDateTime, RealTimeClock.Year);

// Generate a pulse each second
IF( (RealTimeClock.Second & 16#000000FF) = RTC_Reference[0]) THEN
	OneSecPulse := 0;
ELSE
	RTC_Reference[0] := RealTimeClock.Second & 16#000000FF;
	OneSecPulse := 1;
END_IF;

// Generate a pulse each half-second
IF( (RealTimeClock.Microsecond & 16#00080000) = RTC_Reference[1]) THEN
	HalfSecPulse := 0;
ELSE
	RTC_Reference[1] := RealTimeClock.Microsecond & 16#00080000;
	HalfSecPulse := 1;
END_IF;

// End of function
 
Hi Jeremy,

I'm trying to understand why you are using masking in your function. Cause if I understand it right, pulse is not exactly 500 000us but 524288 us or 475712 ms.

Code:
// Parse the controller's WallClockTime
GSV(WallClockTime, ,LocalDateTime, RealTimeClock.Year);

// Generate a pulse each second
IF( (RealTimeClock.Second & 16#000000FF) = RTC_Reference[0]) THEN
    OneSecPulse := 0;
ELSE
    RTC_Reference[0] := RealTimeClock.Second & 16#000000FF;
    OneSecPulse := 1;
END_IF;

// Generate a pulse each half-second
IF( (RealTimeClock.Microsecond & 16#00080000) = RTC_Reference[1]) THEN
    HalfSecPulse := 0;
ELSE
    RTC_Reference[1] := RealTimeClock.Microsecond & 16#00080000;
    HalfSecPulse := 1;
END_IF;

// End of function


You know, the DTR instruction on wall clock time seconds does all of that in one instruction?
 

Similar Topics

I'm new in PLC programming. I have a small project which have 12 temperature sensor. How I should declare the variable for this 12 sensor. I...
Replies
4
Views
2,390
I'm new in PLC programming. I have a small project which have 15 temperature sensor. How I should declare the variable for this 15 sensor. I...
Replies
3
Views
1,888
Hello Folks: I'm trying to create a function that takes an DINT to dynamically set the range to a random number generator. Below is the code, I...
Replies
7
Views
1,853
In my WinCC Runtime program, I have to declare these variables: Dim AllProperties As HMIProperties Dim objProperty As HMIProperty Dim...
Replies
0
Views
2,244
How to declare PIW PQW in WinCC (Analog Values)with simatic manager.... Any Examples Appreciated ..........
Replies
14
Views
7,691
Back
Top Bottom