Category Archives: Plain

Distributed PLC Control Centre

Reviewing the design for a home automation system I realise that a PLC rack is not optional as a control system centre. The reason is that we will mainly be interested in central node processing and communication – we will not be interested in more classic PLC controls. Also we need these centrals to be small and hidden. I am thinking more the style of a flat packed PCB card with RS-485 ports, Wifi, GSM/3G/4G and Ethernet in a flat package with battery backup.

The diagram above illustrate the concept. We mount as many distributed centre’s as we need. These communicate with each other using secure Ethernet (wired of wireless) and control their own subnet of actuators and sensors. As these are small and can be hidden they will be easier to integrate into existing homes. Power can be various distributed mains and battery packages.

This an old picture of my universal adapter that basically can be used as is except that it lack GSM option + I would like to have an option to Connect Raspberry PI (3 or Zero W).

PLC Sensors and Actuators

One major issue is how to identify units in a network. I used STM32F030F4 on these and I absolutely love this little MCU costing 50 cent in TSSOP20 package, but it lack the serial number that is burned into other STM32 MCU’s. This serial number is crucial as it present a factory set ID allowing me to just plug in sensors expecting them to identify themselves. STM32F042F6 solves this, but cost ca 2.- USD from the sources I use, so I am very tempted to use STM32F103C8 or CB and create a larger PCB so it becomes single sided. The later actually lower cost in production – but, lets see where we land as I update the modules.

PLC Cottage Surveillance

My grandparents passed away some years ago leaving a beautifully mountain farm behind. As no-one lives up there we have to leave the farm unattended for months at the time. This is a challenge in winter time as we fear the water pipes with freeze. The farm actually got internet installed so it is possible to use internet to create a remote controlled automation system.

Using Internet for anything you need to address security. Using Windows these days is not an option, so I am happy for Raspberry PI as base units. I am no web service expert, but I believe I can communicate directly between my home and the mountain farm by using a Address Lookup Service that we need to create. Basically the HMI and PLC both connect to internet and get details of whom to communicate with through a public service. Once the address is known they create a secure tunnel for communication. I will deal with security later, for now lets just assume this works and that we can use mobile devices as HMI.

 

The system I want to create will consist of a range of modules:

  • Redundant PLC Base with mains, battery, wired and mobile internet connection as well as connection to sensors and actuators.
  • Sensors for temperature, humidity, water leaks, light, movement etc.
  • Camera, speakers and microphones. Actuators swithing on/off heat, opening/locking doors etc.

I use the mountain farm as design base because it present a few challenges. And I obviously want to control this using Plain.

Sorting source code

I admit it sounds a bit ludicrous, but right now I miss an source code aware sort function in my IDE. If you start maintaining large files with loads of structures or functions you often end up paging up/down looking for them – to reduce this time I start sorting them in alphabetic order.

enum vm_OpCode
{
 Op_Assign=1,
 Op_Call=2,
 Op_Commit=3,
 Op_End=4,
 Op_Exit=5,
 Op_For=6,
 Op_If=7,
 Op_NOP =8,
 Op_On=9,
 Op_Raise=10,
 Op_Rollback=11,
 Op_Spawn=12,
 Op_State=13,
 Op_Switch=14,
 Op_Transaction=15,
 Op_Update=16,
 Op_While=17,
};

The struct above is another example – I sorted it to easier keep things synchronized – doing so is actually an increase in quality because it means the developer uses less time looking for things and get a better overview faster – each of these also have structs, execute functions etc.

PLC Backbone Bus

Just updated the pin numbers on the PLC Backbone Bus. The idea here is that we have 4x RS-X lines (2 optional) and 5V,12V,24V,48V supplied from A and B source. The boards select what power they need. I need to connect to a PSU & battery before I am sure that this is what I want to do.

48V is mostly for higher motor effects. 24V & 12V are quite handy to have around, while 5V is an absolute requirement – thought I might actually ditch 5V and supply a separate 12V for MCU expecting the boards to regulate 5V/3.3V themselves. The idea of having a separate MCU power is to avoid the need for galvanic isolation as any effects are drawn from separate power lines.

PLC Backbone 3D

This is just an early 3D model of the minimum backbone bus just to illustrate and work on practical issues. I am going for the more minimal bus for now. The size of the bus do not decide the size of the boards, but I do like this small size. I will however adjust the actual size to practical applications.

What is missing here is a better way of interconnecting several boards and connecting to the PSU. But, I am happy with the PSU lanes – I had no problem using 2mm wide lanes on each side for GND,12V,24V,48V on both A and B. Simply said we can handle some currents in the backbone.

I added 8 slots expecting that we will use 4, but I also miss mechanical fittings of the IO boards here – as I plug IO boards in I need a mechanism to hold them in place.

It is several design considerations that is not solved yet – vibration, interconnection between boards, fixing of sub-boards, connection to RS-X networks etc. But, we need to start somewhere.

PLC Backbone 2

The previous proposal included a lot of data/address/function pins that actually is a bit obsolete design as we use multiple RS-X channels. This smaller bus uses 2×20. I can use the same width as for a Hat, but maybe a bit deeper boards.

I need the PLC system to be small and mobile to fit robots. I wanted a wider system to get more connector space, but I can add 2nd slots for those few cases. In short – I feel that increasing the size would be a mistake.

It is an alternative – and I could even do both …

PLC Backbone Bus

If I use a 10cm wide backbone I have room for a 2×30 (or 3×30) by 2.54 pitch “bus” that could contain the following Inventory:

Summarised this gives me:

  • 4 pin 5V PSU (5-10A)
  • 4 pin 12V PSU (5-10A)
  • 4 pin 24V PSU (5-10A)
  • 4 pin 48V PSU (5-10A)
  • 4 pin GND 5V
  • 4 pin GND 12,24,48
  • 8 pin data bus
  • 12 address bus
  • 10 function/extra address pins
  • 8 pin for 4 RS-X lines (RS485)
  • 2 clock pins

This is just a working draft…

 

PLC Standards

The more I look for any real standards within PLC the more I get the impression that they either do not exist or is not used. This is consistent with what automation engineers tell me. I was kind of getting my hopes up with “Industry 4.0”, but well… lets crack on with creating our own.