Visual Studio for Raspberry PI

One of my main concerns for some time have been to find a free development kit that actually works for Raspberry PI. I intended to develop directly on the PI, but the drawback with that is that I need a 3rd screen + keyboard/mouse and I simply have no room for it as is. The other is that I have lost a few SD cards in earlier trials so I don’t want to save source on RPI. Cross Compilation will solve this.

Long story short – I have tools I use because I have no option and tools I prefer to use. Visual Studio and previously Visual C++ have been among my  main preferences for years. It simply is one of the best IDEs available. With Microsoft releasing the community version it becomes free for people like me, and with the release of GDB support I can install an extension and use Visual Studio on my PC to work on Raspberry PI like any other embedded project. This is a major step forward in making it easy to develop C/C++ for Raspberry PI in my case. And best of all – you download, install it and it just works without any fuzz.

Using add-on’s like VisualGDB I can also move my STM32 development to Visual Studio and get both STM32, Raspberry PI, Android and Desk-top development under the same “rooth”. I noticed comments from Microsoft on their forum indicating that STM32 and other development will be included in Visual Studio – the note was 1 year old.

MC4X15A Adapter Board

mc4x15a_adapterplug

Earlier I had a BEMF issue with my smaller motor controller, so I have been reading up on other peoples experience and solutions to design my own. What I came up with is 3 changes on the MC4X15A.

  1. Added a 0.33F super capacitor on 3.3V protected by a TVS (on the back) at ca 4V. The supercap will absorb any spike that reaches 3.3V and it will allow the MCU to survive a power dip of several seconds. The later is great as it allow the MCU to monitor and record a Power dip.
  2. Protecting the main PSU with a nasty TVS to avoid that it spikes out of control. This will be set just a few volts higher than the max voltage. This diode is also protecting the surroundings as we have no galvanic issolation on this one. This should also protect against wrong polarity.
  3. I need more capacitors on the PSU, but I have no room for these. I also wanted a battery adapter option. I decided to make room for an adapter board supported by 4 extra M2 screw holes that either can carry extra capacitors or a battery adapter. The example (below) show a 10,000uF/50V capacitor, but notice that this in reality is a vero board so you can add your own design of capacitors.
  4. The connector is a standard 2.54 pitch pin header enabling the adapter board to be engineered on a piece of vero-board. I didn’t want to lock to a specific capacitor at this point so vero-board is fine. This also allows a variety of simpler solutions if I don’t want to use the adapter Board.

mc4x15a_capadapter

I am still not confident that I got everything about BEMF 100% correct, but I will work on that. I might need a combination of capacitors as well as more diodes – not sure. And I need to test this so it will be a few exploding capacitors before I am done :).

 

MC4X15A – High Side Current Sensor

The original current sensor logic will use a shunt between the lower HEXFET and ground (low side current sensing). This is fine for 3-phase, DC or Stepper motors, but it will not enable measuring of current on a single, stand alone Half-Bridge.

An alternative way of doing this that fix this issue is to measure the current on it’s way out as indicated below using “high side current sensing”.

halfbridgewithcurrent

In this schematics we introduce the shunt on the PWM Out and take advantage of INA210 being a high side sensor. I connected BEMF to the left side of the shunt due to routing logistics. With a 0.001 Ohm shunt this error should be constant and very small.

High side current sensing is more responsive to changes in the current flow and adds no disturbance to system ground. The main disadvantage is that because the shunt resistor is not at system ground, a differential voltage must be measured which requires the precise matching of the proper differential amplifier. However, this disadvantage is eliminated with the use of a precision current shunt monitors like INA210 or similar.

mc4x15a_091

Transporting the current out proved to be easy as I mounted the shunt opposite the high side HEXFET using it as a path out. The disadvantage is that as the HEXFET heats up so will the shunt. If this becomes an issue I will extend the length and move the shunt to the right. INA210 is mounted opposite the low side HEXFET and will have the same issue, but reading the datasheet it should have max ca 1% temperature drift error. Current sensing is most critical for 3-phase control, but keep in mind that we measure all 3 phases. As adding all three phase currents should give 0 (zero) we have a sensor error indication implemented.

32 x Servo Hat

 

20161226_232805

Finally had the time to assemble a 32 x Servo Hat. Have not written any code for it yet, but always nice to see SWD answering and led’s coming up with a 10mA current on the lab psu – Things look normal. Will get down to wrapping up a servo controller and assembling a RPI with an user interface later. I will be using RPI3 because of it’s build in Wifi to control my robot.

The MCU on this is STM32F105RB, so it got plenty of juice and IO. Controlling Servos and motors are obvious, the channels can also be used for digital I/O and analogue I/O.

20161226_232910

The picture above show the SWD adapter connected and illustrate why I need to modify this to go out as a thin board horizontally. I only mounted channel 1-16 for now due to the space conflict with the adapter.

20161227_010222

