By continuing to use this site, you agree to our use of cookies. Find out more
Forum sponsored by:
Forum sponsored by Forum House Ad Zone

DRO Z-Axis /4th axis "combiner"

All Topics | Latest Posts

Search for:  in Thread Title in  
Kealan O'Carroll26/04/2019 17:42:16
9 forum posts
6 photos

Hi all,

I've recently added a Ali-Express DRO to my Archdale 18" Mill. I was facing the problem of only having one Z-Axis and not knowing whether to attach it to the knee or the quill, so I bought a 4th glass scale from the seller and added a scale to both axes.

The DRO display only has one input for each axis, so I got an arduino nano via ebay along with a small enclosure and some RS232 cables. The two input cables attach to the scales and the output goes to the DRO display. The arduino calculates which scale is moving in which direction, sums them for an absolute position and then outputs that to the display so both the knee and quill can move in opposite directions at the same time and the DRO Z-position will remain correct.

Component parts came to about a tenner + labour time of assembling it and figuring out the code. It's possible to move the scales fast enough to out-pace the arduino and 'lose' steps, but my scales are 1 micron rather than the usual 5 micron so that's effectively limiting the maximum speed by 1/5th and even at that it's still capable of keeping the position correct up to about 100mm/sec so as long as I keep the quill retract speeds sensible I think it'll be okay.

The arduino gets its power from the 5V output pin on the DRO which supplies the glass scales, so no batteries / plug is required.

I'm an absolute amateur when it comes to the arduino stuff so it may be possible for someone to make the code much more elegant / run much faster but this does me for now.

20190426_171735.jpg

Kealan O'Carroll26/04/2019 17:42:33
9 forum posts
6 photos

Code here:

 


/*
Code by Kealan O'Carroll, April 2019
Encoder.h library by PaulStoffregen
http://www.pjrc.com/teensy/td_libs_Encoder.html

Code intended for an arduino nano with the following wiring:
Pins 2, 4 : Scale 1 inputs
Pins 3, 5 : Scale 2 inputs
Arduino Pins 7, 8 : Outputs to DRO A and B pins. (Pins 6 and 8 on a DSUB9 type plug)

*/

#define ENCODER_OPTIMIZE_INTERRUPTS
#include
Encoder scale1(4,2); //Wire first scale A & B quadrature lines to arduino Pins 2 and 4
Encoder scale2(5,3); //Wire second scale A & B quadrature lines to arduino Pins 3 and 5
//If either of the scales reads in the wrong direction, reverse the pin numbers above (e.g. (4,2) changes to (2,4)

long pos2 = 0;
long pos1 = 0;
long delt = 0;
long oldpos1 = 0;
long oldpos2 = 0;
long delt1 = 0;
long delt2 = 0;
bool outA = LOW;
bool outB = LOW;

void setup() {
DDRD = DDRD | B11000000;
DDRB = DDRB | B000001;
PORTD = B00000000; // sets digital pins all Low
PORTB = B00000000; // sets digital pins all Low
}

void loop() {

pos1 = scale1.read();
pos2 = scale2.read();

delt2 = pos2 - oldpos2;
delt1 = pos1 - oldpos1;
delt = delt2 - delt1;

while (delt > 0) {
if (outA == LOW && outB == LOW) { //if 8 is low and 7 is low
PORTD = B10000000; //push 7 high
PORTB = B000000; //leave 8 low
outB = HIGH;
delt--;
}
else if (outA == LOW && outB == HIGH) { //if 8 is low and 7 is high
PORTD = B10000000; //leave 7 high
PORTB = B000001; //Push 8 high
outA = HIGH;
delt--;
}
else if (outA == HIGH && outB == HIGH) { //if 8 is high and 7 is high
PORTD = B00000000; //push 7 low
PORTB = B000001; //Leave 8 high
outB = LOW;
delt--;
}
else if (outA == HIGH && outB == LOW) { //if 8 is HIGH and 7 is LOW;
PORTD = B00000000; //leave 7 LOW;
PORTB = B000000; //push 8 low
outA = LOW;
delt--;
}
}

while (delt < 0) {
if (outA == LOW && outB == LOW) { //if both are low,
PORTD = B00000000; //leave 7 low;
PORTB = B000001; //Push 8 high
outA = HIGH;
delt++;
}
else if (outA == LOW && outB == HIGH) { //if 8 is low and 7 is high;
PORTD = B00000000; //push 7 low
PORTB = B000000; //Leave 8 LOW
outB = LOW;
delt++;
}
else if (outA == HIGH && outB == LOW) { //if 8 is high and 7 is low;
PORTD = B10000000; //push 7 high
PORTB = B000001; //Leave 8 HIGH
outB = HIGH;
delt++;

}
else if (outA == HIGH && outB == HIGH) { //if 8 is high and 7 is high;
PORTD = B10000000; //leave 7 high;
PORTB = B000000; //Push 8 LOW
outA = LOW;
delt++;
}
}
oldpos1 = pos1;
oldpos2 = pos2;
}

