Machine Automation Forum
A forum addressing machine automation solutions for the complete machine lifecycle. Including offers like Machine Advisor, Modicon PLC/PacDrive, Lexium or Preventa. Discuss and share knowledge on offers relating to cloud-based service platforms, machine localization and monitoring, industrial operations control, motion products as well as safety function!
Link copied. Please paste this link to share this article on your social media post.
Posted: 2022-07-22 11:15 AM
I would not like to invent gunpowder again if I can help it ...
Is there a standard way to show a date on screen with TM171 ? Anything that would look similar to the way we change RTC showing Hour and date afterwards ?
https://www.youtube.com/watch?v=UFCYDB3BnvU&list=PLFqT6GhMpgpKziZxGdSaJPEEB1Q5i8Xo5&index=22
Link copied. Please paste this link to share this article on your social media post.
Link copied. Please paste this link to share this article on your social media post.
Posted: 2022-07-24 10:59 PM
Hi,
If you want to show a time value based on Hours:Minutes you can define this as Format for Status or EEPROM Var.
IF you choose HH::mm as format the value will be automatically converted.
As example a screenshot of the simulation.
The value 180 will be shown as 03:00.
180 minutes = 3 hours
Link copied. Please paste this link to share this article on your social media post.
Link copied. Please paste this link to share this article on your social media post.
Posted: 2022-07-25 11:23 AM
Thanks for your answer.
I came up with this program:
PROGRAM PRG_SHOWDATE
VAR
usiret : USINT;
ShowFlag : TON;
ShowContent : TON;
usiDisplay : USINT;
END_VAR
IF NOT ShowDate THEN
RETURN;
END_IF;
ShowFlag(PT:= 1500);
ShowContent(PT:= 3000);
Case usiDisplay OF
0: ShowDate := TRUE;
ShowFlag(IN := TRUE);//Show flag
ShowContent(IN := FALSE);
IF ShowFlag.Q THEN
usiDisplay := 10;
END_IF;
sysLocalLeds[7] := 1;
usiret:=OverwriteLocalDisplay(3,'TIME',0,0,0,1);
10: ShowContent(IN := TRUE);
ShowFlag(IN := FALSE);
IF ShowContent.Q THEN
usiDisplay := 20;
END_IF;
usiret:=OverwriteLocalDisplay(3,'',TO_DINT(sysClock.hours * 100 + sysClock.minutes),2,0,0);
20: ShowFlag(IN := TRUE);//Show flag
ShowContent(IN := FALSE);
IF ShowFlag.Q THEN
ShowFlag(IN := FALSE);
usiDisplay := 30;
END_IF;
sysLocalLeds[7] := 0;
usiret:=OverwriteLocalDisplay(3,'DATE',0,0,0,1);
30: ShowContent(IN := TRUE);
ShowFlag(IN := FALSE);
IF ShowContent.Q THEN
usiDisplay := 40;
END_IF;
usiret:=OverwriteLocalDisplay(3,'',TO_DINT(sysClock.daymonth * 100 + sysClock.month),2,0,0);
40: ShowFlag(IN := TRUE);//Show flag
ShowContent(IN := FALSE);
IF ShowFlag.Q THEN
ShowFlag(IN := FALSE);
usiDisplay := 50;
END_IF;
usiret:=OverwriteLocalDisplay(3,'YEAR',0,0,0,1);
50: ShowContent(IN := TRUE);
ShowFlag(IN := FALSE);
IF ShowContent.Q THEN
usiDisplay := 99;
END_IF;
usiret:=OverwriteLocalDisplay(3,'',TO_DINT(sysClock.year) + 2000,0,0,0);
99: ShowContent(IN := FALSE);
usiDisplay := 0;
ShowDate := FALSE;
END_CASE;
ShowDate is a BOOL defined as Global variable and set somewhere else. It behaves pretty similar to what is shown when setting the time. The colon symbol (:) is replaced by a dot but otherwise it should be pretty readable.
I tried to encapsulate this inside a Function Block but it looks like you can´t access the local display from within a function block, which sounds reasonable but I would like your comments on this subject please.
Link copied. Please paste this link to share this article on your social media post.
Link copied. Please paste this link to share this article on your social media post.
Posted: 2022-07-25 11:30 AM
To acces a system variabel from an FB you need to declare these variabel as VAR_EXTERNAL in the FB. You can do this via drag and drop of the sysvariable to the declaration in table form.
Link copied. Please paste this link to share this article on your social media post.
Link copied. Please paste this link to share this article on your social media post.
Posted: 2022-07-25 01:26 PM
Ok.But OverwriteLocalDisplay is not a system variable but a Function, so actually I can not drag and drop it on the variables section or instantiate it.
I thought maybe you meant the function output variable which is USINT type, but declaring that as external does not seem to change anything.
This function block will not complain, runs the timers, and sets usiret = 0 which indicates command executed. Inñess this will actually run inside a real PLC (so far only on simulator).
FUNCTION_BLOCK DateDisplay
VAR
ShowFlag : TON;
ShowContent : TON;
usiDisplay : USINT := 0;
END_VAR
VAR_INPUT
DateInput : TypeDataTime;
flagtime : UDINT := 0;
ContentTime : UDINT;
END_VAR
VAR_EXTERNAL
usiret : USINT;
END_VAR
ShowFlag(PT:= FlagTime);
ShowContent(PT:= ContentTime);
Case usiDisplay OF
0: ShowFlag(IN := TRUE);//Show flag
ShowContent(IN := FALSE);
IF ShowFlag.Q THEN
usiDisplay := 10;
END_IF;
usiret:=OverwriteLocalDisplay(3,'HOUR',0,0,0,1);
10: ShowContent(IN := TRUE);
ShowFlag(IN := FALSE);
IF ShowContent.Q THEN
usiDisplay := 20;
END_IF;
usiret:=OverwriteLocalDisplay(3,'',SHL(DateInput.hours,2) + DateInput.minutes,0,0,0);
20: ShowFlag(IN := TRUE);//Show flag
ShowContent(IN := FALSE);
IF ShowFlag.Q THEN
ShowFlag(IN := FALSE);
usiDisplay := 30;
END_IF;
usiret:=OverwriteLocalDisplay(3,'DATE',0,0,0,1);
30: ShowContent(IN := TRUE);
ShowFlag(IN := FALSE);
IF ShowContent.Q THEN
usiDisplay := 40;
END_IF;
usiret:=OverwriteLocalDisplay(3,'',SHL(DateInput.daymonth,2) + DateInput.month,0,0,0);
40: ShowFlag(IN := TRUE);//Show flag
ShowContent(IN := FALSE);
IF ShowFlag.Q THEN
ShowFlag(IN := FALSE);
usiDisplay := 50;
END_IF;
usiret:=OverwriteLocalDisplay(3,'YEAR',0,0,0,1);
50: ShowContent(IN := TRUE);
ShowFlag(IN := FALSE);
IF ShowContent.Q THEN
usiDisplay := 99;
END_IF;
usiret:=OverwriteLocalDisplay(3,'',DateInput.year + 2000,0,0,0);
99: ShowContent(IN := FALSE);
usiDisplay := 0;
ShowingDate := FALSE;
END_CASE;
Link copied. Please paste this link to share this article on your social media post.
Create your free account or log in to subscribe to the board - and gain access to more than 10,000+ support articles along with insights from experts and peers.