Configuring CNC shield V3 for use with Dragonframe animation software

Hello
I have bought an Arduino UNO, CNC shield v3, 4988 stepper motor driver and a 17HS13-0404S stepper motor.

Dragonframe animation software provides a sketch for controlling it with Arduino - but the pins are not configured for use with the CNC shield. I have attached the sketch.

This gentleman kindly explains how to modify the sketch to work with the CNC shield here:

..which I have tried, but I get nothing at all going to the motors when I try to control them from Dragonframe.

I have zero knowledge about coding, so I thought I would reach out to the community for some help and suggestions. In the future I would like to buy three more motors and drivers, so I would love a solution that hooks up all four channels.

Many thanks
Daniel

DFMoco.pde (43.4 KB)

Hi there I'd just like to give this a little bump - hopefully there is somebody out there who can help as I'm really stuck

Many thanks
daniel

.which I have tried,

Please post the code that you tried. Please read the how to use the forum stickies to see how to format and post code. For a variety of reasons, many members are reluctant to download attached code.

Have a look at this post by Robin2. It explains how steppers and stepper drivers work and has a link to another post that has a simple stepper sketch that you can use to individually test each motor to confirm that the hardware is working properly.

Hi groundFungus, thanks for your reply.

I thought people might be reluctant to look at the code, but then sketch is too long to post as a message.

I will take a look at the formatting rules for the forum.

Cheers
Daniel

Here is the code I am trying to modify

DFMoco Sketch

OK, in the case where the code is too long it is acceptable to attach the code. I looked at the code that you attached, but didn't go all the way through so didn't realize that it would not fit.

Per the link that you attached you need to make these changes.
Search the file for "set output pins" and insert the CNC shield pin definitions so it looks like this.

motors[0].stepPin = 2;
motors[0].dirPin = 5;
motors[1].stepPin = 3;
motors[1].dirPin = 6;
motors[2].stepPin = 4;
motors[2].dirPin = 7;
motors[3].stepPin = 12;
motors[3].dirPin = 13;

 // set output pins
  for (int i = 0; i < MOTOR_COUNT; i++)
  {
    pinMode(motors[i].stepPin, OUTPUT);
    pinMode(motors[i].dirPin, OUTPUT);

and the lines in the #else section right before "* Serial output specialization" should be:

#define MOTOR0_STEP_PORT PORTD
#define MOTOR0_STEP_PIN B00000100

#define MOTOR1_STEP_PORT PORTD
#define MOTOR1_STEP_PIN B00001000

#define MOTOR2_STEP_PORT PORTD
#define MOTOR2_STEP_PIN B00010000

#define MOTOR3_STEP_PORT PORTB
#define MOTOR3_STEP_PIN B00010000

Replace what is there with the above.

Those changes are supposed to configure the program to work with the CNC shield.

Thanks again groundFungus

I had previously got as far as modifying the code and uploading to the board, but the problem is that I just get nothing from the motors in Dragonframe software, not a flicker.

Even with the unmodified code I could get something from the motors (albeit not what I need) but the modification just kills any response from them.

I'm certain that I am using Dragonframe in the correct manner so I can only imagine that there must be an error in the code modification provided in order to route the signals through the CNC shield.

I really do appreciate your help
Many thanks
Daniel

Before you blame the software, have you verified that the hardware works properly by writing a small sketch to test each motor individually? This post contains good information about steppers and stepper driver basics. Also a link to a simple stepper program that you could use to test the motor subsystems. Use the modified pin map that is to be inserted for the step and dir pins. Pin 2 = X step, pin5 = X dir for example. Have you set the driver current properly?

I have tested everything using the gbrl hex, uploading with xloader and testing using universal g-code sender

This works absolutely perfectly

OK then. Please post the code that does not work after you modified it (pastebin is fine). Maybe we can see something that you don't.

Do you get any messages from the program in serial monitor?

I have no experience with the slider software so am operating a bit in the dark. I am familiar with the CNC shield, though.

Hey there
Thanks so much for taking a look

Here is the modified sketch

DFMoco - modified

As far as I can see the modification is done per the link. And the code compiles, so I am at a loss as to why it will not work for you. Is there software on the PC that communicates with the slider controller? I mean how are commands communicated to the slider?

I put together a test circuit of 2 DRV8825 boards and steppers and connected to my Uno to test the last code that you posted. I am able to control the two motors by inputting commands through serial monitor. So the software does work, that leaves hardware or PC side software.

It's a really simple interface to communicate, with very little exposed to get wrong. Like I said, when I load the unmodified sketch it does work a little, that is, it rotates the motor on channel 1 only, and only in one direction -

I've attached screen grabs of the connection dialogue and the controller page.

Not sure where we go from here - Perhaps I will try and contact the guy who posted the original mod tutorial, though he does specifically say if you can't get it to work then to consult a friend rather than him! Plus he sells kits to do just this so it wouldn't really be in his interest to help me do a DIY job!

Anyway - thanks so much for your time
Daniel

I would suggest that you try to send commands using serial monitor. If that works, there is a problem on the PC side. If not, the problem may be the Arduino/CNC card. The syntax is:
mm 1 1000 move motor, motor number, steps
mp 1 Return position of motor 1
pr 2 1000. Set step rate, motor, rate
hi Should return "hi" and the software version number (1 4 1.2.7)
sa Stop all motors

Be sure the serial monitor baud is set to 57600 and line endings to cr/lf.

hm these commands work - except for the first one - mm11000

Can it be that there is something wrong with the lines:

motors[0].stepPin = 2;
motors[0].dirPin = 5;
motors[1].stepPin = 3;
motors[1].dirPin = 6;
motors[2].stepPin = 4;
motors[2].dirPin = 7;
motors[3].stepPin = 12;
motors[3].dirPin = 13;

when I remove these the motor works again as before

except for the first one - mm11000

Did you notice the spaces in the command. mm space 1 space 1000. Without the spaces (delimiters) the parser has no way of separating the parts of the command. Like I said, I connected 2 motors up and the software works fine, with all of the command that I sent, with the connections as posted for the 2 so i have no reason to expect that it won't work for 4. So if the hardware is responding to commands from the serial monitor, the problem sure seems to be on the PC side. Look in the controller software (Dragonframe??) and make sure that it is configured to use the right serial port and baud rate.

By the way I am trying this on two Arduino UNO boards and two different CNC shields and the behaviour is exactly the same on both..

when I remove these the motor works again as before

What does that mean? I am not sure what before is.

Have you read my reply#16. Have you tried the mm command with the proper syntax?

I tried with spaces and there is no movement on the motor

There are no settings for baud rate within dragonframe and it's deffinitely connected to the correct port.

As I say it is only when I upload the modified sketch that I get no movement at all. WHen I upload the original DFMoco I get movement on one axis only and only in one direction. So it does seem as if dragonframe is communicating effectively with the board.