First Program
This guide will walk you through creating a program.
For this guide it is assumed:
- A Micro-Vu machine is connected to the computer
- InSpec is open and the machine has been initialized.
- Automated control has been enabled
- An InSpec program should be saved and ready to run.
To enable automated control of InSpec, navigate to Tools>Automation>Enable Automated Control.
First create a new device to connect to InSpec.
Give it a name and leave the Host as localhost
since the machine is connected to the same computer.
For Directory, browse to the folder containing InSpec programs.
Switch to the Variables tab and create a new variable.
Name it count
since this program will count the number of times the InSpec program completes.
Set the Type to Uint32
and the Initial Value to 0. Be sure to press Save for the changes to be applied.
Nearly all programs will use the OnStart event.
It serves as the starting point of the routine.
The event is emitted exactly once so it is safe to do initialization with it.
To add the OnStart event to the routine simply drag it from the command panel on the right or use the shortcut ss
.
Next we will run a part program in InSpec.
Drag the RunProgram command from the side panel or use the shortcut rr
.
We want the InSpec program to run as soon as the routine is started so drag the output of OnStart to the trigger of RunProgram.
Select the device from the dropdown and input the name of the InSpec program below it.
This part is optional, but if any feature fails, is out of tolerance, or the machine has a fault we’ll stop the current InSpec program immediately.
Drag the OnFeatureFailed, OnOutOfTolerance, and OnFault output events to the trigger of StopRunning.
Don’t forget to set the device too.
Now add an Arithmetic command (shortcut: ar
).
We will increment count
every time the InSpec program successfully finishes.
Connect the OnFinished output to the trigger of Arithmetic.
Set the operator to +
and the second operand to 1
.
To get the value of the count
variable, add the GetVariable command (shortcut: gv
).
Select the count
variable from the dropdown.
Connect the Value output to the first operand of Arithmetic.
Notice that we are using the passive output of GetVariable.
This is because we are trying to change the value of count
so using the OnChange event to trigger the change would not work.
Now that the correct value is being calculated we need to store it back in the count
variable.
Add a SetVariable command (shortcut: sv
) and set the variable to count
.
Connect the Result of the Arithmetic command to the Value input of SetVariable.
Now when the program is finished count
will be incremented by 1.
However, the InSpec program will only run one time so the most count
can be is one.
To allow the program to keep running we need to create a cycle.
Add a Wait command (shortcut: ww
), set the time to 1000
ms or greater (to add some delay between cycles).
Connect the OnChange output to the trigger of Wait and the output of Wait to the trigger of RunProgram.
Now when either the routine is started or the variable count
is changed the InSpec program will run.
Since count
is only incremented when the InSpec program successfully completes, the cycle will continue as long as parts pass.
If any fail the loop will stop.
The routine is now complete. Press Start at the top of the program to see it in action.
Since the InSpec program takes time to complete, the RunProgram command will stay yellow as long is the program is running.
If the part was measured successfully, you should now see the Wait command lit up.
The other commands complete instaneously so you may not see them light up.
The count
variable should now be equal to 1 and the program will run again.