Stepper Driver Voltage

Status
Not open for further replies.

tyscof

Member
(SOLVED) Stepper Driver Voltage

Hey all,
So I am trying to drive my stepper with a DM542T and the Teensy 3.5

I was using an arduino but I want to use higher microstepping than just 1/2 steps so naturally I moved up. The code was working fine on my Arduino so I moved all the pins over hoping that the Teensy would work right out of the box but to no avail. I realized that the 3.3v pins are probably what are causing the issue and when looking at the data sheet for the driver it seems I need a minimum of 4V. So I went on Amazon and got some logic level shifters. These should push my 3.3v signal up to the 5v I need. After wiring it up and hitting it with a multimeter, I indeed got the 5v I needed but the stepper wouldn't budge. Further investigating found that when my leads are connected to the driver my voltage reads 2.6v but when disconnected and only on multimeter it will read 5v. I was able to measure this by using a blink sketch making the pin high every 2 seconds. So I am not sure why this is happening other than there must be a resistor in the way that is messing it up. But even if there is one it was working fine with arduino 5v so I am not sure what the difference would be? I also disconnected the leads from the driver and connected them to an oscilloscope. I found I was indeed sending a 5v pulse when using my AcellStepper code but again my assumption is when it hits the driver for whatever reason the voltage goes too low. Are there other reason that you guys can think of that would give me this issue? Is there a simple solution like giving the logic converter 9v instead to overcome whatever the reason for the large drop? Also should there be a pulldown between my signal and ground? When I was doing the blink sketch it would take like 1/2 a second to go from 0 to 5v but I can only image what havoc this could cause when there is a fast pulse. Not sure why it wasn't a problem on the arduino then?

Code:
const int stepsPerRevolution = 200*16;  // change this to fit the number of steps per revolution
#include <AccelStepper.h>
// Define a stepper and the pins it will use
AccelStepper stepper(AccelStepper::DRIVER, 9, 8);
//AccelStepper stepper(1, 9, 8);

//number of steps to each position from 0
//long pos1 = 11810L*8;
//long maxspeed = 3937L*8;
//long accel = 4000L*8;

long pos1 = 2362000;
long maxspeed = 7874;
long accel = 8000;


  
void setup() {
  Serial.begin(9600);
  stepper.moveTo(pos1);
  stepper.setMaxSpeed(maxspeed);
  stepper.setAcceleration(accel);
  //while(!Serial);
  delay(1000);
}

void loop() {
  
//Serial.print("hi");

stepper.run();
   
}
 
Last edited:
Here is a photo comparison of the arduino and teensy. The teensy is definitely different and much less distinct pulses.
Teensy
Teensy.jpg
Arduino
Arduino.jpg
 
Two things: First, the Teensy is waaaaays faster than the Arduino, thus you should try to lower (temporarily for diagnosing) either the Teensy's cpu speed or the stepper settings for slower operation.
Second, these cheap level shifters use resistors and a MOSFET transistor. The latter have an important Gate-Source capacitance which forms, together with these resistors, a low pass filter. Thus, these cheap shifters are never usable for operation at higher speed.
 
https://forum.pjrc.com/threads/41311-Teensy-3-5-interfaced-to-a-RAMPS1-4-board

Paul offered me some good advice about better level shifters in this thread. Unfortunately, I only get a few weeks a year to play with this sort of stuff (around this time of year) and I've got other things on the boil now.. It's a real shame the following thread didn't continue..

https://forum.pjrc.com/threads/4185...al-development?p=144238&viewfull=1#post144238

I've gone back to Arduino 2560's for the moment - my Teensys in a static bag, waiting.. (Trying all the firmwares, Sailfish always produced the best prints for me, but it isn't close to being ported away from 8 bit MCUs.)
 
Okay so now I am stumped. I moved from using the logic shifters over to an opamp. With that and a 10v battery I can switch from 0 to 10v. So when running the arduino (as can be seen above) I see discrete pulses I can also see these same pulses when using the 3.3v directly from the teensy pin(not pictured). But when I go through the op amp to boost the voltage the oscilicope just shows a constant voltage at 10v and then drops to 0v when the stepper would stop moving. I tried reducing the speed down to 8Mhz on the teensy to see if it had the same waveform and it had "A" waveform but it looked different from the arduino or 3.3v teensy you will notice that the voltage is also dropped to around 3v(pictured below). This did move the stepper when hooked up but not the right speed or distance(too low). To get more information I ran a sketch to see what the max switching speed I can get with the current setup before the waveform started to make a mess. I used a blink sketch and I can see the square waveform from 0 to 10 all the way down to about 20 microseconds. After that it starts to have a lower voltage and look hairy. I get a similar voltage drop to the 8mhz acellstepper code with the blink code at 10 microsecond delay. But the blink code has a higher frequency(faster than the acell stepper). Is this problem due to the fact that the opamp circuit is too slow?

Observations:
1) Teensy 120Mhz direct from pin (3.3v) looks identical to arduino
2) Teensy through opamp at 120 Mhz makes constant 10v - switching too fast?
3) Teensy through opamp at 8Mhz more discrete pulses - I am assuming this is due to less speed required for the opamp so it makes the pulses
4) Teensy blink 120Mhz has max 20 microseconds delay - Is the AcellStepper using fast than 20ms?

