Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » 4DIAC - Framework for Distributed Industrial Automation and Control » Time to real conversion in FORTE 10
Time to real conversion in FORTE 10 [message #1807439] Thu, 30 May 2019 07:43 Go to next message
Nugroho AV is currently offline Nugroho AVFriend
Messages: 14
Registered: May 2019
Junior Member
I want to do mathematical operations in the form of integrals and derivations, so I need to block the conversion of data time types to real. How do you convert this data type to FORTE 10?
Re: Time to real conversion in FORTE 10 [message #1807448 is a reply to message #1807439] Thu, 30 May 2019 10:53 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 907
Registered: January 2014
Senior Member
IEC 61131-3 does not define such functions. From the current definitions in IEC 6113-3 it would also be rather hard to define such functions. What should be the the according time value of your 1.0 REAL value? Given the current definitions I would recommend that you give also the time values directly in REAL.

Cheers,
Alois
Re: Time to real conversion in FORTE 10 [message #1807450 is a reply to message #1807448] Thu, 30 May 2019 11:34 Go to previous messageGo to next message
Nugroho AV is currently offline Nugroho AVFriend
Messages: 14
Registered: May 2019
Junior Member
I can run this code in FORTE 8, but I can't run this code in FORTE 10. How can I run that line of code in FORTE 10?
t_now := TIME_TO_REAL(TIME());

[Updated on: Thu, 30 May 2019 11:37]

Report message to a moderator

Re: Time to real conversion in FORTE 10 [message #1807463 is a reply to message #1807450] Thu, 30 May 2019 15:12 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 907
Registered: January 2014
Senior Member
Thanks for the use case.

First of all, please accept our apology that we provided means like the one you mentioned. After reviewing IEC 61131-3 this is wrong on many ways.

First of all the TIME data type should be used for time duration. TIME can never hold a value of now. For this any of the DATE, DATE_AND_TIME, or TIME_OF_DAY data types should be used.

Therefore I think we should clean-up 4diac here and also remove the TIME() function and replace it with something like NOW. However I'm not sure if the return value should be DATE_AND_TIME or TIME_OF_DAY.

Based on that There are functions for subtracting values of these date types to get TIME and for TIME introduce new functions: TIME_TO_REAL_S, TIME_TO_REAL_MS, TIME_TO_REAL_US, TIME_TO_REAL_NS. So that it is clear what the resulting value would be.

What do you think?

Cheers,
Alois

P.S.: May I ask why are you needing the real time in your algorithm? Currently I would mostly need it only for time_stamping and measuring things. But I don't think this is your intention.
Re: Time to real conversion in FORTE 10 [message #1807480 is a reply to message #1807463] Thu, 30 May 2019 20:08 Go to previous messageGo to next message
Nugroho AV is currently offline Nugroho AVFriend
Messages: 14
Registered: May 2019
Junior Member
I want to do integral calculations
##Internal Variabel
t_now,t_last,Error_Old,Ki_in,dtOut_in (All in REAL data type)
============================
##Variables in the FBT interface
Error(REAL), Reset(BOOL), Out(REAL)
============================
t_now := TIME_TO_REAL(TIME());
dt := t_now - t_last;
t_last := t_now;
IF Reset THEN
	Out := 0;
	Out_in := 0;
ELSE
	Out_in := (Error + Error_Old)*0.5*dt + Out_in;
	Error_Old := Error;
   	Out := Out_in*Ki_in;
END_IF;


This code runs on FORTE 8 but does not work on FORTE 10.
Are there alternative ways to do integral calculations on FORTE 10?

[Updated on: Thu, 30 May 2019 20:12]

Report message to a moderator

Re: Time to real conversion in FORTE 10 [message #1807484 is a reply to message #1807480] Thu, 30 May 2019 22:03 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 907
Registered: January 2014
Senior Member
Are you invoking the FB in an E_CYCLE chain? If yes then it is a better option to specify the dt as input parameter. This has the advantage that you can also easily speed up your calculations.

Futhermore the if Reset would be better as state and event. This results in much better readable code.

Cheers,
Alois
Re: Time to real conversion in FORTE 10 [message #1807508 is a reply to message #1807484] Fri, 31 May 2019 12:22 Go to previous messageGo to next message
Martin Melik-Merkumians is currently offline Martin Melik-MerkumiansFriend
Messages: 74
Registered: March 2016
Member
Hi all,

Quote:
First of all the TIME data type should be used for time duration. TIME can never hold a value of now

I support Alois here, the IEC 61131 says that TIME is only for duration, so NOW does not make any sense for this.

Quote:
Therefore I think we should clean-up 4diac here and also remove the TIME() function and replace it with something like NOW. However I'm not sure if the return value should be DATE_AND_TIME or TIME_OF_DAY.

I like the name NOW, and it should return DATE_AND_TIME, as it is explicitly castable into DATE and TIME_OF_DAY, which would cover all data type holding times.

Quote:
TIME_TO_REAL_S, TIME_TO_REAL_MS, TIME_TO_REAL_US, TIME_TO_REAL_NS

In principle I think such functions are needed but providing them with this kind of names would mean that there would be a lot of them as we would have to provide them for a variaty of type.

How about leaning even a little more to the CAST function of IEC 61131 and naming them TIME_IN_[S/MS/US/NS]_TO , so we could provide a *-cast version which types itself to the correct type?

Best,
Martin

Re: Time to real conversion in FORTE 10 [message #1807510 is a reply to message #1807508] Fri, 31 May 2019 13:46 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 907
Registered: January 2014
Senior Member
Martin Melik-Merkumians wrote on Fri, 31 May 2019 12:22

I like the name NOW, and it should return DATE_AND_TIME, as it is explicitly castable into DATE and TIME_OF_DAY, which would cover all data type holding times.

Thanks for pointing that out.

Martin Melik-Merkumians wrote on Fri, 31 May 2019 12:22

How about leaning even a little more to the CAST function of IEC 61131 and naming them TIME_IN_[S/MS/US/NS]_TO , so we could provide a *-cast version which types itself to the correct type?


I like the naming for TIME_IN_[]_TO_xxx. Maybe we should start with a view concrete ones before doing the generic version.

Can you please submit bug reports for your suggestions?

Cheers,
Alois


Re: Time to real conversion in FORTE 10 [message #1807512 is a reply to message #1807510] Fri, 31 May 2019 15:00 Go to previous messageGo to next message
Martin Melik-Merkumians is currently offline Martin Melik-MerkumiansFriend
Messages: 74
Registered: March 2016
Member
Sure, I try to enter the reports this evening.
Re: Time to real conversion in FORTE 10 [message #1807527 is a reply to message #1807512] Sat, 01 June 2019 12:47 Go to previous message
Nugroho AV is currently offline Nugroho AVFriend
Messages: 14
Registered: May 2019
Junior Member
Thank you...
Previous Topic:How to create *.sys file with 4DAIC IDE v1.10.2
Next Topic:Group box "Create Connection" missing in 4diac 1.10
Goto Forum:
  


Current Time: Fri Nov 15 16:01:32 GMT 2019

Powered by FUDForum. Page generated in 0.02002 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top