These are the 4 different motor drivers I have made so far.
The smallest (at left) is capable of 24V @2A. It uses DRV10983 and one of the smallest STM32’s. I got it working, but I had some trouble controlling the logic to behave.
The second one uses a DRV8313 that basically is 3 x Half-Bridges. This works perfectly, but I am not to happy with the Hall Sensors on it + I had some challenges with 30-60V supply. I was however very pleased with the performance of DRV8313 which is why I also use this for a Hat.
No 3 from left is a 24V @ 15A on 4 separate Half-Bridges. This is designed to drive a decent 3-Phase or Stepper. I tested the driver for 10A fine, but I had serious challenges with dodgy MOSFET’s from Asia on this. The only part that I have not been able to get working is INA210 current sensor, but I have 9 left. My initial thought was to abandon this design because the next one is so much more powerfully, but it is also a matter of size. I was all in all quite pleased with this design.
The last one at right is an upgrade to 60V and 50A + I use the Raspberry PI Hat format. The story of this one is yet to be told.
The designed max effects are 48W, 120W, 240W and 3KW
Replaced ESP32 on the failing Hat and Wifi worked. Seems like I had my first ever failing ESP32 module. The Wifi Hat is No 2 from top. This stack includes (from top):
- 7 x Stepper Hat
- ESP32 Based Wifi Hat
- Raspberry PI 3A+
I have 2 USB ports connected here and both show up correctly as Serial ports in Windows. I have a practical problem here programming the STM32F405’s in the middle of the stack – and moving to that 6 pin 1.27 pitch header might not be the smartest I have done. The intention was to mount a JST 6 pin Micro Header, but I had some challenges with the one board I tried this on. I need to set up a test with a MCU I trust and see how it works out.
To program this I probably will use Visual Studio for Raspberry PI, Arduino IDE for ESP32 and Eclipse for STM32. Whatever works! My next task is actually to get SPI working, so that will be interesting. I have never tested Half-Duplex SPI before.
This is the diagram of an Unipolar Stepper Motor with the 5-wire connector at right. The most used Unipolar stepper is the 28BYJ-48-5V pictured below and this is the target of my 7x5WStepper Hat.
This is a high quality/low cost stepper available for < 2.-USD. I purchased one for test and was quite take by its performance. It is silent and its 64 steps/turn is better than you expect due to the build in gear that also makes it strong. It is a bit slow, but all-in-all this is a really excellent stepper motor which is why I decided it needed it’s own control Hat.
Running this is dead simple as you apply 4 steps in sequence.
Reversing the sequence will run the Stepper in the opposite direction. The algorithm have some similarities to trapsoidal on a 3-phase, but the difference is that 1 step moves the motor one step due to the strong cogging in these motors.
To assist us I will create 2 C++ classes. One is hGPIO that wire up the pins, and the second is hStepper that takes the pins and steps. So with an array of 7 x hStepper I should be able to run 7 steppers simultaneously.
What is interesting with this is that one Hat control 7 steppers, 2 Hat’s 14 steppers and so on. And as the Steppers are low cost it is realistic to build some advanced robotic Experiments.
All MCU vendors will deliver some C code they call “HAL”, while I call that Low Level Drivers (or BSP – Board Support Package) and implement my own HAL (Hardware Abstraction Layer). A proper HAL need to abstract from hardware and secure portability of code. But, most important is that I want to write source code in C++11.
StarUML cost a few bucks, but I like it and it’s the only alternative I have found to do decent UML class diagrams. The class diagrams makes it easier to maintain overview and as such they improve quality of software architecture and documentation + they don’t take much time to draw.
I started learning C back in 1983 and coming from languages like Jovial, Fortran, Basic and Pascal it felt like heaven in comparison. Later in 1994 I learned OMT and C++ that was a good fit and I have been a C++ fan ever since. Yes I use C# and Java as well, but only if I can’t avoid it.
This blog have so far been more about electronics than source code, but I have stated a few times already that this will change. The starting point is 3 libraries that will form the basis of all we do.
The first is HAL – Hardware Abstraction Layer. A library that systematically encapsulate hardware in a functional, abstracted way.
The second library is EFC – Embedded Foundation Classes, a library of tightly written C++ targeting embedded MCU’s. This library was started years ago and have been mentioned before because as soon as I move on functionality I also need building blocks.
I will return to the 3rd library/tool later.
I use CubeMX to verify the wiring of my Boards and one of the features I like is that it auto-generate a report like the one below. Just click on the link and you can see the full report of the 7xStepper Hat.
This is basically information that is very handy to have available as you start Programming.
This show the 7 x 5-Wire stepper with the intended connectors and an example of the stepper connected. I have 2 errors on this Hat – firstly I have the +V on the wrong side, so I have to turn the connectors around. I will just use straight connectors for testing. The second is that the PWR connector on the right, bottom corner is to close to the Led. Other than that this seems to be working well so far.The picture below is with straight connectors that I need to use for now.
The jumper in the middle right allow me to connect Stepper Power to USB, but it really is recommended with a separate PSU.
This tester made a big difference. I soldered off what I believed was a failing MCU and tested it to be ok, then soldered it back on and it worked. Turned out I must have had a bad soldering. The tester is the best investment I have done because it saves me wondering if a MCU works or not.I am also getting aware that I have a lot of cold solderings causing problems so I will see if I can start using the oven more.
My STM32 Tester finally arrived, and 12 rejected MCU’s which is ca 40% of all STM32F405’s I had is the result. The sent me a different tester than I ordered, but it did the trick. One MCU broke under testing as well.
10 x STM32F405RG cost va 45.- USD from China and ca 90.- USD from Farnell in Norway. With 40% loss and the unknown of factory rejects I can as well just order from Farnell.
This is the last version of the 32 x IO Hat. I just modified it to use the faster SPI towards RPI bus. The Power connector on the right side is for Servo’s. It enables a different voltage than 3.3V supplied from a separate PSU Hat. The jumper need to be set for 3.3V to be connected to IO. Every line has TVS protection, so this is a decently safe board.
This board basically export 32 pins with TVS protection and add V+ and GND making it ideal for Servo, Sensors or just a plain GPIO Hat.
- 22 Timer based PWM channels
- 32 SW driven PWM channels
- 15 analogue input channels
- 2 analogue output channels
- 32 GPIO of which 17 is 5V tolerant.
- UART/CAN/SPI/I2C ports
- High speed SPI backbone network
- CAN Network
This ESP32 Hat work perfect on IO, but as I switch on Wifi it short-cut and reboot. I might have encountered my first bad ESP32 module, but I am not sure yet. I need to assemble another unit and see if this works as this is the first time I assemble this board.
This is an ESP based Hat in Raspberry PI Format. This is basically an experiment as I want to test SPI and CAN on ESP32. The design only serve as a low cost alternative to using a Raspberry PI as this has both Wifi, Bluetooth, CAN, RS485, UART TTL, USB as well as 5 Sensor ports.
To be continued.
To effectively have a small production line you need to have 3 pieces of equipment/processes.
First step is using a stencil to apply solder paste. this can be done with a stencil alone as a mask on top of a PCB, but a better way is to use a 200.- USD stencil printer. This pic show a low cost one for ca 150.- USD.
Second step is to use the pick and place machine to add components.
The last step is to put this into an automated reflow owen. I actually have one of these, but have not used it much because I solder very fast with a heat fan.
I have 2 reasons for wanting to start using the stencil. It is faster and easier to add correct solder paste, and by using the owen I avoid the number of cold soldering problems I have.
I just assembled a wifi board and sat hours fixing 2 cold soldering – soldering that look perfectly ok through a microscope, but actually is not connected. These problems take time and the first step in improving is to actually use stencils and the owen while I ramp up for a full production line.
The drawback is that a PCB that usually cost 5.- USD now will cost 50.- due to the cost and P&P for a stencil with frame.