8mhzteensy.jpg
 
Most OP-Amps are simply not quick enough to handle digital signals at high speed properly. Comparators or Schmitt-Triggers are better for that.
 
Okay so it looks like the op amp circuit is too slow to do the switching.
I am thinking that I should switch over to a 74HCT125 which should be fast enough since everyone uses them for neopixels but I am not sure there will be enough output current to trigger the octocoupler, thoughts? On the data sheet it says continuous output current +-25ma.
 
That depends on the optocoupler. Some work well with 3mA forward current through the internal LED. Which one are you using? What does its datasheet tell?
 
But there, you have the answer. Each logic input draws between 7 and 16mA or typically 10mA. Thus, the HCT125 which can provide up to 25mA should work. In ever case, after connecting such a level converter for one signal, you would check with an oscilloscope if the signal looks ok with quick rising and falling. Your stepper driver supports a maximum PWM frequency of 200kHz, thus it should be no witchcraft to get clean signals with the HCT125.
 
But there, you have the answer. Each logic input draws between 7 and 16mA or typically 10mA. Thus, the HCT125 which can provide up to 25mA should work. In ever case, after connecting such a level converter for one signal, you would check with an oscilloscope if the signal looks ok with quick rising and falling. Your stepper driver supports a maximum PWM frequency of 200kHz, thus it should be no witchcraft to get clean signals with the HCT125.

SHE LIVES

So that did the trick. Thanks for your help guys!
 
Hi tyscof,

I hope you are still there after 2 years!

I'm trying to use a DM542T with a Teensy 4.1 and am getting no where. I _think_ I've tried everything on this and two other posting. Can you describe what your working setup was? I have a 74HCT125 and have tried it both with and without the pulldown resistor and capacitor. I've tested the DM542T on an Uno and it does work. I just can't seem to get it working with the Teensy. How did you end up getting it working?

Thanks - Shane
 
I'm trying to use a DM542T with a Teensy 4.1 and am getting no where. I _think_ I've tried everything on this and two other posting. Can you describe what your working setup was? I have a 74HCT125 and have tried it both with and without the pulldown resistor and capacitor. I've tested the DM542T on an Uno and it does work. I just can't seem to get it working with the Teensy. How did you end up getting it working?

Thanks - Shane
What stepper driver, what stepper library? Can you post your code?

One issue is that some of the libraries don't allow for the processor being super fast and lack enough microseconds
delay to generate proper pulses for an opto-coupled driver.
 
Thanks for the response Mark.

I'm using AccelStepper.

I'm trying to run the motor nice and slow until I get it working well. Then I'll try to speed it up. Test code is:

Code:
#include <AccelStepper.h>

AccelStepper stepper = AccelStepper(AccelStepper::DRIVER, 32, 31); // interface, step pin, dir pin
void setup()

{  Serial.begin(9600);

  stepper.setMaxSpeed(500);
  stepper.setAcceleration(100);
  stepper.moveTo(5000);
}
void loop()
{
    // If at the end of travel go to the other end
    if (stepper.distanceToGo() == 0)
    {
        Serial.println("Reversing ...");
      stepper.moveTo(-stepper.currentPosition());
    }
    stepper.run();
}

I wonder if I need to increase the pulse width: AccelStepper:SetMinPulseWidth(). I'll give that a shot.

- Shane
 
I wonder if I need to increase the pulse width: AccelStepper:SetMinPulseWidth(). I'll give that a shot.

- Shane

Yes, that's the one, 15us might be a good starting place.

On the Uno it defaults to 5us, but actually takes 30us or so due to slow code execution from what I observed. On T4 its
5.1us or thereabouts unsurprizingly!!
 
OK. I've tried 10, 15, 20, 40, and 100 and I still get no response at all--I can't feel anything in the motor. I've looked at the wires again and I don't see a problem. The DM542T specifies a minimum pulse width of 2.5 us with no maximum. Should I try some other library or some other logic leveler?

- Shane
 
OK. I've tried 10, 15, 20, 40, and 100 and I still get no response at all--I can't feel anything in the motor. I've looked at the wires again and I don't see a problem. The DM542T specifies a minimum pulse width of 2.5 us with no maximum. Should I try some other library or some other logic leveler?

- Shane
 
Wiring stupidity. The power for the 74HTC125 was one off in the ground.

Thanks for your help, Mark. The setPulseWidth was the key. Without it, it doesn't work. I can set it as low as 3 and it still works. At 2, it doesn't, which matches the documented specs. Yea! One more issue overcome. The next problems, I think, are in the workshop, making parts...

- Shane
 
Status
Not open for further replies.
Back
Top