Close
0%
0%

3040 CNC Milling Machine Mods

Upgrades to 3040Z-DQ

Similar projects worth following
Purchased a 3040Z-DQ CNC Machine on ebay, as I needed one to produce a face plate for my Air Gesture Switch project. I felt the machine could be made much better, so I'm upgrading it and documenting the process here.

The "3040" in the model 3040Z-DQ means the working platform is 30cm by 40cm, in reality you can use about 27x37cm. The "Z-DQ" model uses NEMA23 stepper motors, ball screws, and has a 230W DC spindle motor.

These Chinese CNC machines on ebay are good quality and cheap, but require that your computer has a parallel port. Who still has one?

As you can see in the project logs, I swapped out the origional controller for a TinyG v8, which has USB and could be used with many different G-Code senders.

Years pass and I found my TinyG v8 board to be very unreliable. Randomly a axis will corrupt it's saved G54 origin during a job. This has resulted in several failed jobs! Also I've had bugs from day 1 that still haven't been fixed (4 years on!) e.g. Real-time Work Position (G54) at some point stops being updated/displays zeros (same issue regardless of g-code sender). It seems Synthetos has stopped supporting it's TinyG v8 users in favor of the TinyG G2.

I use a X-Carve at work running GRBL which I've never had issues with, therefore I'll for now stick to GRBL.

It's possible to avoid all the controller box modifications I've made if you keep the original stepper controller and connect an arduino running GRBL to the parallel port (see my GRBL to Parallel Port project). Plus this makes things easier if you decide to change controllers in the future. ESP32 GRBL is cool because it can run jobs off an SD card and be controlled over wifi.

The G-Code sender I currently use is called CNCjs. I highly recommend it for GRBL/Marlin/Smoothie/TinyG.

Another thing I upgraded on this machine was the existing limit switch wiring. The limit switches were Normally Open and setup in parallel. I changed it to Normally Closed and in series for better noise immunity, and fault detection.

I have spindle ON/OFF and PWM control working in software.

