Category Archives: Home Automation

3-Phase/Stepper Routing

Left side of the 3-Phase/Stepper/PWM Hat done. This is the hardest bit, but it went much easier this time because the previous attempts gave some hints and lessons learned. I am far from finished, but it is not hopeless. My main concern is the ground-plane getting to fragmented and unable to support the currents – but, I am not out of tricks yet.

This picture show the back-side and the ground input is actually the “2” in the left, bottom corner while DRV8313 are on the inside of that thick 36V power lane. While Ground is connected you can see that it is thin on some places due to the density on the left side. it will be equally dense on the right side, so what I am considering is to add a bridge on top lane (illustrated in light blue) to ensure that I have a direct path that will support the currents I need.

I must admit that doing PCB routing is a bit like a puzle. You need to like these mind games if your going to be good at this. I know many electronic engineers who seldom do PCB routing – only schematics.

I have suffered “Crash O’ Mighty” on this Board a lot. I use a free version of a Target 3001 EDA based on Java and well – it does crash a lot. I am also more and more feeling the pain and limitation of 2-layer designs, but I will need some time to get started with KiKad.

What worries me a little is the signal integrity of the current sensor signals. But, it is nothing I can do about that. The issue is that the ADC signals need to pass strong PWM signals, so that current on one PWM might give a false signature on a 2nd PWM’s current sensor. I do however have the option to filter and compensate for this in software, so lets see. I do expect noise on these signals regardless.

New 3-Phase/Stepper/PWM Hat

I am returning to this board to make a new attempt because it is a very attractive board to make + I just received another bunch of DR8313 chips and Connectors that I need to use for something. What stalled me on the last attempt was several issues:

  • 12 x current sensors are a bit hard to route and I basically forgot that I needed wide power lanes, so I need to make space for them.
  • DRV8313 is rated to 2.5A in peak, meaning that I can’t get 2A out per channel as that would be 6A per chip.
  • Space in general.

The 2.5A limit is worst for PWM stand-alone signals, but the actual target is 1A and I can always combine output’s to achieve 2A. I need a bit of testing, but I think that will work just fine. 2.5A is just fine for 3-Phase and Steppers. The one drawback with steppers are that we need to do a bit more logic in code, but we have the MCU capable to do that and I want a stepper with current sensors.

The one thing I need to test is the current sensor. INA194 have a very attractive footprint and voltage range, but I am a bit concerned about it’s datasheet. It basically need 50mV input before it become ca 1% accurate and with a gain of 50x we basically run out of 3V range at 60mV input. I also use 0.25W shunts to get 1206 footprint (size) so it’s not straight forward to decrease gain and increase shunt resistance as I start using to much effect.

I also need to test currents through DRV8313 and I have a small 3-phase that I can use for that purpose. This is a simple test to run constant current and use a finger to test temperature to see what I can get away with without a heat-sink. But, heat-sink is actually straight forward because DRV8313 use a pad connecting to ground so we went out on the back-side and can add a heat-sink directly to the PCB.

What I will do is to mount INA194 on the breakout boards I made earlier and test. The reality is that I don’t need current sensors to be that accurate, but I need them to indicate levels on low currents (50mA and up). Used on a 3-phase that helps me detect rotor position so I can use vector based algorithm’s. And for a stepper it indicate torque so I can detect end-stops without an external end-stop sensor on CNC machinery.

I can easily make a separate 3-phase, stepper and PWM board, but the combined functionality of this board makes it very attractive to implement it. I can always go into 10cm width to get more space, but I want to make one more attempt on the current size format first.

The different approach I want to try is to move the connectors to the left and right and have USB/Power in the middle. I believe that will allow me to get away with less space around the MCU + I get 2 x DRV8314 on each side.

As for space – the connector account for a lot here and I could get away with a lot less if I made a specialized 3-phase or Stepper Hat as I then would use right angle Micro JST connectors. It is the need for a combined connector that made it attractive to use this footprint. But, I also notice that the smaller JST Connectors handle less mechanical stress. The connectors I use here have 2 pins per channel to handle to make them more robust.

The 10cm wider board will need different width of these connectors, but as I get more space I could also consider adding galvanic isolation between Driver and MCU. We are after all dealing with a lot of effect and coils here and I will need about 6mm to support an array of photo couplers. A quick look at the mockup below indicate that this actually might be possible.

easyIPC Format

Message Header

This is the new message format that I will use on SPI, RS485 and Ethernet. For CAN I am not sure yet. I might want to take more advantage of the strong capabilities in CAN, but lets see.

The format above allows me to communicate device to device in a network, but at the same time also allow for streams of information that is not device depending. A device number is local for the network, meaning that all 1:1 messages on the link etc uses this format. Right now I want to establish a RS485 protocol that can support CLI as well as more advanced schemes. Next I want to bring up SPI and later CAN. But, I also want to add Modbus and CANopen support later – loads of fun.

