Skip to content

Week 16

Servo driver DRV8251ADDAR

I made the PCB according to the example from Neil, but I never really looked into the details of the current sensing and limiting features. Now was the time to take a closer look, to understand the logic and do some testing.

According to the datasheet, the current sensing and regulation feature is called IPROPI. The resistor, that is connected between pin 7 (IPROPI) and ground, is to generate proportional voltage and compare it to the reference voltage pin 4 (VREF).

\[V_{IPROPI}=I_{IPROPI}*R_{IPROPI}\]

For current limitation, the chopping threshold is calculated with the formula

\[I_{IPROPI}*A_{IPROPI}=V_{VREF}/R_{IPROPI}\]

In my case, I have a 5 V microcontroller, so I can control \(V_{VREF}\) in the range fron 0 V to 5 V.

\(A_{IPROPI}\) is the gain of the circuit defined in the datasheet.

For my motor, I want to limit the current to 1,5 A or less. Below is a graph, showing the relationship between Reference Voltage and Trip Current with the 1 kΩ resistor.

V_VREF vs I_TRIP

I wrote a function to set all four PWM pins according to the input of the trip current.

// Calculate and set reference voltage for DRV8251 for current limit
void itripset (float itrip){
  float coeff = 1.575;   // Correlation factor
  int   pwm   = 255;     // PWM range 0 - 5V
  int   vref  = floor(itrip*coeff*pwm/5);
  analogWrite(VREFM1D1,vref);
  analogWrite(VREFM1D2,vref);
  analogWrite(VREFM2D1,vref);
  analogWrite(VREFM2D2,vref);
  mySerial.print("PWM set to: ");
  mySerial.println(vref);
}

After having tested and verified that part of the code, I went ahead and decided to test the standard Stepper.h stepper motor library.

The setup is easy and I created a loop to run the motor five rotations forward and reverse, with delay in between.

It works!

It runs quite smoothly and you can hardly see the housing's rotation on the base plate.

Because I could feel the h-bridges heating up and I don't need the holding function of the stepper motors, I decided to turn off the coils, when the motor isn't running by adding another function.

void motorstop(){
  digitalWrite(M1D1IN1, LOW);
  digitalWrite(M1D1IN2, LOW);
  digitalWrite(M1D2IN1, LOW);
  digitalWrite(M1D2IN2, LOW);  
  digitalWrite(M2D1IN1, LOW);
  digitalWrite(M2D1IN2, LOW);
  digitalWrite(M2D2IN1, LOW);
  digitalWrite(M2D2IN2, LOW);    
}

Design fault

When assembling the parts for the harmonic drive I realized, I made a fundamental mistake in the design. It is quite obvious, when thinking about it afterwards: There are three main components in the harmonic drive that rotate relativly to each other.

  • Wave generator - connected to the motor
  • Circular spline - connected to the foundation
  • Flex spline - connected to ... ?

I forgot to connect the flex spline!

As with the current desing - there is no drive. The gear can rotate freely, because the connection from the flex spline to the main housing is missing.

Because the housing takes the longest time to print and I don't want to make a new at this stage - I'm going to design a fix for this prototype. The only area accessible for the connection is between the two large bearing. I'm going to try and glue an adaptor piece there. Now I realize, that the timing belt is too narrow for the design I had in mind. The next best solution is to try and 3D print the flex spine.

Here is the design I came up with:

Flex spline

Let's see if the flexure in the circumference will allow the spline to flex sufficiently.

After having printed the new flexure and some more components I also got my base plate cut at a local shop and started with the most rewarding part - assembling new equipment.

Base plate with spirit level and circular spline. Note the notches for aligning north-south during installation.

Base plate

New flex spline inserted (red). I still have to decide on how to secure it in place. I might add some dovel pins rather then glueing it (for maintenance).

Flex spline

Here I printed another flex spline and secured it with six Ø3 mm dovel pins.

Flex spline secured

The video shows how the internals of the harmonic drive move.