PLCnext on LinkedInPLCnext on Instagram  PLCnext on YouTube Github PLCnext CommunityStore PLCnext Community

  1. bododonath
  2. PLCnext Engineer
  3. Saturday, 29 August 2020

Hi Team,

 

We have the controller AXC F 1152 with a little program.

Now we want to write a little error log into a text file.

I need some help how I can write the code therefore.

Maybe someone was creating something like this before and can give some tipps.

Thanks & BR

Bodo

 

Accepted Answer
Martin PLCnext Team Accepted Answer Pending Moderation
0
Votes
Undo

Hi Andy,

There is a function block called "RTC_S" that retrieves the current date and time as a string.

~ Martin.

Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support

Martin PLCnext Team Accepted Answer Pending Moderation
0
Votes
Undo

Hi Bodo,

Here is an example of how to write text to a file in in PLCnext Engineer.

https://www.plcnext-community.net/en/discussions-2-offcanvas/example-for-saving-data-in-a-file.html

The example uses Structured Text, but you can use the same FBs in other IEC 61131 languages, if you want.

Hope this helps.

~ Martin.

Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support

bododonath Accepted Answer Pending Moderation
0
Votes
Undo

Hi Martin,

 

what a great and very fast solution.

I've tried the code and it works fine. :)

I have an other question. It is possible to write the file on a local PC System or maybe on file server?

 

BR

Bodo

Martin PLCnext Team Accepted Answer Pending Moderation
0
Votes
Undo

Hi Bodo,

I don't think there is a standard solution to this problem from PLCnext Engineer on its own, but this could probably be achieved using standard Linux utilities.

Possibilites include:

  • Using rsync to copy the contents of local file(s) to a remote machine.
  • Using syslog-ng for decentralised system logging.
  • Using a cloud service to log messages (via MQTT, for example).
  • Looking for solutions from vendors in the PLCnext Store.

You should be able to try most options on a standard Linux system, and once you have a solution working the way you want, you can try porting that solution to the PLCnext Control.

Hope this helps.

~ Martin.

Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support

bododonath Accepted Answer Pending Moderation
0
Votes
Undo

Hi Martin,

Thanks again for your support.

I have a last question fot this topic.

How can collect a String ('hello World') with the actual date?

Do you have an idea.

BR

Andy

bododonath Accepted Answer Pending Moderation
0
Votes
Undo

Hi Martin,

I have a last question (hope so).

In your example : https://www.plcnext-community.net/en/discussions-2-offcanvas/example-for-saving-data-in-a-file.html

I work with a ByteArray35 and if I understand right, that means no more characters like 34.

Now I need the oppertunity for more characters - is this possible?

Thanks

Andy

Martin PLCnext Team Accepted Answer Pending Moderation
0
Votes
Undo

Hi Andy,

I only used ByteArray35 in that example because that was already a defined data type in PLCnext Engineer. But you can use a byte array of any length. To do that:

  • In a DataType worksheet, create a new data type as a byte array of any fixed length (the declaration templates - accessible using right-click - are handy for this).
  • In your program, declare a variable of that type, instead of type ByteArray35.

Hope this helps.

~ Martin.

Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support

bododonath Accepted Answer Pending Moderation
0
Votes
Undo

Hi Martin,

sounds good, but I need more help.

Did you have a short example for me?

Thanks a lot for your support.

BR
Andy

Martin PLCnext Team Accepted Answer Pending Moderation
0
Votes
Undo

Hi Andy,

Hope this helps.

(video has no sound)

Note that the array actually contains 421 elements (0 to 420), so I could have called it ByteArray421, or else declared the array bounds as either [0 .. 419] or [1 .. 420]. 

~ Martin.

Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support

bododonath Accepted Answer Pending Moderation
0
Votes
Undo

Hi Martin,

That's great - it works fine. ?

Thank you so much for your help.

BR
Andy

  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.