ModSlaveSim help v3.07 - 4.3.1. Chromatograph
Download manual: HTML
This example is a simple simulation of a gas chromatograph. The chromatograph periodically analyzes a gas mixture to determine the proportions of its component gases (methane, propane, etc.).
GUIDE:
(To load this simulation select the file Chromatograph from File->Simulation Examples....)
When ready to start press Run Slave Simulation. Press it again to stop or pause the simulation.
As you run the simulation you will see after every cycle of 10 seconds (the Analysis period) that the Finished flag briefly changes to 1, indicating the analysis is complete, and that the gas proportions are updated. In between cycles, only the elapsed time changes, increasing until it exceeds 10 seconds, whereupon it drops down to zero again. If you clear the New data flag after an analysis is complete, you will see that it is set again when the next analysis is completed.
For further guidelines see Running Example Simulations
The program listing and explanatory notes for the simulation follow. Before looking at them, please read the short sections Introduction to programming simulations and Language: Quick Start Guide
The table below shows the simple program underlying the simulation.
Table 2. Slave 1: Chromatograph
Register Address | Register Name | Statement |
---|---|---|
$3058 | New data flag | if $5011 then 1 |
$5001 | Analysis period | |
$5010 | Elapsed time | if $$ >= $5001 then $$ + CycleTime - $5001 else $$ + CycleTime |
$5011 | Finished | if $$ != 0 then 0 else if $5010 >= $5001 then 1 |
$7001 | Nitrogen | if $5011 == 1 then if $$ < 0.30 then $$ + 0.02 else 0.20 |
$7002 | Carbon dioxide | if $5011 == 1 then if $$ < 0.40 then $$ + 0.03 else 0.30 |
$7003 | Methane | 100 - $7001 - $7002 - $7004 - $7005 |
$7004 | Ethane | if $5011 == 1 then if $$ < 0.50 then $$ + 0.04 else 0.40 |
$7005 | Propane | if $5011 == 1 then if $$ < 0.60 then $$ + 0.05 else 0.50 |
Notes.
$5001 : Analysis period. The period for the analysis is stored in register 5001, and may be set by a master.
$5010 $5011 : Elapsed time, Finished. These form a Periodic timer that sets Finished to 1 at the end of each cycle of Analysis period seconds.
-
$3058: New data flag. The chromatograph sets a "new data flag" in register 3058 when the results of a chromatograph analysis are available at the end of the analysis period.
When the value is 1, the master knows that the data is ready. Note that the chromatograph never resets the new-data flag - it is up to the master to do this when it has read the data.
-
$7003: Methane. The analysis is presented as percentages for each of 5 component gases. These percentages are frozen during the analysis cycle, but we want them to change realistically from one analysis to the next. We also want the percentages to sum to 100, which we can do by setting the largest one (methane in register 7003) to 100 minus the sum of the rest:
100 - $7001 - $7002 - $7004 - $7005
-
$7001 $7002 $7004 $7005: Nitrogen, Carbon Dioxide, Ethane, Propane. Each of the other components can be simulated by a statement that ramps the value within a specified range when Finished is set to 1, as illustrated by the statement for propane in :
if $5011 == 1 then if $$ < 0.60 then $$ + 0.05 else 0.50
Here the range is 0.50 to 0.60 and the Propane % changes in increments of 0.05.