Forums.MrPLC.com: Timer percent complete - Forums.MrPLC.com

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Timer percent complete Calculate percent complete and mov to D0010 Rate Topic: -----

#1
User is offline   screaminlean 

  • Sparky
  • PipPipPip
  • Group: MrPLC Member
  • Posts: 15
  • Joined: 06-April 12
  • Gender:Male
  • Location:Wolverhampton, UK
  • Country:United Kingdom
    United Kingdom
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

Attached thumbnail(s)

  • Attached Image: function.jpg

Here to learn, I have not had any training or done any courses so I may be asking basic questions but we all have to start some place
I have VB.net, C#, Perl and PHP experience so if you need any help with thoselet me know!
0

#2
User is offline   screaminlean 

  • Sparky
  • PipPipPip
  • Group: MrPLC Member
  • Posts: 15
  • Joined: 06-April 12
  • Gender:Male
  • Location:Wolverhampton, UK
  • Country:United Kingdom
    United Kingdom

View Postscreaminlean, on 15 April 2012 - 06:11 AM, said:

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


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?

Attached thumbnail(s)

  • Attached Image: tim percent.jpg

This post has been edited by screaminlean: 15 April 2012 - 10:39 AM

Here to learn, I have not had any training or done any courses so I may be asking basic questions but we all have to start some place
I have VB.net, C#, Perl and PHP experience so if you need any help with thoselet me know!
0

#3
User is offline   screaminlean 

  • Sparky
  • PipPipPip
  • Group: MrPLC Member
  • Posts: 15
  • Joined: 06-April 12
  • Gender:Male
  • Location:Wolverhampton, UK
  • Country:United Kingdom
    United Kingdom
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?
Here to learn, I have not had any training or done any courses so I may be asking basic questions but we all have to start some place
I have VB.net, C#, Perl and PHP experience so if you need any help with thoselet me know!
0

#4
User is offline   ParaffinPower 

  • Sparky
  • PipPipPip
  • Group: MrPLC Member
  • Posts: 393
  • Joined: 01-February 06
  • Location:Manchester
  • Country:United Kingdom
    United Kingdom

View Postscreaminlean, on 15 April 2012 - 10:49 AM, said:

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?


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)

0

#5
User is offline   screaminlean 

  • Sparky
  • PipPipPip
  • Group: MrPLC Member
  • Posts: 15
  • Joined: 06-April 12
  • Gender:Male
  • Location:Wolverhampton, UK
  • Country:United Kingdom
    United Kingdom

View PostParaffinPower, on 15 April 2012 - 11:21 AM, said:

View Postscreaminlean, on 15 April 2012 - 10:49 AM, said:

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?


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)



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

Attached File(s)


This post has been edited by screaminlean: 15 April 2012 - 12:03 PM

Here to learn, I have not had any training or done any courses so I may be asking basic questions but we all have to start some place
I have VB.net, C#, Perl and PHP experience so if you need any help with thoselet me know!
0

#6
User is offline   lostcontrol 

  • Sparky
  • PipPipPip
  • Group: MrPLC Member
  • Posts: 413
  • Joined: 27-May 09
  • Country:New Zealand
    New Zealand
Try this, copy this into the mneumonics view of CX-P.

Quote

' Steps to calculate % done of Timer\n 1. Convert Timer Preset to Float\n 2. Subtract Preset from PV to get timer value as incrementing\n 3. Convert result to Float\n 4. Divide (Preset - PV) by Preset to get %\n 5. Multiply by 100 to get whole no %\n.
LD P_On
OUT TR0
AND 23.00
TIMX(550) 0000 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 %

0

#7
User is offline   screaminlean 

  • Sparky
  • PipPipPip
  • Group: MrPLC Member
  • Posts: 15
  • Joined: 06-April 12
  • Gender:Male
  • Location:Wolverhampton, UK
  • Country:United Kingdom
    United Kingdom

View Postlostcontrol, on 15 April 2012 - 02:28 PM, said:

Try this, copy this into the mneumonics view of CX-P.

Quote

' Steps to calculate % done of Timer\n 1. Convert Timer Preset to Float\n 2. Subtract Preset from PV to get timer value as incrementing\n 3. Convert result to Float\n 4. Divide (Preset - PV) by Preset to get %\n 5. Multiply by 100 to get whole no %\n.
LD P_On
OUT TR0
AND 23.00
TIMX(550) 0000 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 %




Thanks alot thats great!!
Here to learn, I have not had any training or done any courses so I may be asking basic questions but we all have to start some place
I have VB.net, C#, Perl and PHP experience so if you need any help with thoselet me know!
0

#8
User is offline   screaminlean 

  • Sparky
  • PipPipPip
  • Group: MrPLC Member
  • Posts: 15
  • Joined: 06-April 12
  • Gender:Male
  • Location:Wolverhampton, UK
  • Country:United Kingdom
    United Kingdom

View Postscreaminlean, on 16 April 2012 - 05:40 PM, said:

View Postlostcontrol, on 15 April 2012 - 02:28 PM, said:

Try this, copy this into the mneumonics view of CX-P.

Quote

' Steps to calculate % done of Timer\n 1. Convert Timer Preset to Float\n 2. Subtract Preset from PV to get timer value as incrementing\n 3. Convert result to Float\n 4. Divide (Preset - PV) by Preset to get %\n 5. Multiply by 100 to get whole no %\n.
LD P_On
OUT TR0
AND 23.00
TIMX(550) 0000 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 %




Thanks alot thats great!!


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
Here to learn, I have not had any training or done any courses so I may be asking basic questions but we all have to start some place
I have VB.net, C#, Perl and PHP experience so if you need any help with thoselet me know!
0

#9
User is offline   Michael Walsh 

  • Omron Expert
  • Group: MrPLC Admin
  • Posts: 433
  • Joined: 03-April 06
  • Gender:Male
  • Location:Charlotte, NC
  • Country:United States
    United States
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.

Attached Image: percent done.jpg

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).
Michael
Charlotte, NC
0

#10
User is offline   screaminlean 

  • Sparky
  • PipPipPip
  • Group: MrPLC Member
  • Posts: 15
  • Joined: 06-April 12
  • Gender:Male
  • Location:Wolverhampton, UK
  • Country:United Kingdom
    United Kingdom

View PostMichael Walsh, on 02 November 2012 - 01:40 PM, said:

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).


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

This post has been edited by screaminlean: 02 November 2012 - 02:25 PM

Here to learn, I have not had any training or done any courses so I may be asking basic questions but we all have to start some place
I have VB.net, C#, Perl and PHP experience so if you need any help with thoselet me know!
0

#11
User is offline   Michael Walsh 

  • Omron Expert
  • Group: MrPLC Admin
  • Posts: 433
  • Joined: 03-April 06
  • Gender:Male
  • Location:Charlotte, NC
  • Country:United States
    United States
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.
Michael
Charlotte, NC
0

#12
User is offline   screaminlean 

  • Sparky
  • PipPipPip
  • Group: MrPLC Member
  • Posts: 15
  • Joined: 06-April 12
  • Gender:Male
  • Location:Wolverhampton, UK
  • Country:United Kingdom
    United Kingdom
Michael Walsh you are an absolute Diamond, Thanks so much it works now!!!! FIX(450) did the trick and I totally missed that!
Here to learn, I have not had any training or done any courses so I may be asking basic questions but we all have to start some place
I have VB.net, C#, Perl and PHP experience so if you need any help with thoselet me know!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users