Category Archives: PLC


I have both 3-phase motors, stepper motors and PWM Hat on my list, so I want to use DRV8313 because this delivers 3 individual Half H-Bridges that are excellent for all of these options then combined together. I am pretty sure I can get 6 of these drivers on a Hat which would give:

  • 6 x 3-Phase Motors,
  • 4 x 4-wire Steppers, 
  • 9 x DC Motors, 
  • 18 x Solenoids/PWM signals. 
  • or any combination of these.

This would actually be a very powerfully Hat.

Looking at STM32F405RG I actually have 26 Timer pin’s with PWM capacity so this looks very doable. What I want to add in addition to DRV8313 is INA193 (or INA194) to measure current on each DRV8313. Ideally I would have this on every PWM, but I am running out of space here, so lets see where we land.

Getting 6 x DRV8313 on a Hat is very doable, but I will need a 60V DC/DC and 6 current sensors as well + a DC-Rail sensor – that is 38 extra passive Components. 

An early mock-up like the one above is just a quick exercise to place the actual components on the PCB for a reality check – and this does not look like a go to me. It is not just about placing components, but all the lanes I will need between them. And it is still capacitors etc that I would like to place here.

So what can I do?

Firstly – 60V is a bit ambiguous for this board, 36V (meaning 24V) is more workable meaning I can ditch the 60V/3.3V DC/DC. That helps a lot.

The second option is the filters that I have on the current sensors – I can remove these from electronics and do them in software – that will reduce 36 components to 12 and the density of the board is suddenly far more realistic – and less complex.

The capability to remove filters from electronics because I can do them in software is something I often face, and in this case we can due to the raw capacity of the M4 MCU. This last mock-up looks far more doable. And I am happy with a 24V limit on this board because this is for small 2-3A motors that seldom needs higher voltages. Now – lets og and design this one!

Upgraded LoRa Options

I finished the LoRa + GPS w/E22-900M30S earlier today and decided to add in E22-900M22S footprint. The modules are almost identical except in size. The only difference is that 30S have pin 10 to 3.3V while 22S have this to ground, so it is straight forward to have both footprints on the PCB.

The 3D model show the 22S module and illustrate well the size difference to the stronger 30S module. This enables 4 LoRa units:

  • E22-400M30S, 433Mhz, 1W, 12km range
  • E22-900M30S, 868Mhz, 1W, 12km range
  • E22-400M22S, 433Mhz, 0.1W, 6.5km range
  • E22-900M22S, 868Mhz, 0.1W, 6.5km range

All modules have an IPX antenna on the module, so I use a PCB antenna with wire to the IPX. This provides a PCB antenna option, but I can also use the IPX directly for more options.

As for the range listed above – this is datasheet numbers. It will be line of sight mostly and I expect somewhere between 2-6.5km for 22S. As for the stronger maybe 5-12km. I say this because E22 modules give very optimistic range data, but we will see.

LoRa/GPS Hat Annotated

  1. IPX Antenna for LoRa directly on the module.
  2. PCB Antenna for LoRa.
  3. Power leds + MCU Status.
  4. USB Connector for MCU.
  5. Separate Power connector.
  6. GPS Module. Can use NEO-6M, NEO-7M or NEO-8M.
  7. GPS Antenna.
  8. USB for GPS Module.
  9. UART TTL.
  10. SWD
  11. STM32F405RG. Powerfully ARM M4 capable of running MicroPython.
  12. Raspberry PI Connector.
  13. CAN Port.
  14. LoRa Module. 1W or 0.1W in 433/868Mhz area capable of up to 12km with up to 300kbps data-rate.

This board can function stand-alone, as part of a CAN stack or as a Raspberry PI Hat. LoRa and GPS can be switched off through separate power supplies.


This is a LoRa and GPS Hat. The larger E22-900M30S with a range of 12km at left and the small NEO-6M at right. NEO-7M and NEO-8M should also work.

I mistook NEO-6M for having a SPI interface, but realized this was for Flash/EEPROM.

I replaced coils normally used to separate frequency interference with 3 x SPX3819. One for the MCU and one for LoRa and one for GPS with Enable pin controlled from the MCU. This way I can switch modules on/off through power. I need to double-check peak power consumption on E22-900M30S, but SPX3819 supplies 500mA so I hope this is sufficient.


E22-900M30S LoRa Hat

This is the first mock-up with the LoRa unit on. This is the larger and stronger of the modules and it occupied a bit more place than I expected, but I will do. It’s not much passive components on these modules and I still think I have just about the space for the GPS and antenna on right side. We will see tomorrow as I make the package. 

The E22-900M22S is about 1/4 of the size. They are based on the same chip, but 30S got a stronger 1W sender. 22S uses 0.1W and cover 6.5Km according to its datasheet. I take those 12km and 6.5km with a pinch of salt. At these frequencies this will be at line of sight, but lets test.

As for my 3D models I am very accurate with PCB footprint, but the rest is as far as I go an illustration. The antenna as an example show the space it will occupy, but it lack details. You can sit days fiddle with these if you want to, but I prefer them simple and editable.

LoRa and GPS Hat

Packing a LoRa and GPS module on the same Hat should be possible and make a lot of sense. I could pack a battery manager as well, but I rather just make a separate board with battery on and this can be stacked on the back of this unit anyway.