Visit the project logs to see what I've done.

  • TM1638 Confirmed

    Johnny07/04/2019 at 12:18 0 comments

    My suspicions were correct. Display driver is TM1638 or similar. Shows mode selected and speed. Not sure what the 3 extra LEDs lit represent though.

    I also found a settings menu.

    Hold down button 1 for 5 seconds. Cycle through menu items with button 1. Change the setting with button 2/+ or 3/-. Finally hold down button 1 for 5 seconds to save.

    F1 = (1-3) default speed input mode, 1 = PWM, 2 = Dial, 3= Push Button.

    F2 = (1-10) Ramping speed, fast (1) to slow (10). About 3 is a good balance. Too low a value and turning the motor speed up too fast can cause the controller to detect over current condition.

    F3 = (1-80) Seems to affect the PWM's lowest duty cyle. About 10 is a good value.

    F4 = (1-100) Push Button mode starting speed, as percentage.

    F5 = (OFF/ON) Display set speed as percentage (OFF) or RPM (ON)

    #P = (0-30000) Displayed speed in RPM at 100% speed

    # Menu item only exists when F5 = ON

    One annoying thing though, PWM mode will not to get up to 100% speed. Mine maxes out at 63%. As seen by the STC micro, 5V is 0%, 0V is 100%. Mine will get down to 2.5V. Not exactly sure what's causing this yet. 

  • PWM into Spindle Controller Working!

    Johnny06/18/2019 at 15:08 0 comments

    So I've worked out how to enable PWM on this controller and in the process discovered more features.

    From what I can tell, there are three modes of speed control, trimpot/dial, +/- push buttons and PWM mode.

    To enter into a mode connect momentarily either P3.0/P3.1/P3.2 to GND while spindle enable is off. P3.0 is dial, P3.1 is PWM and P3.2 is +/- buttons mode. Now enable the spindle and control the speed. To control the speed in +/- buttons mode, P3.0 is + and P3.2 is -.

    P3.6, P5.4 and P5.5 are serial pins that go to a seven segment driver IC, looks to be TM1638. P3.6 is CLK, P5.4 is DIO and P5.5 is STB. From what I've decoded on my oscilloscope, the display says which mode you are in, current state of the spindle (on/off) and the spindle set speed represented as a percentage. Data in the image below is reversed, should have been LSB. 0xC0, 0x73, 0x89, 0xC2, 0x06, 0x89, 0xC4, 0x40... If the TM1638 is used, more buttons might be available.

    I've got PWM to work through Pin 17 of the parallel port, but mind you, the signal from GRBL needs to be inverted first, otherwise for example g-codes S1 would be flat-out and S11000 off.

    Here's how it's connected...

    Signal into Stepper Controller (JP-382A) via DB25 and circuit pre four pin connector:

    If you're curious, the ISO +5V is a isolated 5V generated on the stepper controller by this unmarked black box:

    Four pins on the Stepper Controller connector labeled PWM-OUT go to another four pins on the Spindle Controller connector labeled PWM:

    The image below is the PWM in circuit on the Spindle Controller.

    Also a side note. The Stepper Enable signal from the DB25 Connector does nothing due to a missing resistor on the LED side of the optocoupler. The Enable on the stepper drivers are permanently on.

  • It's been a while

    Johnny06/13/2019 at 08:30 0 comments

    So I never got round to getting software speed control working, just didn't need it and couldn't be bothered, manual control works fine for what I do...

    Recently I started working on my Nixie Clock project again and I needed to mill a wooden enclosure. So I dusted off the CNC and had a go. The TinyG somehow changed its G54 during a big job, and ruined the work. This happened several times more. I looked on Synthetos's github for an update for the TinyG v8, but there hasn't been one for 4 years! Seems they only work on the TinyG G2 these days. So I decided it was time to let the TinyG go...

    At work we use a X-Carve which runs on GRBL. I've never had an issue with GRBL, so I swapped out the TinyG for GRBL. I placed Arduino Uno with CNC Shield found on ebay. And was very pleased with the results.

    I then discovered the ESP32 port of GRBL and wanted to try that, but didn't want to rewire everything again just to try out new controllers. So I put the original stepper controller back in and tested GRBL plugged in via the parallel port.

    Some reverse engineering of the parallel port was required. Here's what I found:

    (as seen from back of female connector)
    • PIN 1 - Spindle Enable
    • PIN 2 - X Step
    • PIN 3 - X Direction
    • PIN 4 - Y Step
    • PIN 5 - Y Direction
    • PIN 6 - Z Step
    • PIN 7 - Z Direction
    • PIN 8 - A Step
    • PIN 9 - A Direction
    • PIN 10 - E-Stop
    • PIN 11 - X Limit
    • PIN 12 - Y Limit
    • PIN 13 - Z Limit
    • PIN 14 - Step Enable (all axis) (does nothing, see later log)
    • PIN 15 - Probe
    • PIN 16 - ?
    • PIN 17 - Spindle PWM
    • PIN 18-25 - Ground.

    All are active low. 

    Works great!

    I needed to slightly modify GRBL's config.h:

    Un-comment INVERT_SPINDLE_ENABLE_PIN and USE_SPINDLE_DIR_AS_ENABLE_PIN.

    Note Spindle Dir pin is on D13 pin on arduino and this will toggle with the bootloader LED flashing at startup. This means your spindle will inadvertently turn on and off a few times if you are in dial mode with the dial left at full lol. To avoid this, remove the bootloader and download the grbl firmware straight to flash.

    PWM signal needs to be inverted.

    And settings currently are:

    $0=10 (Step pulse time, microseconds)
    $1=25 (Step idle delay, milliseconds)
    $2=7 (Step pulse invert, mask)
    $3=6 (Step direction invert, mask)
    $4=0 (Invert step enable pin, boolean)
    $5=1 (Invert limit pins, boolean)
    $6=0 (Invert probe pin, boolean)
    $10=1 (Status report options, mask)
    $11=0.010 (Junction deviation, millimeters)
    $12=0.002 (Arc tolerance, millimeters)
    $13=0 (Report in inches, boolean)
    $20=1 (Soft limits enable, boolean)
    $21=0 (Hard limits enable, boolean)
    $22=1 (Homing cycle enable, boolean)
    $23=3 (Homing direction invert, mask)
    $24=25.000 (Homing locate feed rate, mm/min)
    $25=500.000 (Homing search seek rate, mm/min)
    $26=250 (Homing switch debounce delay, milliseconds)
    $27=2.000 (Homing switch pull-off distance, millimeters)
    $30=11000 (Maximum spindle speed, RPM)
    $31=0 (Minimum spindle speed, RPM)
    $32=0 (Laser-mode enable, boolean)
    $100=400.000 (X-axis travel resolution, step/mm)
    $101=400.000 (Y-axis travel resolution, step/mm)
    $102=400.000 (Z-axis travel resolution, step/mm)
    $110=2000.000 (X-axis maximum rate, mm/min)
    $111=2000.000 (Y-axis maximum rate, mm/min)
    $112=700.000 (Z-axis maximum rate, mm/min)
    $120=10.000 (X-axis acceleration, mm/sec^2)
    $121=10.000 (Y-axis acceleration, mm/sec^2)
    $122=10.000 (Z-axis acceleration, mm/sec^2)
    $130=270.000 (X-axis maximum travel, millimeters)
    $131=370.000 (Y-axis maximum travel, millimeters)
    $132=50.000 (Z-axis maximum travel, millimeters)

    GRBL and the original stepper controller only has one limit switch input per axis, so I've had to rewire the limit switches in series (because I'm using NC switches).

    The G-Code sender I'm using is called...

    Read more »

  • JP-1482 Spindle Controller Schematic

    Johnny07/27/2015 at 13:44 2 comments

    I've now reverse engineered the JP-1482 board and drawn a schematic of everything.

    The micro's connections:

    Control signals:

    Output to spindle and overcurrent detection:

    Power supplies and fan output:

  • STC15W408AS

    Johnny07/25/2015 at 14:00 11 comments

    I've found the datasheet for the mysterious STC15W408AS microcontroller on the spindle controller board. Turns out it's a 8051 at heart. The datasheet is well documented and is surprisingly in well written english. The device is super easy to program too, only need a USB to UART adapter, Keil C51 compiler, uVision4, and a STC ISP application. Hopefully I can read the program memory and save it as a backup. This may be the neater solution. Just program the micro to have the PWM feature. I'll do more reverse engineering and have a play I think.

  • MINI-CNC MOD BOARD DESIGN

    Johnny07/24/2015 at 22:55 0 comments

    So, I started working on designing a board to achieve spindle speed control in software, and also be able to turn it on/off. The spindle speed control works by passing the PWM through a low pass filter, then reading the DC voltage produced on an analog pin of a PIC micro. The micro then reads the value (most significant 7-bit's of 10 bits), and sends it to a digital pot. The digital pot contains an 8-bit data register (16-bit really with command byte) and is 10K and we need 5K, so that's why we are grabbing 7 bits (need 8 bits and grabbing 7-bits divides the value in half). The last log explains why I need to convert PWM to a resistive value (voltage divider). I've also added a feature for the Z auto level probe on the board. The issue there is, my system has been configured to work with Normally Closed limit switches and the act of probing, is a Normally Open operation. So I've made a little circuit to make probing mimic a NC switch. Some parts should arrive this week. I can then make sure it's working 100% before sending the gerber files to seeed studio.

  • Day 4

    Johnny07/15/2015 at 14:23 2 comments

    Added beaglebone black with wifi dongle and now it's wireless. All I needed to do was set the beaglebone black to start the serial port json server and wifi at startup. All that's required is plugging in the power and a way we go.

    Thanks to Chilipeppr being so portable (it's browser based). I can even control the CNC from an ipad or smartphone.

    Lastly I made the spindle able to be turned on and off in software with M3 and M5 commands.

    I tried getting the external PWM spindle control going, but it seems the microcontroller on the spindle controller board has not been configured for it (on this model) :(. The PWM sent to the motor is controlled by this micro by looking at a voltage divider's voltage, who's value changes via the 5K front pot (used as rheostat). From what I can see, the divider is 6K to 5v and 5K rheostat (pot) to ground. The external PWM pin on the board looks to goes through a lowpass filter and to an analog pin on the micro. Despite the different frequencies and duty cycles I tried on the PWM pin, I can't get it to work. I'm thinking of adding a small PIC that can read the PWM signal from the TinyG and control a digital potentiometer (as rheostat). I might add a small switch on the from of the case to select which pot to use (software or manual control). Not elegant, but will work fine.

  • Day 3

    Johnny07/15/2015 at 07:14 0 comments

    Here is the old limit switches.

    And here are the new ones. Notice now that I am using the limit switches as Normally-Closed. This is for better noise immunity and extra safety. Using NC switches has the added benefit that the machine will know if a wire comes loose on a limit switch.

  • Day 2

    Johnny07/15/2015 at 07:13 0 comments

    Now for wiring up.

    I also spent most of the day working out how to software control the spindle speed. The spindle controller board has pins for this (PWM) but not clear details on the function of the pins.

    I first replaced the connectors to ones I can work with.

    I did some quick reverse engineering of the spindle controller and hope to try this out at a later time.

  • Day 1

    Johnny07/15/2015 at 06:55 0 comments

    The first thing I did was inspect the existing controller and tried to get an understanding of the existing system.

    As you can see, the controller has three PCB boards inside. A 3 axis stepper controller (JP-382A), 4th axis controller (JP-1635A), and combined power supply and spindle controller (JP-1482). The controller box also has limit switches for x, y and z. Unfortunately they are wired in parallel, so the TinyG would not know the different between hitting the min or max limit on different axes (useful for homing).

    Next I removed the fan, and stepper controllers.

    I lined up the TinyG against the old heatsink and 3 holes lined up out of 4. Not bad.

    I drilled out the 4th hole and widened the holes just a bit for a better fit.

    I cut a piece of aluminum to connect the TinyG's heatsink pads to the old heatsink with thermal tape.

    Here is the final result. Notice I used M3 bolts with plastic spacers.

    Next I marked where the USB will poke out the back, drilled a hole and filed the hole square.

    Here's the result.

    Next I made a cover for the parallel port hole using a blank PCI-e slot cover.

    The next step was creating larger holes to fit 4 way aviation connectors to accommodate for new limit switch setup. That is, limit switches for min and max. To do this is used my Proxxon tool (like a dremel).

    Finally I put some anti-rust paint on the cut surfaces (because this enclosure is steal and will get cancer) and installed the new connectors.

View all 10 project logs

Enjoy this project?

Share

Discussions

swartskaap wrote 03/27/2016 at 18:49 point

I got the limit switches working. Tx!
All limit switches connected to one GND (red) wire to the TinyG GND-screw connector.
Each limit switch, the remainding wire soldered to an axis.  Fr example;
Y-max = y-max screw on TinyG.
Y-min = y-min screw on TinyG.
Z-min = z-min screw on TinyG.
In the config, for all axes setting min=Homing Only, and max=Limits Only.

HELP.. my engraving is much to large. I seems "Travel Per Revolution" is misconfigured.
My current setting Travel Per Revolution=3,2mm/rev.

Since we have 100% the same config, could you dump your settings, or share it via Dropbox?

  Are you sure? yes | no

Johnny wrote 03/27/2016 at 23:51 point

  Are you sure? yes | no

swartskaap wrote 04/24/2016 at 08:33 point

Yes, i have baal-screw. Exactly the same as your a CNC 3040Z-DQ.

My settings is like this. I'm unsure about vlues for 'Travel per Revolution' and 'Micro Steps'.


  Are you sure? yes | no

swartskaap wrote 03/25/2016 at 20:07 point

GREAT writeup. I was looking for this!! :)

Could you disclose the wiring for the limit switches?

I have exact the same CNC and TinyG. 

Whats the purpose of the yellow, white, red and black wires?

Which wire should be connected to GND, which is for min & max?

  Are you sure? yes | no

Johnny wrote 03/25/2016 at 23:56 point

Hey, thanks :). 

When using Normally Open limit switches, for the tinyg to recognise a limit has been reached (be it x-min, x-max, y-min, y-max, z-min or z-max) the particular limit input on the tinyg will be switched to 0V. Thats the job of the limit switch. 0V(GND) is connected to one end of the limit switch and the other to the input. The connection for a Normally Closed limit switch is identical. Just make sure you specify the type of limit switch in the tinyg settings or else your CNC won't run, it will think it's at a limi. When you use Normally Closed limit switches, the inputs see 0V (through the switch) when no limit has been reached and 3.3V (via pullup resister on the tinyg) when at the limit. I recommend you use Normally Closed limit switches, as they are more immune to noise and you will know if there is a open circuit to any of your limit switches.

  Are you sure? yes | no

Paulmkoenig wrote 11/29/2015 at 02:07 point

We have one and the first thing we did was gut the controls and mach 3 over the parallel port. tinyG seems to work pretty good in its place. 

The platen flatness is quite bad and we haven't fixed it yet. We measured .040 TIR.

We are trying to use it as a drag knife cutter for cutting polystyrene membranes cleanly. 

  Are you sure? yes | no

Johnny wrote 12/01/2015 at 08:18 point

Cool. Let me know how you go fixing the flatness. Could using the machine to mill a flat surface in the waste material work? I guess that would also unfortunately limit the size of the objects going on the bed to being smaller than the working limits.

  Are you sure? yes | no

qwertypop2005 wrote 10/11/2015 at 17:45 point

Interesting stuff Johnny.  I took a similar approach to controlling the spindle speed on one of these machines. You're effort looks a bit more refined than mine. Details of my offering are here....http://www.cnczone.com/forums/pcb-milling/241512-cnc-software.html 

Post 25

Keep up the good work!

  Are you sure? yes | no

Johnny wrote 12/01/2015 at 08:20 point

Hey, yeah I've seen that forum thread before in my googling travels. Nice solution, I originally was going to go down that path of using a digital rheostat, to replace the pot on the front via switch. It's a good solution.

  Are you sure? yes | no

lksch wrote 09/09/2015 at 07:39 point

Hey Johnny,

great Job! i have nearly the same model, but i'm stucked to get Spindle on/off working. 

I connected a arduino with grbl to the parralel port. I dont know what i have to do with the pwm connector on the JP-1482. Because of your shematic an pictures i tried to shortcut the

Sp on/of Sw+ and Sp on/off sw-. but nothing happend. Is the white ic on your cable to the this connector just an opto coupler?

On my board there is a  third yellow cable from the Poti to the Poti connector. Is that maybe the Problem. 

When i want to tur the Spindle on, must the poti be at an "on" postion.

i hope i was able to describe the problem and you find the time to give me some tipps.

regards

Lars

  Are you sure? yes | no

Johnny wrote 09/09/2015 at 07:59 point

Hey Lars, thanks man :). Yeah what you saw was a opto-coupler. Those pins need to be shorted. To do this I used a opto-coupler as you saw. Those pins are actually the same as what's connected to the spindle on/off switch. So the dial still needs to be adjusted for the speed.

