My next project is actually a Hat for this TFT, so I was not happy to receive a broken display. The vendor sent it out in a bag and well – this has to go back sadly.
This would have been an awesome Hat, and I am “kind of” done routing the PCB, but my remaining challenge is the currents that I need to support. My PCB lanes for 36V+ is far to thin for 12-24A, so this will never work!
This version of the Hat have 12 x Current Sensors. One of the challenges is that DRV8315 have Pad’s going through all layers for venting and this act as a barrier against any routing signals. I could have managed this board with 4 layers, so I think it’s time to make that change.
The area between DRV8313 and the connectors get to dense in the first place and this is where I need to apply 36V+. The option I have is to use thick air wires, but I basically have no room for them.
The alternatives I have is (1) try to push some of the components to the back side, (3) use thick air wires, (3) use a larger PCB or (4) ditch current sensors.
This being a Hat the size is set, but I used a wider format on the 3KW motor controller so I can use the same here. One of the challenges with DRV8313 is that it has 2 VM pins separated rather than together. This is from a functional point an excellent driver, but the design require some space around the DRV8313 if you want to use it’s features.
This is a mock-up of the wider board. I extend width from 65mm to 100mm. I need to change connectors a bit, but it is an illustration. I have not given up the original format yet, so lets see.
One of the next tasks as I emerge from my marathon Hat designs is to wrap up an actual HAL (Hardware Abstraction Layer) in C++ for STM32F405. The Drivers from ST is named “HAL”, but they are low level drivers or merely C functions to interface to registers. They lack abstraction and normalized user interfaces. One good example is CAN. My MCU stop as I try to start the auto-generated CAN, so I went into CubeMX and get the following screen:
So where/how do I set bitrate? Answer: with some difficulty! This is just an excellent example of stuff I don’t want to see in a HAL Interface because this is low Level driver stuff. I expect that the developer who create the HAL class actually deal with this and leave the rest of us a straight forward, well documented and normalized interface!
A proper HAL would actually have a function that allow you to set standard bit-rates as per ISO11898-2 that is the standard for CAN. To be honest I think many of the older ST drivers was better than these new “HAL” ones. I like ST’s MCU series, but their software department need to shape up!
I have mentioned before that one of the better “HAL” interfaces I have seen is the Arduino “Wire” library. Not the code itself, but the actual interface. I can’t use that 1:1 because that library is blocking and I want asynchronous schemes, but it is a good start. CAN as an example should only contain a few control functions Send/Receive/Init and the Init parameter should be baud-rate in normalized form. I admit that I have yet to look into what Mbed have done, so I will do that as well.
The most important to get right is actually GPIO pin mapping. Then writing code you often need to wire your electronics in software, meaning you need to know which pin that has a given function. The way I decided to do this was to create a class “hGPIO” and allow the user to map it’s logical pins to actual physical pins. This means that I declare a hGPIO variable “can1GPIO” and map pin1 as Tx, pin2 as Rx, pin 3 as On/Off, pin 3 & 4 Special purpose etc. My SW will be given a GPIO variable and expect the pins to follow that standard.
I don’t use an On/Off function on my CAN port’s yet, but my software don’t need to know that. In fact the only place in my software I should need to worry about actual schematics and driver setup is in a single AppInit function.
I have used both C and C++ on STM32 in the past, and I will still need to use C on some MCU’s. The reason is that GCC for some reason bloat a bit as we start C++ so we use up the first 65Kb Flash faster than with C. This is because C++ drag in libraries and it probably can be optimized, but I do not care about C++ on a 16Kb Flash MCU. On these small MCU’s I just use bare metal because I can’t afford the abstraction layer.
This is not a new task as I did this before and created a C++ library EFC (Embedded Foundation Classes) to go with it. But, time has changed and it’s time to move on so I want to re-visit my old designs and re-fresh them before I start writing loads of new stuff for now 10 Hat different Hat’s + some, but don’t worry my list of Hat’s I want to make is very long so it will still be plenty of electronics, but I will start moving more and more into Software and end-user projects through this year.
Happy New Year!
I purchased the breakout board above from ebay earlier, but as I contact KeyStone Semiconductors I am told that these boards have custom programming and that they have no info about the firmware on this module, so be aware – don’t buy these on ebay.
I would like to use one of these modules to create a DAB Radio Hat. F405 have 2 x I2S channels that should match this board so we can digitalize the sound and send it back out to speakers or into Raspberry PI. That would make an awesome, programmable radio. The modules are 26x26mm and would fit perfect on a Hat, but it all depends on price and availability – so let’s see.
What can we use a DAB Radio Hat for? Obviously to create a Radio :), but having a Radio as part of a control system allows us to play radio channels that can be silenced and replaced with audible alarms as things happen, play Radio on timed schemes to give the illusion that someone is home or simply play radio multiple places in the house.
These 2.54 pitch spring terminals occupy more space than I hoped for, so I had to abandon current sensors on each DRV8313 to get room for them. The red areas are the spring connectors. The yellow is the MCU which I desperately need space around since I will be taking out close to every pin on this design.
I will add in a common current sensor. I also realized that for the current sensors to be of usage for 3-phase I need to mount it on a single PWM outputs (phase current). That array of 1206/1210 components are the capacitors. I decided to remove the larger one and replace them this an array to get the profile down.
Heat sink on this Hat is very straight forward – you mount it on the back to cool down the PCB. Notice that each DRV8313 have an array of holes connecting and venting out on the back side, so it is fully possible to mount this straight on a heat-sink.
Taking out 18 PWM signals on such a small design is maybe ambiguous, so I could drop down to 12 – 3 x 4-Phase, 3 x Steppers, 6 x DC Motors etc. If I did that I could move the MCU to right and attempt 12 (or 6) x current sensors.
The reason I keep on about current sensors is because they enable positioning on a 3-phase as well as torque calculations on both 3-phase and Steppers. With torque calculations on Stepper I could avoid end-stops on CNC machinery etc – simply detect where the end is and just put up a mechanical stop. To get more channels I can just stack up boards, so adding the sensors back is worth more than channel density + 12x 2.5A PWM channels are still a good. Hat.
It’s been many Hat’s lately as I am focusing more and more on this as my main core for everything. I still have a load of Hat’s that I want to start on, but I won’t exactly have much spare time the coming year. This is just a summary of projects that I am working on and intend to complete.
And more – many of my older designs have either been ditched or evolved into more mature designs listed above. I will be focusing more and more on the new Raspberry Hat format for everything. The exception will mainly be a series of intelligent sensors evolving out of my STM32F031F4 micro designs.
Connectors on this board is a challenge because I want to support 3 different usages:
The board above uses 2.54 pitch connectors with space to mount small screw terminals. The ones I show here is just an example with a 18 x PWM and 18 x GND connections. These screw terminals are good, but they require access from top – so an alternative is to use something like the ones below that are right angle.
These are 2.54 pitch – 2 rows with 5.08 pitch apart. A bit big for my taste, but I think I can support them. And they don’t rule out anything as 2.54 pitch is very flexible. Height is an issue because PCB separators are 13mm to fit headers – these are 11mm on the back and a bit taller on the bit that will stick out from the board – I thing they will fit well.I need to make a package and show a 3D with these on a bit later.
This first TFT cost ca 3.- USD and is 0.96″ with 80×160 pixels, 64K colors and what seems like a Half Duplex SPI. What I am looking for in displays are high quality displays with bare-bone adapters only adding connector, PSU and mounting screws. This is the smallest candidate and will be a bit challenging as I can’t hide a Hat behind it. One rule is that the HMI solution can’t extend the panel size, so I need a cable option between this and the GPU board. The entire board is only 24x30mm so this is small.
This is the same display without the bare-bone adapter. One option is that I grab this and add this on the back of my own adapter with GPU, but I have so far avoided this type of connectors. The price difference is marginal. I will look into it.
This cost around 4.- USD and is 1.3″ with a resolution of 240×240 pixels.
I face the same option to either use the adapter or bare TFT on this one. The adapters are however so well done and makes my life so much easier that
The next is this 4″ display with 800×480 pixel resolution as I mentioned before. This uses a OTM8009A controller that is supported in STM32 and several variants exist for ca 20ich USD. They offer SPI or parallel Interface.
I seriously want a 7″ display with minimum 1024×600 pixels, but I have not found anything that that match my criteria yet. I have a 800×480 display for ca 40ich USD, but I expect more 1024×600 displays to pop up soon.
The HMI solution I find most attractive is stand-alone TFT solutions with UART as interface. I have used a few off-the-shelf displays earlier and the concept is great, but I want to evolve this a bit beyon just a stand-alone TFT – I want a complete, plug & play solution.
These displays interface to embedded solutions using a UART. You pre-program the graphics in a GPU and use the UART to exchange data only. This is an excellent solution and concept, but I lack a few components.
I have already started a HMI project with a HMI Designer for a Desktop, Raspberry PI, Android or iPad etc. This is still a bit work in progress, but what I want to add is the embedded “HMI Browser”.
This is just an example display – this is a barebone TFT with a dumb adapter that is perfect for my plans and it exist loads of these. I want more options than a single display, but this is a start. The base concept is that I stack a HMI adapter with the GPU behind this – and as the adapter will be a Hat I can add whatever I want to this again.
I will finish my 3Phase/PWM board first, but this is my next project. Completion of a HMI solution for my projects is long overdue!
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:
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!