The electronic digital caliper for computer (RS-232) interface will work the inexpensive calipers, micrometers and height gauges. There are 4 pins on the connector of the measuring instrument, and the owner's manual will typically describe the output as 24 bit 90 kHz synchronous.
The code contains examples of:
�?9600 bps asynchronous receiver/transmitter
�?90 kHz synchronous receiver
�?Host command processing
�?Tables for data and text
�?Sending text to host
�?24 x N bit fractional multiplication
�?24 bit addition
�?Binary to BCD conversion
�?BCD to ASCII conversion
�?ASCII transmission with leading zero suppression and fixed decimal place
�?Operational mode set by jumpers or override by host
�?Use of watchdog timer
The circuit contains examples of:
�?+5V/-1.5V power from serial port
�?1.5V to 5V logic level conversion
�?minimal PIC to RS-232 interface
The caliper will send a burst of data about three times each second. Each burst contains 48 bits of data, and the first 24 bits are the position relative to the zero point which is set on the caliper. The second 24 bits are the position relative to an arbitrary zero that does not change. This is a kind of an absolute position, but the zero point changes each time the caliper loses power. Each 24 bit value is in ones compliment form (1 sign bit, 23 data bits). This allows for a 0 and a -0. The unit of measure is 1/20480th of an inch.
Usually, the caliper is powered by a small 1.55 volt battery, and the positive of the battery is connected to the metal parts of the caliper making it positive ground. The logic levels are -1.55 volts low and 0 volts high. The clock and data signals from the caliper are AC coupled by C1 and C2. The AC coupling effectively moves the logic levels above ground so they can be easily converted to standard CMOS logic levels (0 and +5 volts). Three gates of IC1 are used as a 3.3x linear amplifier. The amplifier is driven to saturation by the low logic levels from the caliper. The data and clock signals are then sent to the 12C509 microcontroller.
The microcontroller firmware has a synchronous receiver that handles the burst of data from the caliper. In binary mode the 48 bits are sent to the computer literally. For inches or mm mode the first 24 bits are scaled to real units. The raw value is multiplied by 125/256 for inches or by 127/1024 for mm. The result is then converted to BCD, then converted to ASCII and sent to the host computer. Sign and decimal are handled within the BCD to ASCII conversion routine. The asynchronous transmitter is implemented in the firmware like the synchronous receiver.
While idle the interface checks for data from both the host computer and the caliper. The first one to initiate communication gets the full attention of the interface. The host computer should send a 10ms break to get the attention of the interface. Then a '?' will be send to the host when the interface has seen the break and entered command mode. The most common commands issued are 'I' for inches, 'M' for mm, or 'B' for binary. The initial mode is set by jumper block JB1 pins 1,2,3 and 4. The interface will remain in command mode until an 'E' is sent to return to normal operation.
Power for the interface and optionally the caliper is supplied by the host computers' RS-232 port. The RTS and DTR line supply power through D1 and D2 to voltage regulator IC3. The regulated 5 volts from IC3 is supplied to the 12C509 microcontroller (IC2) and the 4049 hex inverter (IC1). D3 is normally not used. Power for the caliper is supplied from the host computers TxD line. Since this line changes state while in command mode, C5 stores enough energy to power the caliper during those times. Diode D4 prevents the C5 for being discharged.