Hope that helps.

Johnny.

  Are you sure? yes | no

lksch wrote 09/09/2015 at 18:07 point

Hey Johnny,

Thank you! Now it works! 

  Are you sure? yes | no

RoboMonkey wrote 07/27/2015 at 14:23 point

I have nearly the exact model...did yours come with limit switches pre-installed?




If you get your head around how to make the spindle holder a bit more friendly, let me know.  I've used a harbor freight die grinder as a makeshift spindle, and it worked great...but I'd love to be able to customize the router.  Unfortunately since the spindle is only held on with 2 screws it makes it quite limiting for that.
Great work.

  Are you sure? yes | no

Sheldon wrote 07/27/2015 at 15:43 point

Rather coincidentally in the last couple of weeks I bought a near-identical model as well (same specs for steppers, spindle, ball-screws and it's even a 3040!), the only main difference is mine does not have limit switches, although it has the same PCB with all the components present (so not a hard upgrade for me).

Oh, and I didn't get a 4th axis so I don't have the additional stepper driver but it looks to be as simple as plugging it in as, like the limit switches, I've everything else ready.

I keep wondering about a spindle upgrade but, other than finding a replacement spindle of the same diameter, I think the only option would be to remove the entire Z-axis and cutting the existing mount off to replace it with a few tapped holes so a generic plate can be used.

  Are you sure? yes | no

Johnny wrote 07/28/2015 at 10:52 point

Hey, yeah mine came with limit switches, although the wiring was a bit dodgy. True, I did see a guy in a youtube video replace his spindle motor with a 2.2KW one. I believe he cut off the spindle clamp part making a flat face. Then he attached his own spindle mount onto the existing. I'll try find the video.

  Are you sure? yes | no

RoboMonkey wrote 07/28/2015 at 13:27 point

that'd be great.  I should post about my modification to allow the use of the Harbor Freight die grinder as a spindle.  No speed control, but chews through wood like a beaver!

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates