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

Digital caliper remote display

All Topics | Latest Posts

Search for:  in Thread Title in  
Ken Weeks19/08/2017 10:08:20
avatar
132 forum posts
36 photos

Hi Dave

I was rather overtaken by events this week (Grandchildren, school holidays) so was a bit slow in getting back to you.

Thank you for taking the time to look at the code.

Your suggestions were very gratefully received, the code has been modified accordingly.

Thoughts about the circuit now need to be turned into fact.

Ken

John Haine19/08/2017 10:14:18
5563 forum posts
322 photos

Ken, what is the site please?

Posted by Ken Weeks on 15/08/2017 10:32:41:

Well we have moved way beyond my original post, nice to see it encouraged so much discussion.

I have found a site that gives a schematic and code for a three axis DRO using an Arduino I want to just have one axis "X".

SillyOldDuffer19/08/2017 10:29:08
10668 forum posts
2415 photos
Posted by duncan webster on 19/08/2017 00:13:15:

having followed this thread with considerable interest I went to dig out the old digital caliper I've had stored away for just such an eventuality. Turns out it is a Digimatic (which I seem to think has a different protocol), and doesn't have a plug connection. Am I wasting my time going any further?

Edited By duncan webster on 19/08/2017 00:13:37

Edited By duncan webster on 19/08/2017 00:13:58

Hi Duncan,

Can you take it apart and have a look inside? One of my digital calipers had no plug (a solid cover), but there were 4 connecting strips inside on the board. Can't comment on the Digimatic protocol; what I've found in practice is quite a bit of variation between types. What you have might be well understood, or not!

Have you got an oscilloscope? Looking at the caliper's output waveforms is pretty much essential if nothing works.

Dave

Ken Weeks19/08/2017 10:34:58
avatar
132 forum posts
36 photos

Hi John

I found the following sites helpful

Blog of Wei-Hsiung Huang: Using Digital Caliper For Digital Read Out (DRO) Applications

http://wei48221.blogspot.co.uk/2016/01/using-digital-caliper-for-digital-read_21.html

Arduino reads digital caliper - martin's useless and useful creations

https://sites.google.com/site/marthalprojects/home/arduino/arduino-reads-digital-caliper

DRO with Arduino and digital calipers by Scrachi - Thingiverse

https://www.thingiverse.com/thing:1731982

The one by Scrachi shows a schematic and code for a three caliper DRO.

The others have some useful information.

I posted the code shown by Schraci and Dave suggested some improvements see his post.

Ken

SillyOldDuffer19/08/2017 11:25:53
10668 forum posts
2415 photos
Posted by Neil Wyatt on 19/08/2017 07:53:20:

A useful post Dave, even for me as a hardened ABV man!

Why couldn't they call the library file 'I2C' rather than 'Wire' so it was obvious what to use with 'LiquidCrystal_I2C lcd'?

It seems these small details of inconsistent naming plague opensource projects and make it difficult for people to set things up intuitively. I would never have looked for a routine called 'wire' (one_wire perhaps!) making resorting to a tutorial or advice essential.

Neil

Glad you found it useful Neil but what's an 'ABV Man'? It can't be Adept Blast Valve can it!

I know exactly what you mean about inconsistent naming. In this example "wire.h" contains the low level definitions for all I2C devices and the protocol. It's needed to connect to any I2C wotsit.

Later, "LiquidCrystal_I2C.h" adds functions like 'print()' to simplify programming an I2C LCD display. LiquidCrystal is built on foundations provided by "wire.h". Actually, the first thing "LiquidCrystal_I2C.h" does is to include "wire.h", so really the programmer doesn't need to know about "wire.h" at all. Confused? You soon will be!

Including "wire.h" as well as "LiquidCrystal_I2C.h" is belt and braces, mostly unecessary. One reason it appears in the sketch is down to the IDE. Someone starting from scratch might use the IDE include library option to install the wire library, knowing that LiquidCrystal needs it. That has the effect of automatically adding a #include to the sketch source file, and, as it does no harm, people just leave it there.

