OxRAMSociety / RobotArm

Public repository for all resources related to the OxRAM Robot Arm project.
https://www.oxramsociety.org/
MIT License
15 stars 7 forks source link

Fine-tune stepper drivers #13

Open dyamon opened 2 years ago

dyamon commented 2 years ago

At the time of writing, some of the stepper motors don't seem to be able to support the weight of the arm. This might be due to the fact that we are not providing enough current to the motors by setting the limit too low on the driver.

Experiment with this.

dyamon commented 2 years ago

What we are using is probably not the best setup for the robotic arm design we are going for.

Overheating problems and pulse on high current

From a RepRap forum post:

"Looks like the current is set too high to me. They run OK for a while until the chips get too hot and start cutting out, cooling a little and cutting back in. That is the pulsing effect you see in the second half of the video."

The video is not available anymore, but we have the same behaviour. From the docs:

"[A4988] offers overcurrent protection. If the boards get too hot, they will interrupt the current until it cools a bit. If the current is too high for the heat sinking, the motors will pulse as the current is interrupted and restored."

Also, about the heat sinks:

"[...] the use of some thermal conductive glue makes things easier. Try Arctic Silver - Arctic Alumina Thermal Adhesive or similar."

The effect of the small heat sink is debatable. Some people think it actually improves the performance of the driver, while RepRap highly recommends active cooling.

How to properly compute Vref

Vref refers to the voltage value that can be regulated through the small potentiometer on some drivers (e.g., A4988, DRV8825).

In order to set the value correctly you need to take into account a couple of parameters:

Once you have all the necessary info you need to refer to the driver datasheet.

Consider this datasheet for A4988. It mentions that the driver has an internal PWM Current Control for which the maximum trip current $I_{MaxTrip}$ can be computed with the following formula:

\begin{equation} I{MaxTrip} 8 R{S} = V_{ref} \end{equation}

where $R{S}$ is the value of a single current sense resistor. If we set $I{MaxTrip}$ as the rated current for the stepper motor we can get the ideal value for Vref.

Example:

Assuming we have a rated current of 2.8A (e.g., from our NEMA 23) and a current sense resistor of 100mΩ we get

\begin{equation} 2.8A 8 0.1Ω = 2.24V \end{equation}

Note: this voltage value might not be compatible with the driver. In this case, our A4988 can't even provide this value of Vref.

Similarly consider this datasheet for DRV8825. In this case the formula is slightly different:

\begin{equation} I{MaxTrip} 5 R{S} = V_{ref} \end{equation}

Example:

Similarly, assuming we have a rated current of 2.8A and a current sense resistor of 100mΩ we get

\begin{equation} 2.8A 5 0.1Ω = 1.4V \end{equation}

This is more or less what we observed during our experiments. We initially found that a value for Vref of 1.5 was giving good performances but we should be able to lower the value more.

Motor drivers used in the MoveoArm

According to this infamous picture and the building manual, the MoveoArm uses the TB6560 motor drivers. Since our electronics setup is inspired by the one from the Moveo, it would be ideal to stick to this choice.

According to the pictures in this datasheet, all the information necessary to setup the driver and limit the current flowing in the motor is reported in the silk screen.

Shoulder motors

The shoulder of the arm (at the base) is powered by two NEMA 23. So far we have used two different "slots" in the RAMPS 1.4 to power two drivers (and motors), syncing them and setting the correct direction via software. The plan was to eventually use the same driver to power two motors, inverting the signal from the hardware side.

IMPORTANT: this is not possible! This is creating a simple parallel circuit (two motors in parallel, with the power supply as a source in series with the driver). Let's assume the rated current for a single motor is 2.8A; since the total amperage flowing through a circuit is the sum of the currents of each branch, we would need a driver providing $2.8A * 2 = 5.6A$ to supply two identical motors in parallel with the correct rated current (TB6560s are not able to do that).

The solution is to use two drivers, put in parallel with the motors. At this point, the source in the circuit is simply the power supply which should be able to provide enough current to both drivers (and hence to both motors).

TB6560 setup

First of all, the driver needs to be set up using the dip switches on the board. The silk screen on the driver should give you all the information necessary to configure it.

Example:

In order to provide the correct rated current (let's say we are aiming for 2.8A, the rated current for our NEMA 23), we can set the driver to provide 3A. The "running current" table tells us to set SW1, SW2, SW3 to on and S1 to off. We should proceed similarly with the rest of the switches.

Keep in mind the terminology:

Finally, have a look at the picture to connect the driver to a RAMPS 1.4. Note that cable colors don't necessarily have any meaning and you should check with a multimeter for continuity to find out the couple of cables A+/- and B+/- that connect the driver to the motor (or alternative look at the current connections and try to remember the order of the colors).

Cable configuration for TB6560 and RAMPS 1.4

Arduino code

We should be able to use the code we have been using so far. In particular instances of AccelStepper should be created in the same way, with unaltered pins setup.

Enable pin still needs to be set to LOW (inverted pin).

Vigo-Falcrum commented 2 years ago

The drivers have been installed according to the instructions above. There is a mistake in the wiring diagram, where the driver is connected to the same potential on the power supply, resulting in no voltage across it (the supply we are using is a slightly different model, I'll add a picture once I get my hands on it again). We set the output current to 3A and the stop current to 50%.

There hasn't been enough time to test the new drivers thoroughly, but there are a few observations from those I managed to run:

In the extended position, the arm behaves inconsistently, usually managing to raise or lower itself, but plunges as soon as it stops with the characteristic sound of overloaded stepper motors.