Category Archives: Plain

Plain – hitting the road

I wrote lengthy blogs about Plain syntax and concepts earlier this year and want to wrap up the specifications and get going. The challenge with pushing on ideas and concepts is that you start getting blind-folded and stuck as you push for results. This is why I prefer new concepts to mature because what seems like a good idea one day might not the second day. Many of the concepts in Plain have however evolved over several years as I started on this far earlier than this blog.

The difference with other programming concepts is that I don’t want to create another language, I want to evolve the way we work so we can achieve more with less. Plain embrace several new concepts aiming for that, but this is untested theory. I believe it will work as expected, but I am also prepared for setbacks as we move forward.

Plain is also more difficult to achieve than normal programming languages because I need electronic devices supporting it and an established infrastructure to build on. Things take time, but we will get there.

Thanks for reading.

PLC – 24-bit Analogue Input Module

This analogue input module uses a ADS1256 that allow 8 channel input with 24 bit precision and 30Kbps sampling rate. With a programmable gain amplifier 1:64, programmable filter and support for single or differential inputs as well as calibration this board can cover most ADC needs.

The input here can be 8 stand-alone channels or 4 differential channels. A stand-alone channel will measure voltage between input and ground, while a differential channel measure voltage between two points. The later is more flexible as it also can be used for current loops. The challenge is however that different usage require different line adaption circuitry, meaning we will need different analogue boards.

My primary focus is on typical analogue sensors like light, temperature etc. This example circuitry feed a voltage in that is split over 2 resistors with the sensor being the 2nd, variable resistor that changes with light, temperature etc. A typical ADC line driver is shown below:

This is the water sensor I illustrated earlier where we use a specialised PCB as a resistor. R1 need to scale the input so we get 0-3.3V out to the ADC. The capacitor is only a filter. More important is that we can Interface to this in two ways – we can create a 2 pin connector for the external resistor only, or we can supply +/- and expect an analogue value in. Many modern sensors will require the last 3 wire Interface as they provide their own specialised analogue interface.

The main drawback with this technique is that we can only have a limited distance between sensor and the ADC since the wire will start acting as a resistor that needs to be taken into account. A different analogue technique that can be used over 5km is a current loop – I will consider making a Board for that later. But, also remember that we have RS-X based sensors that can cover some distance in wiring.

PLC – GSM Module

This is a draft of the the stand-alone GSM Module designed around the SIM800C module. I still want to see if I can get this into the Ethernet module, but made the diagram above to illustrate the content.

The primary interface to the MCU is UART + some GPIO. This uses the AT command set to control the GSM.

An USB is available from the GSM Module for debug and firmware download. The intention is to connect this to the USB on the MCU as well as making it available through an extern port. I have a loose end on how to do this that I need to dig into. I might also put this port a bit hidden as it is only optionally needed.

GSM antenna need to be added.

SIM Card holder need to be added.

Sound In/Out is usually to a mic/speaker. As this is not a phone, but a PLC we would like that digitalised so we can play sound files, do funny things like speech recognition etc. The later will require a Raspberry PI (Zero ) Add-on to do the processing. I am thinking of running an open source solution where the GSM act as a line card to FreeSWITCH or Asterisk + PocketSphinx to support a single line.

All in all I must admit that this module will require some space, so it might be a bit crowded to get in on the Ethernet Module – lets see. It’s a lot of loose ends here yet.

PLC – Ethernet Module

The block diagram above show the Ethernet module. Starting with a dual RS-X to the backbone and a SPI based W5500 for Ethernet connectivity. In addition we add a ESP-12 for Wifi, SPI Flash for storage and a RTC battery & oscillator as well as the mandatory SWD connector. I hope to have a 3D model of this board ready within the next days. The red box on Ethernet/Wifi mark that this is galvanic isolated.

The STM32 design will differ from earlier designs as I will be using x-tal’s with higher quality and add the RTC x-tal as well. I am toying with the idea of testing a supercap as “battery”. A normal battery has a degrading over time that forces it to be replaced on regular basis. As a RTC battery only need to survive a power down for some time it could be interesting testing a supercap as an option. It is also an option to dedicate one of the available pin’s on the backbone to “Power off battery” and use wakeup functionality on the MCU.

I have also drafted a GSM as optional add-on here. As this will be an external breakout it might make sense to add it to this module rather than creating a separate one. This is however something I need to look into. At present I have little experience using GSM like this.

The RS-X backbone speed will probably be 2.5Mbps, both lower and higher speeds are an option.

PLC – All In One Home Central

A Modular PLC system will have some size & cost, and as a home central should be small, easy to hide and low cost it might be wise to produce a specialized “All In One” solution. The diagram above illustrate the content with “backbone” replaced by a MCU. The C firmware will basically only be a simplified version of what we use on the modular system. The content focus on communication only since we expect distributed nodes communicating through RS-X to perform the sensor/actuator parts.

PLC Backbone Block Diagram

Using STM32F405RG on everything is an overkill, but I can always consider dropping down to STM32F105RB/C later. This M4 gives us a powerfully MCU on each module capable of truly distributed processing as we are promoting in Plain.

