Table-Based DSL for Testing HART Sensors in Production Systems
Developing a system for calibrating and testing smart sensors with HART protocol requires supporting diverse hardware: signal generators, environmental chambers, multimeters, HART modems, and switches. The HART protocol operates in point-to-point mode over a 4-20 mA current loop, enabling calibration, configuration, and data exchange. Tests cover characteristic linearization, pressure and temperature cycles, power supply variations, and HART sessions. A client-server architecture using pure SQL with a table-based scripting language allowed a two-person team to implement editable tests across multiple stations.
System Decomposition into Subsystems
The system is divided into key components:
- Hardware control via LabVIEW.
- Test programming in a table-based DSL.
- Data processing and calculations in the database.
- Real-time SCADA-style station monitoring.
LabVIEW was chosen for its ready-made drivers for USB, GPIB, TCP/IP, and RS232 interfaces. The client on the test station acts as an interpreter for commands from the database, skipping OOP abstractions. Test logic is offloaded to server-side scripts, keeping LabVIEW diagrams simple.
Table-Based Scripting Language: Structure and Commands
The DSL is implemented as database tables with linear and looped execution. Each row is an operation with two parameters, making editing straightforward. Indirect addressing is supported within loops.
Key DSL Features:
- Linear operation flow.
- Loops over stimuli (pressure, temperature, channels).
- Timer-based loops.
- Initialization of static stimulus models.
- Over 100 operations for HART communication, measurements, and data logging.
Loops are handled by SQL stored procedures: separate tables store parameters (start, end, step, current value, active sensor pool). Commands like INIT_LOOP and CHECK_END_LOOP control execution. For stimulus loops, a modifiers table handles pre/post-increment logic.
Example loop logic:
- Load stimulus model from database.
- Initialize loop with parameters.
- Execute operations until exit condition.
- Proceed to next command after loop.
Loop Implementation and Optimization
Experiments with SQL procedures proved loops work reliably in the database. Loop parameters (start/end value, step) are stored in tables, enabling dynamic test generation.
Loop Types:
- General loop: over a variable for a sensor pool on a station.
- Pressure loop: with step and stimulus boundaries.
- Temperature loop: chamber initialization.
- Timer loop: repeat operations until time expires.
Adding loops halved test sizes. Operations are adapted: iteration-dependent or independent (for timers).
The table-based test editor automates row numbering, command references, comments, and loop adjustments. A "compilation" stored procedure replaces old tests with new ones. Copy-paste support and interactive hints speed up development. Over 100 programs have been created for production and periodic testing of 4-20 mA/HART sensors.
Hardware and Database Integration
The LabVIEW client fetches scripts from the database and interprets commands sequentially. Long-running operations (stimulus loops) don't demand high speed. Raw data is saved to the database for calculations and report generation.
Approach Benefits:
- Edit tests without recompiling the client.
- Centralized script and data storage.
- Scalable to dozens of stations.
- Minimal development team.
Key Takeaways
- Table-based SQL DSL with loops cuts test code in half while staying fully flexible.
- LabVIEW as a database command interpreter avoids OOP complexity.
- Two parameters per operation for 100+ HART testing commands.
- Automatic reference and numbering fixes in stored procedures.
- Real-time station monitoring via SCADA-like interface.
— Editorial Team
No comments yet.