Custom set of TRNSYS Types that evaluate multiple logical input signals and return a logical output based on the selected gate type.
Type3801–3807 enables the simulation of logic gates within TRNSYS models.
It supports common logic gates (AND, NAND, OR, NOR, XOR, XNOR, NOT) so that users can integrate control logic, switching conditions, and digital decision-making processes directly into their TRNSYS simulations.
Note
TRNSYS already provides AND, OR, and NOT gates within the Calculator Type, which are generally more optimized for simulation speed.
The advantage of this set of Types is that they do not require creating custom inputs or outputs within the Calculator, making them easier to integrate and more visually intuitive compared to code-based implementations.
- TRNSYS v.18
-
Clone the repo or download the source files:
git clone https://github.com/allachance/TRNSYS-LogicGates-Type3801-3808.git
-
Copy the folders into your TRNSYS 18 installation directory, e.g.,
C:\TRNSYS18
| Name | Description | Options |
|---|---|---|
Mode |
Defines how input values are interpreted as TRUE or FALSE |
1 → Inputs must be exactly 0 (FALSE) or 1 (TRUE) 2 → Inputs are TRUE if greater than 0, FALSE if 0 or less 3 → Inputs are TRUE if nonzero, FALSE if 0 |
| Name | Description | Options |
|---|---|---|
Input-n |
Input signal(s) evaluated by the logic gate | — |
Number of Inputs |
Total number of input signals | Minimum: 2 / Maximum: 100 |
| Name | Description | Options |
|---|---|---|
Output |
Resulting logical value from the gate type | — |
-
Add the Component in TRNSYS Studio
-
Insert the desired logic gate into your simulation workspace:
Type3801:ANDType3802:NANDType3803:ORType3804:NORType3805:XORType3806:XNORType3807:NOT
-
-
Configure Parameters
- Set the
Modeparameter to define how the inputs should be interpreted asTRUEorFALSE. - Ensure the number of inputs matches your control logic requirements.
- For
NOTgates, only one input should be provided.
- Set the
-
Connect Input Signals
- Link each
Input-nport to the variables or outputs in your TRNSYS model that represent the logical conditions
(e.g., thermostat signals, switch states, or other binary controls).
- Link each
-
Use the Output
- The
Outputprovides a logical value (0or1) according to the chosen gate type. - Connect the output to other TRNSYS components such as switches, controllers, or system decision logic.
- The
-
Example Application
Enable a fan only if:- The room temperature is above a threshold
AND - The occupancy sensor indicates presence.
- The room temperature is above a threshold
| Input A | Input B | Output |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
| Input A | Input B | Output |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
| Input A | Input B | Output |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
| Input A | Input B | Output |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 0 |
| Input A | Input B | Output |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
| Input A | Input B | Output |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
| Input A | Output |
|---|---|
| 0 | 1 |
| 1 | 0 |