Sunday 9 August 2020

Driver to control a servo from the NANO CNC Shield


 I find that using a dedicated Power Supply for the Servo, rather than using the power from the voltage regulator on the NANO is a better option.

So, I decided to make a driver board that would fit on one of the sockets on the NANO CNC Shield.
 There are three sockets on the CNC Shield for Stepper Motor Drivers.

The schematic for the CNC Shield look like this:
Please Note! This is a cloned CNC Shield, pins are different on the original Keyestudio Shield.

Looking at the schematic we see that the Arduino pin D8 goes to all stepper enable pins, so that can't be used for the servo.

If we look at what other pins are used, we see that each driver has a direction and step pin, all of which are have independent Arduino pins.

So if we use one of the sockets there are two Arduino pin available to us.
But which socket to use?

Socket X uses: D2 and D5
Socket Y uses: D3 and D6
Socket Z uses: D4 and D7

If we look at what the pins can do:
We can see that D3, D5 and D6 have PWM output.
Socket Y, both pins have PWM, so that's the socket I use for controlling my Servo and auxiliary device.

The middle four pins on the driver socket adjacent to the header pins are just a straight link to each corresponding pin.

Pin 6 is GND
Pin 5 is 5 volt, from the regulator on the driver,
Pin 4 is linked to Pin 15 (see circuit below) which is connected to Arduino Pin D6. (Servo)

The header Aux+ in the middle is 5 volt from the voltage regulator on the driver.
The GND pin of this header is switched on/off by pin 16, which is connected to the Arduino pin D3. (Aux)



I have made the circuit and PCB details using KiCAD.
Here are the files: Tims_Servo_to_Driver_Socket_MK2.zip



