Voltage ramp on teensy 4.0 pins too slow for my application

Hi,

I am trying to drive a bunch of 9V DC motors using some H-Bridge chips and my teensy. For my application, I need that the motors turn on and then off very rapidly when asked to by the microcontroller. I hooked up the motors, but I noticed that motor performance was very inconsistent, with some motor turning strongly and other turning weakly. After some trouble shooting, I discovered that the voltage ramp on the teensy pins was also inconsistent. I am turning on the pins for only 50 milliseconds, but the voltage on the pins ranges from 0.4 V to about 0.8 V. Once this goes to the H-bridge, the difference is even more significant. Thus, the inconsistent motor performance.

If I am not mistaken, the voltage on the pins is supposed to reach around 3V eventually, but I am not getting anything close to that during the 50 millisecond they are digital "ON" period. Does anybody know if there is a way to get the voltage across the pins to ramp more quickly?

Thanks in advance!
 
Look on the forum/Manual/Source code for DSE - Drive Strength Enable - adjustments.

The pins are set at a moderate rate to minimize the noise that results from rapid ramping.

If you find a solution, please post - if not post status ...
 
I'm pretty sure there is a serious problem with the circuitry connected to Teensy, or perhaps in the way it's connected, rather than the problem being slow rise time. But what circuitry problem could be, I can't even begin to guess because I can't see your circuitry or even know what really is, other than some sort of H bridge motor driver.

But I can comment on the rise time. I ran a quick test with this simple program, which uses only the default settings, nothing special to configure faster signals speed.

Code:
void setup() {
  pinMode(1, OUTPUT);
  noInterrupts();
}

void loop() {
  digitalWrite(1, HIGH);
  delayNanoseconds(100);
  digitalWrite(1, LOW);
  delayNanoseconds(100);
}

Here is the waveform my oscilloscope sees. On the right hand side you'll see I turned on the scope's measurement of rise and fall time. Both are measuring 1.6 ns when viewed at this scale of 100 ns/div.

file1.png

Here is a zoom in to the rising edge, as fast as the time scope on my scope can go, only 2ns/div. Here with higher resolution the measurement turns to 1.39ns. But really you could argue the rise is about the width of 1 division, depending on where you define the stop and stop of the rise.

file2.png

Also consider the scope's rated bandwidth is only 200 MHz. If you apply this 0.45 rule of thumb for scope bandwidth versus rise time, it's quite possible my scope might have more than 200 MHz bandwidth. If we call this rise time 2ns and apply that 0.45 ratio, it would mean 225 MHz. If the rise is 1.39ns and the 0.45 rule applies, this would be 324 MHz bandwidth.

My point is the rise time is very fast, so fast that even my 200 MHz oscilloscope probably isn't fast enough to accurately measure it. And you can see on the vertical scale of 2 volts/div that it really does rise up to 3.3V, with a small overshoot. I was awkwardly holding a small wire between Teensy's GND pin and the scope probe ground while fiddling with the scope buttons to create these screenshots for you. Some of the overshoot in these images might be contributed from ground inductance that caused that piece of wire. Good quality high bandwidth measurements are difficult, and I did this quickly just for the sake of answering your question about the rise time.

But really my point is you probably have something really wrong with the circuitry or connection to Teensy if you're not getting approx 3.3V logic high. Whatever is wrong, causing your motor control to waiver, it unlikely to be the rise time. We could help you more if you show us what sort of circuitry you're using. Clear diagrams and photos might really help.
 
Hi Guys,

I want to report back on this issue. Its taken me some time, because I wanted to completely rewire all the connections and do other trouble shooting.

FYI, for my H-Bridge driver chip, I am using break out boards for DRV8837. I am running a total of nine 5V DC electric motors with my set up, although only one is switched on at any given time. All nine are hooked in series to the 5V pin on the teensy 4.0's power supply. The motor I am having trouble with is the last in the line, as it never seems to have enough power to turn with the same distance as the others.

Each motor is hooked up to the output + and - pins for the DRV8837, with the chip's input pins going back to the microcontroller. The microcontroller pins going to the DRV8837 are driven Digital HIGH for the +, and Digital LOW for the -. As I said, this gives me a satisfactory result for all the motors except the last one. For each DRV8837 input, the voltage across the pins is about 400 mV, including for the last weak motor.

