585,877 active members*
3,385 visitors online*
Register for free
Login
IndustryArena Forum > WoodWorking Machines > DIY CNC Router Table Machines > DIY L298N Controller with GRBL Wiring Question???
Results 1 to 18 of 18
  1. #1
    Join Date
    Jul 2011
    Posts
    0

    DIY L298N Controller with GRBL Wiring Question???

    Hey guys,

    I've been designing/building a small arduino controlled cnc machine now for a few weeks and I am now trying to get my arduino with GRBL loaded on it to move my stepper motors. The issue I am having is that grbl uses only step and direction connections to operate the steppers. Before I was using the arduino stepper library using the step command stepper(STEPS,pin1,pin2,pin3,pin4) connected to the respective pins on my 4 wire bipolar stepper motor. This is the wiring schematic I was following. Wiring Schematic

    Could someone please provide me with an alternate wiring schematic with only step and direction pins. Do I need different components? Do I need a L297? Please help so many sleepless nights... Thanks.

    -Ryman

  2. #2
    Join Date
    Jan 2010
    Posts
    2141
    An L297 would translate step and direction outputs from the grbl to the coil energization sequence required for the input to the 298.

  3. #3
    Join Date
    Dec 2010
    Posts
    313
    Quote Originally Posted by doorknob View Post
    An L297 would translate step and direction outputs from the grbl to the coil energization sequence required for the input to the 298.
    Yes... Arduino has the Grbl Hex loaded and the Hex file translates the information to step pulses, you are correct, however a little off topic.

    The question still remains........
    What is an alternate way to wire the stepper?
    How does he wire things with a L298N using just "Step" and "Dir" pins, how/ where do the other two wires connect?

    Here is the code showing only three wires for each axis, where does the fourth connect?

    #define STEPPERS_DISABLE_DDR DDRB
    #define STEPPERS_DISABLE_PORT PORTB
    #define STEPPERS_DISABLE_BIT 0

    #define STEPPING_DDR DDRD
    #define STEPPING_PORT PORTD
    #define X_STEP_BIT 2
    #define Y_STEP_BIT 3
    #define Z_STEP_BIT 4
    #define X_DIRECTION_BIT 5
    #define Y_DIRECTION_BIT 6
    #define Z_DIRECTION_BIT 7

    #define LIMIT_DDR DDRB
    #define LIMIT_PIN PINB
    #define X_LIMIT_BIT 1
    #define Y_LIMIT_BIT 2
    #define Z_LIMIT_BIT 3


    Rob
    what is a cnc

  4. #4
    Join Date
    Aug 2007
    Posts
    17
    Quote Originally Posted by crob09 View Post
    The question still remains........
    What is an alternate way to wire the stepper?
    How does he wire things with a L298N using just "Step" and "Dir" pins, how/ where do the other two wires connect?
    The answer provided, is the best answer.

    Because the L298 is expecting to drive the indvidual coils of the stepper, and the Grbl firmware outputs step and direction signals, you need to decode the step and direction signals to feed into the 4 L298 inputs. The easiest way is to use an L297. I just Googled the datasheet and the L297 supports unipolar and bi-polar motors, so no probelm there.

    If you want to get more adventurous, you could program a small PIC or AVR to act as the glue logic between the Arduino and the L298.

    For the old timers in the group, an up/down counter and a handful of gates could also be used.

    If you want it to just work, use the L297.

    Dennis

  5. #5
    Join Date
    Dec 2010
    Posts
    313
    Quote Originally Posted by dcartier View Post
    The answer provided, is the best answer.

    Because the L298 is expecting to drive the indvidual coils of the stepper, and the Grbl firmware outputs step and direction signals, you need to decode the step and direction signals to feed into the 4 L298 inputs. The easiest way is to use an L297. I just Googled the datasheet and the L297 supports unipolar and bi-polar motors, so no probelm there.

    If you want to get more adventurous, you could program a small PIC or AVR to act as the glue logic between the Arduino and the L298.

    For the old timers in the group, an up/down counter and a handful of gates could also be used.

    If you want it to just work, use the L297.

    Dennis
    We know what GRBL does, we know that Arduino can have grbl loaded, the chipset we are using is the l297N.
    So how do you connect the stepper to the Driver and the Driver to Arduino using the information provided in the C language above?

    Again you have not answered the question, instead you stated the obvious.
    No one asked if the L297 is the proper driver to use, or if grbl will work.
    Also as for the "glue" a GUI written in VB or C++ does just fine, grbl is the sketch for Arduino, it is compiled into HEX, the HEX loaded onto Arduino is what Makes the Arduino do what you want.
    Arduino is the processor here, the computer and GUI send packets to the Arduino, the program aka Hex file loaded on the Arduino then process the packets and send pulses to the driver boards, in this case we are looking at the L297N, another case may use ULN2003, or TB6560's.

    So how do we wire this using just "Step and Dir"??

  6. #6
    Join Date
    Aug 2007
    Posts
    17
    May be this will help Let me google that for you ...

    4th site in the list (Stepper motor controllers), schematic at bottom of first page. Step goes to CLOCK, direction to CW/CCW.



    Dennis

  7. #7
    Join Date
    Dec 2010
    Posts
    313
    Quote Originally Posted by dcartier View Post
    The answer provided, is the best answer.

    you need to decode the step and direction signals to feed into the 4 L298 inputs. The easiest way is to use an L297. I just Googled the datasheet and the L297 supports unipolar and bi-polar motors, so no probelm there
    If you want it to just work, use the L297.

    Dennis
    Explain how that helps?
    How does this show people how to wire the L298N to the Arduino and steppers based on the grbl config file?
    Also why are you going off about some L297? Hwy not just say a person whould use the TB6560?

  8. #8
    Join Date
    Dec 2010
    Posts
    313
    Quote Originally Posted by dcartier View Post
    May be this will help Let me google that for you ...

    4th site in the list (Stepper motor controllers), schematic at bottom of first page. Step goes to CLOCK, direction to CW/CCW.



    Dennis
    I don't see how the link you provide shows the connection of the l298N to the Arduino Micro that contains grbl...

  9. #9
    Join Date
    Aug 2007
    Posts
    17
    I think one of us is not understanding what the original poster is asking ...

    1. He was using the Arduino stepper library to output to 4 pins directly hooked to the L298N inputs.
    2. Now he is using Grbl which outputs 2 singals (step and direction).
    3. He needs to decode the Step/Driection signals back to the 4 signals for the L298N (assuming he still wants to use an L298N).


    Whether or not he should stick with the L298N or use a TB6560 is moot.

    Placing a L297 inbetween the Ardiuno Step/Dri outputs and the L298, and hooking the PIN for Step to CLOCK and the PIN for Direction to CW/CCW will again make his previous solution work (Eg. the Arduino & L298N).

    Dennis

  10. #10
    Join Date
    Dec 2010
    Posts
    313
    Quote Originally Posted by dcartier View Post
    I think one of us is not understanding what the original poster is asking ...

    1. He was using the Arduino stepper library to output to 4 pins directly hooked to the L298N inputs.
    2. Now he is using Grbl which outputs 2 singals (step and direction).
    3. He needs to decode the Step/Driection signals back to the 4 signals for the L298N (assuming he still wants to use an L298N).


    Whether or not he should stick with the L298N or use a TB6560 is moot.

    Placing a L297 inbetween the Ardiuno Step/Dri outputs and the L298, and hooking the PIN for Step to CLOCK and the PIN for Direction to CW/CCW will again make his previous solution work (Eg. the Arduino & L298N).

    Dennis
    What?? What Arduino library exactly, the GRBl hex uses the Arduino library, it is written in C language like all other sketches, the only difference is that it is compiled using Hex for space reasons.

    He needs to decode the Step/Driection signals back to the 4 signals for the L298N
    What??
    Here is a completed IC, http://www.ebay.ca/itm/180822358918?...84.m1439.l2649
    wire that to arduino, only using step and dir.
    The question can't be more clear.
    How do you wire this http://www.ebay.ca/itm/180822358918?...84.m1439.l2649 to the Arduino that contains a HEX instance of grbl?
    Most drivers require four pins, "step dir min max" how do you wire using "step and dir"? I still don't see a schematic or an explanation, instead people are suggesting that IC's be added, or they explain the question again.
    The concept is clear, the wiring isn't.

  11. #11
    Join Date
    Mar 2003
    Posts
    35538
    How does he wire things with a L298N using just "Step" and "Dir" pins, how/ where do the other two wires connect?
    You don't. As they both said, you need the L297. Which the original poster asked if he needed.
    Gerry

    UCCNC 2017 Screenset
    http://www.thecncwoodworker.com/2017.html

    Mach3 2010 Screenset
    http://www.thecncwoodworker.com/2010.html

    JointCAM - CNC Dovetails & Box Joints
    http://www.g-forcecnc.com/jointcam.html

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

  12. #12
    Join Date
    Dec 2010
    Posts
    313
    Quote Originally Posted by ger21 View Post
    You don't. As they both said, you need the L297. Which the original poster asked if he needed.
    Why would you need the L297 when GRBL is a firmware written to translate the information being sent from the PC. The computer sends packets to the Ardunio using a G-code sender GUI written in "C", the sketch sends pulses to the driver threw the Arduino I/O's.
    The L297 isn't needed here, look at the grblsheild.
    I also found that one of the pins are common, if you look at the code sample I supplied you will notice that three of the four connections are defined, also check this out Electronics kinda primitive but not mine!
    This works for people with out the L297, but you dont have to take my word for it.

  13. #13
    Join Date
    Mar 2003
    Posts
    35538
    Grbl is a g-code interpreter.

    The link you posted has step/dir signals coming from the Arduino into the drive. The L298 does not accept step and dir signals, so you need the L297 to translate them.
    Gerry

    UCCNC 2017 Screenset
    http://www.thecncwoodworker.com/2017.html

    Mach3 2010 Screenset
    http://www.thecncwoodworker.com/2010.html

    JointCAM - CNC Dovetails & Box Joints
    http://www.g-forcecnc.com/jointcam.html

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

  14. #14
    Join Date
    Aug 2012
    Posts
    0
    There's 2 options here.

    1st option is to use the L297 that has been mentioned earlier and use vanilla grbl. No code changes needed.

    2nd option is to use same wiring as with the stepper example and rewrite the step pulse generation code in grbl. This is not trivial.

  15. #15
    Join Date
    Aug 2012
    Posts
    0
    Btw, this question is why I joined this forum. I started doing proto machine (just for learning all this stuff before real thing) and I'm using cheap chinese motors that have ULN2003 board connected. It takes 4 pins as input too. I found out this: https://github.com/grbl/grbl/issues/56 and contacted nullsub. He sent me code that works with my setup. I'm in process of testing this stuff thoroughly and the author of the code wanted to know my results so he can add this stuff to wiki. So there IS answer to this problem that CAN be done in the code and we will be putting it in wiki. Hope this helps

  16. #16
    Join Date
    Feb 2016
    Posts
    2

    Re: DIY L298N Controller with GRBL Wiring Question???

    Hej, just wondering if you ever got this to work? I've got 3 individual L298 controllers connected to 3 stepper motors, each using 4 pins to connect to the Arduino Uno. GRBL natively uses 2 pins to control the stepper motor (via an L297) but how does this work for the L298 with 4 pins? Just wondering if this was ever solved, or do I have to move to the L297 with the 2 pin controls.


    Quote Originally Posted by MuJ View Post
    Btw, this question is why I joined this forum. I started doing proto machine (just for learning all this stuff before real thing) and I'm using cheap chinese motors that have ULN2003 board connected. It takes 4 pins as input too. I found out this: https://github.com/grbl/grbl/issues/56 and contacted nullsub. He sent me code that works with my setup. I'm in process of testing this stuff thoroughly and the author of the code wanted to know my results so he can add this stuff to wiki. So there IS answer to this problem that CAN be done in the code and we will be putting it in wiki. Hope this helps

  17. #17
    Join Date
    Mar 2009
    Posts
    533

    Re: DIY L298N Controller with GRBL Wiring Question???

    Quote Originally Posted by AutoPumpkin View Post
    Hej, just wondering if you ever got this to work?....
    It appears not.
    The answers given were too abstract for the OP. He was looking for code to "glue" the grbl function and the L298 driver code function into one sketch. This "missing" information was not forthcoming.
    The OP's dilemma is an incomplete understanding of what he needs to do. He correctly used an Arduino Library sketch to control an L298 driver to run his steppers. But this sketch doesn't receive STEP & DIR signals as inputs. He then reloads his Arduino with a HEX grbl sketch which is "missing" (because that is not its function) the code for the L298 driver. The "missing" code may exist somewhere but I'm not aware of it, nor do I have it. So, I too, can't satisfy the OP's question.
    The other answer was to use another piece of hardware, the L297, which can drive the L298 directly, but a different sketch is needed too for the Arduino. It was implied that the HEX grbl sketch could drive the L297, thus meeting the goals of the OP.
    Interfacing objects is a big issue for many beginners when they simply want a "cut&paste" solution without fully knowing how each part works.
    Keep learning until you resolve your problem. Homework is required for success.

  18. #18
    Join Date
    Feb 2016
    Posts
    2

    Re: DIY L298N Controller with GRBL Wiring Question???

    Thanks for the feedback. I was really just checking to see if it's been done before. I'm no expert at coding, but will have a look to see if I can contribute something. Won't be too quickly though.

Similar Threads

  1. L297 - L298n
    By reuven81 in forum Open Source Controller Boards
    Replies: 5
    Last Post: 07-17-2015, 08:08 PM
  2. DIY CNC Router - Arduino + GRBL - Question about accuracy - integer precision?
    By vitaminrad in forum Open Source Controller Boards
    Replies: 8
    Last Post: 01-09-2014, 10:10 PM
  3. Another sPID, G540, and Mach wiring question for the wiring challenged..
    By adam_m in forum DIY CNC Router Table Machines
    Replies: 17
    Last Post: 01-02-2014, 01:29 AM
  4. pluto-p l298n connection
    By AvioP in forum LinuxCNC (formerly EMC2)
    Replies: 2
    Last Post: 09-10-2012, 09:49 AM
  5. Parallel L298N driver circuit help
    By Sidco7 in forum Stepper Motors / Drives
    Replies: 12
    Last Post: 03-01-2011, 04:56 AM

Tags for this Thread

Posting Permissions

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