Category Archives: PLC

PLC – 24 Channel PWM Driver

This show DRV8313 used as a PWM driver on a PLC Module. This way I can get from 12 to 24 PWM channels with up to 60V @ 2A each. This gives an insane combination of 8 x BLDC Motors, 6 stepper motors, 12 DC Motors and 24 Solenoids. I need to think about this one.

In comparison with my previous module with 8 channels this will be limited to 2A, while the other can support far higher currents. But, the reality is that most stuff is below 2A and this is far more usable (assuming we can put on 6-8 x DRV8313). I do however have a problem with 24 current sensors, so I probably need to install a current sensor on the board or one per DRV8313 – lets see. I am not sure I want to make this module, but I admit that it is very tempting.

Just a quick mockup of a PCB with main components and possible connectors just to illustrate that this is very possible. Another option is that I add 12 PWM channels at top and 16 or so Analogue channels at bottom on a combined card.

PLC-PWM Module

This is an old PWM Module drawing. The idea is to create a PLC module that can handle 4,6 or 8 PWM channels with 12/24V and up to 3A. I know from testing of MC4X15A that this is very doable as soon as I solve the current sensor on the channels.

The usage here is to drive solenoids, dc-motors, even stepper motors. An old hydraulic actuator will typically be driven by 2 x 24V PWM signals pulsing at very slow rates using ca 1A per channel. And yes, I can drive 2 x 3 phase motors as well since I will be using the 2 Advanced timers With 4 PWM channels each. Using the same design as on MC4X15A I actually have an option for higher currents, but this needs to come from a singlle PSU Source and I believe a max rating of 10A in total is reasonable and doable. For higher currents we need to consider specialized designs. 

I have a few advantages compared to the motor controller as I have no usage of the BEMF signal and “only” need 8 PWM signals and 8 ADC signals as interface. IR2103 can combine H&L since L input is inverted and as such be driven by a single PWM pulse. I am, not able to offer 5V PWM since the gate drivers and MOSFET design requires a minimum of 10-12V to work.  

Another advantage is that 12 & 24V is provided directly on the backbone, so I don’t need any PSU logic on the Board (except a bit of protection logic). I need to look into routing Power from the backbone to the MOSFET’s and I need to squeeze each channel into 40mm x 6mm to achieve 8. But, it’s no disaster if I reduce to 4 channels. In fact I actually consider making the PWM channel an click-on sub-board – not sure.

I will start on this as soon as I have a solution to current sensing that I like. The advantage with the PLC is that we also have 5V available and loads of the attractive sensor chips need 5V. One I would like to test is MAX9918 because it can handle -20 – +75 Voltage making it attractive for a 60V BLDC Controller later. But, I have not given up on the INA210, INA213, INA214 family yet. The INA family is ranged 26V so they are attractive for a 24V design. Their size is a pain in manual assembling, but it is a blessing in design – if I can get them to work.

The interesting part here is that we take the driver from a BLDC motor, simplify it and re-use it. The result is a very advanced and capable PWM channel.

PLC – Connectivity Module

Still an early draft, but show the 8 RS-485 connectors at top/bottom. I only use right angle headers in the 3D, but they are 2.54 pich so they can be replaced with other connectors.

I still have a few loose ends. RS485 circuit can be switched off into 3-state by setting RE High and DE Low (Neither receiving or sending). I need a similar way for the ESP32 to switch off the STM32F405RG so we can go low power. I also want a 3.7V Battery connected on the back.

I should have plenty with spare pins so we can add a few more leds etc. I do however need to solder up a RS485 (or find a breakout) and test that I can get UARTS where I want on ESP32.

PLC – Connectors Top/Bottom

This new Connectivity Module have 8 x RS485 connectors. I use the front for the antenna and USB, while top/bottom for connectors that most likely will be permanently wired.

Some users would probably request both 4-wire RS422 and RS232 and I will make a board for those later. I also need a CAN board.

As for MCU power – The MCU’s above have too much/too little. For most of the things I do they are an absolute overkill. The exception is math algorithm’s where we would need the stronger Raspberry PI. The only reason I need the STM32F405 here is because of it’s 2x10Mbps UART’s used as backbone.

Just for the record – the 3D model above is just an early draft to illustrate our options. I use those right angle headers on the 3D model, but the real can be fitted with a variety of 2.54 pitch connectors.

PLC System