Edited By Kealan O'Carroll on 26/04/2019 17:44:17

SillyOldDuffer26/04/2019 18:52:27
10668 forum posts
2415 photos

I'm impressed Kevin, good idea and clever implementation.

Just a thought, the bit twiddling to drive the output makes the logic harder for others to follow and may not be necessary in this application. I suspect the main performance bottleneck is the Nano only having two external interrupt pins slowing the encoder library down. Likely the hardware and library are stopping your code following very fast traverses rather than your high-speed implementation. Might be possible to compute the output slightly faster, but I suspect switching to a processor with 4 external interrupts (like the Mega) would rocket propel the whole thing.

Have to say I'd be unbearably smug if I'd got that to work - well done you!

yes

Dave

Michael Gilligan26/04/2019 19:15:51
avatar
23121 forum posts
1360 photos

If Dave is impressed ... just think how I feel

MichaelG.

Andy Carruthers26/04/2019 20:22:12
avatar
317 forum posts
23 photos

Very well thought out and nicely done!

Ian P26/04/2019 20:59:18
avatar
2747 forum posts
123 photos

I too am impressed. Apart from the original idea the execution is an wonderful example of something made in a cost effective, fit for purpose manner. It looks robust but not over engineered and even using moulded on connectors saves cost and time.

If I had two encoders (linear or rotary) on any axis I would want definitely one of these

Ian P

Neil Lickfold26/04/2019 21:25:23
1025 forum posts
204 photos

I have a 3 layer read and also want a scale on the column. This will be useful indeed. Thank you so much for sharing.

Neil Lickfold

Les Jones 126/04/2019 21:32:15
2292 forum posts
159 photos

I built a similar device many years ago for my Seig X3 mill and find it very useful. Mine works with the original Chinese scales (2 x 24 bit protocol). Mine is based on a Pic16f628 with a 4 line by 20 LCD display, It displays the reading from each scale and the sum of the readings.

Les.

Paul Lousick27/04/2019 02:45:38
2276 forum posts
801 photos

Hi Kealan, I also want to fit a 4th scale to my mill.

My intention was to use a manual RS232 switch to change from the column scale to the quill scale and use my existing 3-axis display. The more expensive displays allow for a combined Z-axis reading but out of my budget.

Are you able to post details and circuit for your project. I have a little knowledge about electronics but know nothing about Arduino's.

Paul.

Les Jones 127/04/2019 08:38:29
2292 forum posts
159 photos

Hi Paul,
There is no real need for a circuit as Kealan gives the connections at the start of his program.
These are the lines that give the information.

Code intended for an arduino nano with the following wiring:
Pins 2, 4 : Scale 1 inputs
Pins 3, 5 : Scale 2 inputs
Arduino Pins 7, 8 : Outputs to DRO A and B pins.

The only other connections will be the power to the Arduino.

You will have to make sure that the signal level from the scales is the same as the signal levels on the version of Arduino that you use'

Les.

Edited By Les Jones 1 on 27/04/2019 08:42:47

Edited By Les Jones 1 on 27/04/2019 08:43:14

Kealan O'Carroll05/05/2019 09:35:56
9 forum posts
6 photos

Hi chaps,

