Arduino caliper

Hi

Is there a way to build a digital caliper with arduino? I would like to attach it to a press, measure the thickness of pressed material, which contains of many sheets with identical thicknesses, and then display the number of sheets on a display.
Sheets themselves are about 0,5mm thick but sometimes the thickness may vary, but that is undesireable. If it would have high enough precision then it could display also the info that thickness is probably incorrect?

There are digital calipers for sale, which do not cost very much, how do they work?

Rather than build a digital caliper with an Arduino, it may be easier to hack one of the cheap digital calipers and use an Arduino to read the calipers. This has been done by a member of these forums. Simply google "interfacing arduino with a digital caliper". How do they work? Google "how do digital calipers work?". - Scotty

Some digital calipers and scales have a serial output / quadrature output built-in, ready
for connecting up to other equipment.

Thank you very much, got the answers I need.
Bought the caliper already and will see if I manage to pull it off.

Bought a caliper, which looks exactly like the one used on the linked page, all other components I had at hand. Copied the code and schematic from this page:

But I can not get it working. Caliper works but Arduino can not understand the data. It should send information to serial port once every second but it sends only 0.00, although caliper is not displaying 0.00, at random intervals. Sometimes it does not send anything for minutes.
I tried changing Clock and Data pins in case I did not get them right.
5V for transistors collectors I took from Arduino, GND I connected to transistors emitters and - of digital calipers battery. On the linked site he uses BC548 transistors, I use BC546 but that should not make any difference. On my scope I can not get a clear view of the signal from caliper or of the amplified signal on arduino. I see that there are impulses but the falls and rises are blurry, maybe it is because I am using old USSR scope? Scope can display audio D-class amplifiers signal on output transistors or signals on PWM power supply FETs without a problem.
I do not have a breadboard yet (I ordered one) and components are soldered to each other via thin wires, can this cause my problem?

A photo of the oscilloscope screen is worth a thousand words...

Here are the photos:

output of digital caliper 1v/0,1ms

signal on pin of arduino 2v/0,1ms

signal on pin of arduino 2v/1ms

Hi, the signal into the arduino looks okay, cannot make out the screen graduations too well, but it looks like 5V pulses and they certainly have structure to indicate that it is valid data.

The next step is for you to post a copy of your sketch, so we can see if there are any problems.

By the way, don't be ashamed of your CRO (scope), I'd love to have one like that on my bench, even though I do use digital ones, and as you show it still produces the goods when its needed.

Tom..... :slight_smile:

Sketch is exactly the same as in the linked page:

int i;

int sign;

long value;

float result;

int clockpin = 4;  

int datapin = 5;

unsigned long tempmicros;

 

 

void setup() {

  Serial.begin(9600);

  pinMode(clockpin, INPUT);

  pinMode(datapin, INPUT);

}



 void loop () {

  while (digitalRead(clockpin)==HIGH) {} //if clock is LOW wait until it turns to HIGH

  tempmicros=micros();

  while (digitalRead(clockpin)==LOW) {} //wait for the end of the HIGH pulse

  if ((micros()-tempmicros)>500) { //if the HIGH pulse was longer than 500 micros we are at the start of a new bit sequence

    decode(); //decode the bit sequence

  }

}

 

void decode() {

  sign=1;

  value=0;

  for (i=0;i<23;i++) {

    while (digitalRead(clockpin)==HIGH) { } //wait until clock returns to HIGH- the first bit is not needed

    while (digitalRead(clockpin)==LOW) {} //wait until clock returns to LOW

    if (digitalRead(datapin)==LOW) {

      if (i<20) {

        value|= 1<<i;

      }

      if (i==20) {

        sign=-1;

      }

    }

  }

  result=(value*sign)/100.00;    

  Serial.println(result,2); //print result with 2 decimals

  delay(1000);

}

Now that you mention it, it actually looks like the pulses are a but less than 5V. What if I supply the transistors with 6V?

Hi, that level should be well within spec, make a sketch that just produces an output from the aduino following the input and see if they are the same. That will prove that the input level is the same.

Tom...... :slight_smile:

Thanks Tom, really good advice. I was actually using analogue inputs, added letter A to pin numbers and now it is working.