ReferenceControlArcGet startedDesktop

Write your first Arc sequence

Write a pressurize, hold, vent, and abort sequence for the sample project tank.

In this tutorial, you write your own copy of the Press sequence from the sample project. You add one stage at a time, and you run the sequence from the Tank schematic after each step. You need no hardware, and the tutorial takes about 15 minutes.

You need Synnax Desktop with the sample project open. To open it, see explore the sample project. If you use Synnax Enterprise, you can follow this tutorial in Synnax Desktop, which is free.

The tutorial uses these channels from the sample project:

Channel What it holds
sample_press_vlv_cmd The press valve command: 1 opens it, 0 closes it.
sample_vent_vlv_cmd The vent valve command.
sample_tank_pt The tank pressure in psi, from the Tank simulator.
sample_start_cmd 1 when you click Start on the Tank schematic.
sample_abort_cmd 1 when you click Abort on the Tank schematic.

Step 1Stop the Press sequence

Your sequence writes to the same valves as the Press sequence. Stop the Press sequence so that only your sequence moves the valves.

  1. In the left nav, click Arcs (), or press A.
  2. On the Press sequence, click Stop ().

Leave the Tank simulator running. It turns the valve commands into a tank pressure.

Step 2Create an Arc automation

  1. In the Arcs toolbar, click Create Arc automation ().
  2. Type My press sequence as the name, and click Create.
  3. In the controls bar at the bottom of the editor, open the Driver list and select Node 1. This entry runs the automation inside the Synnax Core.

The status shows “Task not deployed”.

Step 3Write the first two stages

  1. Copy this code into the editor:

    sequence press {
        stage idle {
            0 -> sample_press_vlv_cmd
            0 -> sample_vent_vlv_cmd
            sample_start_cmd == 1 => pressurize
        }
        stage pressurize {
            1 -> sample_press_vlv_cmd
            0 -> sample_vent_vlv_cmd
        }
    }
    
    true => press
    • sequence press holds stages. One stage of the sequence is active at a time.
    • 0 -> sample_press_vlv_cmd writes 0 to the channel when the stage starts.
    • sample_start_cmd == 1 => pressurize moves the sequence to pressurize when you click Start.
    • true => press starts the sequence, at its first stage, when the automation starts.
  2. Click Start () in the controls bar. The status shows “Started task”.

  3. Select the Tank tab, and click Start on the schematic.

The press valve opens, and the pressure climbs on the Tank pressure line plot. The sequence stays in pressurize, because the stage has no way out yet. The control legend on the schematic shows My press sequence.

Your automation writes at authority 255, the default. The schematic writes at 1, so a click on a valve has no effect while your automation runs. See control authority.

Step 4Hold and vent

  1. Replace the code with this code. It adds import time, a condition in pressurize, and the hold and vent stages:

    import time
    
    sequence press {
        stage idle {
            0 -> sample_press_vlv_cmd
            0 -> sample_vent_vlv_cmd
            sample_start_cmd == 1 => pressurize
        }
        stage pressurize {
            1 -> sample_press_vlv_cmd
            0 -> sample_vent_vlv_cmd
            sample_tank_pt > 300 => hold
        }
        stage hold {
            0 -> sample_press_vlv_cmd
            time.wait(duration=10s) => vent
        }
        stage vent {
            1 -> sample_vent_vlv_cmd
            sample_tank_pt < 5 => idle
        }
    }
    
    true => press
    • time.wait(duration=10s) => vent moves to vent 10 seconds after hold starts.
    • sample_tank_pt < 5 => idle goes back to idle, so you can run the test again.
  2. Click Redeploy in the controls bar. The automation starts again with the new code, in the idle stage.

  3. On the Tank schematic, click Start.

The tank is still near 500 psi from step 3, so the first run goes straight to hold, then vents. When the pressure is below 5 psi, click Start again. The pressure climbs to 300 psi, holds for 10 seconds, and falls.

To change timing precision and CPU use, see set the performance level.

Step 5Add an abort

  1. Replace the code with this code. It adds an abort stage, and conditions that move to it from pressurize and hold:

    import time
    
    sequence press {
        stage idle {
            0 -> sample_press_vlv_cmd
            0 -> sample_vent_vlv_cmd
            sample_start_cmd == 1 => pressurize
        }
        stage pressurize {
            1 -> sample_press_vlv_cmd
            0 -> sample_vent_vlv_cmd
            sample_tank_pt > 450 => abort
            sample_abort_cmd == 1 => abort
            sample_tank_pt > 300 => hold
        }
        stage hold {
            0 -> sample_press_vlv_cmd
            sample_abort_cmd == 1 => abort
            time.wait(duration=10s) => vent
        }
        stage vent {
            1 -> sample_vent_vlv_cmd
            sample_tank_pt < 5 => idle
        }
        stage abort {
            0 -> sample_press_vlv_cmd
            1 -> sample_vent_vlv_cmd
            sample_start_cmd == 1 => pressurize
        }
    }
    
    true => press

    When more than one condition in a stage is true, the first one in the code wins. Put the safety checks first.

  2. Click Redeploy.

  3. On the Tank schematic, click Start. Before the hold ends, click Abort.

The press valve closes, the vent valve opens, and the pressure falls. To run the test again, click Start.

Step 6Put the sample project back

  1. In the controls bar of your automation, click Stop ().
  2. In the Arcs toolbar, click Start () on the Press sequence.

The Press sequence starts in its idle stage, and the sample project works as before. You can keep your automation, or delete it from the Arcs toolbar.

Next steps