Integer math help

We are trying to set the date and time to a device over Modbus. The spec for the device seems easy, just not sure if ignition has the math to do it. You just set a few registers, but here is the problem. On a single register we need to set the first 8 bits to the day and the second 8 bits to the month. Is there a way to do this in ignition?



bits 15 to 8 = month (1 to 12) P3: bits 7 to 0 = day (1 to 31)

How about something like this:

month = 1
day = 30
dataReg = (month<<8)+day
1 Like

You may need to flip the order around - Modbus is supposed to be big-endian, but word order differs between different devices.

today =
day =
month = + 1

word = (month<<8) | day

system.tag.write("SomeTag", word)
1 Like

Thanks, This will get us well on our way.