Time display in registers in BCD4 format

kalibabka

Member
Join Date
Sep 2003
Posts
6
I am using a GEFanuc CPUE05 and programing with Proficy Machine edition 5.5 and have managed to show the Month / Day / Hour / Minute in registers by using the (SEV REQ block function 7).

The registers use the format BCD4 which uses half of the 16 bits in the register to show the day and the other half to show the hour.
I would like to separate the two halfs to two new registers so that I can use a comparitor to trigger a time/day flag for triggering an event based upon a certain hour on a certain day of the month.

Is it possible and has somebody done it.
Much appreciation for any help.
 
Here is another way: Copy-n-paste this into a Block (Subroutine)
Code:
COMMENT /* Only ONE Service Request at a time. */; END_RUNG; 
NOCON Read_Bit,G,%T00001; NCCON Write_Clock,G,%T00004; POSCOIL Read_Clock,G,%T00003; END_RUNG; 
NOCON Write_Bit,G,%T00002; NCCON Read_Clock,G,%T00003; POSCOIL Write_Clock,G,%T00004; END_RUNG; 
COMMENT /* This rung sets up the Service Request Function block to read the PLC Clock. The first 'MOVE INT' puts a 0 into Register one of the six used by the 'SVC REQ'.
This 0 tells the 'SER REQ' to 'READ' (a 1 would mean 'WRITE'). The next 'MOVE INT' loads a 1 into the second of six registers.
This tells the 'SRV REQ' to use BCD, a 0 would mean ASCII. The '7 ---FNC' indacates an internal Clock Read/Write Service Request. */; END_RUNG; 
NOCON Read_Clock,G,%T00003; H_WIRE; MOVE_INT 1 0 Read_Write,G,%R00001; H_WIRE; H_WIRE; MOVE_INT 1 1 Use_BCD,G,%R00002; H_WIRE; H_WIRE; SVC_REQ 7 Read_Write,G,%R00001; END_RUNG; 
COMMENT /* The first 'Array Move Byte' function block moves the High Byte in BCD format into a holding Register, then the 'BCD4 TO INT' function changes it into Integer format.
The second 'Array Move Byte' function block moves the Low Byte in BCD format into a holding Register.
The holding register is only used here for clarity, we could use Month_INT register in all three locations with the same results. */; END_RUNG; 
NOCON Read_Clock,G,%T00003; ARRAY_MOVE_BYTE 2 Month_Year,G,%R00003 2 1 1 Month_BCD,G,%R00037; H_WIRE; H_WIRE; BCD4_TO_INT Month_BCD,G,%R00037 Month_INT,G,%R00007; H_WIRE; H_WIRE; ARRAY_MOVE_BYTE 2 Month_Year,G,%R00003 1 1 1 Year_BCD,G,%R00038; H_WIRE; H_WIRE; BCD4_TO_INT Year_BCD,G,%R00038 Year_INT,G,%R00008; END_RUNG; 
NOCON Read_Clock,G,%T00003; ARRAY_MOVE_BYTE 2 Hours_Day,G,%R00004 2 1 1 Hours_BCD,G,%R00039; H_WIRE; H_WIRE; BCD4_TO_INT Hours_BCD,G,%R00039 Hours_INT,G,%R00009; H_WIRE; H_WIRE; ARRAY_MOVE_BYTE 2 Hours_Day,G,%R00004 1 1 1 Day_BCD,G,%R00040; H_WIRE; H_WIRE; BCD4_TO_INT Day_BCD,G,%R00040 Day_INT,G,%R00010; END_RUNG; 
NOCON Read_Clock,G,%T00003; ARRAY_MOVE_BYTE 2 Sec_Min,G,%R00005 2 1 1 Sec_BCD,G,%R00041; H_WIRE; H_WIRE; BCD4_TO_INT Sec_BCD,G,%R00041 Sec_INT,G,%R00011; H_WIRE; H_WIRE; ARRAY_MOVE_BYTE 2 Sec_Min,G,%R00005 1 1 1 Min_BCD,G,%R00042; H_WIRE; H_WIRE; BCD4_TO_INT Min_BCD,G,%R00042 Min_INT,G,%R00012; END_RUNG; 
COMMENT /* This handles the Day Of Week. The DOW is unique in that it is read only. You can write it back but it will be re-calculated if not correct. */; END_RUNG; 
NOCON Read_Clock,G,%T00003; ARRAY_MOVE_BYTE 2 DOW,G,%R00006 1 1 1 DOW_BCD,G,%R00043; H_WIRE; H_WIRE; BCD4_TO_INT DOW_BCD,G,%R00043 DOW_INT,G,%R00013; END_RUNG; 
COMMENT /* These rungs set up the Write to Clock Service Request.
The Month_In, Year_In etc. registers are normally updated through a QuickPanel or similar Operator Interface.
Note, that these rungs use the special 'Continuation Coil' and 'Continuation Contact'. */; END_RUNG; 
NOCON Write_Clock,G,%T00004; INT_TO_BCD4 Month_HMI,G,%R00017 Month_HMI_BCD,G,%R00027; H_WIRE; H_WIRE; INT_TO_BCD4 Year_HMI,G,%R00018 Year_HMI_BCD,G,%R00028; H_WIRE; H_WIRE; INT_TO_BCD4 Hour_HMI,G,%R00019 Hour_HMI_BCD,G,%R00029; H_WIRE; CONTCOIL; END_RUNG; 
CONTCON; INT_TO_BCD4 Day_HMI,G,%R00020 Day_HMI_BCD,G,%R00030; H_WIRE; H_WIRE; INT_TO_BCD4 Sec_HMI,G,%R00021 Sec_HMI_BCD,G,%R00031; H_WIRE; H_WIRE; INT_TO_BCD4 Min_HMI,G,%R00022 Min_HMI_BCD,G,%R00032; END_RUNG; 
COMMENT /* Theses 'Array Move Byte' function blocks move the BCD formated input registers into the six registers used by the 'SRV REQ' function block.
They take six Bytes out of the six registers above and put them into 3 of the six registers used by the 'SRV REQ'. */; END_RUNG; 
NOCON Write_Clock,G,%T00004; H_WIRE; H_WIRE; ARRAY_MOVE_BYTE 2 Month_HMI_BCD,G,%R00027 1 2 1 Month_Year,G,%R00003; H_WIRE; H_WIRE; ARRAY_MOVE_BYTE 2 Year_HMI_BCD,G,%R00028 1 1 1 Month_Year,G,%R00003; END_RUNG; 
NOCON Write_Clock,G,%T00004; H_WIRE; H_WIRE; ARRAY_MOVE_BYTE 2 Hour_HMI_BCD,G,%R00029 1 2 1 Hours_Day,G,%R00004; H_WIRE; H_WIRE; ARRAY_MOVE_BYTE 2 Day_HMI_BCD,G,%R00030 1 1 1 Hours_Day,G,%R00004; END_RUNG; 
NOCON Write_Clock,G,%T00004; H_WIRE; H_WIRE; ARRAY_MOVE_BYTE 2 Sec_HMI_BCD,G,%R00031 1 2 1 Sec_Min,G,%R00005; H_WIRE; H_WIRE; ARRAY_MOVE_BYTE 2 Min_HMI_BCD,G,%R00032 1 1 1 Sec_Min,G,%R00005; END_RUNG; 
COMMENT /* This rung sets up the Service Request Function block to Write the PLC Clock. The first 'MOVE INT' puts a 1 into Register one of the six used by the 'SVC REQ'.
This 1 tells the 'SER REQ' to 'WRITE'. The next 'MOVE INT' loads a 1 into the second of six registers. */; END_RUNG; 
NOCON Write_Clock,G,%T00004; H_WIRE; MOVE_INT 1 1 Read_Write,G,%R00001; H_WIRE; H_WIRE; MOVE_INT 1 1 Use_BCD,G,%R00002; H_WIRE; H_WIRE; SVC_REQ 7 Read_Write,G,%R00001; END_RUNG;
 
