Studio 5000 timer function

dave948

Member
Join Date
Sep 2012
Location
Boston
Posts
19
Studio 5000 V30.
I'm more of a troubleshooter than a programmer but I need to control a TON's count time via an analog input.(0-10VDC).
Looking for tips on best practice for this in either ladder logic or function block.
Thanks.
 
Step 1 is converting the analog to a timer value you want. Here's how I scale tags between different ranges:

Slope = (Output_Min-Output_Max)/(Input_Min-Input_Max)
Out = (Input-Input_Min)*Slope+Output_Min

Step 2 is copying the calculated output into the timer PRE. You should be mindful of if you want to copy the value all the time, or only when the timer isn't running.
 
So, let's assume your input 0-10V corresponds too a timer preset of 0-10 seconds.

Your timer preset is in milliseconds, so that's 0-10V = 0-10000ms.

First thing to do is scale your analog input into meaningful values. You could use a simple CPT instruction, or you can search this site for the RA-provided SCP (scale with parameters) instruction. That allows you to put in a raw data minimum and maximum, and a scaled minimum and maximum.

Once you have a scaled value, it's just a matter of moving the value to your timer preset.

MOV Scaled_Value Timer.PRE
 
Oh, and you MUST NOT forget to range-check the value you move into the Timer's preset register.... your analog input could easily give you a slightly negative value, and if you put a negative value into a timer preset - BANG !! red-light faulted.

Unlike Dr. Who, Rockwell do not have the capability to go backwards in time.

You could use a LIM (Limit) instruction, to prevent moving an erroneous value, but that's not really what you want. You need to Constrain the value to be within limits, and that's most easily done with a couple of rungs....

LES value 0, MOV 0 value
GRT value xxxx, MOV xxxx value

Those two rungs will trap, and correct, values outside of the permissible range, and then you can safely....

MOV value Timer.PRE
 
I played with it for about an hour today, I think I grasp the concept but still need to work some bugs out.
Thanks for the tips so far, I'm sure I'll be asking more questions.
 
So do I need to use the MOV to place the engineering value in PRE or can I just "tag" it in. I've tried both ways, so far neither works but I think I know why.
Limited trial time with the actual rack as it is in use. My company purchased studio 5000 full which does not have emulate. I've been quoted $1500 for emulate? Ouch...
 
You can just put it in the tag for testing, assuming your logic doesn't have anything else writing to that value(ie, don't use both the MOV and try to 'tag' it in).

Also, Don't change the timer preset while the timer is timing, best to check that .tt isn't high before letting the MOV instruction work.
 
You can just put it in the tag for testing, assuming your logic doesn't have anything else writing to that value(ie, don't use both the MOV and try to 'tag' it in).

Also, Don't change the timer preset while the timer is timing, best to check that .tt isn't high before letting the MOV instruction work.

The way the timer instruction works it does the calculation for adding to the accumulator first, then checks for .ACC >= .PRE

If true, it then turns off the .TT, and turns on the .DN

So it really doesn't matter if you write to the .PRE while it is timing. I absolutely know this is OK, as I have done it several times on projects over the last 20-odd years...
 
The way the timer instruction works it does the calculation for adding to the accumulator first, then checks for .ACC >= .PRE

If true, it then turns off the .TT, and turns on the .DN

So it really doesn't matter if you write to the .PRE while it is timing. I absolutely know this is OK, as I have done it several times on projects over the last 20-odd years...

Daba - Good to know!
 

Similar Topics

Hi all, Anyone of you knows if it is possible to access the watchdog timer directly in my code somehow? I have formed the logic of replicating...
Replies
2
Views
1,616
All, I've done a search on this but did not have any luck, but if I have overlooked a topic on this by all means let me know. I am a little...
Replies
11
Views
5,329
What is the best way to extract the hour and minute from the register that comes from Yaskawa VFD. In studio 5000 I have a register saved as INT...
Replies
2
Views
64
I have an Allen Bradley temperature switch that I am trying to use in studio 5000. I am getting the message "Unable to interpret the IODD file"...
Replies
0
Views
45
Hi all. I want to ask what may seem a stupid question, as I have a project to send live data to a Yeacode line printer which will print meterage...
Replies
2
Views
105
Back
Top Bottom