IMD SolutionComputing LibraryShop main store

How-to

Log analog millivolt signals as booleans in Ignition

Edge computing and IIoT Published 7 min read

Short answer

Threshold the millivolt signal in an expression tag with a Boolean data type, enable tag history on that tag only with Sample Mode set to On Change, and disable history on the analog tag. Every stored row is then a 0 or 1 written on a transition instead of a float written on every deadband crossing.

On this page
  1. Why does the historian store floats for a digital signal?
  2. Does the signal need a threshold or hysteresis?
  3. How do you build the boolean expression tag?
  4. How do you add hysteresis when the signal dwells mid-band?
  5. Which tag gets history, and in what sample mode?
  6. How much database space does on-change logging save?
  7. How do you verify the rows in SQL Server?
  8. Questions asked

Two digital proximity switches land on analog inputs as 0-1000 mV, and the tag historian logs exactly what the tag carries: a float, written every time the value crosses its deadband. The historian has no threshold logic, so the boolean has to exist as a tag before history points at it. Build one expression tag per switch with the expression {[.]AnalogTag} > 475, enable history on that tag with Sample Mode set to On Change, and set History Enabled to false on the analog tags. Only the expression tags are historized, so nothing is stored twice. The steps are written for Ignition 8.0 logging to SQL Server Express.

Why does the historian store floats for a digital signal? #

Because the tag historian stores whatever value and data type the tag itself carries, and your analog input tag carries a float in millivolts; the historian has no threshold logic, so the conversion has to exist in a tag before history is enabled on it.

Every scan where noise or drift pushes the value outside the deadband produces another float row, on a SQL Server Express instance that caps each database's size — check the limit for your edition. The switches are digital in nature: below about 50 mV reads as 0 and above about 900 mV reads as 1, and the band between them is crossed, not occupied. The fix changes what gets logged, not how the historian samples it:

Setting Before After
Historized tag Analog input tag (float, mV) Expression tag (Boolean)
Sample Mode Deadband-driven On Change
History on analog tag Enabled Disabled
Rows from signal noise Every deadband crossing None

Converting at the tag layer is the same pattern used when an engineering value is needed instead of a state; historian tag scaling for an unscaled PLC integer value walks that case. Here the wanted output is a state, so the conversion is a comparison, not a scale.

Does the signal need a threshold or hysteresis? #

Start with a single threshold at 475 mV, the midpoint of the 50 mV and 900 mV switching limits, because a proximity output crosses that band in one scan; add hysteresis only if trends later show chatter at the transitions.

The midpoint arithmetic: (50 + 900) / 2 = 475 mV, leaving 475 − 50 = 425 mV of margin below and 900 − 475 = 425 mV above. A switching output that behaves like a transistor passes through 50-900 mV for an instant, so one comparison is enough. Trend the analog tag through several actuations first: if every transition crosses the band within one scan and you never see intermediate values, the single threshold holds.

Signal condition Logic Where it lives
Clean transitions, no dwell between 50 and 900 mV Threshold at the 475 mV midpoint Plain expression tag
Slow edges, ripple, or a switch that can sit mid-band On above 900 mV, off at or below 50 mV, hold state in between Expression calling objectScript() with a state variable

Decision: run the single threshold and watch the stored history. Move to hysteresis only when the data shows repeated 0/1 toggling at one transition.

How do you build the boolean expression tag? #

Create one expression tag per proximity switch in the same folder as the analog tag, set its data type to Boolean, and give it the expression {[.]AnalogTag} > 475, where AnalogTag is your analog tag's name.

First confirm in the tag browser that the analog tag spans the expected range with the switches actuated and cleared. Then:

  1. In the tag browser, create a new tag in the same folder as the analog tag, one per switch.
  2. Set Value Source to Expression.
  3. Set Data Type to Boolean.
  4. Enter the expression:
{[.]AnalogTag} > 475
  1. Save the tag, actuate the switch, and watch the value flip between false and true.

The [.] prefix is a relative tag path: it resolves against the folder the expression tag lives in, so copying the folder for the second switch keeps the reference valid. If the tag shows bad or error quality, the reference path is wrong — that is a binding fault, not a signal fault. The tag must settle at quality Good and track the switch with no visible lag.

How do you add hysteresis when the signal dwells mid-band? #

Use the objectScript() expression function from the third-party Simulation Aids module to hold prior output between evaluations, because a standard expression is stateless and cannot remember whether the output was last true or false.

Standard expression syntax cannot store the previous output, and hysteresis needs it. objectScript() supplies that state as binding.state, a dictionary that persists between evaluations; args[0] is the analog value passed in. The module must be installed before the function exists. Use it as the boolean tag's expression:

objectScript("someModule.thresholdFunction(binding.state, args[0])", {[.]AnalogTag})

someModule is the project script library you create for the function:

def thresholdFunction(state, milliVolts):
    # state: dict persisted by objectScript(), empty on the first evaluation
    # milliVolts: float, the analog tag's value in mV
    if 'prior' in state:
        if state['prior']:
            result = milliVolts > 50
        else:
            result = milliVolts > 900
    else:
        result = milliVolts > 475
    state['prior'] = result
    return result

Once true, the output stays true until the input drops to 50 mV or below; once false, it stays false until the input exceeds 900 mV. The first evaluation after a gateway restart has no prior state and uses the midpoint. Test it by holding the analog value mid-band — a bench source or a written simulated value near 500 mV — and confirming the boolean holds its last state instead of toggling. If you do not want a third-party module on the gateway, stay with the single threshold and accept the rare chatter row.

Which tag gets history, and in what sample mode? #

