Category Archives: Motor Controllers

32xServo Hat Revision 1.1

32xservehat_1_1Not very exiting, but it has taken me most of the day. This is the revision 1.1 of the 32xServo Hat. Just for the record – the red lanes are actually ground plane so it will all be covered with GND – I just switched it off for the picture.

  • Added optional TVS diode on PSU for better protection.
  • Added 100uF and 100nF capacitor on PSU for spike cutting.
  • Adjusted pin header positions to better fit 3×4 headers.
  • Adjusted the lower 16 channels as they where a bit close to the bottom edge.
  • Added TVS on all 32 channels for protection of the MCU.
  • Changed all LED’s to 0603 package.
  • Added weak pull-up on nRESET.

32xservehat_1_13d

The lower 16 channels can use 3×4 right angle connectors allowing the Hat to be used in a stack. I finally found a good price on 3×4 right angle down to ca 10 cent each – still looking. You can still use classic 2.54 Pitch pin headers that is even cheaper.

Revision 1.0 is actually ok to go, so I will try putting this into production & sales since a lot of people have asked for it. It will be exiting to see what assembly prices I can achieve. PCB & Components are probably ca 10.- USD all together.

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.

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.

 

3-Phase Micro – printf

serial_printf

int main(void)
{
  int x=0,y;
  char buf[100];
  AppInit();
  printf(“\nBasicPI Micro 3-Phase Controller!\n”);
  while(true)
  {
    nanodelay(1000000);
    printf(“%d tick\n”,x);
    x++;
  }
}

The 3-Phase micro controller use a RS485 (RS-X) connector. I have not enabled the RS-X package yet, but I always start with a simple printf implementation and a terminal program. This is in 99% of the cases the only debug I need. It will be implemented on top of RS-X as well. Just nice to see that the MCU actually is ticking before we start digging into running the motor – this gives me eyes to look what is happening. My apologies for the formatting of the C main above – I need to find a better way to show source code annotations…

4 x Half Bridge Driver

I really like routing electronics. It is something relaxing about this task that I find very enjoyable. I started routing on pen & paper single layer some 30+ years ago, so having access to a professional EDA and 2 layers are a dream. I would like to upgrade to 4 layers to get two layers assigned to ground and power to increase signal qualities, but I am amazed with what I get away with on 2 layers.

4xhbdriver_nitting1

This is the filters, TVS and protections circuitry on the 4 x Half Bridge driver connecting up to the terminal connectors. I decided to make a combined board with MCU and jumper to take out all signals for now. I will simply avoid mounting everything for some of the tests.

4xhbdriver_nitting2

This is the backside of the same Connectors. One of my challenges was space as wanted to add a 6,1V TVS diode on every signal Connected between the driver and the MCU due to the effects involved. I did not thing I would make it, but as I looked at the terminal jumpers that are hole through I realized that I could just attach a 4 x TVS array on the “other layer”.

It don’t look much as it is done, but it actually is quite a bit of work before the rat-nest of wires come nicely together. In this case I changed schematics to adapt it to the PCB. Having terminal Connectors like this between driver and MCU also makes it easy to use these as tes poits connecting a Logic Analyzer/Oscilloscope. I will need an adapter board due to the tight 1.27 Pitch thought – I will be back with a complete board a bit later.

Current Sensor Design

currentsensorschematics

This is my current sensor. INA210 comes with a fixed gain of 200. Other variants have different gain. I like this concept because it saves me passive components and space on a critical area + the resistors on the chip have better accuracy. R16 and C5 is the low pass filter. INA210 is bi-directional and high side. The Circuit above is low side design since I Mount IN- to ground.

currensensor

This is the PCB snip. R1 (cyan) is the current shunt. The two place via connectors are the IN+ and IN- measuring the current. I am real happy with this layout because the sensor leads are so short that it will minimize noise introduction. Notice that I am deliberatly placing the place-via on the solder pads on the shunt With virtually no distance to the INA210. The low pass filter is added closer to the MCU/Connector. The layout of this worked out even nicer than I hoped, so I will be curious to test this one to see what I get out on noise vs. signal. I am actually amazed as to how much I get out of a two layer PCB – assuming this Works as expected.

I decided to add 4 current sensors and BEMF sensors because the current sensors will be heated as well and if they fail or give errors (drift) while heated they might cause a more serious error. I basically need to test them as I burn the circuit + it’s cool to have them mounted.