I suppose if you wanted to make one of these without getting a PCB made, is use an old stepper driver that has been fried (I'm sure I am not the only one that has done this) and strip it of all components and copper, and make a perf-board, then solder components with wire.





If you like what I have done, or want to know more.
Please leave a comment below.

15 comments:

  1. Hello Tim,

    Long time no see. During this time, I'm busy for studying in my lab (Physics lab) and teaching my students. But I'm until doing this project (finished about 70-80%). I have some questions? Firstly, how to set microstepping for stepper motors? Setting on your code? Or by jumper on board? Or both? Secondly, can I set microstepping 1/16 for stepper? Are stepper motors overheat? Finally, I followed your introduction about configuration bluetooth, when I wrote "AT" (Serial monitor: "OK"), but I wrote "AT+NAME", "AT+UART" (Serial monitor: nothing happened).

    ReplyDelete
  2. Hi PhiLe.
    I have the stepper motor stepping at 1/4 (mode 1) on the board. Only one jumper used, the middle one.
    In my code, line 61, # define MICRO_STEP_RESALUTION 4 sets the micro-stepping.
    I did not go higher than this, because you end up with very high numbers for variables in the code. If the bot needs to go a long distance then you may end up with a number the Arduino NANO can not handle. (or run out of memory doing the calculations)
    I do not know what stepper motors you are using, or how they are connected to your wheels.
    Lines 59 and 60 in my code will have to be changed to suit your hardware. Alter these two lines to calibrate your bot.
    Your stepper motors will have a maximum start speed. (a speed from stand still) Line 63 is the value to change if your steppers stall.
    The stepper motor Drivers have Adjustment for current limiting. I use DRV8825 drivers. (these need a minimum of 8 volt stepper power to work correctly)
    A starting point for me when it comes to setting the amperage: If the rated voltage of the motor is less than what I am supplying. I work out the wattage using the rated voltage and current or resistance. (what ever two values I have) The start with the amps I worked out from the voltage I am using with the wattage rated for the steppers. (if they get warm adjust accordingly)
    Pololu do very good instructions.
    https://www.youtube.com/watch?feature=player_embedded&v=89BHS9hfSUk

    I must mention, just in case. Hope you know about 3.3v data lines on blue tooth modules.
    Which Bluetooth module do you have?
    Are you able to get the data sheet for it?
    Can you give me links to what details you have for it?
    My instruction shows two types, each have slightly different commands. (these commands are not set in stone, gets past copywrite issues)
    Have you tried: AT+NAME? (note the question mark at the end)
    Also try; AT+UART? (with the question mark)

    Some makes need the question mark when asking for information some don't.
    Some makes need an equal sign when setting a parameter, some don't.

    I hope it make sense.
    Tim

    ReplyDelete
    Replies
    1. Hi Tim,

      My bluetooth module is HC-05. In your bluetooth configuration code which you send me, at line 25 "a=mySerial.read();" seems wrong. When I upload code for arduino, it's happens a error. It notices " 'mySerial' was not declared in this scope ", then I write again "a=BTS.read();" and upload code, it's success.

      Delete
  3. OMG, my apologies.
    I must have must have re-named things to give them more understandable names. Before I uploaded it, and missed that line.
    You are correct in what you have done.
    I will correct this and replace the file.

    Thank you, I hope you did not pull too much hair out sorting it.
    Tim

    ReplyDelete
  4. The only question that remains is: Why isn't this a commercial product? The demand is obvious! I need this for the servo on my eggbot-clone and also (via the AUX) for the CNC laser etcher I'm planning on.

    ReplyDelete
    Replies
    1. Thankyou for leaving a comment.
      I think it's not commercial product yet, because it works well with your own code. I write my own so it does not matter what which pin does . But I have recently found out from someone with an egg-bot and making a laser etcher, if you want to use grbl you will need to add a jumper wire to the pin you use.

      Delete
    2. Have you seen this? https://content.instructables.com/ORIG/FNP/SFZ3/KK8AMM8Q/FNPSFZ3KK8AMM8Q.png?auto=webp&fit=bounds&md=e1219f689af192effe23e7090e418f98
      Someone made a SMD version that sits very nicely with the drivers on a nano CNC shield...
      I don't mind adapting code to my hardware setup but I am afraid I did not understand your comment about the need to jumper wire a pin: I'd like to use GRBL but the laser is on-off so I was planning on using the AUX port to power it. Do you have more information? Thanks!

      Delete
    3. That is the person I was referring to.
      The grbl firmware can be modified to correct some of the errors of the Chinese cloned board OK.
      But it is difficult to modify some of the pins in grbl to do a different function.
      So some changes have to be done physically.
      So the header pins 15 and 16 referenced in the circuit above need to be left off the board when it is made.
      That is: When the small driver board is plugged into the CNC board, pins 15 and 16 will not be connected to the CNC board.
      Instead of a pin attached to each of the two pin positions 15 and 16, each has a wire attached with a Dupont plug on the end of each.
      The one that controls the laser (16) plugs onto the pin that goes to D11 (Spindle PWM). You will need to look on the underside of the CNC board to find this pin. Follow the trace from D11 on the Arduino, I think its one of the pins marked -Z on the clone version. (I am guessing the clone got the trace wrong here as well)
      Doing it this way also means that you can use the laser driver in socket Z, keeping Y as Y.
      I hope this made some sense to you.
      If you need more help just ask.

      Delete
    4. My clone will arrive in a few weeks, I'll check if they have updated the tracing from the version you have. In any case, now I understand what the issue is, thanks! But first I have to solder my own version of your driver using perf board as I don't yet have the ability to make my own PCBs...

      Delete
  5. I hope all goes well for you.

    ReplyDelete
  6. I am very happy with the outcome when using this module with my laser engraver! I'm using only the AUX channel for PWM controlled power to my laser diode. I have the module plugged into the Z-Axis socket for power. Pins 15 and 16 are soldered to come out at the top instead of the underside, allowing me to connect the D11 signal (which is indeed available both at Z- and Z+ endstops) with a jumper cable.
    For some reason, I had to change the MOSFET to a IRL44N. I get twice the power easy (no difference to connecting the laser directly to 5V) and continuous operation (stopped working when the diode got warm before) compared to the FQPF2N60C.

    ReplyDelete
    Replies
    1. Hi Hajo.
      Glad it it works for you.
      That's a beefy MOSFET (IRL44N) what power is your laser?

      Delete
    2. It's only the standard 250mW but for some reason the FQPF2N60C just didn't let through enough current, independent of load situation. So, even when run at 3% PWM, the brightness I got for focussing was half that of what I get now. I think it is just not fully open yet @ 5V switching voltage. Since I could solve it with the larger MOSFET, I did not check everything, however...

      Delete
    3. As long as you have a working solution.
      I have a habit of just sticking what ever I have at hand in the draw, it may want a larger resistor on the gate, something the mega ohm range, it could be the 10k is probably still trying to hold it open.
      Thanks for the feedback.

      Delete
  7. Undeniably believe that which you stated. Your favorite justification seemed to be on the web the simplest thing to be aware of. I say to you, I definitely get irked while people consider worries that they plainly don’t know about. You managed to hit the nail upon the top as well as defined out the whole thing without having side-effects , people could take a signal. Will probably be back to get more. Thanks cnc turning

    ReplyDelete