# Writing Ignition Time to PLC

**URL:** <https://forum.inductiveautomation.com/t/writing-ignition-time-to-plc/50951>\
**Category:** Ignition\
**Created:** [September 14, 2021, 12:24pm UTC](https://forum.inductiveautomation.com/t/writing-ignition-time-to-plc/50951 "2021-09-14T12:24:01Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmszr3](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@cmszr3](https://forum.inductiveautomation.com/u/cmszr3)\
**Post date:** [September 14, 2021, 12:24pm UTC](https://forum.inductiveautomation.com/t/writing-ignition-time-to-plc/50951/1 "2021-09-14T12:24:01Z")

</div>

Good Morning -

I am wanting to use the Ignition Server time to log some PLC stored data. Has anyone ever used Ignition time to sync with an Allen-Bradley PLC?

Thanks in Advance,  
Caitlyn

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 14, 2021, 12:36pm UTC](https://forum.inductiveautomation.com/t/writing-ignition-time-to-plc/50951/2 "2021-09-14T12:36:05Z")

</div>

Hi Caitlyn,

It is much easier and more accurate to go the other way. Sync your Logix PLC to something like a Time Machines’ TM2000B, and also have your Ignition Server use that as its NTP source. In the PLC when logging data into an array, use a GSV of the WallClock object’s CurrentValue. That is an LINT microseconds UTC, and it will be accurate to single-digit microseconds or better. Ignition can’t do that itself.

---

<div class="post-metadata">

**Author:** ![DSI600](https://avatars.discourse-cdn.com/v4/letter/d/ad7895/32.png) [@DSI600](https://forum.inductiveautomation.com/u/DSI600)\
**Post date:** [September 14, 2021, 12:46pm UTC](https://forum.inductiveautomation.com/t/writing-ignition-time-to-plc/50951/3 "2021-09-14T12:46:52Z")

</div>

+1 for the TM2000B device, but for the instances where a customer doesn’t want the extra device and at a minimum you need SCADA and the PLC at the same time (even though it may not be accurate) here is a script we use. For later versions of Ignition this runs in a gateway event script (Scheduled) or just put it in a gateway event script (Timer)

```auto
year = system.date.format(system.date.now(), "yyyy")
month = system.date.format(system.date.now(), "M")
day = system.date.format(system.date.now(), "d")
hour = system.date.format(system.date.now(), "H")
min = system.date.format(system.date.now(), "m")
second = system.date.format(system.date.now(), "s")
msecond = system.date.format(system.date.now(), "S")

#Specify the full tag path to the PLC OPC tags
paths = [
		"pathToPLCTag_year",
		"pathToPLCTag_month",
		"pathToPLCTag_day",
		"pathToPLCTag_hour",
		"pathToPLCTag_min",
		"pathToPLCTag_sec",
		"pathToPLCTag_mSec"
		]

# Specify the values
values = [
		year,
		month,
		day,
		hour,
		min,
		second,
		msecond	
		]

if not initialChange:
	system.tag.writeBlocking(paths, values)

```

---

<div class="post-metadata">

**Author:** ![cmszr3](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@cmszr3](https://forum.inductiveautomation.com/u/cmszr3)\
**Post date:** [September 14, 2021, 12:52pm UTC](https://forum.inductiveautomation.com/t/writing-ignition-time-to-plc/50951/4 "2021-09-14T12:52:31Z")

</div>

Typically I would take that route but no additional hardware is part of this project unfortunately. Gotta work with what we have.

---

<div class="post-metadata">

**Author:** ![cmszr3](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@cmszr3](https://forum.inductiveautomation.com/u/cmszr3)\
**Post date:** [September 14, 2021, 12:53pm UTC](https://forum.inductiveautomation.com/t/writing-ignition-time-to-plc/50951/5 "2021-09-14T12:53:21Z")

</div>

That’s exactly what I was looking for. Thank you so much!

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 14, 2021, 1:10pm UTC](https://forum.inductiveautomation.com/t/writing-ignition-time-to-plc/50951/6 "2021-09-14T13:10:01Z")

</div>

Even if you don’t have a precision source, use the LINT format to read and write time. Messaging can interleave with logic, so broken-out time elements will eventually bite you in the [expletive].

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [September 14, 2021, 10:45pm UTC](https://forum.inductiveautomation.com/t/writing-ignition-time-to-plc/50951/7 "2021-09-14T22:45:15Z")

</div>

> [@DSI600](#):
>
> ```auto
> year = system.date.format(system.date.now(), "yyyy")
> month = system.date.format(system.date.now(), "M")
> day = system.date.format(system.date.now(), "d")
> hour = system.date.format(system.date.now(), "H")
> min = system.date.format(system.date.now(), "m")
> second = system.date.format(system.date.now(), "s")
> msecond = system.date.format(system.date.now(), "S")
> 
> ```

Using that, you could - in very rare instances - end up with the values out of sync with each other depending on when it's run. For example, imagine it calculates just before midnight of the eve of the last day of december, and it actually crosses over into 1st jan of next year in the time that the code runs. You could end up with:

```auto
year = 2021
## ticks over to 2022
month = 1
day = 1
hour = 0
min = 0
second = 0
msecond = 100

```

instead of

```auto
year = 2021
month = 12
day = 31
hour = 23
min = 59
second = 59
msecond = 300

```

for example.  
Best to store `now` and then manipulate that, despite the slight offset it'll cause imo.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [September 15, 2021, 10:57am UTC](https://forum.inductiveautomation.com/t/writing-ignition-time-to-plc/50951/8 "2021-09-15T10:57:30Z")

</div>

+1 for the TM2000B, as well. Especially because I use one. (Okay, it was the 2000A. I was an early adopter)

Other alternatives to consider.

- _ **Linux:** _ install PTPd on the gateway and configure it as a master. Logix platforms use PTP, so you would just have to tick on the clock sync checkbox on the PLC.
- _ **Also Linux:** _ install NTPd. Later CompactLogix firmwares support sockets, and some ContorlLogix ethernet modules already supported them. Install the NTP AOI available at Rockwell’s sample code section.
- _ **Windows:** _ install the Logix5000 Clock Update Tool and run it as a service.

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [September 15, 2021, 4:15pm UTC](https://forum.inductiveautomation.com/t/writing-ignition-time-to-plc/50951/9 "2021-09-15T16:15:05Z")

</div>

I have a need for this type of device on an air gapped network, does anyone know what kind of cable length can be used with the amplified antenna? Ive read everything on their web site and, don’t see any mention of realistic cable length.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 15, 2021, 5:19pm UTC](https://forum.inductiveautomation.com/t/writing-ignition-time-to-plc/50951/10 "2021-09-15T17:19:40Z")

</div>

I’m not sure how cable length matters for an air-gapped setup… But the Time Machines’ outdoor antenna products brochure says they can use 250ft of rg58 cable.

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [September 15, 2021, 5:20pm UTC](https://forum.inductiveautomation.com/t/writing-ignition-time-to-plc/50951/11 "2021-09-15T17:20:46Z")

</div>

It doesn’t matter for the air-gapped part, it matters because the building is a huge concrete structure. Ty for the info!
