Digital caliper remote display

Advert

Digital caliper remote display

Home Forums Help and Assistance! (Offered or Wanted) Digital caliper remote display

Viewing 21 posts - 76 through 96 (of 96 total)
  • Author
    Posts
  • #312069
    duncan webster 1
    Participant
      @duncanwebster1

      So now that it's working on LCD, how about a version using one (or more) of these

      **LINK**

      They are so much brighter and easier to see than LCD, but I've not managed to work out how to insert the decimal point, my project used it as a tacho, and I wasn't particularly interested in non integer, or text

      and Dave, it's quite easy to damage an Arduino pro mini, get the 5 pin header one pitch out, or find that there seems to be 2 versions with mirror imaged pins.

      Edited By duncan webster on 14/08/2017 23:57:51

      Advert
      #312112
      Ken Weeks
      Participant
        @kenweeks58536

        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".

        I have attached the code and commented out (//) the bits that I think are not needed for a one axis read out.

        Pins 6 and 7 take the out put from the caliper into the Arduino but I am not sure how to set the out put from the Arduino to the L.C.D.

        Is it done by the altering "LiquidCrystal lcd(6,5,4,3,2,1); to read "LiquidCrystal lcd(x.x);" where x.x represents a pair of numbers between 1 and 6 i.e "LiquidCrysyal lcd(1,2);"

        Perhaps somebody who understand coding better than I do would kind enough to check it through to see if it would work or if I need to alter anything else.

        Thanks in advance Ken

        // 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 = 7;
        unsigned long tempmicrosX;
        
        //int datapinY = 10;
        //int clockpinY = 9;
        //unsigned long tempmicrosY; 
        
        //int datapinZ = 12;
        //int clockpinZ = 11; 
        //unsigned long tempmicrosZ;
        
        LiquidCrystal lcd(6,5,4,3,2,1);
        
        void setup() {
        
          lcd.begin(20, 4);
          pinMode(clockpinX, INPUT_PULLUP);
          pinMode(datapinX, INPUT_PULLUP);
        
         // pinMode(clockpinY, INPUT_PULLUP);
        //  pinMode(datapinY, INPUT_PULLUP);                                                                      
        
        // pinMode(clockpinZ, INPUT_PULLUP);
        // pinMode(datapinZ, INPUT_PULLUP);
        
        }
        
        void loop () {
        
            //PAC X
            traitement(clockpinX, datapinX, tempmicrosX, 1);
          //PAC Y
          //traitement(clockpinY, datapinY, tempmicrosY, 2);
          //PAC Z
          //traitement(clockpinZ, datapinZ, tempmicrosZ, 3);
        }
        
        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|= 1<<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;
          // case 2:
            //lcd.setCursor(0, 1);
            //resuTmp = ((int)resu - resu) * 100;
           // sprintf(msg,"Y : %d.%d     ", (int)resu, abs(resuTmp));
            //lcd.print(msg);
           // break;
          // case 3:
           // lcd.setCursor(0, 2);
            //resuTmp = ((int)resu - resu) * 100;
            //sprintf(msg,"Z : %d.%d     ", (int)resu, abs(resuTmp));
            //lcd.print(msg);
            //break;
        
          } 
        }

        #312132
        SillyOldDuffer
        Moderator
          @sillyoldduffer
          Posted by Ken Weeks on 15/08/2017 10:32:41:

          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".

          I have attached the code and commented out (//) the bits that I think are not needed for a one axis read out.

          Pins 6 and 7 take the out put from the caliper into the Arduino but I am not sure how to set the out put from the Arduino to the L.C.D.

          Is it done by the altering "LiquidCrystal lcd(6,5,4,3,2,1); to read "LiquidCrystal lcd(x.x);" where x.x represents a pair of numbers between 1 and 6 i.e "LiquidCrysyal lcd(1,2);"

          LiquidCrystal lcd(6,5,4,3,2,1);
          
          
            lcd.begin(20, 4);
          
          ...
                  value|= 1<

           

          Hi Ken,

          What you have is very similar to Bob's sketch so it should work. 3 statements need looking at.

          First, fix a bug by changing:

          value|= 1<

          to

          value|= 1L<

          Secondly,

            lcd.begin(20, 4);

          This means that the connected LCD will have 20 characters on each of 4 lines. If your LCD is the more common type with 16 characters on 2 lines type, change the statement to:

            lcd.begin(16, 2);

          Thirdly,

          LiquidCrystal lcd(6,5,4,3,2,1);

          This defines which pins on the arduino the display will be wired to. It means:

          Pin 6 on the Arduino will be connected to 'RS' on the LCD

          Pin 5 on the Arduino will be connected to 'E' on the LCD

          Pin 4 on the Ardulino will be connected to D4 on the LCD

          Pin 3 on the Ardulino will be connected to D3 on the LCD

          Pin 2 on the Ardulino will be connected to D2 on the LCD

          Pin 1 on the Ardulino will be connected to D1 on the LCD

          dsc04513.jpg

          I'm not keen on that because Pin 1 is also used by the Arduino's Serial Interface. There will be bad behavior if you try and use the Serial monitor. Instead I'd use 7,6,5,4,3,2 e.g.

          LiquidCrystal lcd(7,6,5,4,3,2 );

          Also, because the caliper is already using pins 7 and 8, we should move the clockpin. That is change,

          int clockpinX = 7;

          to

          int clockpinX = 9;

          and move the caliper clock connection from pin 7 to pin 9 on the Arduino.

          Hope that makes sense.

          Dave


          Edited By SillyOldDuffer on 15/08/2017 11:43:01

          #312133
          SillyOldDuffer
          Moderator
            @sillyoldduffer

            Wow! Deleting two characters from my last post caused the forum software to throw a wobbler. I never typed it in like that. Eeek.

            #312820
            duncan webster 1
            Participant
              @duncanwebster1

              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

              #312835
              Neil Wyatt
              Moderator
                @neilwyatt

                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

                #312849
                Ken Weeks
                Participant
                  @kenweeks58536

                  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

                  #312850
                  John Haine
                  Participant
                    @johnhaine32865

                    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".

                    #312852
                    SillyOldDuffer
                    Moderator
                      @sillyoldduffer
                      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

                      #312853
                      Ken Weeks
                      Participant
                        @kenweeks58536
                        #312856
                        SillyOldDuffer
                        Moderator
                          @sillyoldduffer
                          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

                          #312865
                          duncan webster 1
                          Participant
                            @duncanwebster1

                            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

                            #312874
                            SillyOldDuffer
                            Moderator
                              @sillyoldduffer

                              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

                              #315310
                              Ken Weeks
                              Participant
                                @kenweeks58536

                                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;
                                }
                                }

                                #315319
                                Ken Weeks
                                Participant
                                  @kenweeks58536

                                  Hi All

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

                                  Ken

                                  #315329
                                  SillyOldDuffer
                                  Moderator
                                    @sillyoldduffer

                                    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.

                                    #315364
                                    Ken Weeks
                                    Participant
                                      @kenweeks58536

                                      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

                                      #315373
                                      SillyOldDuffer
                                      Moderator
                                        @sillyoldduffer

                                        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

                                        #315375
                                        Neil Wyatt
                                        Moderator
                                          @neilwyatt
                                          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!

                                          #315398
                                          SillyOldDuffer
                                          Moderator
                                            @sillyoldduffer
                                            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…

                                            #315495
                                            Ken Weeks
                                            Participant
                                              @kenweeks58536

                                              Hi Dave

                                              Glad I contributed something to our exchange.

                                              I got the module from Amazon.

                                              Thanks once again for all your help

                                              Regards

                                              Ken

                                            Viewing 21 posts - 76 through 96 (of 96 total)
                                            • Please log in to reply to this topic. Registering is free and easy using the links on the menu at the top of this page.

                                            Advert

                                            Latest Replies

                                            Viewing 25 topics - 1 through 25 (of 25 total)
                                            Viewing 25 topics - 1 through 25 (of 25 total)

                                            View full reply list.

                                            Advert

                                            Newsletter Sign-up