This last picture show the 32xServo mounted on Raspberry PI 3. It can be stacked with an extra spacer or by mounting it at top. If stacked you can control 8 x 32 = 256 servos. More interesting is probably the capability to combine Hat’s to make Advanced systems.

MC4X15A Stepper-/BLDC-Motor Controller – Revision 0.9

mc4x15a_top

First actually finished draft. I call it 0.9 because I plan some minor changes before I send it out. Firstly the size did not work out as expected. I ended  up using 40mm width due to the MCU and mount holes. I first extended it at bottom to get M2 mounting holes. Later I had to extend it on top because routing was getting tight. It’s a combination of all the connectors and using so much of the MCU that drive the size a bit on 2-layer + in this case a bit of bad planning. But, well – 80 x 40mm with all the features added and proper mounting holes is not that bad.

mc4x15a_bottom

This shows the backside of the board. Dense 2 sided assembly on the driver and almost single sided assembly on the rest. I would like to work on the size a bit, but for now I want to move on and order the PCB so I can test lane capability and concepts to move on. The driver area is only ca 40×20 mm.

MC4X15A Motor Controller

mc4x15a_2

This Motor Controller is still a bit of work in progress, what is remaining is the communication parts and a review of protection logic. The actual challenge here is size. I am mounting components on both sides to get it small, but as it get smaller the PCB routing get far more advanced. I am a bit surprised on how much easier it was with the Communications adapter and 3xAxist Mini Stepper to just use a bit of extra space and use single side assembly.

  1. 4 x Half Bridge Drivers
  2. 5-36V Power Connector
  3. Current, BEMF Sensors, Gate Drivers. HEXFET’s on opposite side.
  4. STM32F405RG w/ full BasicPI SWD connector.
  5. Space for communication parts. RS485 added, Ethernet and CAN being considered.
  6. 3.3V Switched PSU
  7. Hall sensors.
  8. 2 x Temperature sensors.
  9. End Stop Connectors
  10. Resolver/Encoder.

I have reserved pins for Ethernet, CAN and RS485 simultaneously, but I am not sure wherever to add it all or not. In addition to that I want to add a SPI port for “disk”. I am considering several options. Adding a SPI Flash is straight forward, but I am toying with a few ideas around having an embedded SSD solution.

A sharp eye will observe that the stand-alone driver is embedded into the controller. I will make a separate PCB later.

VNH2SP30 – 30A Motor Driver

vnh2sp30

This picture is a Dual DC-/Stepper- Motor shield for Arduino. It is available on various sources for ca 5.- USD +/-. The Picture is borrowed from one of the shops on AliExpress.

The interesting thing about these monster chips is that they are full H-Bridges capable of working up to 40V with a 30A continuous output. The only drawback is that they are 5V design on signals, but we can add level shifters to deal with that. I have failed to find a 3.3V version. The trigger level is 3.25V so a 3.3V signal might work by accident thought.

The chip shown is VNH2SP30. You will find loads of notes and design on this chip on the net as they are very popular for good reasons. They also provide a very easy path to a straight forward 30A stepper motor.

The size of the chips are however actually larger than the total area I use on my own using discrete components, thought I only target 15A. But, as stated before you need to deliver the current to the motor as well. I actually want to buy one of these for testing.

3.3V Switched PSU

3v3switched

This little fellow have the same layout as a classic 7805 and is a 35V to 3.3V switched regulator capable of 600mA. The circuit handle 42V, but the capacitors will limit the circuit to 35V I think. I just fancied making this as a bread-/vero-board breakout. The entire circuit is 20×10 mm and occupy less space Integrated on a PCB. The schematic is included below. Sorry for the weird component numbering as this is clipped out from a different schematics.

3v3switchedschematics

3-phase Micro – cable issue

20161217_091130

I was initially quite happy with the way this cable fitted, particularly as I found a trick on how to solder these. But, this is how it looked after having fiddling with it for a day. I could add a proper micro match connector, but they are a bit expensive.

micro-cable

Another solution is to add a cable holder on the PCB at the end to avoid that handling the cable is exposed as stress on the solder points. In this case I need this cable since I am connecting to a motor with a special connector, but for the micro PWM driver that have the same issue it might be an option to simply use 2.54 pitch connectors. It is nice to have things small, but they need to be functional as well. The challenge is to find a solution that is practical and don’t drive size or cost to much.

 

Backfiring 3-phase motor

Reviewed the design today and the issue is that the way I am testing easily unleash spikes on several hundreds volt since I disconnect a coil with energy in it. The voltage can be extremely high even if it’s close to no energy in it. Two solutions are suggested (1) avoid disconnecting the motor while it is running, or (2) add protection circuitry if I insist on doing it.

What I plan is to use the 3.3V from DRV10983 to drive the hall sensors. This will then be a separate 3.3V from the one driving the MCU. Secondly I need to add at least 4 TVS diodes which is easy since I am using a small, nice array of 4 x 6.1V diodes that would have done the job. Again this should not happen in normal operation.