It's not really an open source problem; commercial code is exactly the same. Under the bonnet computers are amazingly complicated. I used ProcessMonitor to debug a very simple 'C' program on Windows and found the operating system had called about 30 different DLLs before reaching the ten lines of code I'd written! As those 30 DLLs will have been written and modified by many different teams at different times, it's not surprising to find inconsistencies and poor choices in naming.

Dave

duncan webster19/08/2017 12:34:22
5307 forum posts
83 photos

img_2995 (small).jpg

pictures of digimatic board. Even If I could work out which tracks to connect to I don't thing I could work with such fine connectons without ruining it

img_2994 (small).jpg

Edited By duncan webster on 19/08/2017 12:35:03

SillyOldDuffer19/08/2017 13:40:12
10668 forum posts
2415 photos

I think it's a dud Duncan. No sign of any connectors designed to share data.

The line of 20-odd connections on the lower right hand side of the square chip will be for driving the display. Although it would be possible to tap into them and decode the signals, quite hard work.

I'm hopeless at fine soldering and wouldn't risk it either. Perhaps you can find a cheap caliper to play with on ebay or Lidl's? Most of them have sockets.

Dave

Ken Weeks05/09/2017 10:23:03
avatar
132 forum posts
36 photos

Hi All

Having read all the post' and installed the Arduino software on the computer, I have produced a schematic and code for a single axis DRO.

The suggestions made by Dave were incorporated

Caliper input moved to D8 and D9

The outputs on the Arduino to the LCD moved up by one

Arduino 1 now 2 D1 on the LCD

Arduino 2 now 3 D2 on the LCD

Arduino 3 now 4 D3 on the LCD

Arduino 4 now 5 D4 on the LCD

Arduino 5 now 6 E on the LCD

Arduino 6 now 7 RS on the LCD

I have attached the code schematic in a seperate postand and would appreciate comments/suggestions

// DRO.ino
// AUTHORS : Scrachi
// CREATED : 2016-06-10
// INSPIRED BY :martin's useless ans useful creations
//< https://sites.google.com/site/marthalprojects/home/arduino/arduino-reads-digital-caliper// Recuperation de donnees depuis des pieds a coulisse "chinois"
// pour affichage sur LCD 20*4
#include <LiquidCrystal.h>
int sign;
long value;
float resu;
int resuTmp;
char msg[20];
int datapinX = 8;
int clockpinX = 9;
unsigned long tempmicrosX;
LiquidCrystal lcd(7,6,5,4,3,2);
void setup() {
lcd.begin(20, 4);
pinMode(clockpinX, INPUT_PULLUP);
pinMode(datapinX, INPUT_PULLUP);}
void loop () {
PAC X
traitement(clockpinX, datapinX, tempmicrosX, 1);
}
void traitement(int clockpin, int datapin, unsigned long temps, int axe){
while (digitalRead(clockpin)==HIGH) {}
temps=micros();
while (digitalRead(clockpin)==LOW) {}
if ((micros()-temps)>500)
decode(clockpin, datapin, axe);
}
void decode(int clockpin, int datapin, int axe) {
sign=1;
value=0;
for (int i=0;i<23;i++) {
while (digitalRead(clockpin)==HIGH) {}
while (digitalRead(clockpin)==LOW) {}
if (digitalRead(datapin)==HIGH) {
>if (i<20) {
value|= 1L<<i;
}
if (i==20) {
sign=-1;
}
}
}
resu=(value*sign)/100.00;
switch (axe) {
case 1:
lcd.setCursor(0, 0);
resuTmp = ((int)resu - resu) * 100;
sprintf(msg,"X : %d.%d ", (int)resu, abs(resuTmp));
lcd.print(msg);
break;
}
}

Ken Weeks05/09/2017 11:47:15
avatar
132 forum posts
36 photos

Hi All

I was unable to post the schematic here so I have added it to Kens Album.

Ken

SillyOldDuffer05/09/2017 12:40:42
10668 forum posts
2415 photos

Hi Ken,

