Category Archives: STM32 Development

EDA Bug

I used a little trick on the 3-port Galvanic RSX as I connect to ground through the ground layer on layer 0. If you look at the area marked in green this is part of the ground, but the EDA don’t warn me that this is an iceland isolated from actual ground. I added a connection (in yellow circle) to fix the issue.

Just a reminder that an EDA is only a tool. It might contain snags so it’s up to yourself to actually check what it is doing.

RPI Hat / 3-Port RS485 with Galvanic Isolation

I made a 5 port (3 port RS485 and 2 port CAN) earlier that is great, but I want a version that is galvanic isolated for solutions that require wiring around a house or more hash environments. ADM2582E is a “All-In-One” package for this, so using 3 of these I get a 3-port RS485 will full isolation. This will cost ca 15.- USD more than the plain one due to the more expensive isolation chips, but those bucks are worth it.

The 3D model above is a bit premature, but it gives you an idea of how the Hat will look like. I have also included a snip of the PCB to illustrate the galvanic isolation.

I have not connected the 3 ports to the MCU yet as I basically wanted to see if I could achieve 3 ports with proper spacing. I am actually quite happy with the result. The 4 red areas are ground. As we have isolation it means that each port have it’s own isolated ground completely separate.

PLC-/Home Automation -Control System

This diagram illustrate my Home Automation Centre. The idea is to use isolated RS485 networks – no power – to control actuators and sensors. Power will be entered by through RS-X adapters I will draft later. I am a bit undecided on Ethernet/Wifi as this also can be sorted through Raspberry PI. The one thing I do not like with the PI is the SD (TF) card as this is its weakest point regarding reliability. GSM is available low cost and needed for dial-up solutions. The Serial Flash act as a disk. This is only an early idea draft, so lets see where we land.

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).

Water Detector

This drawing illustrate a water detector. A water detector is basically a standard ADC reading between two resistors where the 2nd resistor is a PCB as illustrated above. As the water raises the PCB will start leading current and the ADC reading will move from 3.3V to GND. This is the same principle as used for temperature- and light detection resistors- except that the resister is a PCB in this case. We we can apply the sensor with a cable some meters from the actual sensor Logic as we don’t want electronics flooded.

A water detector is something you don’t believe you will need, but if you ever have a water leak you would like to know about it fast since water usually cause less damage if it removed instantly.

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.

On-Line Documentation

I just uploaded a design doc for the Universal Motor Controller on the downloads page. I used LibreOffice 5.3 since it could export to PDF, but believe me this is the last time I use that. I had so many problems importing drawings that I ended up importing everything to Word and then copy & paste as bitmap from Word to LibreOffice. LibreOffice doc’s and illustrations is not a good combination. I like LibreOffice, but I like Things that work more!

Universal Motor Controller

I designed this universal motor controller capable on driving DC-, Stepper-, BLDC- and even AC – motors earlier. The design parameters was 12-24V at 15A. This is quite a capable controller, but I did a mistake that limit the controller to 12-20V since I connected the Gate Drivers to the Motor PSU directly. To compensate for this I need to modify the design and implement a separate 12V PSU. As I correct this I also want to consider some additional changes.

I am considering is to replace the RS485 with an isolated RS485 due to the amount of energy involved. The 3rd change is Ethernet on a separate adapter board. Basically I want to copy the modules I use on the Universal Adapter as soon as I have tested them.

I am not sure about Ethernet. Ethernet sound nice due to the functionality, but it is a clumsy, 4-wire 1:1 solution. RS485 is slower, but it is a 2-wire network. It actually makes more sense having dual RS485 to be honest. CAN & Ethernet is easier to deal with using an adapter board- RS485 is considered a lower level of communication than CAN because CAN have protocols like CANopen, J1939 etc. The reality is that if we use RS-X that changes.

What I probably should do at some point is to create a “Ethernet” on top of RS-X by using a dual RS-X connection. But, that is fun for later…

So the modified design will be

  • STM32F405RG MCU, 168Mhz, 32bit M4, 1MbFlash, 192KbSRAM
  • 4 x separate half bridge drivers, 30V @15A
  • Current sensors on all
  • BEMF sensors
  • PSU Voltage Sensor
  • Separate 3.3V supercap to sustain MCU in power dips.
  • 3 x hall sensors
  • 2 x temperature sensors.
  • 1 x resolver
  • 2 x end sensors
  • 1-2 x RS485
  • Adapter board for battery/caps
  • Adapter board for CAN/Ethernet/Wifi

Applications

  • Solenoid driver
  • DC Motor driver
  • Stepper Motor Driver
  • Brushless 3-Phase motor driver

Fast ADC

The build in 12 bit ADC will give a resolution of 0.0007V if I use it to control a 30V Lab PSU, so I was looking for something with a higher resolution. I did find something that could handle 24 bit @ 2.4Msps, but it required a NDA to see the price – I think not. A little surprised about prising on fast ADC’s.

The one over is a decent choice that is quite popular. ADS1256 from TI delivers 24 bits @ 30Ksps on 8 channels for ca 6.- USD +/-. It has been around for a while. The breakout board is ca 16.- GBP on ebay. I will play with this a little, but for now I will settle with that build in 12 bit on STM32 because they are also very fast.

I do however not need fast sampling rate, I need a very fast response in the MCU on changes. The build in ADC’s have threshold interrupts that should do that for me. Fun to come.

I do however like the ADS1256 so maybe I throw up a PLC ADC board with opto isolators. Non-isolated ones exist.