# Library with no code

**URL:** <https://community.br-automation.com/t/library-with-no-code/9917>\
**Category:** Other\
**Created:** [January 29, 2026, 3:07pm UTC](https://community.br-automation.com/t/library-with-no-code/9917 "2026-01-29T15:07:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vratislav](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/vratislav/32/10881_2.png) [@Vratislav](https://community.br-automation.com/u/Vratislav)\
**Post date:** [January 29, 2026, 3:07pm UTC](https://community.br-automation.com/t/library-with-no-code/9917/1 "2026-01-29T15:07:43Z")

</div>

Check this mind experiment. [A Software Library with No Code](https://www.dbreunig.com/2026/01/08/a-software-library-with-no-code.html)

---

<div class="post-metadata">

**Author:** ![Vratislav](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/vratislav/32/10881_2.png) [@Vratislav](https://community.br-automation.com/u/Vratislav)\
**Post date:** [January 29, 2026, 3:17pm UTC](https://community.br-automation.com/t/library-with-no-code/9917/3 "2026-01-29T15:17:42Z")

</div>

# Spec-Only Libraries for B&R PLC Programming

Inspired by the concept of “software libraries with no code” – libraries that contain only specifications and tests, with AI generating the actual implementation on demand.

* * *

## 1. Utility Libraries for Structured Text

Similar to utility libraries in other languages, spec-only libraries could exist for common PLC tasks:

| Library | Description |
| --- | --- |
| `stringutils` | String manipulation (parsing, formatting, validation) |
| `timeutils` | Time handling, format conversions, timers |
| `mathutils` | Interpolation, filters, statistical functions |
| `datalog` | Data logging to files/databases |

**SPEC.md** would define:

- Input/output data types (REAL, STRING, UDINT…)
- Boundary behavior (overflow, null values)
- Timing requirements (max execution time)

* * *

## 2. Function Blocks from Specification

Instead of copying ready-made FBs, there would be a specification + tests:

```auto
SPEC: MotorController_FB
- Inputs: Enable, SetSpeed, Direction
- Outputs: Running, AtSpeed, Error, ErrorID
- States: IDLE -> STARTING -> RUNNING -> STOPPING
- Timeout for StartupTime: parameterizable
- ErrorID according to B&R conventions (see table)

```

**tests.yaml:**

```yaml
- name: "Start motor"
  inputs: {Enable: TRUE, SetSpeed: 1000}
  after_cycles: 10
  expected: {Running: TRUE}
  
- name: "Emergency stop"
  inputs: {Enable: FALSE}
  expected: {Running: FALSE, immediately: TRUE}

```

* * *

## 3. Communication Patterns

Specifications for typical communication tasks:

- **OPC UA client** for reading/writing variables
- **MQTT publisher** with retry logic
- **Modbus TCP master** for specific devices
- **REST API client** for cloud services

Advantage: AI generates code tailored to the specific project and HW configuration.

* * *

## 4. Motion Control Sequences

Motion sequence specifications:

```auto
SPEC: HomingSequence
Purpose: Safe axis homing with sensor reference

Parameters:
- HomingVelocity: REAL (default 10 mm/s)
- HomingDirection: DIRECTION (default NEGATIVE)
- SensorInput: BOOL reference

Sequence:
1. Verify MC_Power is active
2. Move towards sensor at HomingVelocity
3. On sensor detection: MC_Stop
4. Move opposite direction at HomingVelocity/4
5. On leaving sensor: MC_SetPosition(0)
6. Done

Errors:
- Timeout 60s -> ErrorID 1001
- Limit switch -> ErrorID 1002

```

* * *

## 5. HMI Templates and Visualization

Specifications for mappView widgets and pages:

```auto
SPEC: AlarmPage
- Display active alarms with timestamp
- Filter by severity
- Acknowledge individually or in bulk
- History of last 100 alarms
- Export to CSV

```

* * *

## Practical Implementation

### Spec-only B&R library structure:

```auto
/my_br_library/
├── SPEC.md # Detailed specification
├── tests.yaml # Test cases
├── INSTALL.md # AI prompt
├── datatypes.typ # Data type definitions (must be fixed)
└── examples/
    └── usage_example.st # Usage example

```

### INSTALL.md for B&R:

```auto
Implement [NAME] for B&R Automation Studio in Structured Text.

1. Read SPEC.md
2. Use data types from datatypes.typ
3. Implement as FUNCTION_BLOCK / FUNCTION
4. Follow B&R conventions (AsXxx libraries, Error handling)
5. Generate test program
6. Reference: plc.h, plctypes.h for data types

```

* * *

## When It Makes Sense vs. When It Doesn’t

| Makes Sense | Doesn’t Make Sense |
| --- | --- |
| Simple utilities (string parsing) | Safety functions |
| One-off sequences | Critical motion control |
| Prototyping | Certified libraries |
| Specific customer requirements | Performance-critical code |
| Communication with non-standard devices | Core automation |

* * *

## Concrete Ideas to Start With

1. **String Parser** - parsing configuration strings (e.g., “IP:192.168.1.1;Port:502”)
2. **DataLogger** - saving variables to CSV with file rotation
3. **StateMonitor** - generic state machine with transition logging

* * *

## References

- Original concept: [A Software Library with No Code](https://www.dbreunig.com/2026/01/08/a-software-library-with-no-code.html)
- Example implementation: [whenwords](https://github.com/dbreunig/whenwords)

---

<div class="post-metadata">

**Author:** ![valerio.manenti](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/valerio.manenti/32/11712_2.png) [@valerio.manenti](https://community.br-automation.com/u/valerio.manenti)\
**Post date:** [February 8, 2026, 3:23pm UTC](https://community.br-automation.com/t/library-with-no-code/9917/4 "2026-02-08T15:23:24Z")

</div>

Thanks for your post @Vratislav , very interesting!
