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.

Saturday, 8 June 2019

Modifing Clone Keyes CNC Shield




One the web are Chinese cloned Keyes CNC Shields for the Arduino NANO.
They are cheep and good value. BUT.

If you want to set Micro Stepping as they are, you can't.
Who ever cloned/made this shield made a mistake and put the pins that should go to Vcc, to GND.

As the pins that set the Micro Step Mode are already pulled down to GND internally as default, and to change there state, they need pulling up to Vcc.

Three ways to check you have a clone:
1. The original Shield by Keyes has a blackish solder mask. (I have not had an original to check if it is correct and was copied wrong, or the original is also wrong.)
2. Some text on the board is incorrect.
Should be marked D9 and D10
Should say Control.
3. Pins are connected to the ground rail. (The bit that matters)

The first step to put things right, is to isolate the pins from the GND rail.
This needs doing in Eight places.

First Two are on the top side:
I found, warming the header pins, made it easier to slide off the plastic supports.

The next Six are underneath:





After isolating the pins, check that they Are Isolated, using a circuit tester.
Check that they are no longer connected to ground.

Isolating the pins from the GND track has separated the GND track and need reconnecting in two places.
Solder two pieces of tined copper wire in the place shown above.

Now the isolated pins need connecting to the Vcc circuit.
Luckily there are pins connected to this circuit close by to the isolated pins.

Using tined copper wire make solder bridges to these pins as shown:
Be sure to keep the tined wire away from the track that runs under the bridge.


That's it.
The Micro-Step jumper Header Pins should now work as they should.


GRBL Code

I write my own code when using this board, BUT.

If you are going to use gbrl firmware some changes to the code need making.

When you download the gbrl-master and unzip the file, in the folder you will find a folder called grbl, inside that folder you find a folder called cpu_map, inside that folder you will find two files, cpu_map_atmega328p.h and cpu_map_atmega2560.h.

As this shield is for the Arduino NANO, the file that needs changing is: cpu_map_atmega328p.h.

Open the file and you should see as shown (or similar).

There are 2 ways to do this:

1. Only use cloned shield. (If you don't intend to use a shield that is configured correctly).

Using screenshot as reference:
Line 39, change 2 to 5.
Line 40, change 3 to 6.
Line 41, change 4 to 7.
Line 47, change 5 to 2.
Line 48, change 6 to 3.
Line 49, change 7 to 4.

2. If you want to be able to quickly change from one type of shield to the other.

I will do this higher line numbers first so original line numbers (screenshot) I reference stay same for a time.

Lines 47,48 & 49 need replacing with:

#ifdef KEYS_CLONE
#define X_DIRECTION_BIT 2 // CLONE NANO Digital Pin 2
#define Y_DIRECTION_BIT 3 // CLONE NANO Digital Pin 3
#define Z_DIRECTION_BIT 4 // CLONE NANO Digital Pin 4
#else
#define X_DIRECTION_BIT 5 // Uno Digital Pin 5
#define Y_DIRECTION_BIT 6 // Uno Digital Pin 6
#define Z_DIRECTION_BIT 7 // Uno Digital Pin 7
#endif // KEYS_CLONE

Lines 39, 40 & 41need replacing with:

#ifdef KEYS_CLONE
#define X_STEP_BIT 5 // CLONE NANO Digital Pin 5
#define Y_STEP_BIT 6 // CLONE NANO Digital Pin 6
#define Z_STEP_BIT 7 // CLONE NANO Digital Pin 7
#else
#define X_STEP_BIT 2 // Uno Digital Pin 2
#define Y_STEP_BIT 3 // Uno Digital Pin 3
#define Z_STEP_BIT 4 // Uno Digital Pin 4
#endif // KEYS_CLONE

After line 30 insert a variable that can be changed to decide which shied is used?

#define GRBL_PLATFORM "Atmega328p"
#define KEYS_CLONE true

Changing the value of KEYS_CLONE:
true = using clone
false = using correct shield.



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


I have a web site as well: Tim's Place Mirror: Tim's Place





Tuesday, 2 April 2019

Tim's Draw Bot




I had a few stepper motors salvaged from CD/DVD Drives.
So I decided to make a small Draw Bot using two of them.
It is controlled via Bluetooth.
Powered by three 3.7v LiPo batteries in series 11.1v.
power to the motors is regulated to 5v 400mA.
Controller is an Arduino NANO.
Stepper Drivers are two modified L293D driver shields.


This was a nice little project to do, but.

The stepper motors from CD/DVD Drives are bipolar permanent magnet type with only 20 steps/revolution.
To get accuracy from this type of stepper, requires a gearbox.
If you watch the video you will see that errors constantly occurred.

I may make a larger version using hybrid stepper motors.
or get some of the cheap unipolar motors.

Did some code to allow for bios between the two wheels, made a big improvement, but the motors are not strong enough to compensate for a sloping surface.


Got two cheep geared unipolar motors to try.

Made an other Draw Bot using 2 of these motors.
Not a good chose for this type of project.

Big Fail.

There is too much backlash in the gear box.
Cannot rotate the Draw Bot accurately enough.

Didn't do a video, I think a Photo says it all.
The lower plot is the Draw Bot with the 28BYJ-48 motors.

Decided to modify how the motors drive the wheels. Moved the motors so that the wheel was not directly affixed the shaft of the motor, but was driven via a gear.
This gearing reduced the drive by 5:1 which also reduced the backlash 5.

This improved things but took 5 times longer to draw.
Too Slow.


I got some Hybrid Stepper Motors


Improved it but not perfect.
Added some code to compensate for step fractions, but still if the surface is sloping, it wanders off track.

Realized I haven't added any voltage control to the stepper motors so I added a DC-DC Buck to drop the voltage to 8.5v.
Had to keep the voltage above 8.2 volt because I am using DVR8825 drivers.
Also I am tapping of the Motor power to drive a LM7805 for the servo.
Change the code I wrote for Acceleration and Deceleration.
Tested it at Full Speed and Half Speed



As I am using a cloned Keyes CNC Shield, I have made a driver for the Servo that fits in the Y Drive socket. Fitting the Left Hand Driver in the X Driver socket, fitting the Right Hand Driver in the Z Driver socket.




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




I have a web site as well: Tim's Place