Silicon ChipDigital/Analog USB Data Logger - December 2010 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Desalination plants make heavy reliance on technology
  4. Feature: Soldering SMDs: It’s Becoming Unavoidable by Nicholas Vinen
  5. Feature: Recycle Your Cordless Drill – Make It Corded by Leo Simpson
  6. Project: A Hot-Wire Cutter With Inbuilt Heat Controller by John Clarke
  7. Project: Digital/Analog USB Data Logger by Mauro Grassi
  8. Project: Digital Lighting Controller For Christmas Light Shows, Pt.3 by Nicholas Vinen
  9. Project: A High-Quality DAB+/FM Tuner, Pt.3 by Mauro Grassi
  10. Project: Build A Hearing Loop Level Meter, Pt.2 by John Clarke
  11. Vintage Radio: The Philco 4-Valve Mantel Set by Rodney Champness
  12. Book Store
  13. Advertising Index
  14. Outer Back Cover

This is only a preview of the December 2010 issue of Silicon Chip.

You can view 17 of the 104 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 "A Hot-Wire Cutter With Inbuilt Heat Controller":
  • Hot Wire Cutter Controller PCB [18112101] (AUD $5.00)
  • Hot Wire Cutter PCB pattern (PDF download) [18112101] (Free)
  • Hot Wire Cutter front panel design (PDF download) (Panel Artwork, Free)
Items relevant to "Digital/Analog USB Data Logger":
  • PIC18F27J53-I/SP programmed for the Universal USB Data Logger [0411210A.HEX] (Programmed Microcontroller, AUD $20.00)
  • Universal USB Data Logger Software [0411210A.HEX] (Free)
  • Universal USB Data Logger User Manual (PDF download) (Software, Free)
  • USB Data Logger panel artwork (PDF download) (Free)
Articles in this series:
  • Digital/Analog USB Data Logger (December 2010)
  • Digital/Analog USB Data Logger (December 2010)
  • Digital/Analog USB Data Logger, Pt.2 (January 2011)
  • Digital/Analog USB Data Logger, Pt.2 (January 2011)
  • Digital/Analog USB Data Logger, Pt.3 (February 2011)
  • Digital/Analog USB Data Logger, Pt.3 (February 2011)
Items relevant to "Digital Lighting Controller For Christmas Light Shows, Pt.3":
  • Digital Lighting Controller LED Slave PCB [16110111] (AUD $20.00)
  • Digital Lighting Controller Slave Unit PCB [16110102] (AUD $25.00)
  • dsPIC33FJ64GP802-I/SP programmed for the Digital Lighting Sequencer/Controller [1611010A.HEX] (Programmed Microcontroller, AUD $25.00)
  • Firmware and PC software for the Digital Lighting Controller [1611010A.HEX] (Free)
  • Digital Lighting Controller LED Slave PCB pattern (PDF download) [16110111] (Free)
  • Digital Lighting Controller Master PCB pattern (PDF download) [16110101] (Free)
  • Digital Lighting Controller Slave PCB pattern (PDF download) [16110102] (Free)
  • Digital Lighting Controller master unit front panel design (PDF download) (Panel Artwork, Free)
  • Digital Lighting Controller mains slave unit front panel design (PDF download) (Panel Artwork, Free)
Articles in this series:
  • Digital Controller For Christmas Light Shows (October 2010)
  • Digital Controller For Christmas Light Shows (October 2010)
  • Digital Lighting Controller For Christmas Light Shows, Pt.2 (November 2010)
  • Digital Lighting Controller For Christmas Light Shows, Pt.2 (November 2010)
  • Digital Lighting Controller For Christmas Light Shows, Pt.3 (December 2010)
  • Digital Lighting Controller For Christmas Light Shows, Pt.3 (December 2010)
Items relevant to "A High-Quality DAB+/FM Tuner, Pt.3":
  • Software for the DAB+ Tuner (Free)
Articles in this series:
  • A High-Quality DAB+/FM Tuner, Pt.1 (October 2010)
  • A High-Quality DAB+/FM Tuner, Pt.1 (October 2010)
  • A High-Quality DAB+/FM Tuner, Pt.2 (November 2010)
  • A High-Quality DAB+/FM Tuner, Pt.2 (November 2010)
  • A High-Quality DAB+/FM Tuner, Pt.3 (December 2010)
  • A High-Quality DAB+/FM Tuner, Pt.3 (December 2010)
Items relevant to "Build A Hearing Loop Level Meter, Pt.2":
  • Hearing Loop Level Meter PCB pattern (PDF download) [01111101] (Free)
  • Hearing Loop Level Meter panel artwork (PDF download) (Free)
Articles in this series:
  • Build A Hearing Loop Level Meter (November 2010)
  • Build A Hearing Loop Level Meter (November 2010)
  • Build A Hearing Loop Level Meter, Pt.2 (December 2010)
  • Build A Hearing Loop Level Meter, Pt.2 (December 2010)

Purchase a printed copy of this issue for $10.00.

