AddThis

Bookmark and Share

Friday, 20 February 2009

DS1620 based USB Digital Thermometer

The DS1620 chip supports 3-wire (SPI) protocol and allows loose timing, so you can easily build a thermometer with it. It provides ¬0.5 centigrade accuracy, which should be sufficient for room temperature.

Note that, in a common design of a device like this, a microprocessor (CY7C63001A in this case) usually has a dedicated firmware to control DS1620 and returns the measurement through HID INPUT REPORT. My implementation, however, uses the generic firmware supplied with Morphy USB-IO. As the result, the USB host (PC) must control every details to interface with DS1620.

Background

I have once made another PC-accessible thermometer. It has a voltage-output thermo-censor (LM35) and an A/D converter (MPC3204), that is driven through PC parallel port. It worked just fine, and I'm still using it. However, it has several problems:

  • The A/D converter requires an accurate reference voltage.

  • MPC3204 must be driven sufficiently fast, so we cannot control it reliably from a userland application.

  • The application must access hardware directly, since the device requires nonstandard protocol on parallel port.

  • Parallel cables are to be short, so the themometer must be located near a PC.

  • The device must be self-powered (with dry cells in this case).

The first two problems are simpy solved by replacing LM35 + MPC3204 with a DS1620. Rest of the problems are solved by the use of USB.

Hardware

It is just a USB-IO with DS1620. No more, no less. The schematics clearly shows the fact. (If you erase the U2 box (representing DS1620) on the chart, it becomes the schematics of USB-IO. :-)

The remarkable point of the design might be the use of the USB-IO ports; SPI CLK signal is allocated from Port #2, while DATA is from Port #1. It allows the use of "I/O with strobe" commands of USB-IO Ver.2 Firmware.

The awkward design (or, just one of those) is that a signal from USB-IO Port #1 (that is initialized to High level after power up) is directly connected to the CS (chip select) of DS1620 that is a level-triggered active-High signal. Just an inverter should be sufficient to fix the problem, but an extra logic IC looks too much for this small circuit. If I wrote a dedicated firmware, I would initialize the particular signal to Low level. That's all I had to do.

Host Software

By design, the host software must take care of every details. I wrote several Java classes on top of USB-IO driver class library to control DS1620. I also wrote very unexciting sample application (Thermo.java).

To use the class, you should first initialize an instance, and just ask for a temperature by calling getTemperature() command. SPI protocol implemented through USB-IO is extremely slow; it takes about 70ms to send or receive a byte, causing 110bps bandwidth. However, DS1620 takes about a second to complete a temperature measurement process, so the protocol overhead is not significant.

The class also provides high resolution version of the method, getHiResTemperature(), which returns temperature in a higher (unspecified but aprox. 0.05 digree) resolution instead of normal 0.5 centigrade steps. See Javadoc for details.

0 comments:

Post a Comment

There was an error in this gadget