CNC Drawing Machine

Hi all.

I am building a drawing machine with an Arduino and CNC shield. I have used the attached GRBL library to upload to Arduino, and I have create a .gcode file to send using the Universal GCODE Sender (GitHub - winder/Universal-G-Code-Sender: A cross-platform G-Code sender for GRBL, Smoothieware, TinyG and G2core.).

My problem at the moment is that my servo (pen control) is not working! If I test it individually it works fine, but I haven't been able to make it work with the software while drawing.

Any suggestions/ideas?

I have tried to many things, and this has been now my last resource. Hopefully someone can suggest something I haven't thought about yet.

grblservo-ArduinoLibrary.zip (194 KB)

Hi, How are you powering your servos? You need external power not 5V from Arduino...

I have an external supply of 12V, 2A. I have also soldered from the external supply to the Vin pin of Arduino to ensure that the servo will get enough power from the external and not the USB.
(maybe in my previous attached photo you can see the red wire soldered to the pin)

The .gcode file was made in Inkscape and exported with TurnKey Laser Exported plugin

output.gcode.zip (78.9 KB)

Hi,
Whoa.. what servos are you using? Most run on 5V or 6V. If you are using +5V from Arduino the onboard voltage regulator is likely failing.

Your 5V servos need separate external 5V power..

This might help you.

@terryking228
I am using the CNC shield that provides the power supply for the servo.

@justone
I have checked the video and many other info online. I have tried many different libraries. The only one the works best is the one I have attached. However, the only problem is that the servo can't lift the pen.

I have followed all advice and tutorial from the CNC Shield, but still, it seems that all things I have tried have failed to make the servo work.

Again, if I use the same CNC Shield with the same servo but running a standard servo example in Arduino, it works fine. It just it can work same time when I upload from the Universal GCODE Sender.

Such a disappointment...

So scatter the code with lots of Serial.print() statements to check which parts of the code are executing and what values it's getting. Then just type in the GCode for raise/lower pen in the Serial Monitor and see where it's getting stuck.

  1. Check that it gets any code at all.
  2. Check if it is getting the right value for the raise/lower instruction
  3. Check if that's going to the right place to be processed into a servo instruction
  4. Check what it tried to write to the servo
  5. Check that nothing else is competing with the servo and undoing step 4.

That's the beauty of open-source: you can edit all of the code.

I am just guessing, but could there be a conflict between your library and the servo library?

Limited timers mean that different libraries some time try to use the same one and it usually does not work out well.
I just took a quick peek at the gbrl library you posted and it does mention both timer1 and timer2.
NOT that I understood any of it. Just making a guess.

Please post a link to your CNC shield and post a simple cnc program that tries to move the servo.

Where is the servo getting it's power from? I only see two modules, x and y, and the 12V input. There doesn't appear to be any other regulator on the board.

When you say it works with the standard servo library, does that mean you are hooking the servo up to the arduino? If yes, I would suspect an issue with the servo hookup/power on the board

louisbourdon:
The .gcode file was made in Inkscape and exported with TurnKey Laser Exported plugin

That Gcode has no Z instructions in it. I would expect a Z instruction to raise or lower the pen. It seems to me like you are relying on the spindle control M5 command to turn off the laser, that is raise the pen but I can't see in that Gcode where the pen is lowered / laser is turned on, that would be an M3 or M4 command.

Well...
For this part:

MorganS:

  1. Check that it gets any code at all.
  2. Check if it is getting the right value for the raise/lower instruction
  3. Check if that's going to the right place to be processed into a servo instruction
  4. Check what it tried to write to the servo
  5. Check that nothing else is competing with the servo and undoing step 4.

The code uploads fine, and everything seems to working properly except the raise/lower part of the servo - I don't know how/where to check if it is getting the right values though.

I haven't found anything that conflicts with the servo - I am using the shield as suggested by its developer (attached photo on my initial post). I have tried different powering methods, and connecting to different servo ports available from the shield; same results.

I also tried different libraries such as the GRBL-Robottini as the developer comments that the servo raise/lower instruction should work fine, but again --- it doesn't work. I follow the steps for installation/powering/connection; still nothing.

Here I include the library, and the GCODE I am sending to it (again, I have tried many different files but still no results for the servo).

grblRobottini.zip (162 KB)

output.gcode.zip (78.9 KB)

Ok... Problem fixed!

Nothing to do with the Arduino code or the shield. The problem was in the GCODE file, as it didn't include information for the M5 / M3. I finally used the GRBL Robottini library for Arduino, used Inkscape with the MI extension (as explained here: DrawingBot with improved head and rotate pen (for fountain pen) by avanhanegem - Thingiverse), and send the GCODE to Arduino using the SourceRabbit Code Sender.

I include the final file that I used for a reference

Cheers!

servo_0003.gcode.zip (86.2 KB)