RS485 is in this case running 2Mbps, so I want top-side to send a Start TDM signal with a list of devices that will respond. Device 0, Device1 etc. The logic is simple – Device 0 is always Network Master starting the loop by sending a list of devices that need to respond. At the end of it’s own sequence it sends EOT and device 1 starts within 4 ms etc.

I have 3 XPortHub devices I can add into the network for testing so we can get this off the ground.

TDM Sequence

This illustrate the TDM scheme between 2 nodes in a Network. Start TDM is only sent from device=0.

Start TDM

The content of Start TDM is a list of devices that will respond and in what order. Each device have a time-slot of 4ms to respond before the next takes over. Devices not on the list will be silent.

End of TS

End of TS (Time-Slot) is the last message send by all devices. This is broadcast and gives the next device a 4ms window to start sending it’s Messages. This scheme is used on RS485 and SPI. RS232 and Ethernet are full duplex and I want to evaluate options for CAN a bit later.

XPortHub changes

I have not tested everything yet, but rev 1.1 of XPortHub need a few changes:

  • correct package on serial flash.
  • wap sequence on dip switch.
  • replace battery with a proper battery holder. Can be mounted on back-side if needed. This also fix the short-cut here.
  • Test Power Connector. I have a 2-pin connector that is right-angle and fit well. That should be ok as is.
  • Add Led’s if possible. I have a few spare pins and it would be nice with some more led’s.

These are just minor adjustments as the board seems to work fine!

XPortHub Update

I finally managed to sort out the CubeMX/SW4STM32 error so I can move on a bit. The XPortHub (pictured above) is coming together very well. Sadly I have to upgrade this due to the Flash footprint error, so I will make some other adjustments as well.

CubeMX auto-generate all drivers with pin-setting, FreeRTOS, USB driver and even the FATFS system allowing the Micro SD Card to be used as a disk.

The pin-out above shows how dense this design is getting with only 5 spare pins. Using the USB as a serial link with a little console app this basically have more content than my first IBM PC back in 1983. It bring back some nostalgic reflections to my early days fiddling with DOS and C compilers.

What I will do next is actually to create a terminal application and a CLI with a Utility package that in many ways with mimic the old DOS/Console days.

Failure of the week

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.

DAB Radio Hat

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.

Raspberry PI Hat’s

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.

XPortHub. Basically a communication Hub With CAN, RS485, RS232, SPI, I2C, USB + Micro SD Card, RTC, Flash etc. This Board is actually assembled and so far working well.

Wifi Hat based on ESP32 to enable a low-cost Wifi/Bluetooth With CAN, RS485 and a few IO ports. I have PCB for this Board, but have yet not assembled or tested it.
32 x IO / Servo Controller.

Not ordered.

8 x DC Motors + 16 x Sensors.
7 x 5-Wire Stepper Driver.
3KW Universal motor driver, Capable of 60V @50A on 3-Phase, DC, Stepper or Solenoids.
NB-IoT/4G Hat.
Light-weight 60V PSU. This is only a test board with the Hat format.
LoRa + GPS Hat. Shown With 12km 1W configuration.
LoRa + GPS Hat. Shown With 6.5km 0.1W configuration.
2A Motor Controller. Can run 6 x 3 Phase, 4 x Steppers, 9 x DC motors or 18 Solenoids/PWM signals. This is still work in progress.
3KW 3Phase Motor Controller. This uses DRV8301 and is designed for 60V@50A. This actually need a revision before it is ordered.
Mini stand-alone 3-Phase Controller for 2A. This is assembled and is working, but the 60V DC/DC needs a revision.
CAN – USB Adapter. Assembled in rev 1.1 and working.
ESP32 Utility Driver – 4 sensors, 8 Servo/IO, 2 H-Bridge, 7 PWM signals. This is assembled and working rev 1.1.
Model Train Cockpit Controller. This is a failure and need a revision + a support adapter. A rev 1.2 is on my list.
STM32FxxxRx Breakout Board. Assembled and tested for F105 and F405.
Breakout for STM32F031F4 or STM32F042F6. Assembled and working.
My SWD Adapter. This will need an upgrade, but it has been one of my most usefully designs. It enables me to use a small 1.27 pich footprint on my designs and deal With ST-Link 2.54 Pitch. Next Version will have Reset and Boot Connectors.
Micro sensors and actuators. I had 4 of these designs and the Temperature, Light, Proximity sensor will be upgraded. More external sensors will be added later.

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.



2A Motor Hat – Connectors

Connectors on this board is a challenge because I want to support 3 different usages:

  • 3-Phase that require a 3 pin connector.
  • 4 wire stepper that require a 4 pin connector.
  • PWM that require 1 pin + ground for every signal.

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.