As Les has said, the wiring is in the comments of the code, but Ive put a diagram below.
As per Dave's comment you might be better off with an arduino mega or something with 4x interrupt pins if you want it to run faster

wiring.jpg

David Tocher05/01/2021 12:34:45
47 forum posts
1 photos

I've just completed adding the quill scale to the column scale. It ran without any problems except it required a change in direction. I am using 5 mincron scales and it counts correctly even when I release the quill handle.

The pictorial wiring schematic does not correspond with the comments in the sketch and I used the connections in the sketch.

Thanks for your contribution.

ronald bakker25/03/2021 11:21:59
9 forum posts

hi all , new guy here , have bought a three axis dro and have been looking at the idea of the axis combiner to give the the columb and the quill a shared z axis on the dro

i cant seem to find the sketch david is talking about and i am slightly worried with how the ground lines are hooked up on the schematic

scale one and the plug going intoo the dro has the ground (pin 4) hooked up to the ground tab on the arduino

but scale two has the zero (pin 2) hooked to the ground on the ardiuno , is this correct ?

have all the stuff needed here to make one but dont want to make a misstake soldering the thing up and after plugging it in release the magic smoke

David Tocher25/03/2021 12:45:24
47 forum posts
1 photos

A 'sketch' in Arduino-speak is what I'd call a program. The comments at the start of the program/sketch and the schematic wiring diagram (called in Arduino-speak a 'fritz' contradict each other in a minor way.

I used the screen in the SUBD9 cable from the display unit daisy-chained to the screen of the cables going to the scales, making sure there were no possible loops which can pick up hum.

Provided you don't do anything silly like connecting the 5v to ground I don't think you can do any damage. All the Nano connections to the scales are inputs and, I'd guess, the pins on the display are also inputs and the worse that can happen it won't work!

It's been working fine for a while and I'm very pleased with it. Using DRO on the mill makes things so easy and now being able to raise or lower the quill to change to/from cutter and drill chuck without losing the Z position is great.

Again thanks to Kealan for his efforts.

Matt Harrington25/03/2021 12:47:41
avatar
212 forum posts
16 photos

What a great idea. My mill has no quill but one day.......

Matt OH

ronald bakker25/03/2021 13:17:15
9 forum posts
Posted by David Tocher on 25/03/2021 12:45:24:

A 'sketch' in Arduino-speak is what I'd call a program. The comments at the start of the program/sketch and the schematic wiring diagram (called in Arduino-speak a 'fritz' contradict each other in a minor way.

I used the screen in the SUBD9 cable from the display unit daisy-chained to the screen of the cables going to the scales, making sure there were no possible loops which can pick up hum.

Provided you don't do anything silly like connecting the 5v to ground I don't think you can do any damage. All the Nano connections to the scales are inputs and, I'd guess, the pins on the display are also inputs and the worse that can happen it won't work!

It's been working fine for a while and I'm very pleased with it. Using DRO on the mill makes things so easy and now being able to raise or lower the quill to change to/from cutter and drill chuck without losing the Z position is great.

Again thanks to Kealan for his efforts.

ok so it doesnt matter if i use zero (pin 2) or ground (pin 4) to connect the power out from the dro to the scales and the arduino ?

David Tocher25/03/2021 16:15:45
47 forum posts
1 photos

Ronald:

I'm not sure which pins you are referencing. There are at least two different SUBD9 pin-outs from/to the scales/display so the connections need to be checked for your setup. The website or manual should give the pinouts but . . . .

My display unit connections on the SUBD9, which are all that I used, are

pin 2 0v

pin 6 A+

pin 7 +5v

pin 8 B+

Pins 6 and 8 are the two quadrature signals and the other pair the power.

There is a PE (protected earth?) connection on pin 4 that is connected to the screen but I don't think it's a good idea to use it for the power because of the risk of earth loops which can cause electrical interference.

I rewired the plug from my quill to match the X, Y and Z plugs so they are all interchangeable. The screen is not connected to 0v wire anywhere external to the display unit but does contact the metal case of my Nano box and the screens of the two Z scale cables.

SillyOldDuffer25/03/2021 17:18:02
10668 forum posts
2415 photos
Posted by ronald bakker on 25/03/2021 13:17:15:
Posted by David Tocher on 25/03/2021 12:45:24:.
...