Enable history on the boolean expression tag only, with Sample Mode set to On Change and your SQL Server provider selected, then set History Enabled to false on the analog tag so it stops writing rows entirely.

  1. Open the boolean expression tag's properties and set History Enabled to true.
  2. Set Sample Mode to On Change, the mode documented on the tag history configuration page of the Ignition User Manual for storing a value when it changes rather than on a period or deadband.
  3. Select your SQL Server historian provider under History Provider.
  4. Read Max Time Between Samples on the same tag. A non-zero value writes a heartbeat row at that interval even when the value is steady; leave it at zero for strictly on-change rows, or set a long interval for periodic proof of life.
  5. Open each analog tag and set History Enabled to false.

Existing analog history is untouched: disabling stops new rows, it does not delete old ones, and the boolean is a new tag path in every query and trend. In the historian provider's Status view, the boolean tags should show as logging and the analog tags as not logging.

How much database space does on-change logging save? #

With two switches actuated eight times per hour each, the boolean tags store 32 rows per hour, while the analog tags stored a row on every deadband crossing — including the ones noise caused.

The boolean arithmetic, with example inputs you replace with your own actuation count: 2 switches × 8 actuations per hour = 16 actuations, each actuation being one rising and one falling transition, so 16 × 2 = 32 rows per hour and 32 × 24 = 768 rows per day, each row an integer 0 or 1.

For comparison, an analog input whose noise crosses the historian's deadband twice a minute writes 2 × 60 = 120 rows per hour per tag; two tags give 240 rows per hour and 240 × 24 = 5,760 rows per day, each carrying a float. Those deadband crossings are illustrative — substitute your observed rate — but the shape of the result is the point: boolean growth scales with actuations, analog growth scales with noise. On SQL Server Express, with its per-database size cap, that difference decides how long the partition tables live before retention must trim them; setting historian pruning and retention for Ignition tag history covers the prune settings.

How do you verify the rows in SQL Server? #

Actuate each switch three times, confirm six transitions on a chart of the boolean tag, then query the historian's data partition and check that new rows for the boolean tag paths hold integer 0 and 1 values.

  1. With the gateway running, actuate and release each switch three times.
  2. Put a chart or tag history binding on each boolean tag and confirm six transitions per switch — three true, three false — in the order you performed them.
  3. Query the historian's data partition tables and confirm the new rows for the boolean tag paths hold 0 and 1, since the historian stores a Boolean as an integer; where the Ignition Edge tag historian writes its data maps the table layout. Confirm there are no new rows for the analog tag paths.
  4. Leave both switches static for longer than Max Time Between Samples and confirm the row count matches the setting: zero extra rows at zero, one per interval otherwise.
  5. Restart the gateway with one switch actuated and confirm the boolean resumes in the correct state, which proves the first-evaluation fallback when hysteresis is in use.

When all five checks pass, the conversion is complete: the database holds 0/1 rows on change, the analog floats have stopped accumulating, and the original analog history remains queryable under its old tag paths.

Questions asked

What happens to the analog tag's old rows after history is disabled?

They stay where they are. Disabling history stops new rows; it does not delete existing ones, and the old analog data remains queryable under its original tag path. Treat the boolean as a new tag path in trends and reports, and keep the old rows when you need the audit trail. When you want the space back, the prune settings are the lever, not the history flag.

Why threshold at 475 mV instead of 900 mV?

Because 475 mV is the midpoint of the two switching limits: (50 + 900) / 2 = 475, leaving 425 mV of margin to each side. Thresholding at 900 mV would trip late on any signal that rises slowly or rests slightly below the high limit. Move the constant toward the noisier side of the band only if the resting level hugs one limit.

Can this be done without adding any tags?

No. The tag historian records the value of the tag it is enabled on, so a boolean can only be logged by a tag that carries a boolean. The expression tags are the lightest form of that: they evaluate at runtime, only they are historized, and the analog tags stop writing, so the database never stores the signal twice.

What does Max Time Between Samples do on the boolean tag?

It forces a heartbeat row at that interval even when the value has not changed, proving the historian connection is alive on quiet signals. Set it to zero for strictly on-change rows, or leave a long interval if reports need periodic proof of life. Verify the effect by leaving both switches static longer than the setting and counting rows.

What happens when the analog input goes to bad quality?

The expression tag inherits the bad quality from its input, and the historian records the quality state instead of a clean 0 or 1, so reports should filter on quality. Put the alarm on the analog input tag, not the expression tag, so a broken wire or failed channel surfaces as an alarm rather than as a gap in the history.

Keep reading

  • Troubleshooting

    Ignition historian logs memory tags but not OPC tag changes

    Memory tags record because their history subscription was created fresh; the migrated OPC tags carry a stale recording subscription that a storage-provider field edit alone does not rebuild. Fix one tag first: disable history, save, re-enable history with the production provider, and save again, then verify with one safely forceable fault before batching across the remaining tags.

    Edge computing and IIoT

  • How-to

    Setting historian pruning and retention for Ignition tag history

    Prune tag history on the history provider, not with the transaction group's delete setting: in the Gateway's tag history configuration, enable data pruning and set a retention period in days. At 250 MB per day of growth, 30 days of retention holds about 7.5 GB and a full year about 91 GB. Deadband and Max Time Between Samples decide most of the daily rate, and QC records from transaction groups keep growing on a separate budget.

    Edge computing and IIoT

  • Troubleshooting

    Why Ignition tag historian tables are not created

    In Ignition tag history, periodic mode still stores nothing until the tag value changes once and fires the initial store. A connection that reads Valid and a login with full write rights are never exercised before that first store, so a static tag keeps zero rows even at a one-second sample rate. Force one controlled value change, count the rows, and only then look at provider or database permissions.

    Edge computing and IIoT