Silicon ChipMinilog: An 8-Bit Single-Channel Data Logger - July 1996 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Appliance repairs are still worthwhile
  4. Feature: Installing A Dual-Boot Windows 95/ Windows 3.1x System On Your PC by Greg Swain
  5. Feature: Fuel Injection In Economy Cars by Julian Edgar
  6. Project: Build A VGA Digital Oscilloscope; Pt.1 by John Clarke
  7. Project: Remote Control Extender For VCRs by Rick Walters
  8. Serviceman's Log: Lightning strikes again by The TV Serviceman
  9. Book Store
  10. Project: Build A 2A SLA Battery Charger by John Clarke
  11. Project: Minilog: An 8-Bit Single-Channel Data Logger by Anthony Mott
  12. Order Form
  13. Project: A Three-Band Parametric Equaliser by Bob Flynn
  14. Feature: Radio Control by Bob Young
  15. Review: The Tektronix THS720 Tekscope by Rick Walters
  16. Vintage Radio: Making a few odd repairs by John Hill
  17. Product Showcase
  18. Notes & Errata: Digital Voltmeter for Cars, June 1993
  19. Market Centre
  20. Advertising Index
  21. Outer Back Cover

This is only a preview of the July 1996 issue of Silicon Chip.

You can view 25 of the 96 pages in the full issue, including the advertisments.

For full access, purchase the issue for $10.00 or subscribe for access to the latest issues.

Items relevant to "Build A VGA Digital Oscilloscope; Pt.1":
  • VGA Digital Oscilloscope PCB patterns (PDF download) [04307961-4] (Free)
Articles in this series:
  • Build A VGA Digital Oscilloscope; Pt.1 (July 1996)
  • Build A VGA Digital Oscilloscope; Pt.2 (August 1996)
  • Build A VGA Digital Oscilloscope; Pt.3 (September 1996)
Items relevant to "Remote Control Extender For VCRs":
  • Remote Control Extender PCB pattern (PDF download) [15107961] (Free)
Items relevant to "Build A 2A SLA Battery Charger":
  • SLA Battery Charger PCB pattern (PDF download) [14305961] (Free)
Items relevant to "A Three-Band Parametric Equaliser":
  • 3-band Parametric Equaliser PCB pattern (PDF download) [01107961] (Free)
Articles in this series:
  • Remote Control (June 1995)
  • Remote Control (March 1996)
  • Radio Control (April 1996)
  • Radio Control (May 1996)
  • Radio Control (June 1996)
  • Radio Control (July 1996)
  • Radio Control (August 1996)
  • Radio Control (October 1996)