RussB said:
Here is another way: Copy-n-paste this into a Block (Subroutine)
Code:
 COMMENT /* Only ONE Service Request at a time. */; END_RUNG; 
 NOCON Read_Bit,G,%T00001; NCCON Write_Clock,G,%T00004; POSCOIL Read_Clock,G,%T00003; END_RUNG; 
 NOCON Write_Bit,G,%T00002; NCCON Read_Clock,G,%T00003; POSCOIL Write_Clock,G,%T00004; END_RUNG; 
 COMMENT /* This rung sets up the Service Request Function block to read the PLC Clock. The first 'MOVE INT' puts a 0 into Register one of the six used by the 'SVC REQ'.
 This 0 tells the 'SER REQ' to 'READ' (a 1 would mean 'WRITE'). The next 'MOVE INT' loads a 1 into the second of six registers.
 This tells the 'SRV REQ' to use BCD, a 0 would mean ASCII. The '7 ---FNC' indacates an internal Clock Read/Write Service Request. */; END_RUNG; 
 NOCON Read_Clock,G,%T00003; H_WIRE; MOVE_INT 1 0 Read_Write,G,%R00001; H_WIRE; H_WIRE; MOVE_INT 1 1 Use_BCD,G,%R00002; H_WIRE; H_WIRE; SVC_REQ 7 Read_Write,G,%R00001; END_RUNG; 
 COMMENT /* The first 'Array Move Byte' function block moves the High Byte in BCD format into a holding Register, then the 'BCD4 TO INT' function changes it into Integer format.
 The second 'Array Move Byte' function block moves the Low Byte in BCD format into a holding Register.
 The holding register is only used here for clarity, we could use Month_INT register in all three locations with the same results. */; END_RUNG; 
 NOCON Read_Clock,G,%T00003; ARRAY_MOVE_BYTE 2 Month_Year,G,%R00003 2 1 1 Month_BCD,G,%R00037; H_WIRE; H_WIRE; BCD4_TO_INT Month_BCD,G,%R00037 Month_INT,G,%R00007; H_WIRE; H_WIRE; ARRAY_MOVE_BYTE 2 Month_Year,G,%R00003 1 1 1 Year_BCD,G,%R00038; H_WIRE; H_WIRE; BCD4_TO_INT Year_BCD,G,%R00038 Year_INT,G,%R00008; END_RUNG; 
 NOCON Read_Clock,G,%T00003; ARRAY_MOVE_BYTE 2 Hours_Day,G,%R00004 2 1 1 Hours_BCD,G,%R00039; H_WIRE; H_WIRE; BCD4_TO_INT Hours_BCD,G,%R00039 Hours_INT,G,%R00009; H_WIRE; H_WIRE; ARRAY_MOVE_BYTE 2 Hours_Day,G,%R00004 1 1 1 Day_BCD,G,%R00040; H_WIRE; H_WIRE; BCD4_TO_INT Day_BCD,G,%R00040 Day_INT,G,%R00010; END_RUNG; 
 NOCON Read_Clock,G,%T00003; ARRAY_MOVE_BYTE 2 Sec_Min,G,%R00005 2 1 1 Sec_BCD,G,%R00041; H_WIRE; H_WIRE; BCD4_TO_INT Sec_BCD,G,%R00041 Sec_INT,G,%R00011; H_WIRE; H_WIRE; ARRAY_MOVE_BYTE 2 Sec_Min,G,%R00005 1 1 1 Min_BCD,G,%R00042; H_WIRE; H_WIRE; BCD4_TO_INT Min_BCD,G,%R00042 Min_INT,G,%R00012; END_RUNG; 
 COMMENT /* This handles the Day Of Week. The DOW is unique in that it is read only. You can write it back but it will be re-calculated if not correct. */; END_RUNG; 
 NOCON Read_Clock,G,%T00003; ARRAY_MOVE_BYTE 2 DOW,G,%R00006 1 1 1 DOW_BCD,G,%R00043; H_WIRE; H_WIRE; BCD4_TO_INT DOW_BCD,G,%R00043 DOW_INT,G,%R00013; END_RUNG; 
 COMMENT /* These rungs set up the Write to Clock Service Request.
 The Month_In, Year_In etc. registers are normally updated through a QuickPanel or similar Operator Interface.
 Note, that these rungs use the special 'Continuation Coil' and 'Continuation Contact'. */; END_RUNG; 
 NOCON Write_Clock,G,%T00004; INT_TO_BCD4 Month_HMI,G,%R00017 Month_HMI_BCD,G,%R00027; H_WIRE; H_WIRE; INT_TO_BCD4 Year_HMI,G,%R00018 Year_HMI_BCD,G,%R00028; H_WIRE; H_WIRE; INT_TO_BCD4 Hour_HMI,G,%R00019 Hour_HMI_BCD,G,%R00029; H_WIRE; CONTCOIL; END_RUNG; 
 CONTCON; INT_TO_BCD4 Day_HMI,G,%R00020 Day_HMI_BCD,G,%R00030; H_WIRE; H_WIRE; INT_TO_BCD4 Sec_HMI,G,%R00021 Sec_HMI_BCD,G,%R00031; H_WIRE; H_WIRE; INT_TO_BCD4 Min_HMI,G,%R00022 Min_HMI_BCD,G,%R00032; END_RUNG; 
 COMMENT /* Theses 'Array Move Byte' function blocks move the BCD formated input registers into the six registers used by the 'SRV REQ' function block.
 They take six Bytes out of the six registers above and put them into 3 of the six registers used by the 'SRV REQ'. */; END_RUNG; 
 NOCON Write_Clock,G,%T00004; H_WIRE; H_WIRE; ARRAY_MOVE_BYTE 2 Month_HMI_BCD,G,%R00027 1 2 1 Month_Year,G,%R00003; H_WIRE; H_WIRE; ARRAY_MOVE_BYTE 2 Year_HMI_BCD,G,%R00028 1 1 1 Month_Year,G,%R00003; END_RUNG; 
 NOCON Write_Clock,G,%T00004; H_WIRE; H_WIRE; ARRAY_MOVE_BYTE 2 Hour_HMI_BCD,G,%R00029 1 2 1 Hours_Day,G,%R00004; H_WIRE; H_WIRE; ARRAY_MOVE_BYTE 2 Day_HMI_BCD,G,%R00030 1 1 1 Hours_Day,G,%R00004; END_RUNG; 
 NOCON Write_Clock,G,%T00004; H_WIRE; H_WIRE; ARRAY_MOVE_BYTE 2 Sec_HMI_BCD,G,%R00031 1 2 1 Sec_Min,G,%R00005; H_WIRE; H_WIRE; ARRAY_MOVE_BYTE 2 Min_HMI_BCD,G,%R00032 1 1 1 Sec_Min,G,%R00005; END_RUNG; 
 COMMENT /* This rung sets up the Service Request Function block to Write the PLC Clock. The first 'MOVE INT' puts a 1 into Register one of the six used by the 'SVC REQ'.
 This 1 tells the 'SER REQ' to 'WRITE'. The next 'MOVE INT' loads a 1 into the second of six registers. */; END_RUNG; 
 NOCON Write_Clock,G,%T00004; H_WIRE; MOVE_INT 1 1 Read_Write,G,%R00001; H_WIRE; H_WIRE; MOVE_INT 1 1 Use_BCD,G,%R00002; H_WIRE; H_WIRE; SVC_REQ 7 Read_Write,G,%R00001; END_RUNG;

You are the MAN!!!

thanks
 

Similar Topics

I am running a machine on RSLogix5 and I would like know what a good program would be to display some continuous data from a couple integers on...
Replies
6
Views
2,113
Hello, I am new to Codesys, and am trying to learn about it for a project we're developing. I've got a couple questions, but first a little...
Replies
1
Views
73
Hello, I am learning to create shapes and VB Scripts in HMIWeb Display Builder. I wanted to change color of my rounded rectangle by script. I...
Replies
0
Views
72
Got a repaired laptop back from warranty and loaded it up with all my software, unfortunately with my version V32.03 Studio 5000 I cannot change...
Replies
3
Views
168
Hello brothers We are contacting you because an error like [display change is currently controlled remotely] occurred while using the equipment we...
Replies
2
Views
174
Back
Top Bottom