Logic
This part covers logic and its building blocks: control groups, controls, condition groups, action groups, conditions, and actions.
Logic
Logic is the workspace where all algorithm blocks are created.
- Algorithm blocks contained in a logic execute at each execution cycle of that logic.
- Multiple logics can be created within a single project.
- When multiple logics exist, each logic runs simultaneously regardless of order.
Add a logic with + in the left menu. Each logic has the following settings.
Enabled
Sets whether the logic is used. Disabled logics do not execute.
Name
Enter the display name. Any name can be used.
Execution Cycle
Sets the execution cycle of the logic. The blocks in the logic execute at the specified cycle; choose a value appropriate for your hardware and control objective. Shorter cycles give faster response but higher CPU usage. The minimum is 1 millisecond, and 50 to 100 milliseconds is suitable for general use.
For example, if the execution cycle is 50 milliseconds and all blocks take 5 milliseconds to run, the system waits for the remaining 45 milliseconds before executing the blocks again.
Reverse Execution
Reverses the execution order of child blocks. When off, blocks execute top to bottom; when on, bottom to top.
Edit, Duplicate, Delete
Manage logics with the Edit, Duplicate, and Delete buttons in the left menu. Deleted logics are moved to the trash and removed automatically after 30 days (Part 3).
Block Selection Mode / Clipboard
Select multiple blocks (controls, conditions, actions, etc.) at once to duplicate, delete, copy, cut, and paste them in bulk. Click the checkbox icon in the top-right corner to enter selection mode, click blocks to select them, and use the action buttons in the header. Pasting works within the same logic and across different logics.
| Shortcut | Action |
|---|---|
Ctrl+C | Copy |
Ctrl+X | Cut |
Ctrl+V | Paste |
Delete | Delete |
Esc | Exit selection mode |
Control Group
A control group bundles multiple controls into one group and configures how they execute. Control groups can only be added directly under a logic, either with + Add in the upper right or with the + button shown above or below existing blocks.
Priority Mode
Determines which control executes when multiple controls in the group satisfy their conditions at the same time.
- None: No priority is applied. Each control executes in its order within the group when its condition is met.
- By Priority: Among controls whose conditions are met, the one with the highest priority executes. Lower numbers mean higher priority; if a higher-priority condition is met while another control is running, the running control is stopped immediately and the higher-priority control executes.
- First Only: The control whose condition was met first executes. After it completes, if its condition is no longer met, the next control that met its condition executes.
- Last Only: The control whose condition was met last takes precedence, and any currently running control is stopped immediately.
Common Settings and Management
Enabled, Name, and Reverse Execution behave the same as for logic. Move blocks by drag and drop, and edit, duplicate, or delete them from the right-click menu. Deleting a group also deletes all blocks it contains.
Control
A control is the basic execution unit of algorithm blocks, consisting of a condition area and an action area. When the condition area is met, the actions execute in order, and after all actions complete, the condition area is evaluated again. When one logic holds several controls, they run in order from the top, and once the last one finishes execution returns to the first.
The condition area can contain conditions and condition groups; the action area can contain actions, action groups, and controls. Nested structures are supported, so you can build configurations that branch into different actions depending on the situation after a condition is met.
Condition Operator
The operator that combines multiple conditions or condition groups in the condition area.
- AND: Actions execute only when every condition and condition group in the condition area is met.
- OR: Actions execute when at least one condition or condition group is met.
Condition Option
An option applied to how the condition area is evaluated.
- None: The condition is met when true and not met when false.
- Invert: The condition is met when false and not met when true.
- Rising Edge: Met only at the moment the condition changes from false to true. Example: the moment a push button is pressed.
- Falling Edge: Met only at the moment the condition changes from true to false. Example: the moment a pressed push button is released.
- Hold Time: Met once when the condition stays true for the specified hold time. The hold time resets to zero when the condition is met or becomes false during the hold period. Example: holding a push button for 3 seconds.
- Count: The count increases by one each time the condition changes from false to true, and the condition is met once when the count reaches the specified value. The count resets to zero when met, or when the timeout expires. Example: pressing a push button 3 times.
With Count selected, you also set the count, the timeout, and the Timeout Mode. Interval Time requires the interval between the moments the condition becomes true to stay within the timeout (e.g. pressing 3 times with intervals shorter than 1 second). Total Time requires the total time from the first true moment until the full count to stay within the timeout (e.g. 3 presses within 5 seconds of the first press).
Priority
Enter the priority to apply when the control belongs to a control group whose priority mode is By Priority. Leave it empty if not applicable.
Common Settings and Management
Enabled, Name, and Reverse Execution behave the same as for logic. Move controls by drag and drop, and edit, duplicate, or delete them from the right-click menu. Deleting a control also deletes all blocks it contains.
Condition Group
A condition group bundles multiple conditions or condition groups and calculates whether the combined result is met. Condition groups can be nested, enabling complex logical expressions.
The Operator (AND / OR) and Option work the same way as the control's condition operator and condition option, and the option applies to the combined result of the group. For example, a rule such as "all three conditions stay true for 3 seconds" is built by applying the Hold Time option to the condition group rather than to each condition.
Action Group
An action group bundles multiple actions and sets how the group repeats: by count, range, condition, or duration. Action groups can contain actions, action groups, and controls, and support nesting.
Repeat Options
- By Count: Repeats the group the specified number of times.
- By Range: Repeats from the start value to the end value, incrementing by the step. The current index is stored in the selected index variable, which must be of numeric type.
- While Condition is Met: Repeats while the repeat condition is true. The repeat condition is written with block coding and must return a digital value. It is checked at the start of each iteration, so an iteration in progress runs to completion even if the value becomes false.
- For Duration: Repeats for the specified time. Expiration is also checked at the start of each iteration, so an iteration in progress runs to completion even if time runs out.
Depending on the selected repeat option, the Repeat Count, Index Variable, From, To, Step, Repeat Condition, and Repeat Duration fields are displayed. Enabled, Name, Reverse Execution, and the move/edit/duplicate/delete operations are the same as for other blocks.
Condition
Add a condition inside a control or condition group, or with the + button shown above or below blocks in the condition area. Each condition has an enable state, a name, a type, and an option; the option works the same as the control's condition option.
Condition Types
| Group | Type | Description |
|---|---|---|
| Logic | Always | Always met. Use this when an action should always run. |
| Once | Met only once at startup, then never again. Useful for one-time initialization such as setting default variable values. | |
| Compare | Compares a variable's value against a specified value. The most commonly used type. | |
| Date/Time | Schedule | Met on specified dates. Repeat intervals can be set by day, week, month, or year (weekly intervals also take the days of the week), and the end option is No End, End Date, or Repeat Count. |
| Time Range | Met only during specified time ranges within a day. Multiple ranges can be configured. | |
| Periodic | Met for one cycle (one logic execution cycle) at regular intervals. Use this for actions that run periodically. | |
| State | Watch Condition | References whether another condition, condition group, or control is met. Useful for reusing existing conditions. |
| Watch Action | Uses the execution state of another action, action group, control, or control group (Not Started, Running, Complete, Error) as a condition. | |
| On Change | Met for one cycle whenever a variable's value changes. Tolerance and Sampling Period tune what counts as a change. | |
| Misc. | Custom Condition | Write the condition yourself with block coding. The blocks must return a digital value. |
Action
Add an action inside a control or action group, or with the + button shown above or below blocks in the action area. Each action has an enable state, a name, and a type, and the detail settings depend on the type. Most action types use resources registered in advance in the Settings menu (Part 6).
Added actions are edited, duplicated, and deleted from the block's … menu, and reordered by drag and drop. Conditions can only be moved within the condition area, and actions only within the action area.
Action Types
| Group | Type | Description |
|---|---|---|
| Hardware | I/O Device Control | Controls various I/O devices such as LEDs, sensors, LCDs, and motors. |
| System | Set Variable | Writes a value to a variable. Write Mode also performs inversion, arithmetic, and string appending. |
| Shell Command | Executes terminal commands. Can run system commands or launch external programs. | |
| Read/Write File | Reads from or writes to files. Supports text and binary formats. | |
| File System | Creates, deletes, moves, or copies files and directories. | |
| Delay | Waits for a specified duration. Normal mode works in milliseconds and Precision mode in microseconds (0 to 999μs). | |
| Timer | Controls a timer with five commands: Start, Stop, Reset, Set Time, and Get Time. Useful for measuring elapsed time or implementing timeouts. | |
| Data | Collection | Adds, removes, or retrieves data from collections. Supports list and map types. |
| Database | Stores or retrieves data from databases. Supports SQL, Firebase, and more. | |
| Statistics | Calculates real-time statistics such as average, max, min, and sum from collected data. | |
| Data Logging | Records current variable values to the specified data logging channel. | |
| Media | Play Media | Plays, pauses, or stops audio/video files or URLs. |
| Display Image | Displays an image on screen. Specify a file path or URL. | |
| Synthesizer | Plays notes on a virtual instrument. Set pitch and duration, or play MIDI files. | |
| Camera | Captures images or starts/stops video web streaming from the camera. | |
| Audio Analysis | Analyzes audio frequencies and amplitudes in real time using FFT (Fast Fourier Transform). | |
| Record Audio | Records audio from the microphone. | |
| Transform Audio | Adjusts the tempo and pitch of audio files. | |
| AI | AI Analysis | Performs AI analysis on video or audio. See the AI Analysis section below. |
| LLM AI Query | Sends a text query with optional attachments to the LLM AI provider and stores the response in a variable. | |
| Text-to-Speech (TTS) | Converts text to speech using AI. Supports built-in local models and online AI services. | |
| Speech-to-Text (STT) | Converts speech to text using AI. Supports built-in local models and online AI services. | |
| IoT | Telegram Message | Sends or receives messages via a Telegram bot. |
| Send Email | Sends emails via SMTP. | |
| Push Notification | Sends a push notification to the user's mobile app. | |
| Zigbee Device Control | Reads sensor values or controls actuators of Zigbee devices. Supports 3,400+ devices via Zigbee2MQTT (an open-source bridge that connects Zigbee devices over MQTT). | |
| Home Assistant Integration | Controls Home Assistant sensors, switches, and lights, or exposes Grablo variables to Home Assistant. | |
| Communication | MQTT Communication | Publishes (sends) or subscribes to (receives) messages using MQTT, the standard IoT messaging protocol. |
| Modbus Communication | Exchanges data with PLCs and other industrial equipment using the Modbus protocol. | |
| OPC UA Communication | Communicates with industrial equipment using the OPC UA protocol. | |
| HTTP Communication | Sends and receives HTTP requests to web servers or REST APIs. | |
| User Defined Communication | Implements custom protocols over serial, TCP, UDP, WebSocket, Bluetooth, or shared memory. | |
| Control | PID Control | Performs feedback control with the PID algorithm, for precise control of temperature, motor speed, and more. |
| Misc. | Custom Action | Write the action yourself with block coding. |
Wait Until Finished
The Play Media, Synthesizer, Text to Speech, and Audio Transform actions have a Wait Until Finished setting. When it is on, the action stays in the running state until playback ends, so the next action does not start. When it is off, the action completes as soon as playback starts and the next action runs immediately. Turn it off when other actions must proceed during playback.
Status Variables
Some actions report their current state as a number. Use the returned value with Compare conditions.
| Action | Status values |
|---|---|
| Play Media | 0 initial / 1 playing / 2 paused / 3 stopped / 4 playback complete / 5 error |
| Synthesizer | 0 initial / 1 playing / 2 paused / 3 stopped / 4 playback complete |
| Speech to Text | 0 idle / 1 listening / 2 processing / 3 complete / 4 error |
AI Analysis
The AI Analysis action runs an analyzer registered in Settings → AI Analyzer with the analysis type you select. Once running, the results are written to variables continuously, so automation is built by combining them with Compare conditions. All analysis is performed on the controller; video is never sent to the cloud.
Commands
A single analyzer can hold several analyses. Registering and starting them is done with the following commands.
- Add Analysis: Adds an analysis to the analyzer and binds the variables that receive its results.
- Clear All Analyses: Removes every analysis registered on that analyzer.
- Start Analysis and Stop Analysis: Shown for audio analyzers only; they start and stop audio capture and analysis.
Common Settings
| Setting | Description |
|---|---|
| Confidence (%) | Only detections at or above this value are used. Raising it keeps only certain results; lowering it misses fewer. The default depends on the model: 50 for object detection, 70 for face detection. |
| Detection area | Drag on the camera preview to limit the analyzed area. Without one, the whole frame is analyzed. |
| Select By | Decides which detection is written to the variables when several are found: Highest Confidence, By Confidence Index (0-based), Largest Size, or Closest From Ref. Point. Color tracking offers Largest, Closest, and By Index. |
| Reference Point | The reference coordinates used when Select By is set to the closest detection. |
Analysis Types
Twenty video analysis types and two audio analysis types are supported.
| Type | Description |
|---|---|
| Object Detection | Detects 80 object classes such as people and vehicles in real time. |
| Face Detection | Detects faces, including emotion recognition and age/gender estimation. |
| Face Recognition | Compares detected faces against enrolled faces to identify who they are. |
| Pose Estimation | Returns 17 body joint coordinates per person. |
| Hand Tracking | Returns 21 hand joint coordinates, including gesture recognition. |
| Action Recognition | Recognizes around 400 activity categories such as walking, running, and sitting. |
| Hand Gesture Recognition | Recognizes 25 hand gestures such as swipes and thumbs-up. |
| Color Tracking | Tracks objects of a specified color in real time. |
| Line Tracking | Provides the floor line's offset and angle for line-follower robots. |
| Line Crossing Counter | Counts people entering and exiting across a virtual line drawn on screen. |
| Fire Detection | Detects flames in real time. |
| QR / Barcode | Detects and decodes QR codes and multiple barcode formats. |
| OCR (Text Recognition) | Reads multilingual text, including Korean and English, in real time. |
| License Plate Recognition | Detects and reads vehicle license plates. Supports Korean and Latin plates. |
| Teachable Machine Classification | Uses image classification models trained with Google Teachable Machine. |
| Edge Impulse Classification / Object Detection / Anomaly Detection | Uses vision models trained with Edge Impulse, including normal/abnormal classification. |
| Custom Classification | Uses a classification model trained directly on the controller, without external services. |
| Custom Anomaly Detection | Learns only normal samples and detects deviations from them. No defect samples are required. |
| Sound Classification | Classifies microphone input into 521 categories such as speech, alarms, and glass breaking (audio). |
| Edge Impulse Classification (Audio) | Uses audio classification models trained with Edge Impulse. |
Results are continuously written to the variables bound to the output fields of the
AI Analysis action. Bind a digital variable such as Person Detected or a
numeric detection count, and combine it with a Compare Value condition.
Training Custom Models
Targets not covered by the built-in models can be trained in two ways. Teachable Machine and Edge Impulse models are trained in those external services and uploaded as model files. Custom Classification and Custom Anomaly Detection are trained directly on the controller, with sample collection and training driven by the AI Analysis action's Command field.
- Custom Classification commands: Add Sample, Delete Sample, Train, Class List, Class Count, Sample Count, Sample List, Delete Class, Delete All, plus the read commands Read State, State Match?, and Read All States.
- Custom Anomaly Detection commands: Add Good Sample, Delete Good Sample, Train, Good Sample Count, Good Sample List, Delete All, plus the read commands Read Score and Is Anomalous?.