CAN Adapter with Wifi

I need a CAN adapter for a special job and decided to build my own. I use ESP32 to get Wifi, Bluetooth and USB Connectivity, but I decided on adding a STM32 to get dual CAN Connectivity. ESP32 do have an undocumented CAN port as well, but I assume ExpressIF have their reasons for hiding it. The display is because I also want to use this as an Analyzer sniffing. And as a adapter of this type will be connecting to industrial equipment I also want the galvanic issolation.

This will cost me around 20.- USD in components + display and boxing, but to buy something like this I would probably have to pay 500.- to 1000.- USD if I could find one.

I have listed both UART and SPI for communication between ESP32 and STM32 because I am unsure about both on ESP32. I know they exist, but have no experience with them so I can as well just Connect both . I also added a battery option on the PSU.

New DRV8313 BLDC Controller

My previous DRV8313 design used the larger 64 pin F105/F405 MCU and a more complicated sensor design. What I could do is to use the smaller F303 that is 48 pin and fokus on hall sensor driven motors to get size down. The issue is that current sensing is very difficult/unreliable for small motors on low speeds, so ignoring these sensors will simplify the design – reduce size.  The challenge here is that I am not very good at compromizing – I don’t want this BLDC for a project, I want it because I want to experiment with the design and coding – so I want “everything” on it like a spoiled child …

This last draft is the same as before, but I replace F405/F105 with F303 so I can take advantage of it’s programmable Op-Amps to scale current sensing to the motor. I am considering a version where I cut DC Rail, current Sensors and BEMF Sensors as well, but for now I can just design them in and avoid assembling them.

The issue with current sensors is that it’s a huge difference between 2.5A and 50mA. If you dimension the sensor for 2.5A and 500mV you will typically read 10mV on 50mA. The signal get so weak that it risk drowing in noise. So to compensate for this I need to add filters and amplifiers. This also makes it more challenging to control motors on low speeds, while current sensing is excellent on high speeds where you get strong current signals. STM32F303 can compensate for this by using 3  programmable, built in op-amps that amplify the signal. To be honest it is actually far more complicated to make a small BLDC Controller than making a large one.

While I like the STM32F030F4 due to their size they make no sence in this case. I need a 48pin package so I get all 3-phase motor pins and I need the programmable op-amp build into STM32F303.

BLDC Mini Controllers

As I wrote earlier my mini BLDC Controller who support 28V and 2A is basically to powerfully for the job. The motor I Control uses ca 250mA on 12V etc. I used DRV10983 for the job, but I also designed a far more advanced BLDC Controller with DRV8313 earlier. That ended up “larger” as it was 50 x 22 millimeters. But, it also contained current sensors, BEMF sensors. hall sensors With leds and STM32F105.

DRV8313 support 60V/2A, so it’s no wimp and it is basically 3 x Half Bridge drivers allowing you to drive the motors with Your own Logic – FOC etc. This draft have CAN for a change.

The reason I abandoned this was because of DRV10983 that allowed me to downsize, but I also realized that I needed changes on this. I would like to test DRV8313 and I bought a bunch of them, so I will see if I can find time to re-design this one.

2P Motor with Encoder

 

This is a classic N20 DC motor With gearbox and a Encoder. I made a micro stand-alone Control system for these, but I did not support the Encoder. The Encoder will send pulses back as the motor run indicating speed and relative position allowing us to use this as a small stepper motor.

My micro DC motor Controller was a bit booring – it just worked 🙂 – in this case I want to replace the screw terminal and add support for the Encoder. I have plenty spare pins.  The only difficult issue here is the size. But, I think I will dig in on 50 x 15 millimeters With mounting holes so I get all components on one side.

I also need to re-visit my mini PWM generator and Sensor for the same reasons – Connectors and mounting holes. I admit I focused a bit too much on size alone then I made these.

Another Component is to make a ESP32 With battery capable of switching on/off these as well as operating them – I need to think about that a bit because I could also just use the ESP32 and add the size needed replacing the STM32F030.

