ModMultiSim help v3.04 - 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.).
(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 table below shows the simple program underlying the simulation.
|Register Address||Register Name||Statement|
|$3058||New data flag||
if $$ >= $5001 then $$ + CycleTime - $5001 else $$ + CycleTime
if $$ != 0 then 0 else if $5010 >= $5001 then 1
$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.