This is a collection of soft mods for the generic I/Os of a Linux based PLC. It can be used for example with Raspberry Pi, Beagle Bone Black. The Linux Scheduler and some specific circuits are used to implement different things, which would require more complicated hardware, otherwhise.
The function block, called "SoftPWM" is a soft PWM driver that makes use of a standard digital Output Pin. The Interval is constantly changed, to achieve the precise timing which is necessary to fulfill the requirements of the specified duty cycle. It has to be used from a separate, high priority task, which drives the output. But as the interval of this task constantly changes, you should best not add anything else to this task.
The function block "SoftAIN" is implementing the sampling of a so called "Poor man's ADC". It just uses a small variation from the widely documented "Poor man's ADC", by using two GPIOs, instead of just one. The advantage of this approach is, that we are more flexible in the selection of I/O drivers, which can be used with that. Virtually every combination of a digital input and output can be used to sample an analog input.
We are using the digital output as the VRef. This way, it is easy to safely pull down the capacitors current, as the output is pulling down only the current, which itself loaded before.