Mini BLDC Controller Working

Had a heck of a job getting this to working – seems like I was doomed to do all possible mistakes. First the SWD Connector on the pic is connected wrong, after that the cable was swapped around and finally I banged the wrong pins. To even make it worse I did not manage to get MCU pins working with the CubeMX, so reverted to CoIDE and old libs and voila…

At the moment I am controlling speed through PWM duty cycle and it Works “ok”. 3.3V is also working well giving me 8-28V range on the motor. The MCU is just ticking on 8Mhz using the internal clock. The next will be to control the motor through I2C, in which case I also get to optimize with motor parameters.

 

BLDC Mini Controller

This is rev 1.0 of the mini Controller. I patched the 3.3V on the back-side so this is feeded 3.3V from DRV10983 and Works fine between 8-28V IN. I also added 1000uF capacitors that I hope will be sufficient to absorb sparks. I have not added the MAX3485 yet, but I can test without this.

This shows the Controller + motor Connected. The vero Board in the midle is so I can measure phases on a Scope. Time to Write some test code.

Reading the datasheet I should be able to Control the DRV10983 simply by sending a pulse between 1KHz to 25KHz. The duty cycle is the speed. But, I also have I2C Connected for the more Advanced Interface.

Mini BLDC Testing

This illustration show the new PCB layout, but the old have the same capacitor options. Previously as I tested this mini driver I did not apply the capacitor and the result was 2 blown drivers. I actually believe that a large capacitor as planned is all that is needed to absorb the spikes that took out 2 boards earlier.

The 2nd part is that I want to add a 1A/47uH coil and use the 3.3V from DRV10983 rather than the added AMS1117.

The 3rd part is to program the Controller properly to see if I can Control speed. The hard reality here is that I try running a 50mA 3-phase motor and DRV10983 is scaled for 2A motors. The driver might simply be to large for the job.

Mini BLDC 8-28V Input

This design have 2 PSU’s. One is the ANS1117 that takes up to 12/16V input and 0.5A. The second is the DC/DC on DRV10983 that delivers 100mA and allow the Circuit to be used up to 28V. I have connected both for now. The datasheet for MAX3485 indicate up to 200mA, but my own measuring indicate MCU + RS485 will use < 20mA, so lets try. I will simply avoid mounting AMS1117 and remove it on the NeXT layout if it Works.

3 Phase Motor Controller w/Hall Sensors

This is an old Project some of you will remember. I use DRV10983 from TI to provide a micro 3P Motor Controller. The MCU is STM32F030F4 that also is pin compatible With STM32F042F6. The smaller F030 provide 16K Flash while F042 provide 32Kb Flash.

I added a RS-X for Connectivity and Hall Sensors. The entire PCB is 5cm x 15mm. A bit larger than rev 1.0, but I have all Components on the same side + added a 1A coil.

The only difference between this and the earlier is the PCB layout and the selection of a larger coil. The Controller “worked”, but I only tested SPEED pin with limited success. So I need to solder up a new version and make a new test before I continue with this. Notice that 1.27 pitch cable headers are all 2.54 Pitch to deal with some of the challenges I had.

I am considering to dropping the PSU which is AMS1117. The DRV10983 do have a 100mA 3.3V PSU included that might be sufficient. It will drive the MCU, but I am not sure about the RS485.

 

PLC – Connectivity Module

Still an early draft, but show the 8 RS-485 connectors at top/bottom. I only use right angle headers in the 3D, but they are 2.54 pich so they can be replaced with other connectors.

I still have a few loose ends. RS485 circuit can be switched off into 3-state by setting RE High and DE Low (Neither receiving or sending). I need a similar way for the ESP32 to switch off the STM32F405RG so we can go low power. I also want a 3.7V Battery connected on the back.

I should have plenty with spare pins so we can add a few more leds etc. I do however need to solder up a RS485 (or find a breakout) and test that I can get UARTS where I want on ESP32.