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.

 

RS485 Circuits

This is a classic RS485 circuit that I realize is not that good. It works fine, but it requires that ground always is included because of the 12V diodes.

This simplified circuit is in many ways better as we actually can use a twisted pair only. This shows a none-isolated RS-X port. I also drag both RE and DE into the MCU so we can send and receive at the same time. In fact, I could save a pin by setting RE to GND and always receive. I also avoided the leds and some 47Ohm line resistors. I also change to 3.3V version.

This last circuit is a fully isolated RS485 using ADM2582E. This includes a DC/DC and is completely isolated, but it also requires more space and cost ca 5.- USD more.

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.

Plain VM – RTOS

I need a few C/C++ components to implement the Plain VM, one of them is a RTOS . I wrote my own RTOS that runs on both Arduino, ESP32, STM32, Windows and Linux years ago. It is a simple linear scheduler.  I found it quite handy even on Windows applications as it scale better and have some good timing/signalling schemes.

The principle is simple as we loop executing task after task, but controlled by timing parameters and signals. This means we execute a single instruction in each VM before we continue to the next VM.

We will be using this stand-alone as well as together with FreeRTOS, Windows and Linux.

Plain – Parsing VM Instructions

One concern as I implement the VM is the parsing performance on instructions. The Data Descriptor below illustrate the challenge. It is a dynamic structure with bit fields. For every bit field I end up decoding it causing AND /ROTATE instructions.

It is bit packed to save space, but decoding a bit-packed field will cost performance. To increase performance I could use more space – I can’t win, so this will be a horse trade.

For now I will ignore the challenge and be prepared to optimize this later. Plain is not designed for high speed, it is designed for high level logic, so I think it will be ok. I will do a performance test later.

The fastest “bit” packing is a XML string if you ignore space. This will surprice many, but a well build XMP parser is far faster than a bit decoder.

ESP32 PI – Raspberry PI Replacement

I have a few Raspberry PI Hat’s laying around and I wonder if I should make a ESP32 based replacement for Raspberry PI Zero W. The IO on ESP32 is far more capable than the one on the PI, but we have a few limitations and less pins to play with.This is an early draft with the 3D above and PIN mapping below.

Raspberry PI Pin ESP32 PI Description
1 3.3V
2 5V
3 8 – GPIO32 GPIO2 / I2C-SDA
4 5V
5 9 – GPIO33 GPIO3 / I2C-SCL
6 GND
7 10 – GPIO25 GPIO4
8 11 – GPIO26 GPIO14 / UART-TXD
9 GND
10 12 GPIO27 GPIO15 / UART-RXD
11 13 GPIO14 GPIO17
12 14 GPIO12 GPIO18
13 16- GPIO13 GPIO27
14 GND
15 GPIO9 GPIO22
16 GPIO10 GPIO23
17 3.3V
18 GPIO11 GPIO24
19 27 GPIO15 GPIO10 / MOSI
20 GND
21 28 GPIO2 GPIO9 / MISO
22 7 GPIO35 GPIO25
23 30 GPIO4 GPIO11 / CLK
24 31 GPIO16 GPIO8 / CE0
25 GND
26 33 GPIO17 GPIO7 / CE1
27 ID_SD I2C ID EEPROM
28 ID_SC I2C ID EEPROM
29 GPIO5 GPIO5
30 GND
31 GPIO18 GPIO6
32 GPIO19 GPIO12
33 GPIO21 GPIO13
34 GND
35 GPIO22 GPIO19
36 GPIO26 GPIO16
37 GPIO6 GPIO26
38 GPIO7 GPIO20
39 GND
40 GPIO8 GPIO21

 

SG90 9G Servo is no wimp

This litle Servo about 3 x 3cm is far from a wimp as far at current usage goes. A single Servo have no problem dragging a 10A PSU down – actually I think it’s the current regulation that is predictive, meaning it drops out because current raise is to fast – but, anyway – the only PSU I have that can manage this is a 80A battery.

I connecting 4 of these to my ESP32 Utility Driver and some of my dodgy wires burned up.

Looking at the scope I observe a small Voltage drop as the Signals pulse in. As I add servo’s it become worse. I think I need to alter my algorithm a little to spread the pulses out in time and avoid 12 servos that pulse at the exact same time. I also think I need to buy a 6V battery and ditch the 12V to 5V regulator as it most likely is this that dip a bit.

The ESP32 Utility Deriver does however work well. I am a bit puzled over my DPS5005 PSU’s. They seem to use a predictive aproach to regulating current.

ESP32 with CH340 Auto Reset Working

Been a long day with try & fail. I managed to get Auto Reset working on 1.0 by connecting RST to ChipPU amd DTR to GPIO0, but it only worked some times.

Walking back to my rev 1.1 I wanted to test manual loading and discovered it did not work either. Inspecting ESP32 I notice that I had missed a soldering – and voila… suddenly my progamming port work as it was supposed to.

1,5 days of fuzz for a bad soldering. A bit annoyed as I know I should have tested manual loading instantly to verify that I did not have a dodgy ESP32, but well.