Close
0%
0%

USB Caliper HID

Uses a Trinket Pro to provide an USB HID keyboard interface to a commonly available digital caliper

Similar projects worth following
The primary goal of this project is to provide me with an interface from a digital caliper to SketchUp to facilitate design entry. The unit is small enough to attach to the caliper and has 3 function buttons which provide the ability to massage the measurement sent to the USB interface.

I use SketchUp a fair bit to model projects. It's a pain to measure something and then have to re-key it when inexpensive caliper provide a port which outputs that value.

The Trinket Pro provide a small form-factor interface with an USB HID which can interface to the caliper and feed the caliper value to the PC via a standard USB keyboard interface. It relies on the standard keyboard driver which is already present in the OS.

Rather than just feeding the value directly from the caliper to the keyboard port, we have the ability to process it somewhat.

At this point, I just need to append some characters to the caliper value.

  1. [Enter] key -- most entries are made with this button.
  2. [ , ] -- useful for entering multiple values; as with be for drawing a rectangle. ( i.e. x [,] y [Enter] )
  3. [/] [2] [Enter] -- used for drawing circles. Calipers measure diameters. SketchUp expects radii -- this function tells SketchUp to divide the value by two(2).


Video of prototype

  • 1 × Trinket Pro
  • 2 × FETs, ROHM RUE002N02 low gate drive FET (
  • 3 × Switch, tactile, Panasonic EVQ-PAG07K
  • 1 × Spring-loaded connector 2x3contacts, TE 193277-1 To connect to caliper
  • 1 × Enclosure, Listerine breath strips

View all 8 components

  • Phase 2

    Lou Cabral01/07/2015 at 12:48 0 comments

    Ergonomics .....At this point, I will be locating the function switches (and possibly the Trinket) onto the caliper body.

  • Added preliminary code

    Lou Cabral01/06/2015 at 05:18 0 comments

    Incomplete, and a little buggy, but it reads caliper packet , and can output via USB.

  • We don't need no stinkin' badgeries!

    Lou Cabral01/03/2015 at 04:40 0 comments

    https://plus.google.com/u/0/photos/101335555163629297035/albums/6099968672251747297/6099968674851427202?pid=6099968674851427202&oid=101335555163629297035

    Umm......at some point, I reread the guidelines for the Trinket contest -- "must be battery operated".

    Anyway, long story..short, the HID module will operate from a battery (if you bother to plug one in), but it will operate off of the USB bus just file.

    You can ignore any reference of battery stuff in the write-up -- unless you're a stickler for details.

  • Getting USB HID to work

    Lou Cabral01/03/2015 at 01:07 2 comments

    I've had a really unsuccessful time in trying to get the USB HID to work on the Trinket Pro. From what I had seen, and read on the web, it should not have an easy task.

    The problem that I encountered was that the Trinket bootloader(USBTiny) would start up, and it would be enumerated by the host system correctly. But, when the bootloader passed control to my sketch, the host would always failed to enumerate the Trinket as a Keyboard HID -- it would remain a USBTiny.

    I spent several frustrating days trying to get it going. Out of frustration, I ended up modifying the Trinket.

    It's a simple change. I added GPIO control of the USB pull-up resistor. I now works consistently.

    The change which I made is to allow the sketch to pull the USB data low/high which causes the USB host to re-enumerate.

    There might be a non-hardware solution, but for now, I am going to leave it alone. The current mod uses a diode, but just a wire may be sufficient.

  • Decoding the Caliper's Output

    Lou Cabral01/03/2015 at 00:20 0 comments

    The calipers that were chosen are commonly available, and inexpensive -- under $15 when on sale. They are available at Harbor Freight(US), and Canadian Tire(Canada). They are OEM'ed to large retail distributors, and will look slightly different. So far, from what I've seen, the shape of the electronics housing and the color of the buttons remains consistent.

    There are a few people out there who have already interfaced to similar calipers. Some info is available on the web regairdng the different interfaces available.

    I needed to be sure about the caliper that I purchase, so, I undertook to have a looksy. Here's what I found;

    At first, I thought that it might be outputting in BCD, but that was not the case. Maybe it uses a 4-bit processor?

View all 5 project logs

  • 1
    Step 1

    Level translators and Caliper Connector

    The output from the caliper is digital but only swings from 0 to 1.5 Volts. We need to bump that up in order to interface with the Trinket Pro. The circuit uses open-drain config which will allow interface to a 3V or 5V Trinket.

    I wanted to be able to not have to modify the caliper in any way, so, I chose to use a spring-loaded connector.

    I also did not want to have to make (or had time to) a PCB. I was able to 're-purpose' an Adafruit SMT breakout board for mounting the FETs and the connector.

    (all the parts are available at Digikey)

  • 2
    Step 2

    Putting It All Together

    All the fit snugly in place. There is no real need to glue or fixture the board or the switches( Panasonic EVO-PRG07K).

    Please note the diode from D5 to the USB pull-up. This is a 1N4148 but any switch/rect diode should work.

    The enclosure is a Listerine breath strips case. All the 'machining' on the enclosure was done with a craft knife.

  • 3
    Step 3

    V-USB Library and Config changes to usbconfig.h

    Download the library from here....

    https://code.google.com/p/vusb-for-arduino/


    and import library into Arduino IDE.


    A few changes were required to the usbconfig.h file.


    /* Name: usbconfig.h
    
    //#define USB_CFG_DMINUS_BIT      4
    #define USB_CFG_DMINUS_BIT      7
    
    #define F_CPU               16000000L 
    #define USB_CFG_CLOCK_KHZ       (F_CPU/1000)
    
    
    /* ----------------------- Optional Hardware Config ------------------------ */
    
    #define USB_CFG_PULLUP_IOPORTNAME   D
    /* If you connect the 1.5k pullup resistor from D- to a port pin instead of
     * V+, you can connect and disconnect the device from firmware by calling
     * the macros usbDeviceConnect() and usbDeviceDisconnect() (see usbdrv.h).
     * This constant defines the port on which the pullup resistor is connected.
     */
    #define USB_CFG_PULLUP_BIT          5
    /* This constant defines the bit number in USB_CFG_PULLUP_IOPORT (defined
     * above) where the 1.5k pullup resistor is connected. See description
     * above for details.
     */
    
    //#define USB_CFG_INTERFACE_PROTOCOL  0
    #define USB_CFG_INTERFACE_PROTOCOL  1   // keyboard

View all 5 instructions

Enjoy this project?

Share

Discussions

neolinux wrote 05/14/2016 at 19:06 point

  Are you sure? yes | no

Lou Cabral wrote 05/16/2016 at 13:05 point

You can.  Just remember, that with that converter, the signal is not inverted as it is with my converter.   In the code, you will have to change the digitalread(s) to be non-inverted.

digitalread(Caliper_nCLK)  <=> !digitalread(Caliper_nCLK)

digitalread(Caliper_nDATA)  <=> !digitalread(Caliper_nDATA)

  Are you sure? yes | no

ubergeekseven wrote 01/05/2015 at 15:52 point

what logic level translators are you using?

  Are you sure? yes | no

Lou Cabral wrote 01/05/2015 at 16:01 point

Just the 2 FETs ... ROHM RUE002N02TL.

(I may change due to small package size. I thought they were SOT23 when I ordered them)

  Are you sure? yes | no

ubergeekseven wrote 01/07/2015 at 15:48 point

I'm am idiot. Somehow I overlooked that while excitingly looking through your post. I ordered everything, but I'll be using this along with a Leonardo and hid. Plan on making an array of other inputs for measurement with direct keyboard input. Adding an optical encoder with a wheel to measure longer distances as well. Maybe later adding a laser distance and other measurement devices. This would be great in a shop for tool and part setup.
I'll update you on my progress once I receive everything.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates