32 x Servo Controller Logic


The illustration above shows ruffly how servo logic will come out if you bit bang directly. Some of the Arduino libraries does this. As each servo uses up to 50ms on a pulse you can in theory service 20 servos in a second. The limitation here is that you bit-bang one channel at the time in sequence.


This second illustration shows how we want it to be with all 32 servos operating in parallel. This way we have a much higher capacity and avoid latency between servo operations.

To achieve this we need to use a table with 32 channels and accurate timing for then we switch on, length of pulse and then we switch off. Switching off is an issue because we need to do it with some accuracy. Our RTOS is perfect for this type of jobs and will achieve 0.1 ms accuracy without any problem.

The 32 x Servo Hat uses 32 pins that can be used for multiple purposes.

  1. Servo
  2. Digital output
  3. Digital input
  4. Analogue input
  5. Analogue output

The servo interface is (1) signal pin, (2) Voltage pin and (3) Ground pin.

As the user set a servo value in Raspberry PI using the easyIPC libraries that value is transferred to the 32 x Servo hat, the value is inserted into the 32 channel entry and the pulse will be corrected to represent the new value. The total time latency should be very low, but up to 100ms from a value is set in RPI and the output is corrected must be expected. I will return on actual latency timing later.

Manual Subscription System

I had to clean my subscription pages due to the amount of bot’s that joined. Once a bot subscribe they also start commenting every article with nonsense. So for now you need to contact the site on subscribe@basicpi.org and you will be added manually. Add Your name and a valid email address.

I apologize for this inconvenience.

3D Printer

I have a Prusa i3 3D printer that I purchased from Hong Kong a few years ago. It was a DIY kit costing around 280.- USD at the time. The printer was good value, but I ran into several problems with it’s control system. The one I use is based on Arduino, but with re-designed electronics so you get an all-in-one system that is based on Atmega2560.

Moving on I wanted to re-write the firmware package, but I also want to upgrade my printer with more advanced features than my current hardware will allow.

  1. Scalability to add more control IO to expand the printer’s capabilities.
  2. Proper firmware package that is well designed, easy to maintain and not riddled with real-time issues.
  3. Ethernet wired and wireless.
  4. Proper printer queue solutions.
  5. I want to target CNC machinery in general, not only 3D printers.

Using the current Prusa i3 as a starting point I need the following:

  1. 5 axis on standard RAMPS or equal.
  2. 3 end-stop switches.
  3. 2 temperature sensors.
  4. 2 heaters.
  5. 1 fan.
  6. USB serial solution.

I want to build this on top of my current system with Hat’s and RS-X modules, so it’s more an issue of what do I need to add on electronics. Also keep in mind that I still have my 6 legged robot in mind as I create modules.

The major benefit of this system is that we enable people to build and experiment themselves on plug & play level rather than creating Yet Another 3D Printer Control System.



DRV8301 is a pre-amplifier for 3-phase motor controllers. It is programmable through SPI, handle 60V, contains a 1,5A buck converter and support for 2 current sensors. DRV8302, DRV8303 and DRV8305 are other variants of this. I really want to dig into DRV8305, but they are a bit hard to get and I had my eyes on DRV8301 for quite a while.

I have a dev board from TI with this, and I am a bit concerned about the total footprint with all components, but I want to give it a try. The buck converter will feed MCU and RS-X transceiver, so it will be interesting to see what I can achieve.

Com Adapter w/Galvanic Isolation


Finally done. This picture illustrate the 3 different grounds and the space between the areas that is part of the galvanic isolation. Finally got everything on and routed, so will double check tomorrow (or later today) and order PCB’s. Hopefully this is my x-mas fun project, but I don’t really expect to see the PCB’s before early January due to x-mas post.

I was thinking about adding a LCD display and by irony I actually have. I have a UART on the SWD port that is perfect for usage together with a Nextion display.

Com Adapter 1_2


I wanted to use STM32F405RG for this, so I needed to update the design with lessons learned from my breakout board. I also replaced ESP-03 with ESP-12E/F and replaced all 0805 packages with 0603 as well as adding an extra status led. I still lack support for ESP-01. As a result of the smaller 0603 packages I got more space and this is single sided assembly only. I have soldered quite a few boards with 0603 components and yes they are small, but I never get them wrong anymore.

 I have not done cost calculation yet, but I estimate ca 20-25.- USD in component/PCB Cost.

Notice the silc drawing in red on the MCU and W5500. I recommend that you always remove that silc on tight chips because it makes it difficult to inspect pins after soldering. The white line is difficult to distinguish from solder waste. Also avoid ground plane on mount side if your assembling yourself. This is why I wanted single sided assembly so I could use ground planes on the other side. The adapter is quite small 80*50mm.

I did consider replacing the tiny Murata x-tal used on the MCU, but looking at the size of the alternatives realizing that my x-tal cost 21 cent compared to 5 cent on the larger I ditched the idea. I have soldered quite a few Murata x-tals now and I never get them wrong (expect for the ones I drop on the floor). Those HC49C pack with 2 x caps each look gigantic in comparison. I will upload New schematics once I am done.

Micro Sensor Module


The 7x PWM module (blue on bottom) worked just fine. I have not used ULN2003 much so eager to test and see how it works. I have not tested the sensor (white on top) yet. The larger DHL11 module is mounted on back because it got a bit tight in the front. Will dig into the bit-bang protocol and analogue readings tomorrow.

Micro DC Motor Controller


Assembled and tested my Micro DC Motor Controller. Running the test motor on 50ma in the picture. Added a coin to show how small these boards actually are. A few mechanical issues only. The SWD connector is “ok”, but it is a bit close on the MCU. The screw terminal (blue) is almost on top of the LM9110S H-Bridge.

It works perfect, but I have a few spare pins so I will see if I can add current sensor to calculate torque. I can see the current increase as I hold back the motor and I would like to measure that to implement thresholds if the motor run into to high load or stall.

20A ++ Motor Driver

I would like to make a small 3P Motor Controller for 20A and it’s plenty of SO8 size HEXFET’s that can do the job. The challenge is how to get the PCB to support this without going to large. I made this draft that I will try out.


This is a snap from the EDA showing the PCB at the end of a 28mm wide stick. The SO8 HEXFET’s go edge to edge so you can drill a hole to take the output between them. R1, R2 and R3 are current sensors. The picture below show a 3D of the components. I have not completed routing, but I should have plenty of space for the 12 signals (2 x 3 PWM. 3 x BEMF, 3xCurrent Sense) on the other side..


The idea is to mount a flat heatsink on top of the HEXFET’s and shunts.


One trick is that I on the back side aligne the holes with 2P and 3P screw connectors to give me the option to use those as well. I will need to give this driver a test to see if I actually can get 20A out of the PCB. I am aware that some of the small ESC’s claim to deliver far more than this, but dissecting a few I found that they claim more current than the datasheet on their HEXFET’s. And they also use inner layers only that is far less efficient than Outer layers. They do however provide a nice array of 12 HEXFET’s with a heatsink. All in all buying an ESC for 6.- USD claiming 30A you have to give guys who created this some credit.

Just for the record, 20A continuous equals much higher motor current’s, but I don’t like overselling. The HEXFET I am using have 170A peak. It will be january before I receive everything I need, but I will be fuzing HEXFET’s and PCB’s to find their limits.

The challenge with current sensors in this is that you need to scale for maximum meaning you get very little on small motors. This is actually also why I fancy making specialized Motor Controllers for small motors, but the STM32F303CB comes in 48 pin package with motor drivers and programmable op amps perfect for this job.


The drawing above shows a normal copper lane (illustrated), but if you look at the PCB layout you will notice that it makes it rather easy to add solder mass to deliver higher currents. This will also be tested to see what we can get out of this design.