The MCU is the classic STM32F405RG which have 3 SPI’s and I will use all 3. One for RPI, One for LoRa and one for GPS.

LoRa is E22-900M30S with a huge range, programmable sending power and frequency selection. This is based on the SX1262 RF chip. I have no experience with this, so I have ordered various units to start with. This unit is a bit large so it will occupy most of the left half. Luckily this has a IPX antenna so we don’t need to worry about antenna wiring.

NEO-6M, NEO-7M and NEO-8M are GPS modules that are very small. I will be using NEO-6M, but NEO-7M and NEO-8M are backward compatible, so we can upgrade and check those later.

This board is straight forward. Most of the work is actually to make the packages for the LoRa and GPS module.

4G/NB-IoT Hat

SIM7020E is a small module that offer 4G services and access to the new NB-IoT service that is available to give access to remote sensors that earlier was not possible. All-in-All this is just a new wrapping on a service that have been available since GSM and can be achieved with several low cost modules. The difference with NB-IoT is that is support better latency/cost schemes.

I really would have preferred to put 4G, GPS and LoRa on one Hat, but I will run into space and antenna issues so the 4G module will be on it’s own.

PSU requirement for SIM7020 is 500mA power peak, but this should be achievable through standard PSU. At some point I need to add a PSU module supporting my Hat’s, but that is for later concerns. To support the power and avoid a power dip I added space for a 0,33mF Supercap on the 3.3V. This should significantly reduce the peak current + the hole-though connectors can actually be used for a battery as well.

Debug is through USB or UART2, Firmware upgrade is only UART2 – a bit weird, but I have added both. Powering either of the USB’s will power everything to allow debug as needed with a single USB. ESD protection is added for VBAT (3V+, SIM card lines and UART2 lines.

This is my 7th Hat in the new format. I had no reference on the SIM7020E schematics, so will be exiting to see if this works at all. Was a bit annoyed over the UART’s from SIM7020E because they where 1.8V, so had to add a level shifter. Used TBX0108 in SO20 format from Texas Instruments, so will see how that goes as well. Luckily I have a test board on the way so I get to test NB-IoT before I dig into my own board.

Functionality on NB-IoT uses a STM32F405RG to either connect on USB, SPI to Raspberry PI or CAN. Connection to SIM7020E is through UART on TTL level. Both UART’s are level shifted. The external UART is for Programming/Debug, while the extra USB also id for Debugging.

I have no experience using these modules, but I expect that I will be able to send/receive data using TCP/UDP at a speed of 26.15-68.5Kbps. It will be interesting to test.

Next out is GPS and LoRa Hat’s.

MC4X60V50A as a Hat

Updated 3D Model 18.dec.2018

This is a bit more than a mockup since it is almost complete, but adding 15mm to an existing design is a lot of extra space. I turned the Hat so that the Raspberry PI Ethernet would be at right. Basically this is 35mm wider than a normal Hat, so it is still small for a 3KW Motor Controller.

Actually I now have some extra space so I can add in a few things. I ditched a RS485, but I would also like more sensors if I have pins/space available. I have a connector to connect 5V on PI to 5V from Motor. This enables MCU and Driver to have separate PSU. I can also add pins to mount extra capacitors behind on the left side. This will be perfect as they will be left of Raspberry PI or other Hat’s. I actually could remove the large 1000uF capacitors on top to save some Space, but lets see how it works out.

Heavy Universal Motor Hat

This is an unfinished 3D of MC4X60V50A or MC4X for short. I initially stated that I did not want this as a Raspberry PI Hat, but I do have SPI1 available + CAN is already planned. It would make a powerfully module + I could add an isolated GW as an add-on etc. The controller itself is more or less finished and the driver stages are mature design.

Firstly I don’t need to attach a Raspberry PI, but it would be a very powerfully stack to be able to add the 20++ modules I now plan. If I add the 40-pin GPIO at bottom-left I would get the RJ45 and USB’s of Raspberry PI 2/3 at left as an extension. This could work out very well – lets try it out and see where we end up.

Just to remind everyone – this Motor Driver support 60V @50A. It basically does so on all 4 independent drivers, so you can run 4 x heavy PWM/Solenoids, 2 heavy DC Motors, a 3-Phase BLDC Motor or a heavy stepper Motor.


Radio/4G/GSM Hat

I drafted a GSM/GPS module some time ago, but I never ordered it as I decided to ditch that PLC design and pick up a smaller footprint. Time has changed so I want to make a new approach.

Using STM32F405RG as core I want to add NB-IoT, LoRa and GPS capabilities.

NB-IoT is a new 4G service allowing 300Kbps, low cost data links over mobile networks.

LoRa is Long Range radio and cover 433Mhz and 868Mhz modules to communicate up to 12 km with 300kbps speed.

GPS is as you know a system using satellites to detect position.

I want to make Raspberry PI Hat’s with these breakout’s. Looking into the practicalities I probably need 2 hat’s for this due to space restrictions. All three of these will need high frequency antennas, so I might for that reason alone need 3 Hat’s. Let’s see where we end up.

A natural infrastructure is that you use NB-IoT to reach remote places and then WiFi or LoRa locally. Both Wifi and LoRa units are secure these days. My real reasons for doing this has to be secret as I basically need these components for a test-bed/prototype and this is a great opportunity to add components to a modular Control system that is excellent for home automation and prototyping.