One of the challenges I have is the size of connectors in front of the modules. I am actually considering using Top and Bottom on the modules to increase connector space. Another issue is that the screw connectors used on the RS485 board below is not really operational from front alone. Looking at the Servo Controller I could probably add another 16 inputs of which many would be analogue.

The GSM Module above can go as is. I am however considering replacing both SIM808, W5500 and Raspberry PI. SIM808 was chosen because it has digital voice interface, but it also cost 10.- USD and occupy a lot of space. W5500 and Raspberry PI can be replaced with ESP32.


PLC-Connectivity Module

This draft will give me 6 (8) RS-X ports. 6 if I use the backbone and 8 if I use this stand-alone. In addition Ethernet, Wifi and Bluetooth as well as USB.

RS-X Port is 4 pins with 12V and RS485 differential signalling. Basically it feeds 12V Power to the RS-X devices. I like playing with this idea a bit. This would be a very interesting RS-X router. It’s Wifi/RS-X capability makes it an ideal bridge between Wifi and Wired networks.


This next diagram show the ESP32 Connectivity capabilities stand-alone with USB, Ethernet, RS-X, CAN, Wifi and Bluetooth. I definitely want to make this module as it will be small. I wonder if I should make this as and add-one to the STM32 based PLC board?

PLC – Connectivity Module

I drafted a GSM/Ethernet module as well as a 3xGalvanic RS485 earlier, but I am toying with the idea of attempting a PLC Module with STM32F405 using ESP32 for Ethernet/Wifi and 4-6 RS-X ports. 4 if used as PLC-module, 6 if used stand-alone. I have also 2 CAN ports if I can find space/pins for them and I actually have CAN/UART’s on ESP32 as well.

I could connect ESP32 to the backbone as illustrated below, but I have little data on it’s UART speed yet. It’s just an idea for now.

I have not made a move on my PLC concept yet for the simple reason that I have far to many designs/PCB’s that I need to work on and too little time as is. But, still fun to toy with ideas. ESP32 basically cost the same as a W5500 and can do both Ethernet, Bluetooth and Wifi. It will however need an external Phy for Ethernet.

Returning to Plain

A blog is excellent for sharing ideas down and returning to evolve them later. It’s been a while since I wrote about Plain. I basically stopped because I had other things I wanted to work on, but I think it is time to review/consolidate the specification and move on.

Is it worth it? Will it make a difference?

I work on PLC alike technology as a profession, and I am stunned by how much work that goes into even simple system changes. What I want to achieve is (1) plug in a new sensor or actuator, (2) automatically detect this as an unallocated resource, (3)  put it into a system diagram with a few clicks.

We will get there…

Universal Motor Controller – Actuator Control System

I have a few electronic designs that annoy me simply because I lack time to work on them. The reason is simply to much happening in RL with projects (have to pay the bills) + focus on Software. This one is the worst. It is actually one of my most advanced designs and a very capable Actuator Control System.

I started this partly because I wanted to make my own 3-phase motor controller. But, as I did the design I also added a 4th Half-Bridge, Hall Sensors, Temperature Sensors, End point Sensors, Resolver input as well as the RS-X port. It is much better 3-phase motor controllers than this around, but that’s the point – this is not a motor controller it is a scalable Actuator Control System.


I blogged a lot about MicroPLC/Home Automation lately, and this design fit’s right into this scheme. We can’t use long wires with actuators involved as they need to be close to the objects they control (high currents). A centralized PLC design is not optional in a home that actually need distributed unit’s like this.

I will get down to it, but for now I want to focus on getting the HMI running. One of the first projects will be test applications for these devices.

The concept I will use is that the HMI Browser contact this device and upload the HMI. So all you install on the desktop, phone or tablet is a HMI Browser. This is similar to things you know from classic Web Browsers and HTML5, but the main difference is that we operate on a closed, industrial network consisting of a combination of technologies.

One aspect of easyIPC that I have not mentioned is that you have a set of HMI & devices that actually are a closed, industrial loop. It is not connected or available to internet or the outside world unless you want it to. Neither will you be able to connect any phone or tablet if it is on Wifi – the devices will need to be enabled from inside (white listed).

PLD – Executable Logic

The diagram above is a minimum PLD function similar to classic, empty functions. The only challenge here is lack of executable details.

This 2nd diagram show one way of presentaing executable details. This is key to our success, so we need to work a bit on this.

This last diagram show a possible single-step debugging technique. Notice that we display variable values and highlight diagram parts that is the next step. Again – we need to experiment a bit with this to see what works and what doesn’t.