The Minilog can be used with a companion liquid crystal display so that its recorded data can be read or it can be connected to a PC to download its data. Build the Minilog: an 8-bit data logger The Minilog is a tiny, single channel, 8-bit, 0-5V data logger. It can be read in the field or it can communicate with a PC. The logging configuration can be easily altered by the user to suit any application because a BASIC STAMP ll is used in the design. By ANTHONY MOTT This project was developed from a more complicated applica­tion that required the collection of four or five sample readings from an air speed sensor in a model aircraft. In that application it was necessary to be able to launch the logger remotely and be able to read the recorded data in the field. While retaining the operational benefits developed in the model air60  Silicon Chip craft unit, only the bare essentials of hardware are used in this mini logger. The heart of the unit is a BASIC STAMP II (BS2) chip and an ADC0831 serial output analog to digital converter (ADC). The BS2 is a complete computer module built on a 24-pin DIL header. It uses a PIC16C57 microcontroller, 24LC16 EEPROM, voltage regulator, power down controller, serial I/F and a 20MHz resona­tor. The PIC16C57 is pre-programmed with a PBASIC interpreter – similar to other BASICs but with controller specific commands. BS2’s instruction set can be used on any of its 16 I/O lines. Program and data are stored in the 2048 byte 24LC16 EEPROM. The EEPROM ensures that program and data are retained indefinitely, power or no power. A handheld readout unit is describ­ ed for field use. This has a 40- character 2-line liquid crystal display unit controlled by a serial input LCD managing “backpack” and two push buttons. Current drain is so low that a separate battery is not fitted; rather the display unit steals some power from the logger’s battery. The display unit connects to a 5-pin block on the Mini­log board. It is possible to use a PC to read and display the Mini­log’s stored data Fig.1: the Minilog is based on the Basic STAMP II module togeth­er with IC1, the analog to digital converter. by using a terminal program. Using capture features available in most terminal programs allows a user to store and display the Minilog’s data and use that data in a spreadsheet or other data analysis programs. An additional mode of operation is “direct read”. With the display unit connected, the data present at the logger input is presented on the display and updated five times each second. Minilog’s logging program is written, developed and stored on an IBM compatible PC, using the BS2 software supplied in the Stamp development kit. A copy of three heavily commented programs to configure the Minilog (for the three basic roles outlined above) will be available on disc and printout. Note that the remarks are not stored in the BS2 but are kept in the PC file so there is no excuse for not making clear and detailed notes about your program. The program is loaded into the BS2 from the PC’s COMn port (“n” is autosensed) and takes about one second to load, making “write and try” much more convenient than conventional CPU/EPROM combinations. The 4-pin connector on the Minilog is used for loading the program from the PC. The same connector is used when reading data from the Minilog to the PC with a terminal program. Circuit details The circuit of the Minilog is shown in Fig.1. The ADC0831 ADC chip used in Minilog has two pins, Vref and Vin, allowing range and span setting. However, to keep Minilog simple, these pins are connected with Vref to +5V and Vin to ground. This arrangement gives a 0-5V input range. An additional resistor can be fitted to act as a voltage divider to increase the input voltage range (see later). A 1MΩ resistor and a .01µF capacitor are fitted at pin 2 to filter noise. The resistor will also help protect the ADC0831 from “over voltage” inputs. Each input reading will be converted to a single byte value in the range 0 to 255. An input of +3.2V will be converted to 163 (256/5*3.2=163.84) and stored as this value. Note that the deci­mal portion of the calculation is ignored. The highest speed of Minilog is better than ten samples per second; ie, one every 100 milliseconds. This can decrease to one per minute in 1ms steps. The sampling rate is determined by the software and can be any value that you may require, from milli­seconds to hours. Comments in the software explain how changes can be made. Battery drain from the 216-style 9V battery whilst logging at five samples per second is about 15mA without the display connected. If using very slow sample rates, using the BS2 SLEEP command rather than PAUSE will put the BS2 into a power down state between readings and this will reduce the current drain considerably. Data storage space depends on program length. With 2048 bytes available for program and data, the shorter the program, the greater the data storage space. With each of the three pro­grams supplied, there is room to hold at least 1000 samples. Using Minilog The following describes how the MINILOGL.BS 2 program sup­ p lied with a Minilog kit works. It is simple to change the pro­gram to suit your purpose – there are ample comments in the software to make changes easy. Once the program is loaded, the Minilog can be connected to the data source, powered up and when the event to be logged is ready, it is started by momentarily closing the “launch” switch contacts. The first closure trips July 1996  61 Believe it or not this teeny little board (shown here larger than life) is a single channel data logger which can store up to 1000 events. It uses the Basic STAMP module (a PIC processor with on-board Basic interpreter) and an analog to digital converter with an input range of 0-5V. the Minilog into its data collection routine – subsequent closures will be ignored. The display need not be connected at this time. Minilog will take samples and store them until the avail­able memory is full and then halt. If Minilog is powered down before the memory is full, it will simply stop – all data col­lected will be retained. Powering up Minilog again will allow the data to be read, however launching Minilog again at this time will result in the stored data being overwritten from the begin­ning. If the display is connected before Minilog is powered up, a prompt to start will be displayed and if a launch switch closure happens, the display will report that logging is under way. Mini­ log will report via the display when it has filled the data memory. The display may be disconnected once logging is under way without interfering with the program. However, connecting the display unit after turning the Minilog on will cause the display to malfunction as the initial62  Silicon Chip ising data that the Minilog sends to the LCD backpack at turn-on will not have been processed. To read the data collected, connect the display unit, power up Minilog and follow the display prompts which provide for displaying the data or erasing the data memory by using the two pushbuttons “A” and “B”. The Minilog software handles brief pushbutton closures and holding a button down continually may produce strange results. An exception to this is when scrolling through the “pages” of data – holding button “A” down will scroll through at about two pages per second. Provision has been made in the software for each sample to use up to four character spaces. This means that 12 samples plus page identification can be displayed as a “page” using the 40character 2-line LCD unit. A logging session recording 250 samples would be displayed over 21 “pages”. The reason that four spaces are provided for a 3-digit sample is that a formula may be incorporated in the program so that raw data fed into the ADC is actually processed and displayed in a meaningful format. Remember that the BS2 uses only integer arithmetic – no decimals please. If you want data with decimal places, you will need to multiply by 10 or 100 and read an inferred decimal point. There are comments in the software showing how to use formulas and how to change the page display format. Two additional programs, MINI­ LOGP.BS2 and MINILOGD.BS2 (see listing), are available. MINILOGP. BS2 provides for logging of data and unload­ing the stored data to a PC using a terminal program. When Mini­log is used in this manner, the display unit can be used to keep track of what is happening but it is not essential. Comments in the software explain how to use this program. MINILOGD.BS2 is used with the display unit and provides an instant readout of the data present at the ADC input, with the display being updated about five times per second. Again, formu­las can be included between the data and the display, making this program useful for testing or calibrating instruments. Precautions Fig.2: wiring diagram for Minilog. The STAMP module plugs into a 24-pin header on the PC board. The BS2’s on-chip regulator will be destroyed if the power supply is reversed, overvoltage is applied or if too much current passes through the regulator. The maximum input voltage should be limited to 12V. Mini­log uses the on-chip regulator for the ADC0831, display unit (when connected) and the BS2 itself. A total load current of 18mA has been measured and provided the regulator thermal dissipation is kept low (by not exceeding 9V), up to 50mA drain is possible. The ADC0831 span and reference pins are connected to +5V and ground in Minilog. This means that the ADC input should not exceed +5.3V or -0.3V. To help protect the input of the ADC, a 1MΩ resistor and a .01µF capacitor are provided, as noted above. These work as a noise filter and help limit possibly destructive currents. Limiting diodes are not recommended because they could rectify stray RF signals and create odd voltages at the ADC input pin. Where the voltage input range would exceed the 0-5V ADC0831 input limit, provision has been made on the Minilog PCB to install an additional resistor to act as a voltage divider. This would change the allowable raw input range according to the following table: Input Range Resistor Value 0-5V Not required 0-7.5V 2MΩ 0-10V 1MΩ 0-15V 500kΩ 0-20V 333kΩ Construction As can be seen from the photos, there is very little to assemble with this project. Use sockets for both ICs –you will probably want to use the BS2 module in another project. Be sure to fit the two resistors, capacitor and link before fitting the 24-pin socket. Take care with the power lead polarity and orient the sockets and ICs correctly. There is no need for a power switch, as the polarised plug and socket is cheaper and easier. The arrangements for the launch switch will depend on your appli­cation – a short lead with a microswitch is suggested. Two leads are required: one of four conductors to connect the Minilog to your PC for programming the BS2 and to “unload” data when using a terminal program. This lead requires a link between pins 6 and 7 on the DB9 to allow the BS2 software to sense which COM port is being used to program the BS2 module. The second lead of five conductors is used to connect the Minilog “remote” pins to the display unit. As these connectors are not polarised to the Minilog board, both the pin header and socket for each connector should be marked clearly to aid correct connection – a dab of liquid paper fluid is effective for this purpose. Listing For Direct LCD Readout ‘ MINILOGD.BS2 ‘ ‘ MINILOG OPERATING PROGRAM. (Anthony Mott, April 1996). ‘ ‘ (SERIES 2.2 PROGRAM.) ‘ ‘ FOR INSTANT (OR DIRECT) DISPLAY OF DATA INPUT, TO LCD DISPLAY IN ‘ REMOTE UNIT. ‘ ‘ USES BS2 CHIP AND ADC0831, PLUS A 40 X 2 LCD DISPLAY REMOTE UNIT. ‘ THE REMOTE UNIT PUSH BUTTONS HAVE NO EFFECT WITH THIS PROGRAM. ‘ (USES VERSION 3A LCD SERIAL BACKPACK.) ‘ ‘ IN LISTING, NOTE DIFFERENCE BETWEEN 0 (ZERO) AND O (CAPITAL “o”). ‘ ‘ I CON 254 ‘ LCD INSTRUCTION VALUE CONSTANT. B CON $4054 ‘ SERIAL BAUD RATE CONSTANT FOR ‘ 9600 BAUD; = $4000 HEX + 84 DECIMAL = ‘ $4000 + $54 = $4054. ($ = HEX.) FOR 9600 ‘ NEED TO FIT JUMPERS ON BACKPACK BOARD AT ‘ “BPS” AND FOR 40 X 2 DISPLAY, AT “LINES”. ‘ (SEE SERIAL BACKPACK INSTRUCTION MANUAL.) S CON 11 ‘ SERIAL DATA OUT, BS2 I/O PIN 11. SAMP VAR WORD ‘ VARIABLE FROM ADC SAMPLING FUNCTION. DISP VAR WORD ‘ CALCULATED VARIABLE FOR DISPLAY ON LCD. ‘ ** NOTE THAT BS2 I/O PIN NUMBERS ARE NOT ‘ THE SAME AS BS2 I.C. PIN NUMBERS ! LOW S PAUSE 1000 ‘ ONE SECOND DELAY FOR LCD TO “WAKE-UP”. SEROUT S,B,[I,1] PAUSE 5 ‘ CLEAR DISPLAY, 1 = CLEAR. ‘ PROCESS OF CLEARING DISPLAY TAKES TIME, ‘ THIS SHORT DELAY FOLLOWING “CLEAR” ‘ IS NECESSARY TO AVOID MISSING SUBSEQUENT ‘ CONTROL CODES OR DISPLAY DATA. IT IS ‘ REQ,D AFTER EACH “CLEAR SCREEN”. SEROUT S,B,[“MINILOG DATA LOGGER...”] ‘ PRINT “HEADER”. SEROUT S,B,[I,194,”DIRECT READ FUNCTION: VALUE =”] ‘ FIXED PORTION OF SECOND LINE; ‘ I = LCD INSTRUCTION CONSTANT (254), 194 ‘ IS LOCATION TO COMMENCE TEXT DISPLAY. ‘ FIRST LINE IS 128-167, SECOND IS 192-231. SAMP = 0 ‘ ZERO VARIABLE. SAMPLE: LOW 3 SHIFTIN 5,6,2,[SAMP\9] ‘ READ ADC AND DISPLAY VALUE ROUTINE. ‘ SELECT ADC AND INIATE CONVERSION. BS2 I/O ‘ PIN 3 IS CONNECTED TO ADC “CHIP SELECT”. ‘ TRANSFER DATA FROM ADC0831 TO BS2: ‘ DATA IN I/O PIN 5, CLOCK OUT I/O PIN 6, ‘ DATA INPUT FORMAT MODE 2, VARIABLE = ‘ SAMP, 9 DATA BITS (AS REQ,D BY ADC0831). continued on page 64 July 1996  63 Continued from page 63 HIGH 3 PARTS LIST ‘ DESELECT ADC. DISP = SAMP * 1 ‘ ENTER MANIPULATION FORMULA HERE. WITH ‘ A MAXIUMUM STORED VALUE OF 255, AND A MAXIMUM DISPLAY CAPACITY (FOR THE ‘ PROGRAM AS WRITTEN), OF 65,530, THE MAXIMUM MULTIPLIER HERE IS LIMITED ‘ TO 65530/256=256. NOTE THAT BS2 WORKS WITH INTEGERS (WHOLE NUMBERS) ONLY. ‘ “10 * 3.2” WOULD GIVE A RESULT OF 30, THE .2 BEING IGNORED. ALSO ‘ “32 / 10” WOULD GIVE 3, (BUT THE .2 CAN BE RECOVERED IN THIS CASE - READ ‘ BS1 AND BS2 MANUALS.) ‘ EXAMPLE 1: INPUT TO ADC IS 0 TO 5 VOLTS, AND WANT THE DISPLAY TO SHOW THIS ‘ VALUE TO 3 DECIMAL PLACES. 5 VOLTS WILL EQUAL A COUNT OF 255. ‘ 5/255=0.0196078, SO MULTIPLY STORED VALUE BY 196 AND DIVIDE BY 10 WILL ‘ GIVE A DISPLAY VALUE OF 4998 FOR 5 VOLTS INPUT. HAVE TO INFER DECIMAL ‘ POINT POSITION TO GET 4.998. REPLACE “DISP=SAMP*1” WITH “DISP=SAMP*196/10”. ‘ EXAMPLE 2: INPUT TO ADC IS 0 TO 10 VOLTS, VIA VOLTAGE DIVIDER. WANT ‘ DISPLAY TO READ 0 TO 10 VOLTS FROM 0 TO 255 “SAMP”. 10/255=0.03921568. ‘ IGNOR LAST FIVE DECIMAL PLACES, AND MULTIPLY “SAMP” BY 39. SO FOR 6 VOLTS ‘ INPUT, HALVED BY VOLTAGE DIVIDER, IS CONVERTED TO 255/5*3=153. ‘ (5= 0-5V ADC INPUT RANGE, 3= 6V INPUT/2). ‘ 153*39=5967, SO HAVE TO INFER DECIMAL POINT TO READ AS 5.967 VOLTS, ‘ REPLACE “DISP=SAMP*1” WITH “DISP=SAMP*39”. NOTE CALCULATION SCRATCH-PAD ‘ LIMITATION OF 65,025, OTHERWISE WOULD USE *392/10 TO IMPROVE RESOLUTION. ‘ COULD ALSO DIVIDE RESULT BY 10 TO GIVE A SHORTER, AND SIMPLER ‘ DISPLAY: 5.96 VOLTS, “DISP=SAMP*39/10”). NOTE THAT BS2 ARITHMETIC IS ‘ DONE STRICTLY IN LEFT-TO-RIGHT ORDER. SEROUT S,B,[I,225,DEC DISP] ‘ DISPLAY DISP, COMMENCING AT LCD LOCATION ‘ 220, IN DECIMAL FORMAT. PAUSE 200 ‘ 1/5th SECOND DELAY BETWEEN SAMPLE READINGS. ‘ THIS CAN BE ALTERED, BUT MAKING DELAY TOO ‘ SHORT MAY RESULT IN BLINKING/ILLEGIBLE ‘ DISPLAY. SEROUT S,B,[I,225,” “] ‘ BLANKS OUT OLD VALUE ON DISPLAY BEFORE ‘ READING AND DISPLAYING NEXT ONE. GOTO SAMPLE ‘ START READ/DISPLAY PROCESS AGAIN. A bridging socket is required for the remote pins when using the MINILOGP.BS2 software without the display unit. Construction details of the display backpack and LCD unit are covered in detail in the backpack kit. Testing Minilog’s performance is best done with a linear potentiometer connected across the 5V supply, with the wiper to the Minilog input. Connection of a slide or rotary potentiometer in this way would also allow logging of the mechanical position of an actuator, wind vane, doorway, gearwheel, control lever, etc. Software The Basic Stamp development kit 64  Silicon Chip includes a disc with an editor/programmer – a:\STAMP2\STAMP2\.EXE. This program is used to create, edit, debug and load programs for the BS2 module. The STAMP2 editor is best accessed from DOS (or DOSSHELL), because Windows will interfere with port assignment (Windows 95 is OK). There are three versions of the Minilog program provided on the disc – MINILOGL.BS2 talks to the LCD backpack and MINILOGP.BS2 talks to a PC. A shareware copy of a terminal commu­nication program, set up for 9600 baud, COM2 and auto LF is included so that you can set up PC communication quickly. MINILOGD.BS2 provides an instant readout on the LCD of the data pres- Minilog module 1 Minilog 2.2 PC board 3 22kΩ 0.25W or 0.125W resistors 1 1MΩ 0.25W or 0.125W resistor 1 1µF tantalum electrolytic capacitor 1 0.1µF ceramic capacitor 1 .01µF ceramic capacitor 1 9V battery and snap connector 1 24-pin DIL socket 1 8-pin DIL socket 4 5-pin socket shells (one is cut down to 4 pins) 1 3-pin polarised socket shell 1 3-pin polarised header 14 crimp fitting sockets for shells 1 11-pin length of single header strip (to make one 2-pin, one 4-pin & one 5-pin) 1 DB9 socket, with solder tails 1 Basic Stamp II module 1 Basic Stamp II development kit 1 Minilog software Light duty hook-up wire for leads Display unit 1 Hitachi LM018XML (or equivalent) 40 character 2-line LCD (Farnell Cat No 491-640) LCD serial backpack, (includes hardware to connect to display) available as a kit or assembled and tested (from MicroZed) 2 pushbutton switches, normally open contacts Case to house display and push buttons (210 x 50 x 30mm) Kit availability A kit for both the Minilog unit and the display unit will be available from Microzed Computers, PO Box 634, Armidale, NSW 2350. Phone (067) 722 777. ent at the input (see example listing included with this article). All three programs have notes and comments about the way Minilog works and ideas for making changes to suit your particular application. Acknowledgement: The author would like to acknow­ ledge the encouragement and support given by Bob Nicol of MicroZed Computers in preparing this article SC for publication.