Jump to content

Recommended Posts

Posted
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
Posted (edited)
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
Posted
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?
Posted (edited)
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
Posted
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
Posted
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).
Posted (edited)
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
Posted
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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...