Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 13 of 13

Thread: Stepper Driver Voltage

  1. #1
    Junior Member
    Join Date
    Dec 2017
    Posts
    12

    (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 by tyscof; 01-04-2018 at 03:50 PM.

  2. #2
    Junior Member
    Join Date
    Dec 2017
    Posts
    12
    Here is a photo comparison of the arduino and teensy. The teensy is definitely different and much less distinct pulses.
    Teensy
    Click image for larger version. 

Name:	Teensy.jpg 
Views:	183 
Size:	110.0 KB 
ID:	12326
    Arduino
    Click image for larger version. 

Name:	Arduino.jpg 
Views:	168 
Size:	101.5 KB 
ID:	12327

  3. #3
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,066
    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.

  4. #4
    https://forum.pjrc.com/threads/41311...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/41857...l=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.)

  5. #5
    Junior Member
    Join Date
    Dec 2017
    Posts
    12
    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?

    Click image for larger version. 

Name:	8mhzteensy.jpg 
Views:	148 
Size:	130.3 KB 
ID:	12332

  6. #6
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,066
    Most OP-Amps are simply not quick enough to handle digital signals at high speed properly. Comparators or Schmitt-Triggers are better for that.

  7. #7
    Junior Member
    Join Date
    Dec 2017
    Posts
    12
    Arenít Schmitt-Triggers traditionally made with an op amp?

  8. #8
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,066
    Rather with comparators, since the latter are optimized for speed and less for linear, distortion-less gain.

  9. #9
    Junior Member
    Join Date
    Dec 2017
    Posts
    12
    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.

  10. #10
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,066
    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?

  11. #11
    Junior Member
    Join Date
    Dec 2017
    Posts
    12
    Quote Originally Posted by Theremingenieur View Post
    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?
    In this link it says:
    Logic Signal Current: 7~16mA (Typical 10mA)
    Couldn't find the chip or specific octo that it uses though.

  12. #12
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,066
    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.

  13. #13
    Junior Member
    Join Date
    Dec 2017
    Posts
    12
    Quote Originally Posted by Theremingenieur View Post
    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •