[Irene] Motor Drivers

I used a waveform generator to output a square wave with T = 2.0ms, Ampl = 3.3Vpp, HiLevel = 3.3Vpp, Offset=1.65Vdc, LoLevel=0V, and Duty Cycle between 20% and 80%. The servo seems to work fine, with a few glitches when the duty cycle was low.

Animated GIF - Find & Share on GIPHY

However, using the servo library on the Arduino, the pwm output from pin 9 looks funny. Here is a comparison on the oscilloscope:

Yellow is the square wave from the waveform generator, and green is the output from the Arduino using the servo.h library and the sample code provided by adafruit here https://learn.adafruit.com/adafruit-arduino-lesson-14-servo-motors/arduino-code-for-sweep. Upon inspection of the Arduino servo library, it looks like the servo.write() function sets an interrupt. When I set my own pwm using the following code:

void loop()
{
  digitalWrite(servoPin,HIGH);
  delayMicroseconds(active_us);
  digitalWrite(servoPin,LOW);
  delayMicroseconds(period_us - active_us);
}

Hallelujah, the Arduino output has the correct duty cycle and period, but the amplitude voltage is lower. Here is what the output from the oscilloscope looked like:

In the context of the system, I would need to use interrupts to manage the PWM when integrated with the sensors.

I ordered parts for five alternatives because I don’t think we have time for ordering parts for a Plan B. In order of potential, my options are:

  1. NEMA 17 & L298 hbridge (cheap from amazon): There are many resources out there using these two parts together and I (almost) had it working with the same type of hbridge last week. 
  2. NEMA 17 & L298 hbridge (expensive from sparkfun): I’ve learned from Build18 that cheap parts are not reliable, so here’s an alternative. The hbridge is the same model, but the breakout board looks more enhanced. The heat sink is larger.
  3. NEMA 17 & TB6600 motor driver (as recommended by Nathan Serafin). This driver is very heavy duty and reliable, but there are not many resources out there for how to use it.
  4. Continuous rotation servo: I feed this a time interval and it spins for that amount of time, but is very imprecise.
  5. The original servo: I believe I could hack something together to make this work, but it wouldn’t be pretty. I have better options, and this is only a backup on backups.

If the option that I go with does not have enough torque (which is unlikely), I can use a counterweight to require less torque.

I got through trying options 1-3. Here are my results.

  1. NEMA 17 & L298 hbridge (cheap from amazon):Animated GIF - Find & Share on GIPHY

    The motor stutters, but is drawing much less current than the imposter NEMA 17.

  2. NEMA 17 & L298 hbridge (expensive from sparkfun): I wired everything, but there is no current flowing. I looked at the user manual and found operating instructions that include the use of ENA and ENB, which I haven’t needed to use before when following other tutorials. I will try more wiring configurations
  3. NEMA 17 & TB6600 motor driver: This I have no clue how to wire up (LOL). I will meet with Nathan to figure it out.

In other news, I have mounted the camera and LED to the door. They are both taped on so we can remove or adjust them.

Here is what the camera output looks like:

And with the lights off and LED on:

And I was standing about two feet away:

I’m behind and still working to solve the same problems as last time.

Leave a Reply

Your email address will not be published. Required fields are marked *