Ethernet Module is what I have started on now. This will host a STM32F405RG, 2 RS-485’s for the backbone, a W5500 based Ethernet and optionally a ESP-12 module for wireless. I am also adding RTC battery, SPI flash and a SWD connector. I need to see what space I have available, but as with my previous Raspberry PI Hat’s I intend to re-use much of the MCU related design on every Board if pins & space allow it.

RS-X Module connect the 2 backbone lines to 3-4 isolated network lines. I want isolation on anything in & out of the PLC.

Mobile Phone module is for internet connectivity on remote places or as a secondary backup should a primary internet be cut. It exist so many small, low cost modules these days that we just grab one of those.

Battery Control Module is so we can connect a LIPO package to operate if mains fall out. This should also include charging and monitoring of the battery.

PSU Mains Module is basically PSU modules needed for 5V, 12V, 24V &48V.

Raspberry PI Module will allow us to interconnect with a Raspberry PI for computing, Ethernet, Wifi, USB, Bluetooth etc. The target here is Raspberry PI 2, 3 or Zero W.

Analogue Input Module is a x channel 16 or 24 bit ADC input module. This allow us to read analogue sensors with some accuracy. We need more than the internal 12 bit ADC, so I am thinking maybe a low cost 12 bit board and a bit more expensive 24bit board.

PWM Module is a x channel PWM output, each channel formed as a Half H-Bridge and supporting 2A continuous current. We probably should manage 8 channels – not shure.

Composite Camera Module. I am not sure about this board as I am tempted to use H.264 camera’s only in which case I will ditch this module.

Sound In/Out Module is basically targeting doorbell, but I am open for the possibility to provide a multi-channel music mixer as well. I need to consult with friends in the London music industry a bit, and it is possible this actually will be several boards to adapt to a stage show.

DC/Stepper Module will basically be very similar to the PWM module, but I probably need various currents & voltages for different motors. I am thinking only of small motors supported directly because I expect separate controllers for the larger motors.

3-Phase Motor controller – well, the name say it all, but I am not sure I want to make this board. The reason is because a 3-phase motor usually require some power that is better handled on a separate controller on the other side of an isolated RS-X. Let’s see…

Servo Controller is probably a 16 channel controller like we created before on a Hat, but I will be using Timer’s for PWM this time to get a 16-bit resolution on the PWM duty out.

As mentioned a few times before – this is an idea draft and I write it down to let it mature – plans will change.

New Micro PLC Backbone

My previous backbone board had to little space between connectors + no connection for PSU & communication – this one has 10mm between connectors which is more realistic – thought I still expect one Add-On board to use ca 20mm width. The total width “as is” is 100mm, so it is still very small.

I actually need to find a solution on the mechanical boxing before I finish this one + this is still only an idea draft that need to mature. I probably should add bias and terminator for RS485 on the backbone. Have some spare space on right.

As for add-on boards I am toying around with the following ideas;

  • An Ethernet connectivity board.
  • An RS-X connectivity board.
  • An Raspberry PI connectivity board.
  • An analogue input board.
  • A PWM channel board.
  • A camera input board.
  • A voice & mic board.
  • A DC-/Stepper- Motor board.
  • A 3-Phase motor board.
  • A GSM/3G/4G Board.

We can have a lot of fun here, but I will let these ideas mature a bit…

Plain in Modern PLC Design

A classic PLC design tend to use what we call “Remote IO”. We basically have a top-side control system that read some input and control some output through a “long wire”. The PLC itself contains little or no intelligence. This design have a legacy from days where CPU power was a limitation, but it is still very popular because it is simple and in many cases sufficient.

The drawing above illustrate Remote IO using a light switch PLC style. As we change the switch the signal will be sent all the way to top-side where logic decide that we need to set the light on/off and the signal is sent all the way back down.

This drawing illustrate a modern approach with distributed processing as implemented in Plain. In this case we only use top-side to control the behaviour of logic executing on the device.

Distributed processing is little supported in PLC languages, so this have more or less been the domain of advanced systems written in languages where we write logic per device. In this case we would need complementing software on 4 devices (top-side, 2 x Hub’s and the device). Plain simplify this to a single small application where the user easily can decide wherever processing should happen top-side or distributed.

Micro PLC Backbone

Just an update on the backbone board. I have decided to use a “All-In-One” central for home automation, but I still want to make a minimized PLC alike system. This backbone is very small – only 50mm width and 65mm height. The connectors are basically so tight with only ca 6.3mm apart that we are not likely to use every slot. I considered making it larger, but decided against it because the primary target here is mobile robotics. The connectors give me the option to use 1, 2, 3, 4 or even more slot width on a single card + I can add backbone board by having a board to board cable.

The main difference is that I ditched the A and B PSU signals and use a wider, combined lane to increase available ampere. I also add drill holes for each board. I am still a bit undecided about how I connect this to the PSU etc. I will be back on that.

This last picture illustrate the new power lanes. Wide tracks on both sides to support higher currents. The weak point is however how to connect this to a PSU. At present I would use a 40 pin connector and 4 cables per voltage – I need to think about that. One option is to add screw connectors etc. I will not order this board before I have a PSU design + some add-on boards, so we can let the ideas mature a bit.