The values I plan is 0.001Ohm shunt and INA210 that gives 200x gain. This giver 0,015V at 15A and 3V out to the ADC while the shunt use 0,225W. I am a bit concerned that the shunt is to small, so might need to increase the shunt and reduce gain to get a better signal – we will see. The drawback of increasing the shunt is that a shunt with 0,002 Ohm uses 0,45W, a shunt with 0,005Ohm 1,1W etc. The effect usage on the shunt need to be keept as low as possible.

sc70

I have only been using SMD components for ca 1 year. I started with 1206, continued with 0806 and now I only use 0603. INA210 is SC70-6 body (X4 above) – the two resistors R2 and R3 are 0603 size to give an impression of how small this actually is. I am however not even worried about these anymore – a bit of training and patience does that to you.

DRV8711

drv8711

This block diagram is DRV8711, a Stepper Motor Pre-Amplifier from TI. This cost around 5.- USD as samples, so I am not sure I want to bother about it. But, I find it very interesting because it has an easy step/pwm interface as well as a more complex SPI. It adds features like stall detect in logic, current sensors on both phases, BEMF etc.  

I am not sure if I want to use these advanced pre-amplifiers or use more complex code. Using discrete half-bridges also enables other options to use them separate. Modern MCU’s are also so powerfully that its not rocket sciense to do the same in software + a bit of electronics. But, well we will see – I will keep an eye on the price and study this one a bit.

Driving a stepper is a rather straight forward + using software you can apply different algorithms. If you use an integrated pre-amplifier like this your locked to the logic implemented by the vendor. It’s ups and downs with everything.

20A Stepper Motor Driver

4phasedriver

This is just a concept sketch of the driver step for a 4 phase driver. We add the 4th phase, but I only use one current shunt on this. The width is ca 33 mm using the same trick in mounting a 4 pole 5.08 pitch connector on the back. I need to adjust this and find space for the 6-wire motors so will play around with ideas for now. The size above is ca 33mm x 23 mm , so an actual controller in 35 x 50 mm size might be possible.

Stepper Motor Controller

RAMPS are great for driving stepper motors for 3D printers because they are small and cost around 1.- GBP each. They are quite capable of controlling steppers up to 2A with some heat sinks, but controlling steppers above that is a challenge. Available controllers are large and tend to be expensive.

stepsticka4988

Looking at the 3-phase motor controller it is quite easy to add a 4th half-bridge to control a larger stepper motor up to 20A. The concept is simple using a discrete gate driver, two HEXFET’s and a dedicated MCU. On a driver this size you also want current sensing and a bit of protection logic. If we design for 12-24V it means we are designing a 500W stepper motor. My target is actually up to 10A, so a 20A should give me some margins.

I also want to study a gateway to the Mach 3 or similar standard. This is something I currently know little about, but I am told that this standard is important as it enables existing top-side systems to be used. My first idea is to create a RPI GW Hat to connect easyIPC and Mach 3, but I will return to the details later.

Lets look at some stepper motors (Pictures from various internet sources) to get an idea:

stepper-nema11This is a smaller Nema 11 using 0.67A. The 6 wires means we have 2 phases where each phase are two coils in series. I need to experiment a bit with this as well as test on the 28BYJ-48 that uses similar wiring with 5 leads where the two centre ones are connected. Driving motors this small is well within more cost optional solutions, but we should be able to run this as well if needed.

stepper_nema23 The Nema23 above is rated at 3,5A and typical for our target range. The same for the Nema34 below rated at 5,5A.

stepper_nema34This is a classic Nema17 (below) with double shaft. You get these below 10.- USD with single, double and hallow shafts. This one have a 0.44Nm holding torque using 1,5A. Again well within the capababilities of a RAMP.

stepper_nema17doubleYet another Nema23 with a gearbox mounted (below). Rated to 4A. Looking at various sources I find that the majority of steppers are within the range of a RAMP and very few above 10A. So a low cost controller targeting 0-10A (max 20A) should be a great addition to what currently is out there.

 stepper_nema23gear

As for wiring we should allow a stepper 4,5 or 6 wires where the 5th and 6th is +, – or not used. Minimum voltage should be 12V. We obviously need end points and I would like to add some temperature sensing as well as support for encoders. I will have a look for pre-amplifiers for this, but so far I have not seen anything worth mentioning so I am planning discrete gate drivers. This is not always a disadvantage, but a modern pre-amplifier usually implement some logic that we otherwise need to code.