Based on a PIC micro, this simple project can log lots of data to a memory card. It can read from many types of digital and analog sensors and features a real-time clock and calendar to “time-stamp” the data. It has a USB port and comes with a PC host program, allowing you to configure the sensors, change settings and charge the battery. Universal USB Data Logger: Pt.1 By MAURO GRASSI T HIS LOW-POWER USB Data Logger is useful for a myriad of applications, especially where you need to log data over a long time period. It logs to an MMC/SD/SDHC memory card (with FAT file system), which means you can store up to 32GB of information. That’s a lot of logged data. The average current consumption is 36  Silicon Chip typically less than 1mA and it can be powered using two AAA cells (either NiMH rechargeable types or alkaline). Alternatively, it can be powered from a USB port on a PC or an external 5-7V DC supply. If NiMH cells are fitted, these will be recharged whenever the device is connected to a PC (via the USB port) or powered from an external DC supply. The logger can accept inputs on up to eight lines, with a maximum of up to six digital lines and up to four analog lines. Many different types of analog and digital sensors can be used and the digital inputs can also be used for frequency measurement or event counting. It is even possible siliconchip.com.au to connect a GPS (Global Positioning System) module to log geographical coordinates as well. For storage, just about any MMC, SD or SDHC memory card can be used. They are ideal for this application because they are cheap, reliable, have low power requirements and are available in capacities ranging from 16MB up to 32GB. Typical applications A typical application for this device would be to log data from a remote weather station. For example, let’s say you wish to monitor a weather station with humidity, wind speed, rainfall, temperature and barometric pressure sensors. With this device, you can log their values over many days into a CSV (comma separated values) file on the memory card. Then, when you’ve finished logging, you can connect the USB Data Logger to your Windowsbased PC and download the file via the USB port. Alternatively, you could simply remove the memory card and use a memory card reader. The downloaded log file can then be opened using Open Office or Microsoft Excel. From there, it’s easy to graph the readings and analyse them. Another use involves diagnosing a problem with a car engine. You can monitor the relevant engine sensors and log them while driving, then later analyse the data to locate the problem. You can even log your route if you connect a GPS module to the USB Data Logger. These are just two examples and there are lots of other uses, including monitoring industrial processes, collecting all sorts of field data, trouble­ shooting and testing. We’ve made the logger as flexible as possible by making it compatible with a wide range of sensors. PIC microcontroller The USB Data Logger is built around a PIC18F27J53-I/SP microcontroller (IC1). This is an 8-bit microcontroller with 128KB program (Flash) memory and 3KB of SRAM (Static Random Access Memory). It’s a 28-pin device and is well suited to this application due to its impressive list of internal peripherals and low price. The following peripherals are used in this project: the USB device controller; the integrated RTCC (Real siliconchip.com.au USB Data Logger: Main Features • Uses an MMC/SD/SDHC memory card (FAT file system) for up to 32GB of storage capacity. • • • USB full speed (12Mbps) interface for connection to a PC. Host PC program for Windows-based PCs. Up to six digital sensor inputs with support for I2C (Inter-IC Communications) and One Wire Dallas protocols. Also supports a Full Duplex Serial Port UART (Universal Asynchronous Receiver Transmitter) interface (eg, for connecting a GPS module). • Up to four analog inputs (two shared with digital inputs) with 12-bit A/D conversion and ±5% accuracy. The analog inputs can also accept frequency signals up to 192kHz or can function as a 32-bit event counter. • Custom scripting language allows a wide range of different digital sensors to be used. • • Low power consumption (around 1.5mA in standby mode). Flexible power options – can be battery-powered (using two AAA cells), USB powered or powered from an external 5-7V DC power source. • NiMH cells can be trickle-charged using USB power or an external power source. • An external voltage reference can be connected for greater than ±5% accuracy on the analog inputs. • • Battery protection to prevent over-discharge. Includes an on-board Real Time Clock Calendar (RTCC). Time Clock Calendar) with separate oscillator circuit; the SPI, I2C and UART serial peripherals; ten output compare/capture peripherals; one of three comparators; the 12-bit A/D (Analog-to-Digital) converter with internal band gap reference; and the comparator voltage reference. SPI (Serial Peripheral Interface) is a four-wire (plus ground) serial communication protocol, while the I2C (Inter-IC Communications) and UART (Universal Asynchronous Receiver/Transmitter) peripherals use two wires. Other microcontroller features which this project benefits from include the DMA (Direct Memory Access) support for the SPI peripheral, the low-power “sleep” modes and the very useful PPS (Peripheral Pin Select) feature. Sensor support The USB Data Logger supports a wide range of sensors and these are connected via terminal block CON4. There are four digital pins (D0-D3), two analog pins (A2-A3) and two analog/ digital pins (D4/A0 and D5/A1). These latter pins can be used for either digital or analog sensors (but not both). Table 1 shows the pin configurations – be sure to check the comments. Digital sensors The USB Data Logger is extremely versatile in that it can accept inputs from I2C, One Wire Dallas and serial port (UART) digital sensors. Using digital sensors can reduce A/D conversion errors compared to sensors connected to the analog inputs (see below). This is because digital sensors usually contain their own A/D converters which are optimised for the task. I2C and One Wire Dallas sensors must be connected to digital inputs/ outputs D0-D3 (pins 1-4 of CON4). The great thing about using I2C sensors is that you can connect many different sensors to the same I2C bus, which consists of just two lines. In fact, as many as 127 I2C devices can be connected to the same bus! Similarly, only one line is required to connect many different One Wire Dallas sensors to the Data Logger. As the name suggests, One Wire Dallas sensors only require the use of one pin. IC1’s Peripheral Pin Select feature allows the appropriate internal comDecember 2010  37 CON1 A3 A2 D5/A1 D4/A0 D3 D2 D1 D0 15k 8 7 6 CD 2 1 9 4 3 6 5 WP 8 7 +3.3V 100nF 33k 330k 10Ω USB DATA LOGGER G Q1 2N7000 10nF 33k 4.7k 10nF TANT 4.7 µF K D3 SDCS SDDO A K A 470Ω SDDI SDCLK SDS1 33k LED1 λ K A 4.7k 10nF D5 AN3 AN2 AN1 AN0 13 20 RP13 Vss1 8 D+ D– AN4 11 12 16 15 100nF 7 100nF 9 10 A K D1–D4: 1N5819 OSC1 Vss2 19 OSC2 VddCORE 6 /Vcap T1OSO T1OSI VUSB 14 IC1 PIC18F27J53I/SP MCLR Vdd 18 RC7 21 RB0 24 RB3 23 RB2 22 RB1 17 RC6/IO 4.7k 5 4 3 RB7 RB6 RB5 RB4 1 1k 4.7k 33pF X1 20MHz 12pF X2 32.768kHz S2 220 F 10V LOW ESR TANT 10 µF 1k A K D5: 1N4004 33pF 12pF LOW ESR 47 µF 4.7k 3 GND 2 GND OUT IN L LED TANT 10 µF 5 4 S1 TANT 22 µF L1 47 µH TPS61097 A K 1 5 1 2 3 Vin REG2 LM3940IT-3.3 EN Vout REG1 TPS61097-33 4 IN GND K D4 A K 1 2 3 4 1 2 3 G S GND V+ D– D+ GND GND +3.3V OUT Vin (+5V–7V) +3.3V(HI) OUT 2N7000 LM3940 D OUT BATTERY 2xAAA NiMH (900mAh) CON3 4 A CON2 USB TYPE B D2 (SHIELD) A D1 K 10Ω Fig.1: the circuit is based on a PIC18F27J53-I/SP micro­controller (IC1). This accepts digital and analog inputs via CON4 and reads and writes data to a memory card via CON1. IC1 also interfaces to USB socket CON2 via an internal controller, while regulators REG1 & REG2 provide 3.3V supply rails. Power can come from two AAA cells, from a USB port on a PC or from an external 5-7V DC supply. 2010 SC  S D 100nF 4.7k 28 4 2 27 5 26 4.7k 2 15k 4.7k 470Ω 4.7k 3 470Ω 4.7k 25 +3.3V TANT 220 µF +3.3V 1 CON4 MEMORY CARD SOCKET 38  Silicon Chip siliconchip.com.au munications peripheral to be routed to whichever sensor lines the digital sensor(s) are connected to. The supplied Windows-based host program allows you to configure the firmware for the types of sensors connected to the various inputs. Finally, there is support for a configurable, full-duplex serial port (via the UART peripheral). Among other things, this allows a GPS module (eg, the EM-408 – Altronics K-1131) to be connected to two of the digital inputs (for bidirectional signalling). Doing this will allow position information to be logged, as well as keeping the real-time clock synchronised with GPS time, guaranteeing accurate timekeeping (more on this next month). Analog sensors The simplest analog sensors output a voltage that’s directly proportional to the measurement value. For example, a ratiometric temperature sensor outputs a voltage that varies linearly with changing temperature. Accelerometers with analog outputs also vary their outputs linearly in response to acceleration. Up to four analog sensors with variable voltage outputs can be used with the USB Data Logger. Inputs A0 and A1 are for sensors with low-voltage outputs (0-3.6V), while A2 and A3 are for sensors with high voltage outputs (0-13.8V). These two sensor input pairs differ only in the voltage dividers used at the inputs. While low voltage sensors can be connected to A2 and A3, the measurement resolution will be poor. Internal voltage reference The reduced voltages from the analog sensors are fed to inputs AN0- AN3 of IC1 and are digitised using a 12-bit A/D conversion process. Normally, the accuracy of this 12-bit A/D conversion depends on the exact supply voltage to the microcontroller. For this reason, the firmware checks the supply voltage to IC1 regularly using an internal band gap reference (1.2V ±5%) and adjusts the A/D conversion values accordingly. Note, however, that due to the tolerance of the reference voltage (ie, 1.14-1.26V), the digitised values also have a possible error of ±5% although it will typically be better than this. If you require an accuracy of better than ±5% for the analog sensors, a precise voltage reference can be connected to one of the four analog inputs. This reference can then be used to accurately measure the other analog sensors. Just how this is done in explained in Pt.2 next month. Frequency and counter inputs The Universal USB Data Logger can also measure the frequency applied to any of the six digital inputs (D0-D5), at up to 192kHz. Inputs D0-D3 can handle signals ranging from 0-5V, while D4 & D5 can handle signals from 0-3.6V. The reason that inputs D0-D3 can handle higher voltages is that IC1’s input transistors are 5V-tolerant on those pins. If you require the circuit to tolerate even higher voltages, the voltage dividers at inputs D4/A0 and/or D5/ A1 can be changed to suit. This is also true for the analog inputs. As well as measuring frequency, the six digital inputs (D0-D5) can also act as simple counters, logging the number of positive or negative edge transitions that occur. In this mode, since the counters are 32 bits, the maximum number of events that can be counted is over four billion per input. Circuit details Refer now to Fig.1, the circuit diagram. It consists primarily of microcontroller IC1, a memory card socket (CON1), a couple of power supply ICs (REG1, REG2) and a handful of minor components. The sensors are connected to eight I/O pins of IC1 (RB4-RB7 & ANO-AN3) via terminal block CON4. I2C and One Wire Dallas sensors must be connected to digital inputs/ outputs D0-D3 (pins 1-4 of CON4). These lines all have 4.7kΩ pull-up resistors to the +3.3V supply rail, which is required for this type of sensor as they have open collector outputs, allowing multiple devices to share the same bus. D4/A0 and D5/A1 (pins 5 & 6 of CON4) use a voltage divider made up of 470Ω and 4.7kΩ resistors. This means that these two inputs can accept analog sensor output voltages up to 3.3/(4700/5170) = 3.6V. The low-value series resistors (470Ω) do not preclude the use of digital sensors with these pins. By contrast, the A2 & A3 analog inputs use voltage dividers made up of 15kΩ and 4.7kΩ resistors. This gives a maximum sensor voltage range of 3.3/ (4700/19,700) = 13.8V (since the voltage fed to IC1 cannot exceed 3.3V). The 10nF capacitors form RC filters with the 470Ω & 15kΩ resistors to reject noise on the analog inputs. Memory card interface CON1 is the memory card socket and this has an internal normally open (NO) switch that’s used to detect when the memory card is inserted. A 33kΩ into MOTORS/CONTROL? Electric Motors and Drives – by Austin Hughes Fills the gap between textbooks and handbooks. Intended for nonspecialist users; explores all of the widely-used motor types. $ 60 Practical Variable Speed Drives – by Malcolm Barnes An essential reference for engineers and anyone who wishes to or use variable $ 105 design speed drives. AC Machines – by Jim Lowe Applicable to Australian trade-level courses including NE10, NE12 and parts of NE30. Covers all types of AC motors. $ 66 DVD Players and Drives – by KF Ibrahim DVD technology and applications with emphasis on design, maintenance and repair. Iideal for engineers, technicians, students, instal$ 95 lation and sales staff. There’s something to suit every microcontroller motor/control master maestroininthe the SILICON CHIP reference bookshop: see the bookshop pages in this issue Performance Electronics for Cars – from SILICON CHIP 16 specialised projects to make your car really perform, including engine modifiers and controllers, $ 80 instruments and timers. 19 Switching Power Supplies – by Sanjaya Maniktala Theoretical and practical aspects of controlling EMI in switching power supplies. Includes bonus CD$ ROM. 115 ! Audio ! RF ! Digital ! Analog ! TV ! Video ! Power Control ! Motors ! Robots ! Drives ! Op Amps ! Satellite siliconchip.com.au December 2010  39 Table 1: Pin Assignments For CON4 Pin Number Pin Name Pin Function Pin Comments 1 D0 Frequency Input/Digital Input or Output Digital function, 0-3.3V signal output, 0-5V signal input 2 D1 Frequency Input/Digital Input or Output Digital function, 0-3.3V signal output, 0-5V signal input 3 D2 Frequency Input/Digital Input or Output Digital function, 0-3.3V signal output, 0-5V signal input 4 D3 Frequency Input/Digital Input or Output Digital function, 0-3.3V signal output, 0-5V signal input 5 D4/A0 Digital Input or Output/Analog/Frequency Input 6 D5/A1 Digital Input or Output/Analog/Frequency Input Analog/frequency input, 0-3.6V signal; can also be used for digital functions Analog/frequency input, 0-3.6V signal; can also be used for digital functions 7 A2 Analog Input 0-13.8V analog input 8 A3 Analog Input 0-13.8V analog input pull-up resistor normally holds the SDS1 line high but this is pulled to ground when the card is inserted and the switch is closed. The memory card is powered from the 3.3V rail and this is connected directly to pin 4 of the socket. This negative side of the supply is switched by Mosfet Q1 (2N7000) as its drain is connected to pins 3 & 6 (GND) of CON1. Charge pump This FET needs at least 4.5V applied to its gate to guarantee that it turns on fully, which is higher than the main power supply rail (3.3V). Therefore its gate is driven by a charge pump circuit based on diodes D3 & D5, a 10nF capacitor and a 4.7µF tantalum capacitor. To power the memory card up, IC1 drives this charge pump circuit using a square wave from pin 13 (RP13), generated by one of its output compare (OC) peripherals. At the same time, D5’s anode is pulled high by pin 17 of IC1 (which also controls LED1). It works as follows. When the signal at RP13 is close to 0V, the 10nF capacitor quickly charges via D5 to about 3.3V – 0.6V = 2.7V (0.6V is the drop across D5). Then, when the signal at RP13 subsequently goes high (ie, to 3.3V), the junction of this capacitor with D5 is immediately pulled to 3.3 + 2.7 = 6V. At this point, D3 conducts, charging the 4.7µF tantalum capacitor. The charge on the tantalum capacitor builds over several cycles until D3 no longer conducts, at which point its charge is close to 6V. So the circuit “doubles” the applied voltage (or near enough). The 6V is high enough to turn on Mosfet Q1 via the 10Ω current-limiting resistor. The associated 330kΩ pulldown resistor ensure that Q1 turns off when there is no longer any drive signal to the charge pump circuit from the microcontroller. During periods of extended idle time (ie, when not logging for extended periods), the microcontroller goes to sleep and its pin 13 output goes low. As a result, Q1 is off and this turns off the supply to the memory card, to conserve power. From this, it follows that the higher the logging frequency, the greater the power use and this needs to be considered if the unit is powered solely from a battery. In addition, if the logging interval is very short (ie, less than 5s), Table 2: Supply Connections For CON3 Pin Number Pin Name 1 GND Ground (0V) 2 +3.3V +3.3V rail from REG1; capable of supplying up to 50mA. Can be used to power low-current external sensors. Always powered. 3 Vin 4 Vdd (HI) 40  Silicon Chip Pin Function & Comments Input for external 5V - 7V DC power supply +3.3V rail from REG2. Can supply up to about 250mA provided either USB power or external power is applied. Used to supply “power hungry” sensors. power to the memory card will not be turned off. That’s because the initialisation sequence for the memory card would take too long and logging events would be missed while initialisation was taking place. Double function As well as driving D5 for the charge pump, IC1’s RC6 (pin 17) output also controls LED1. This flashes briefly whenever logging is turned on or off and also occasionally flashes while ever logging is enabled. This LED can also be driven while the charge pump is in operation; in other words, the RC6 pin of IC1 is multiplexed. This doesn’t interfere with the charge pump operation, since the firmware automatically adjusts the drive to LED1 and the RP13 output as appropriate. Memory card SPI connection The SPI (Serial Peripheral Interface) peripheral of IC1 handles communications with the memory card, while high-level software layers add support for a FAT (File Allocation Table) file system. This file system (including both FAT and FAT32) is supported by all common operating systems. MMC/SD/SDHC cards can be accessed either in their native mode or in SPI mode. The advantage of SPI mode is that the interface is simpler and this makes the hardware layer easy to implement. The penalty is slower transfer speeds but this is of no consequence here as SPI speeds are quite adequate for data logging. IC1 communicates with the memory card using one of the two on-board SPI peripherals, in this case SPI2. It also has hardware support for DMA (Direct siliconchip.com.au Memory Access) for this peripheral, allowing data to be transferred to and from the memory card at the same time as the microcontroller is executing code, making data transfer more efficient. SPI communication uses a 4-line bus and is capable of full duplex transfers between a host and a slave. The four lines are: SDCS (chip select – active low), SDDO (serial data output), SDDI (serial data input) and SDCLK (serial clock). In this case, the microcontroller is the SPI master. When the SDCS line is pulled low, the memory card becomes active and listens for commands. The SPI peripheral is routed via the PPS (Peripheral Pin Select) feature of IC1, so that the SDCLK line is at pin 21 and the SDDI and SDDO lines are at pins 18 & 22 respectively. The latter two are connected (transposed) to the DO (Data Out) and DI (Data In) lines respectively of the memory card. These lines are used to transmit and receive data in conjunction with the clock signal (SDCLK) generated by IC1. The SPI bus runs at 12MHz in this application, which is the fastest that the microcontroller will allow. Note that the SDCS line is pulled high by a 33kΩ resistor to disable the memory card by default (eg, when the microcontroller is in sleep mode), while the data output line from the memory card is also pulled high by a 33kΩ resistor. Two oscillators The microcontroller uses two oscillators – primary and secondary. The primary oscillator uses a 20MHz crystal (X1) to provide the main system clock. The oscillator’s output is divided by five and multiplied by 12 (using an internal PLL stage) to derive the 48MHz clock which is used by the USB peripheral (USB full speed device, 12Mbps) and the core. The core runs at 12 MIPS (Million Instructions per Second), which is its highest rated speed. The firmware implements a fullspeed (12Mbps) USB device and the D+ & D– data outputs (pins 16 & 15) connect to a USB Type-B socket (CON2). This can be connected to a PC using a standard USB cable. A USB driver is required and we describe how this is installed in Pt.2. (Note: the USB Data Logger has its own VID (Vendor ID) and PID (Product ID) pair, sub-licensed by Microchip). siliconchip.com.au The PC board fits neatly into a plastic instrument case that’s available from Altronics. The full assembly details will be in Pt.2 next month. The secondary oscillator uses a 32.768kHz watch crystal (X2) and two 12pF ceramic loading capacitors. This oscillator is almost always powered (even when the microcontroller is sleeping) and is used for timekeeping by the real-time clock/calendar (RTCC) peripheral inside IC1. This operates without firmware intervention to provide accurate timekeeping. There are no switches to set the time and date. Instead, the time and date are automatically synchronised with the PC when the logger is connected to a USB port and the host program is launched. Battery protection The secondary oscillator is only switched off when the USB Data Logger goes into “deep sleep” mode. This happens only if the firmware detects that the battery is critically low. In that case, IC1’s core is shut down and goes into a deep sleep mode to prevent the cells from discharging any further (which could damage them). In addition, in this special sleep mode, the contents of the SRAM are lost and the timekeeping fails (to prevent battery drain). Once it has entered deep-sleep mode, the USB Data Logger will require a reset to resume normal operation. The way to do this is explained in next month’s article. Note that, during normal operation, the microcontroller spends most of its time sleeping (thus reducing the power consumption) until the next logging event occurs. This sleep mode is different from the deep-sleep mode described above, however. While sleeping, the RTCC still operates, to maintain accurate timekeeping. Sensing the supply voltage During operation, IC1 monitors the supply voltage applied to boost regulator REG1. This is done by also applying this voltage to an ADC input, in this case AN4 at pin 7. As shown on Fig.1, the supply voltage is fed to AN4 of IC1 via a voltage divider consisting of two 4.7kΩ resistors. IC1 then converts the divided analog voltage on its AN4 input to a 12-bit number. When the logger is powered using two AAA cells, the supply voltage to REG1 will be about 2.7V at most (the maximum cell voltage is around 1.4V per cell and there is a Schottky diode in series with the positive battery terminal). On the other hand, if external power is applied to REG2, the voltage applied to REG1 will be close to 3V (the output of REG2 is at 3.3V and Schottky diode D1 is in series with its output). A 100nF monolithic capacitor bypasses the divided voltage applied to AN4. This will be 1.35V maximum for a battery and about 1.5V if external power is applied. December 2010  41 Parts List For USB Data Logger 1 PC board, code 04112101, 60 x 78mm 1 plastic instrument case (Altronics H-0342 or H-0343) 1 SPDT sub-mini toggle switch (S1) (Altronics S-1421) 1 sub-mini momentary pushbutton switch (S2) (Altronics S-1498) 1 28-pin 0.3-inch IC socket (or 2 x 14-pin IC sockets) 1 20MHz crystal (X1) 1 32.768kHz crystal (X2) (Altronics V-1902) 1 USB Type-B socket, vertical PC-mount (Tyco Electronics Amphenol 5787834-1) 1 2 AAA battery holder (Jaycar PH-9226) 2 AAA 900mAh NiMH cells or 1 x 2-pack AAA 950mAh NiMH cells 1 memory card socket (Jaycar PS-0024) 1 8-way horizontal PC-mount 5.08mm pluggable terminal block header (Altronics P-2598, Jaycar HM-3108) 1 8-way screw terminal socket (Altronics P-2518, Jaycar HM3128) 1 4-way horizontal PC-mount 5.08mm pluggable terminal block header (Altronics P-2594, Jaycar HM-3104) 1 4-way screw terminal socket (Altronics P-2514, Jaycar HM3124) In operation, the microcontroller checks the supply voltage on a regular basis. If the cells are “dangerously” low in voltage (indicating they have been discharged too much), the microcontroller goes into deep sleep mode. However, it’s quite easy to solder in by hand. This switchmode regulator has much better efficiency than a linear regulator and it allows the circuit to be powered from just two AAA cells. This has four main advantages. First, cells are expensive, so using two rather than three decreases the cost. Second, using two AAA cells allows them to be trickle charged from a 3.3V rail since their voltage will not exceed about 2.8V when fully charged. Third, this allows us to use a standard double cell holder. Fourth, it keeps the unit small and light. As mentioned previously, power can be supplied in three ways: (1) from two AAA cells; (2) from a PC via USB port CON2 (5V); or from an external 5-7V DC supply connected to pins 2 and 4 of CON3 (see Table 2). Switch S1 selects between either the USB power source or the external 5-7V source and either of these sources can recharge the battery (if rechargeable cells are used). Regulator REG2 (LM3940IT-3.3) is used to reduce the USB or external supply voltage to 3.3V. This is a linear low drop-out 3.3V regulator which can operate from an input voltage as low as 4.5V. Its output is fed via Schottky diode D1 to the input of the switchmode regulator (REG1). Power supply options The entire circuit of the USB Data Logger is powered from the 3.3V rail. This includes the microcontroller (IC1) and the memory card. However, while the microcontroller itself is powered by a 3.3V rail, its core runs from a 2.5V rail and this is derived using an internal low drop-out regulator. A 10µF tantalum capacitor on pin 6 (VddCore/Vcap) decouples this 2.5V rail. When running from a battery, the +3.3V rail is regulated using REG1, a TPS61097-33 low-power synchronous boost regulator IC (made by Texas Instruments). This switchmode IC can convert an input voltage of between 0.9V and 3.3V into a regulated +3.3V rail and is capable of supplying up to 100mA. Only three external components are required for REG1 – a 47µH inductor (L1), a 22µF tantalum bypass capacitor at the input and a 220µF low-ESR filter capacitor at the output. The regulator itself comes in a SOT-23 5-pin SMD (Surface Mount Device) package. 42  Silicon Chip Semiconductors 1 PIC18F27J53-I/SP micro (IC1) programmed with 0411210A – from www.microchipdirect.com 1 2N7000 FET (Q1) 1 TPS61097-33DBVT boost regulator (REG1) 1 LM3940-3.3 regulator (REG2) 4 1N5819 diodes (D1-D4) 1 1N4004 diode (D5) 1 LED 3mm blue (LED1) (Altronics Z-0707, Jaycar ZD-0130) Inductors 1 47µH choke (Jaycar LF-1100) Capacitors 1 220µF low ESR 10V 1 47µF low ESR 63V 2 22µF tantalum 2 10µF tantalum 1 4.7µF tantalum 4 100nF monolithic 2 10nF monolithic 1 10nF greencap 2 33pF ceramic 2 12pF ceramic Resistors (1%, 0.25W) 1 330kΩ 2 1kΩ 3 33kΩ 3 470Ω 2 15kΩ 2 10Ω 10 4.7kΩ A 10µF tantalum capacitor decouples the input to REG2, while a 47µF low ESR (Equivalent Series Resistance) aluminium electrolytic capacitor is installed across its output, to ensure stability. Don’t be tempted to use a common electrolytic here – it must be a low ESR type. The 1kΩ resistor to ground is there to provide a minimal load, while diode D4 provides reverse polarity protection when using an external supply. Note that the input voltage at CON3 must be strictly between 5V and 7V DC (REG2 has a maximum input voltage rating of 7.5V). As such, you can use a 6V SLA (Sealed Lead Acid) battery or, if mains power is available, a regulated 6V DC plugpack. If you want to use the data logger in your car (and don’t want to use a battery), you can power it via a USB charger that plugs into your car’s cigarette lighter socket and provides a regulated 5V. Battery charging The two rechargeable AAA cells provide power to the boost regulator (REG1) via Schottky diode D2. These will typically be rated at 900-950mAh and are trickle charged from the 3.3V output of REG2 via Schottky diode D1 and a 10Ω resistor while ever USB or siliconchip.com.au external power is connected. The value of this resistor is chosen so that the charging current is around 0.05C (where C is the capacity of the battery). This amount is considered safe for indefinite charging and fully charging a battery in this way can take up to 15 hours (you can recharge the cells more quickly by removing them and placing them in an external charger if necessary). For 900mAh cells, a charge rate of 0.05C means a charging current of 900 x .05 = 45mA. From there, it’s easy to calculate the required resistor value. Assuming that the voltage drop across D1 is 0.3V and that the average cell voltage is 1.25V, then the resistor value will be is (3 - 2.5)/0.045 = 11.1Ω. A 10Ω resistor is the nearest preferred value. Diode D2 is reverse biased during charging and only becomes forward biased when USB or external power is removed. Note that if you are using non-rechargeable, alkaline cells, together with an external power source, the 10Ω resistor must be omitted to prevent charging. In this case, D2 provides reverse polarity protection against a reversed battery connection. The USB Data Logger can run for long periods on just two AAA cells – typically two to three weeks, depending on the logging frequency. However, for very long term logging without an external power supply, a 6V SLA battery rated at 12Ah will be required. Pushbutton switch Now let’s consider the operation of switch S2. As shown, this momentary SPDT switch is wired in parallel with the lower 4.7kΩ resistor in the divider. Pressing this switch pulls IC1’s AN4 pin to GND and this is detected by the microcontroller which then takes the appropriate action. Basically, the firmware uses the output of an internal comparator to sense when S2 is pressed. The AN4 pin is also connected to the inverting input of an internal comparator, while the non-inverting input is connected to an internal voltage reference. This voltage reference can be controlled by the firmware and is derived from IC1’s supply voltage using an internal resistor ladder network. In this case, the threshold is set at around 0.4V by the firmware, so any voltage below this at the AN4 input switches the output of the comparator high. siliconchip.com.au 【 【 Biggest-WebShop-VHF UHF Standard BandPass Filter Temwell&Toko Type: Alternative online- 72hr Shipping Since there is a 2:1 voltage divider Total 200Kpcs, 500 models, 2&3 tuning In-Stock on this input, this means that the 1 7HW/7HT Toko 302MXP Type UHF (2/3 Tuning Filter) comparator output is low provided S2 TW-P/N-Fo-BW TW-P/N-Fo-BW TW-P/N-Fo-BW TW-P/N-Fo-BW K2B1-360M-10M K2B1-505M-13M K3BT-435M-20M K3CT1-833M-21M is not pressed and the voltage at the K2B1-370M-10M K2B1-525M-13M K3BT-455M-20M K3BT-835M-20M input of REG1 is above around 0.8V. K2B1-380M-10M K3BT-370M-10M K3BT-465M-15M K3CT1-860.5M-23M K3BT-880M-25M K2B1-390M-10M K3BT-370M-16M K3B-485M-20M This should always be the case when K2B1-410M-10M K3BT-390M-10M K3BT-510M-15M K3CT1-904M-12M the circuit is being powered, so the K2B1-420M-11M K3BT-390M-16M K3BT-500M-16M K3CT1-915M-12M K2B1-435M-11M K3BT-410M-11M K3CT2-600M-20M K3CT1-938M-15M comparator output is normally low. K2B1-450M-11M K3BT-410M-16M K3BT-612M-18M K3CT1-947M-18M The comparator module is configK2B1-460M-11M K3BT-415M-16M K3CT2-651M-10M K3CT1-960M-12M K2B1-475M-11M K3BT-415M-20M K3BT-680M-13M K3CT1-1015M-25M ured to generate an interrupt when K2B1-490M-13M K3BT-425M-20M K3CT1-833M-16M -----------------------its output goes from low to high. This 2 7HW Toko 252MXPR Type UHF (2 Tuning Filter) TW P/N-Fo-BW Toko P/N TW P/N-Fo-BW Toko P/N occurs when S2 is pressed and starts K2B-405M-20M 252MXPR-2735A K2B-453M-20M 252MXPR-2767A a timer that measures how long S2 is K2B-435M-20M 252MXPR-2737A K2B-480M-20M 252MXPR-2765A 3 5HW Toko type UHF Double Tuning Band Pass Filter held down. TW-P/N-Fo-BW TW-P/N-Fo-BW TW-P/N-Fo-BW TW-P/N-Fo-BW The USB Data Logger recognises K2RB-365M-10M K2RB-474M-11M K2RB-670M-20M K2RB-959M-25M both a short press (less than 1s) and a K2RB-380M-10M K2RB-475M-11M K2RB-700M-20M K2RB-1010M-26M K2RB-415M-10M K2RB-505M-14M K2RB-735M-20M K2RB-1130M-26M long press (more than 1.5s). Once the K2RB-425M-10M K2RB-530M-14M K2RB-820M-20M K2RC-1195M-35M key press is registered, the timer is shut K2RB-430M-10M K2RB-545M-14M K2RB-880M-20M K2RC-1225M-35M K2RB-450M-11M K2RB-625M-14M K2RB-914M-25M K2RC-1305M-35M down (to save power) and the firmware 4 5HT Toko type UHF Triple Tuning Band Pass Filter rearms the comparator interrupt after TW-P/N-Fo-BW TW-P/N-Fo-BW TW-P/N-Fo-BW TW-P/N-Fo-BW K3RFT-360M-20M K3RFT-460M-18M K3RBT-655M-16M K3RBT-945M-20M a hold-off delay. K3RFT-380M-20M K3RFT-480M-18M K3RBT-705M-20M K3RBT-980M-20M In operation, long presses of S2 are K3RFT-400M-15M K3RFT-495M-20M K3RBT-735M-20M K3RBT-1010M-20M K3RFT-410.7M-10M K3RFT-515M-20M K3RBT-800M-20M K3RBT-1055M-20M used to start and stop the data logging. K3RFT-420M-16M K3RFT-518M-20M K3RBT-830M-20M K3RBT-1090M-20M The short press is used to flash LED1 K3RFT-435M-10M K3RFT-520M-14M K3RBT-862M-20M K3RCT-1125M-20M K3RFT-440M-18M K3RFT-590M-18M K3RBT-880M-20M K3RCT-1230M-20M (blue) to provide operational feedback See more BW& Perf+Spec: www.temwell.com.tw to the user. This LED is driven by the Temwell-VHF.UHF 5-20 Watts Diplexer【 【 RC6 pin of IC1 as described previously, with a 470Ω resistor providing current Tx limiting. We will describe its operation in more detail in Pt.2 next month. Rx (5 Watts, 7H313) Scripting Language Finally, we’ve written a custom scripting language so that the USB Data Logger can be configured for use with a wide range of digital sensors. This also involves the use of a Windowsbased host program that can parse this scripting language and compile it into “machine code”. This is then programmed into the USB Data Logger’s non-volatile memory (ie, into a file on the memory card). The reason for this scripting language is to allow a wide range of digital sensors to be used with the data logger. Rather than designing it to work with a select few sensors, with the scripting language you can configure it to suit whichever sensor you would like to use, as long as it operates using one of the supported protocols (I2C or Dallas One Wire). Having written a script to suit your sensor, the resulting code is then executed by the microcontroller, allowing it to communicate with that sensor and read its output. Next month That’s all for this month. Next month, we’ll give the assembly details SC and describe how it’s used. (10-20 Watts) (EX) VHF.UHF 5 Watts Diplexer List (50Ω Ω) TEMWELL's P/N Fo. Tx/Rx IL dB Tx/Rx DCQ31S-308M/334M-P 308/334M 3.0/3.5 308/344M 3.0/3.0 DCM31S-308M/328M-P DCN31S-308M/344M-P DCM32S-367M/383M-P DDQ440M/465MP 308/328M 367/383M 440/465M DDQ450M/475MP 450/475M DDQ34S-450M/476M-P 450/476M DDQ35S-450M/480M-P DDM34S-450M/470M-P DDM35S-450M/466M-P 450/480M 450/470M 450/466M 3.0/3.5 3.0/3.0 3.0/3.0 3.0/3.0 3.0/3.0 3.0/3.0 3.0/3.0 3.0/3.5 (EX) VHF.UHF 10-20 Watts Diplexer List (50Ω Ω) TEMWELL's P/N Fo. Tx/Rx IL dB Tx/Rx DiAN 128 / 148M SMA 128/148M 1.8/1.8 148/168M 1.8/1.8 230/270M 1.8/1.8 350/390M 1.8/1.8 430/470M 1.8/1.8 430/460M 1.8/1.8 DiAN 138 / 158M SMA DiAN 148 / 168M SMA DiAN 152 / 172M SMA DiBS 230 / 270M SMA DiCS 330 / 370M SMA DiCS 350 / 390M SMA DiDS 410 / 440M SMA DiDS 430 / 470M SMA DiDS 450 / 490M SMA DiDN 430 / 460M SMA DiDN 450 / 480M SMA 138/158M 1.8/1.8 152/172M 1.8/1.8 330/370M 1.8/1.8 410/450M 1.8/1.8 450/490M 1.8/1.8 450/480M 1.8/1.8 See more BW& Perf+Spec: www.temwell.com.tw Temwell Innovative.3/4 Tuning B.P. UHF Module Filter 【 【 BW (-3dB) 40~60MHz ;UHF Fo: 210~1.3G IL:1.5~2.5dB; Group Delay:30~40 nsec Designed 4 type BW of: 8-20/20-40/40-60/60-100MHz...etc ~N connector~ Pass Band 221~245M 246~275M 276~310M 356~400M 401~455M 456~515M 516~555M 556~595M 596~640M 661~700M 701~750M 751~800M 801~830M 831~860M 1001~1100M 1251~1300M 3 Tuning (7H3 series) ~N connector~ 4 Tuning (7H4 series) Temwell-P/N-Fo-BW IL Temwell-P/N-Fo-BW IL TM-TT63368B-240M-40MN TM-TT67277B1-250M-35MN TM-TT67727B-293M-40MN TM-TT67728B-378M-40MN TM-TT67256B-427.5M-40MN TM-TT67811B-485M-40MN TM-TT67812B-535M-40MN TM-TT67825B-585M-40MN TM-TT67826B-630M-40MN TM-TT63326B-666M-40MN TM-TT67230A-730M-40MN TM-TT67797B-775M-50MN TM-TT67804B-815M-60MN TM-TT67516A-850M-70MN TM-TT67341A-1030M-77MN 2.0 2.5 2.0 2.0 1.5 2.0 2.0 2.0 2.0 2.5 2.5 2.0 2.0 3.0 2.0 TM-TT63364B-1280M-120MN 2.0 TM-TF69523B-240M-60MN TM-TF64377B-248M-50MN TM-TF64208B-325M-50MN TM-TF69728B-378M-40MN TM-TF64209B-455M-50MN TM-TF6972F-470M45MN TM-TF69257B-530M-40MN TM-TF69825B-585M-40MN TM-TF69633F-660M-58MN TTM-F64327E-666M-50MN TM-TF69652B-725M-55MN TM-TF69653B-775M-55MN TM-TF69655B1-825M-55MN TM-TF64371F-845M-70MN TM-TF67341A-1030M-77MN 1.5 1.5 1.5 2.0 2.0 2.0 2.5 2.5 2.5 2.5 2.5 2.0 2.5 2.5 2.5 TM-TF64364B-1280M-120MN 2.0 See more BW& Perf+Spec: www.temwell.com.tw A.Customized Division: Joe<at>temwell.com.tw B. Mail Order Division: Sales<at>temwell.com.tw Standard Filter 200K In-Stock, 72 hr Delivery ~Welcome reseller~ www.temwell.com.tw / Mail: info<at>temwell.com.tw Made in Taiwan/ Designer & Manufacturer & Exporter TEMWELL CORPORATION ISO9001:2008 RoHS SAW Filter's Conjugation