I originally thought that the voltage from the microcontroller pins for motor #9 was ramping too slowly, but when I finally got a scope and hooked it up I found that the signal across the DRV8837 input pins was very noisy (pic attached). This was NOT the case for motors 1 to 8. I put a capacitor across the motor, and this cleaned up the noisy signal, but the motor was still weak. I even swapped out the DRV8837, but the result was the same. I tried putting a capacitor across ALL the motors, but this just seemed to cause them all to malfunction at random times. I have ordered a replacement motor for motor #9 in case it is bad, but I really don't know what else to try.

Any suggestions?
 

Attachments

  • compressjpeg.zip
    914.8 KB · Views: 35
With all those motors hooked to the Teensy you may be drawing too much current, scope your Vin pin to see if the voltage is sagging.

I would guess you must have the motors wired in parallel instead of series but anyway if your driver looks like this...

Hbridge.jpg

You would wire the VCC pin with 3.3 volts as that determines the logic level.
You would wire the VIN pin with 5 volts assuming you have 5 volt motors.
 
Hi, I know its been a few days, but I wanted to report back.

"With all those motors hooked to the Teensy you may be drawing too much current"

I understand your point, but the thing is I am only running one motor at any given time. It is strange that the problem is only on the motor "at the end of the line".

So I put together a crappy schematic of the project and the code I am running.

I REALLY appreciate your help with this guys!
 

Attachments

  • motor_test1_-_submitted_to_pjrc_forum.ino
    3.6 KB · Views: 31
  • 9 motor controller diagram.pdf
    394.5 KB · Views: 57
Jambalaya:
Is that schematic actually the way you have this circuit wired? My first questions would be, where are the capacitors that should be attached to the +5V connections? I would recommend .1uF film and at least 5 to 10 uF good quality electrolitic capacitors on the +5 volt lines. This is especially true if you have long leads involved. Circuits like these generally need a separate PS for the peripheral parts in the circuit, or at least separate wires connected to the supply as opposed to tagging off the Teensy 5volt and ground pins.

My 2 cents worth,
Ed
 
You need separate grounds for power and signals. Power grounds carry high currents and for motors like this very high dI/dt values, which means a great amount of noise voltage across the ground wire. The signal ground or grounds need to be separate wires, routed with the signals, separate from any high current wiring. Then the noise voltages on the power ground wire doesn't polute the signals.

My suspicion is the reason the last motor is more problematic is its wiring has the biggest loop-area, loops act as antennas. Thus best practice is twisted-pair for every power/ground cable and every signal/ground cable. This minimizes loop area and successive half-twists cancel each other too.

If you can arrange that the only high-current wiring is from the 5V supply to the motor drivers, and never goes near the microcontroller, that's also likely to help. There's little hope of stable operation if you run the motors and the microcontroller from the same 5V BTW.
 
Ok. I went back and learned how ground loops can add noise to a circuit. Based on that, I rewired my project such that the ground rail has one and only one path for the current to follow. I uploaded a new diagram that you can use to compare what I did before to what I did now. I tested the motors out now and they are considerably less noisy than before, so I think it worked.

It was not practical to use a separate power supply for the motors (as suggested here) because this project will be a computer peripheral, and it would be impractical to plug it in to an electrical source as well as the computer. It was also not practical to have two separate ground wires forming two circuits (twisted pairs), as the DRV 8837 only has one ground pin with connects through the chip to both the motor and the logic gate. Thus, there is one positive rail for the logic, one positive rail for the motor, and the connections inside the chip take care of the rest.

As I said this does work, but I'm posting here to give others doing something similar a reference and also to let those more experienced comment if further improvements could still be made.

Thanks again for all your help.
 

Attachments

  • Electronics Layouts v2.xlsx.pdf
    117.1 KB · Views: 37
OK, I hooked Vcc to the +3.3v pin and it made the motors weaker. Not sure why. As I said, I am still experiencing some variation between motors, but it is much better than before now that the ground loop issue has been fixed. For the benefit of future readers, I am attaching a schematic of the final fix I did to clean up the ground loop.

Thanks again to everybody who replied!
 

Attachments

  • Nine motor controller diagram v3.pdf
    395.5 KB · Views: 29
Back
Top