Sign in to follow this  
Followers 0
screaminlean

Timer percent complete

12 posts in this topic

Hi Me again I have my program almost done thanks to peeps here all i need to do now is figure out how to Calculate percent complete and mov to D0010? Set value for the timer is in D0001 and Timer value is T0000 I made a function block ST but have no idea how to hook up the timer to execute it and the output result moved to D0010 I have attached a sceen shot of the function so far. Thanks in advance

Share this post


Link to post
Share on other sites
Ok I tried to use TIM 0000 N01_psv AND P_0_1s /B(434) T0 N01_psv D10 so every 0.1 seconds that the timer is active the calculation is done and pushed to D0010 but this will not be any good as a timer counts down! anyone done this before? Edited by screaminlean

Share this post


Link to post
Share on other sites
All I can think of doing is X = TimeDone Y = % Complete so X = Timer Set Value (SV) Minus Timer Current Value (T0) Y = X Divided by Timer Set Value(SV) But how to implement this on the ladder?

Share this post


Link to post
Share on other sites
Hello If you use a timer within your ST, then you can do the maths in there too. Much easier than fannying aobut with maths in ladder imho. TIMHX(StartCondition,MyTimer,TimerValue)

Share this post


Link to post
Share on other sites
Dont know how to use ST functions and I have 4 timers i need to do the same with see attached this is my program so far rung 06 is the first instance L10_PLC1.cxp Edited by screaminlean

Share this post


Link to post
Share on other sites
After bieng able to sign in to the site i Can post again! I still cant get this to work right? I have NQ5 with bar graph set to UINT and my timers are TIMHX(551) CP1E so cant use function blocks or ST. any easier ways? Regards

Share this post


Link to post
Share on other sites
This code (same as above, except with TIMHX) should work just fine. I just tested it in simulation mode. LD P_On OUT TR0 AND 23.00 TIMHX(551) 000 D0 FLT(452) D0 D10 // Convert to Float -(410) D0 T0 D12 // Subtract FLT(452) D12 D12 // Convert result to Float LD TR0 /F(457) D12 D10 D20 // Divide by Preset *F(456) D20 +100.0 D20 // Multiply by 100 to get value as % I am guessing that your HMI is not set to read D20 properly. You need to make sure that you set your graph to read D20 as a REAL or FLOATING POINT number. Make sure to monitor it in CX-Programmer as a REAL number also. In the three different cases shown the percent done value (Real number in D20 is correct). 1st case: (D0 (setpoint) - T0 (current value)) / D0 (setpoint) -> (2000 - 1854) /2000 = 7.3 (%) which is stored in D20. 2nd Case: (2000 - 1042) / 2000 = 47.9 % 3rd Case: (2000 - 353) / 2000 = 82.35 % It works, you must have a number format issue somewhere in your HMI or in your ladder. If you are doing a MOV instruction after the math, make sure to do a MOVL as a REAL number is a double word (meaning that it is contained in D20 and D21 in this example).

Share this post


Link to post
Share on other sites
Hi I got the same result now in the plc thanks, I have only 4 options for the number format in the NQ5 HMI Unsigned Int Signed Int BCD Hex And current seeting in the HMI is Unsigned, can i get a conversion from REAL to Unsigned? Multiply it by 10 using *F(456) Floating point multiply? Regards Pete Edited by screaminlean

Share this post


Link to post
Share on other sites
If you want whole percent values as an integer (ie 25%, 50%, etc.), use this: LD P_On OUT TR0 AND 23.00 TIMHX(551) 000 D0 FLT(452) D0 D10 // Convert to Float -(410) D0 T0 D12 // Subtract FLT(452) D12 D12 // Convert result to Float LD TR0 /F(457) D12 D10 D20 // Divide by Preset *F(456) D20 +100.0 D20 // Multiply by 100 to get value as % FIX(450) D20 D25 If you want integer values that represent tenths of a percent (so that 25.2% is 252), then use this: LD P_On OUT TR0 AND 23.00 TIMHX(551) 000 D0 FLT(452) D0 D10 // Convert to Float -(410) D0 T0 D12 // Subtract FLT(452) D12 D12 // Convert result to Float LD TR0 /F(457) D12 D10 D20 // Divide by Preset *F(456) D20 +1000.0 D20 // Multiply by 1000 to get value as tenths of a % FIX(450) D20 D25 Then display D25 on your screen as an Unsigned Integer format. Of course if you use the tenths of a percent example (2nd set of code), you will need to scale the display by 10 to get the decimal in the proper place.

Share this post


Link to post
Share on other sites
Michael Walsh you are an absolute Diamond, Thanks so much it works now!!!! FIX(450) did the trick and I totally missed that!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0