A few comments:

  • The schematic looks good. I see you're using a bidirectional level converter module. I have no experience of them but the spec implies they're intended to do 3.3V to 5V rather than 1.5V to 5V. It may not matter in practice but if you happen to get erratic decoding it may be down to the level converter.
  • The code is a bit mangled, very possibly as a result of publishing it on the forum.
    • void loop() starts with PAC X, which won't compile. (I just commented it out)
    • A few lines inside int decode() there's a line starting '>if'. The sketch compiles OK after the '>' symbol is removed, .
  • Also at the end of int decode(), the switch(axe) construct is unnecessary because there's only one axis. ( The switch becomes useful if a second axis caliper is added, and no harm is done if you leave it in. )

Unfortunately I can't test the sketch works in action because my experimental caliper uses a different protocol. Does it fly at your end?

By the way, if anyone is planning to use cheap calipers for CNC, beware! Digital calipers seem to send readings at the rate of 3 per second. That isn't fast enough to control a machine.

Dave

PS. My own efforts aren't going well. After replacing my gash junk box transistor level convertor with a proper LM393 comparator, life got complicated. First the minus sign stopped working; then I noticed that 1 in 3 decodes fail completely. There seems to be a timing problem, almost as if the Arduino isn't keeping up with the Caliper. As that's very unlikely, it must be something I've done. It's making my head spin.

Ken Weeks05/09/2017 15:45:44
avatar
132 forum posts
36 photos

Hi Dave

Thanks for taking the time to have a look and pass on your comments.

The bidirectional module in the schematic is just a picture I had

I intend to use this

POLOLU-2595 Logic Level Shifter, 4-Channel, Bidirectional This tiny logic level shifter features four bi-directional channels, allowing for safe and easy communication between devices operating at different logic levels. It can convert signals as low as 1.5 AND V to as high as 18 AND V and vice versa, and its four channels are enough to support most common bidirectional and unidirectional digital interfaces, including I AND sup2C, SPI, and asynchronous TTL serial. Features Dual-supply bus translation Lower-voltage (LV) supply can be 1.5 AND V to 7 AND V Higher-voltage (HV) supply can be LV to 18 AND V Four bidirectional channels Small size 0.4 AND Prime AND AND times AND 0.5 AND Prime AND AND times AND 0.08 AND Prime (13 AND mm AND AND times AND 10 AND mm AND AND times AND 2 AND mm) Breadboard-compatible pin spacing.

This Arduino stuff is all new to me so I will now have a go at compiling the code and building the circuit.

Thanks once again

Ken

SillyOldDuffer05/09/2017 16:25:02
10668 forum posts
2415 photos

Nice work Ken. I looked for a Caliper friendly level shifter and couldn't find any. Thanks to you identifying one I now know they're available in the UK. Hurrah!

Good luck building the circuit and firing it up for the first time. Fingers crossed! If by mischance you get stuck, feel free to post about it.

Dave

Neil Wyatt05/09/2017 16:35:30
avatar
19226 forum posts
749 photos
86 articles
Posted by SillyOldDuffer on 19/08/2017 11:25:53:
Posted by Neil Wyatt on 19/08/2017 07:53:20:

A useful post Dave, even for me as a hardened ABV man!

Glad you found it useful Neil but what's an 'ABV Man'? It can't be Adept Blast Valve can it!

Oops... AVR!

SillyOldDuffer05/09/2017 18:46:17
10668 forum posts
2415 photos
Posted by Neil Wyatt on 05/09/2017 16:35:30:
Posted by SillyOldDuffer on 19/08/2017 11:25:53:
Posted by Neil Wyatt on 19/08/2017 07:53:20:

...

Glad you found it useful Neil but what's an 'ABV Man'? It can't be Adept Blast Valve can it!

Oops... AVR!

Ah, the Advanced Vibration Reducer. Your official job description as Commander in Chief (Moderators) no doubt...

Ken Weeks06/09/2017 10:09:18
avatar
132 forum posts
36 photos

Hi Dave

Glad I contributed something to our exchange.

I got the module from Amazon.

Thanks once again for all your help

Regards

Ken

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