ok so it doesnt matter if i use zero (pin 2) or ground (pin 4) to connect the power out from the dro to the scales and the arduino ?

It might. Although 0V and Gnd are the same on the Arduino, they may not be on the DRO, which is providing the power. Makes sense for the DRO to put power between the 0V and 5V pins, but the Gnd could ba just a cable shield. As shields are often only connected at one end to prevent earth loops, the Gnd pin may not complete the circuit Try it and see - no risk of smoke because the Nano just won't power up if the DRO Gnd pin is floating. Or test it with a multimeter.

Electrical safety earths, signal earths, and RF earths are all a bit different, but as a rule of thumb it's not a good idea to carry power on an earth line. So if a plug has a 0V pin, use it, not Gnd. However, just to keep us on our toes, printed circuit boards often label the 0V line as Gnd, Vss, or other things. The Nano is an example of 0V = Gnd.

Dave

ronald bakker25/03/2021 18:01:23
9 forum posts

guess i connect the shielding together to prevent radio interference and connect the 0's together and to the zero on the arduino board , that way all the cables are hooked up the same way (to the dro unit) and the power side from the dro side will power the arduino like it does on the schematic so it should work the same way as a single glass scale would

thanks for youre help i apreciate it

ronald bakker25/03/2021 18:12:23
9 forum posts
Posted by David Tocher on 25/03/2021 16:15:45:

Ronald:

I'm not sure which pins you are referencing. There are at least two different SUBD9 pin-outs from/to the scales/display so the connections need to be checked for your setup. The website or manual should give the pinouts but . . . .

My display unit connections on the SUBD9, which are all that I used, are

pin 2 0v

pin 6 A+

pin 7 +5v

pin 8 B+

Pins 6 and 8 are the two quadrature signals and the other pair the power.

There is a PE (protected earth?) connection on pin 4 that is connected to the screen but I don't think it's a good idea to use it for the power because of the risk of earth loops which can cause electrical interference.

I rewired the plug from my quill to match the X, Y and Z plugs so they are all interchangeable. The screen is not connected to 0v wire anywhere external to the display unit but does contact the metal case of my Nano box and the screens of the two Z scale cables.

seems like its the same pin out as the schematic , i have a chineese dro on order and my guess is that the pinouts are the same throughout as they advertize it will work on multiple chineese glas scales

like i said in the former comment i probably just make a 4 way central connection from all the three cables combined for the 5v pin and another one of the 0 pin and connect those with the fourt branch to the power input of the arduino

the A and B connections i connect as described on the sketch and as an extra i will twist the shielding of the three cables together (but whont connect it to the arduino ) 

that way the power side will be the same as it would be if it was the cable directly from the glass rule to the dro (just split up) and the signal gets processed by the arduino like it should too

allso thank you for youre help

Edited By ronald bakker on 25/03/2021 18:13:56

Edited By ronald bakker on 25/03/2021 18:17:57

All Topics | Latest Posts

Please login to post a reply.

Magazine Locator

Want the latest issue of Model Engineer or Model Engineers' Workshop? Use our magazine locator links to find your nearest stockist!

Find Model Engineer & Model Engineers' Workshop

Sign up to our Newsletter

Sign up to our newsletter and get a free digital issue.

You can unsubscribe at anytime. View our privacy policy at www.mortons.co.uk/privacy

Latest Forum Posts
Support Our Partners
cowells
Sarik
MERIDIENNE EXHIBITIONS LTD
Subscription Offer

Latest "For Sale" Ads
Latest "Wanted" Ads
Get In Touch!

Do you want to contact the Model Engineer and Model Engineers' Workshop team?

You can contact us by phone, mail or email about the magazines including becoming a contributor, submitting reader's letters or making queries about articles. You can also get in touch about this website, advertising or other general issues.

Click THIS LINK for full contact details.

For subscription issues please see THIS LINK.

Digital Back Issues

Social Media online

'Like' us on Facebook
Follow us on Facebook

Follow us on Twitter
 Twitter Logo

Pin us on Pinterest

 

Donate

donate