Home

MEASUREMENT & SENSORS

image

Contents

1. The IOMan ager object receives all requests for sec tors This enables it to make smart decisions regarding caching You will find these routines in ioman c One key define in this file is IOMAN_NUMBUFFER It deter mines how many sectors IOMan can cache I find that the IOManager holds several clever solutions that apply to most embedded designs It supports delayed write So as you fill up buffers with data you can either force a write or let the IOManager decide when a write is necessary IOManager also can allocate memory itself or use memory that you have previ ously allocated This is key to being flexible enough to make it applicable to a broad variety of systems The hwInterface hardware interface object has three responsibilities initialize the hardware read the sectors and write the sectors In the first part of this article series I presented code outlines for interfacing to a CompactFlash card and included those routines As you study this design I think you will find it straight forward yet sophisticated enough to handle your embedded system requirements I was looking for FAT32 support because I predicted that smaller capacity memory cards will soon disappear from production or their prices will rise above the larger capacity designs The text in the EFSL manual reads This library is released under the Lesser General Public License LGPL This means that you may use the library and its source code for any purpose
2. 69 70 IL it was designed to run see Listing 2 Line 61 We figured this breakpoint could be made intelligent by using the development environment s applica tion programming interface to upload the status information to the host PC automatically We planned to display the task information there using the graphing capabilities of Excel or possi bly by generating a plug in for use with the Ellipse development framework However when we actually got around to developing a state history GUI the amount of work involved did not look so appealing So we searched instead for existing shareware capable of per forming the same operations We found an unexpected solution We had previously worked with the Analog Devices VDSP integrated devel opment environment IDDE that has a state history plug in VDKHistory dll Running under Windows this plug in used to display the performance of Analog Devices s preemptive VDK scheduler This www circuitcellar com st CIRCUIT CELLAR plug in includes an interface for cus tomizing the performance analysis of multiple threads There is consider able similarity in functionality need ed to analyze preemptive and cooper ative scheduling Thus the VDK dynamic timing and event informa tion was stored in a history table with a structure equivalent to the HistoryStruct entries in Listing 3 The VDK Help pages indicated that the VDK state history plug in accessed a global VDK
3. I d used the SPI pins to allow for future use of the SPI periph erals on the R8C to drive the JTAG interface even faster At first I ported XAPPO58 to run on the host using a simple serial protocol to toggle the output bits and read the Production Designing Service 3D Endosure Designing Virtual Assembly PCB Design Components pcs Keypads www EzPCB com www circuitcellar com CIRCUIT CELLAR Email sales ezpch com May 2009 Issue 296 N NI N 9 May 2009 Issue 296 input bits It was slow clocking at only a few kilohertz one serial byte per logic pin change By running the application on the pod and sending only the XSVF data across the USB link I avoided the overhead The seri al port was configured to support full hardware flow control so no special host application was required I could use any terminal emulator with a send raw file option However I wrote a small utility to automate the communication It resets the pod which gives control to the pod s ini tialization function That let me check that the power supplies match Once they matched I sent a command to turn control over to the XSVF appli cation and started sending the xsvf file across When the programming was done control returned to my pod function and it sent the completion status to the host utility How much of a difference does it make Running the application on the host and sending each chan
4. R8C Microcontroller programming a CPLD chip Renesas Technology Corp www renesas com en r 8ctiny Can you think of another use for the pod Experimenting with LCD inter WebPack Software and XC9500 family of CPLDs faces testing SPI chips preprogram Xilinx Inc www xilinx com ming PC EEPROMs the possibilities are limited only by your needs al Got Serial g 2B2C Factory om Your Fingertip a eed Network z m rom Idea to Reality gt Design gt Prototyping gt Production See Our Differences in gt Quality gt Service gt Price Milling Turning Grinding CNC Wire Cutting Laser Plasma Water Jet Plastic Injection sheet Metal Gear SLA FDM SLS LOM Volume Discounts Available MachinePIER is Qridconnect Tel 408 421 9840 Email sales machinepier com www gridconnect com Website http www machinepier com 1 800 975 4743 May 2009 Issue 226 www circuitcellar com s CIRCUIT CELLAR es Q May 2009 Issue 296 ee Ss a RECHE by Andrew Mitz amp Jon Daley DOS in the e15 Century A USB Flash Drive Reader for MCUs Works for DOS With a little effort you can turn DOS into a handy real time operating system As Andrew and Jon explain it can be the perfect fit for embedded applications that may require too many resources for a single board microcontroller Read on to learn how this USB flash drive reader for DOS can enhance your future embe
5. The last module is the top level module for this chip unimaginatively named top v see Listing 1 The other two modules had inputs and outputs but they existed only for referencing from other modules For the top level ProtoMat S Series PCB Milling Machines Electrical engineers agree with a Protomat S Series prototyping machine at your side you ll arrive at the best solutions fast These highly accurate benchtop Jl PCB milling machines eliminate bread boarding and sa E allow you to create real repeatable test circuits EU including plated vias in minutes not days e Declare your independence from board houses e Affordable entry level price tag e The best milling speed resolution and accuracy in the industry BRE Laser amp Electronics e Single sided double sided and multilayered machining without hazardous chemicals For complete details visit www Ipkfusa com or call 1 800 345 LPKF e Optional vacuum table and autosearch camera for layer alignment a May 2009 Issue 296 H ICbank 3 PORT INTERFACE A hay j t i E pre gja UA UL Pe S EK 5170 RS 485 to Ethernet Converter Povverful feature Protocol converter RS485 between Ethernet Offer TCP IP Communication to Devices with RS485 I F Network TCP UDP DHCP ICMP IPv4 ARP IGMP PPPoE Ethernet Auto MDI MDIX 10 100 Base TX Auto negotiation
6. With compilers that cut power consumption Your MCU can go green TI HI TECH C PRO ANS C Compilers featuring Omniscient Code Generation OCG OCG is a new whole program compilation technology that cuts power consumption by reducing interrupt latency and increasing speed while simultaneously reducing code size It s a win win for your project and the environment HI TECH C PRO compilers for Microchip PIC10 12 16 18 32 MCUs and other microcontrollers Denser code better performance www htsoft com ocg E OCG vvvvvv htsoft com sales htsoft com s 61 7 3722 7777 All trademarks are the property of their respective owners 22 May OO ge Meas ement tenens gt PPP al 1 Smart Lead Acid Battery Meter An MCU Based Gauge for SLA Batteries Dale Wheat PA construct a USB GPIO Pod Part 2 USB JTAG Module DJ Delorie G DOS in the 21 Century A USB Flash Drive Reader for MCUs Works for DOS Andrew Mitz amp Jon Daley Transformerless Power Supply Tom Struzik eeeaaeeeos gudrs eeeeees Li TI 1 LI MM LN T N a J7 Tramnmsformieriess A A Look at a Modern DSP Its All About the Content Stupid Tom Cantrell Steve Ciarcia FROM THE BENCH TASK MANAGER A A World Without NTSC SMart a Bridge the Gap Between NTSC and VGA Jeff Bachiochi NEW PRODUCT NEWS edited by John Gorsky ESSONS FROM THE TRENCHES FAT File System Review
7. alty Card and so on can be developed in BASIC and are fully compatible to the ISO 7816 standard Encryption technology like AES DES or ECC is included Programming is accomplished through a bidirectional O contact Communication takes place at 9 600 bps or more accord ing to the T O and T 1 protocols defined in ISO IEC standards 7816 35 and 7816 4 The latest cards also implement the con tactless 15014443 protocol This is completely invisible to the Basic programmer All you have to do is define a command in the card and program it like an ordinary Basic procedure Then you can call this command from a 2C Basic program running on the PC Again the com mand is called as if it was an ordinary procedure The BasicCard operating system takes care of all the communications for you It will even encrypt and decrypt the commands and responds if you ask it to All you have to do is specify a different two byte ID for each command that you define A development kit for the BasicCard 2C5 12 is avail able for about 78 The BasicCard 2C3 12 is priced at 1 30 in quantities of 10 or more ps Basicc ard ZeitControl cardsystems GmbH www basiccard com NEW 8 16 AND 32 BIT INDUSTRIAL MCUs Three new series microcontrollers with embedded flash technology for industrial applications are now available All are designed to meet the performance and reliability requirements of a wide range of drive applications across a variety of ind
8. as before I knew that using a rectifier would make it impossible to drive a TRIAC gate from a processor output directly 66 To minimize exposure to high voltages during construction decided to build a transformerless power supply prototype as a unit separate from the logic circuit prototype 19 Another alternative was a resistive design rather than a Capacitive one The problem with the resistive design was that it required a 10 W resistor which would result in both size and power dissipation issues Ultimately I determined that the 10 mA capacitive design was a rea sonable compromise between available current and com ponent size To minimize exposure to high voltages during con struction I decided to build the transformerless power supply prototype as a unit separate from the logic circuit prototype The idea was to allow for the troubleshooting of the logic section from a normal 5 VDC supply and risk only high voltage exposure when troubleshooting the power supply itself However at some point I knew both sections would have to be integrated but being built as separate prototype units helped minimize risk Once I had an assembled prototype of a transformer less power supply the first issue was trying to deter mine how well the power supply was working The problem was that the DC ground for the circuit design floated just 5 V below the hot line of the 120 VAC mains Thus if I had tried to measure the 5 DC output
9. i e 256 pixels line x 2 bits pixel A field has 262 5 scans lines that make up one screen scan The first and last few are usually out of the field Video scale register VSCL N A PixelClocks Number of CTRA PLL clocks pixel 00 FF 8 bit value FrameClocks 16 or 32 x PixelClocks 000 FFF 12 bit value Table 2 This 32 bit register contains an 8 bit count of clocks per pixel and a 12 bit count of clocks per frame 1 or 2 bit resolution dependent CIRCUIT CELLAR www circuitcellar com LLL ECET TERG OS E e O FeO Accelerate your Design Time with EmbedaedDeveloper com Speed up your design time during the critical evaluation phase of your project by avoiding locating and comparing devices from different manufacturers We make it easy just one visit to EmbeddedDeveloper com will shave hours Or days off your schedule 7 Embedded Developer s simple navigation and intuitive search engines help you quickly locate COmpar and evaluate thousands of different microcontrollers from different manu facturers without knowing part numbers HEARST business media ELECTRONICS GA DEDDEVELOPERGOT FIND COMPARE BUT Compare all devices by their performance and features in seconds download a data sheet find and buy development tools or link to a distributor for an RFQ or chip sample without ever leaving the site Embedded Developer is the only site in the
10. pliers have diligently worked to overcome historic DSP objections high price high power consumption hard to program needs extra chips and glue logic and more Let s put all the labels and precon ceptions aside and take an impartial look at a modern DSP in disguise the Piccolo from Texas Instruments Yes it s a natural for classic DSP apps such as fancy e g sensorless motor controls and smart e g power factor correction switcher power supplies But I think you ll be surprised to see the potential Piccolo offers general purpose applications as well In many many respects it Multiple temperature grades 40 to 85 C 40 to 125 C 40 to 125 C Automative ja O O D A F2802x 64 KB Flash memory 60 MHz 64 KB Flash memory 40 MHz 32 KB Flash memory 60 MHz 32 KB Flash memory 40 MHz definitely isn t your father s DSP PIPE DREAM Piccolo comprises a family of parts with roots in the venerable Texas Instruments C2000 DSP line up see Figure 1 Nevertheless from 50 000 you d be hard pressed to tell the difference between Piccolo and a traditional 32 bit MCU see Figure 2 Notably it s got on chip memory peripherals and glue logic and is fully capable of stand alone single chip operation But dive down to treetop level and the DSP difference becomes more apparent The processing core itself with an eight stage pipeline is more c
11. re not going to implement only what s needed to get the job done We re likely to probe kick stretch test and add fea tures that improve and enhance the design even if only implemented for use during in house testing We also like to get under the hood and understand the inner workings With that in mind Id like to present a more general purpose FAT file system You can remove the features you won t use and tune the operation to suit your appli cation and specific hardware I purchased a low power Altera NIOS evaluation system for another project On that board is an interface to an SD card along with the embedded file system library EFSL This library is available for download from SourceForge as are other interesting hardware and software projects If you haven t looked at the site yet be careful It s full of great projects and you could spend mega hours wandering through them GET STARTED The EFSL is written in C and is only a library It doesn t do anything out of the box but will tie in nicely with your embedded C code It has hardware targets for Linux the Atmel ATmegal28 and the Texas Instruments DSP families In a future article I ll get this up and running on another embedded system and make that available to you The download package includes a manual that explains the design and how to apply the library to your specific applica tion This library handles FAT12 FAT16 and FAT32 with with long fil
12. you re entitled to special introductory pricing i subscription services on Act now to receive the April 2009 preview bonus material which launches with Time Triggered Systems Co Operative Schedulers 101 by Circuit Cellar feature author Michael Smith ITCELLAR DIGITAL PL 225 CIRCU Photo 1 rj lhe Analo Dev Supporting baci E Pevices BF533 g basic audio and video Ge board is capabi Strations S Poni 2009 N J p gt sue CIRCUIT CE ELLAR www Circuitcel To access the preview edition visit www circuitcellar com and click on the April issue icon on our home page KJILICON UPDATE www circuitcellar com by Tom Cantrell Whistle While You Work A Look at a Modern DSP Remember your father s DSP Well the Texas Instruments Piccolo isn t it Tom presents this DSP in disguise and describes how you can use it to handle signal processing applications such as switcher power supplies and other handy applications CIRCUIT CELLAR abels and acronyms have always been part of the silicon game Shorthand can be helpful but sometimes it can be misleading especially as the underlying technology changes over time RISC and CISC are examples of labels whose meanings have devolved to the point of meaninglessness Yes when originally coined many years ago the terms clearly defined distinct architec tures But over time as each camp adopted the best features of the other th
13. 6 bits are an index into the tile color set table TCT The bottom 10 bits are an index into the tile bitmap memory TBM The tile color set table is a list of 64 4 byte entries Each TCT entry holds the 8 bit color informa tion for each of the four potential colors Thus this tile could choose to use any of the 64 color sets The 10 bit CIRCUIT CELLAR www circuitcellar com tile bitmap memory index is used as the upper 10 bits of a 16 bit address that holds all of the tile s bitmapped data GRAPHICS While I consider characters tiles and sprites to be graphi cal in nature the graphics engine driver uses point plotting to draw lines and polygons You may be familiar with Carte sian coordinates where x as a horizontal offset and y is a vertical offset from 0 in the center Offsets increase when moving up and to the right while they decrease when mov ing down and to the left of center Any point P consists of an x and a y offset from O It is usually written as P x y Note that the video screen is usually mapped with an inverted y axis so that P 0 0 is the upper left corner of the screen and P screen_width screen_height is the lower right corner of the screen While the Cartesian coordinate system eases rendering it is labor intensive when dealing with rota tions Therefore you may find the polar coordinate system more efficient when you must deal with rotational move ments even though you will need to convert back a
14. 8 4 ADC voltage ranges Ua ai os n i o 4 ai Va an til i A KU Prog pacing clock Externally triggered a PSH ee ratal pW RIED ET eT TET TTT ort SHET Pa 4 inputs 1 output i sien S F agf R TEG al b ae ol vl Jak vl EKE EII au ca 4 16 bit counters JSPs Pa cnt 4 12 bit DACs m alo n PEO e Eper I R ci lt NO CDa sc NOCOU ee Coe N see our website for x86 SBCs peripherals and option details 33 Technologic a Sysbems We use our stuff Visit our TS 7800 povvered vvebsite at www embeddedARM com 7 8x oversampling Bonus Video Portal Circuit Cellar recurring author 500m 1000m Chris Coulston presents the ming first installment of the DIY I ms um guide to building a Goldsprints racing system 100mph I I I I I I I I I eee i g0hz upoat Sensor calipration I Circuit Cellar video from the 16 annual Trinity College Fire Fighting Home Robot Contest 2009 ees E wee Upcoming Microchip MASTERS 2009 Recent Renesas Devcon Old Tech New App L Ntfirst glance this issue looks more like one you would ve read in the mid 9085 rather than in mid 2009 The topics of DOS sealed lead acid SLA batteries NTSC C code digital signal processing DIY power supplies and JTAG don t really scream cutting edge technology But when presented by Circuit Cellar authors who spe
15. C class member variable HistoryBuffer g History MAX HISTORY ENTRIES currentEntry TICOS Historylable The VDKHistory dll plug in was able to generate the state history shown in Photo 1 when we added this variable to a C file linked to our C project We encountered typical issues asso ciated with using someone else s existing code in an unusual way We had to redefine display constants such as TASK_BLOCKED in terms of the con stants needed by the VDK plug in Ana log Devices event Type of information can be chosen from a list of possible events equivalent to taskCreated taskDestroyed and taskSwitched Their taskStatusChange event type permits the recording of when the task status switches between Ready Run ning Blocked or Sleeping The VDSP development environ ment handles projects with both C and C code But we wanted to avoid generating such a mixed project how ever there was no documentation available for using the VDK plug in in this unusual manner This made things a little difficult For example it is straightforward to access the global VDK C g_Histo ry variable from C and assembly code using the standard name mangled syn tax format of extern History Buffer g_History__3VDK However OV May 2009 Issue 296 CIRCUIT CELLAR DIGITAL PLUS BONUS if you build your own version of the C Listing 3 Adding this HistoryStruct to the code adds all the necessary information to n
16. Corporation All rights reserved Atmel logo and Everywhere You Are are registered trademarks of Atmel Corporation or its subsidiaries Other terms and product names may be trademarks of others NEW SEALED LIMIT SWITCHES Many limit switches must function in harsh conditions or outdoors environments which may damage switches and lead to frequent change outs Even limit switches that are IPO7 sealed often require wiring replacements This could mean changing several meters of cable on out door equipment In order to facilitate faster maintenance the newly introduced models MP750 through MP760 sealed limit switches with the ability to connect through an M12x1 connector which maintains IP67 protection on the switch are now available The connector can be mounted on the side but a bottom mount option is also available The MP7O0 series limit switches are available with a metal housing and a five pin connector or with a plastic housing and a four pin connector Mount ing holes can be placed either 20 mm or 25 mm apart for installation flexi bility The switches are additionally supplied with a large variety of actuator options and conform to IEC 947 5 1 and EN 60 947 5 1 Pricing for the switches starts at around 40 Microprecision Electronics www microprecision us NEW OSCILLOSCOPES FOR DEBUGGING The WaveAce series of digital oscilloscopes is a line of portable affordable easy to use oscilloscopes in the 60 to 300 MHz
17. Full half Duplex Serial RS485 3 Ports 1 200 115 200 bps Terminal block I F Type Control program IP Address amp port setting serial condition configuration Data transmit Monitoring Accessory Power adapter 9V 1500mA LAN cable Etc DIP Switch 485 Baud Rate setting LED Power Network 485 Port transmission signal I JILGbank D biti ti Pl drit n ILbank Gateway t Eleciranice MP SF DIY KIT Doi Powerful feature MP3 Encoding Real time decoding 320Kbps Free charge MPLAB C Compiler student edition apply Spectrum Analyzer Application Focusing for evaluation based on PIC Offer full source code schematic Microchip dsPIC33FJ256GP710 16 bit 40MIFs DSC VLSI Solution VS1033 MP3 CODEC GD NXP UDA1330 Stereo Audio DAC i Texas Instrument TPA6110A2 Headphone Amp 150mW 160 220 j sad TT qty 100 qty 1 Touch screen SD SDHC MMC Card External extension port UART SPI I2C 12S Powerful feature Play MP3 Information Reward forward Vol Focusing for MP3 Player Only SD Card interface Power battery 150 offer full source code schematic qty 100 qty 1 MCU Atmel ATmegai28L MP3 Decoder VS1002 VS1003 WMA IDE Interface Standard IDE type HDD 2 5 3 5 Power 12V 1 54 LCD 128 x 64 Graphic LCD Etc Firmware download update with AVR ISP connector Powerful feature Play MP3 Information Reward forward Vol Focusing for full MP3 Player Witho
18. MSR145S DG3061A 3101A 3121A RWT320 UK 7409 0 FT232RL PSoC Starter Drop n solution connects PC to Popular UART and FIFO chips Intelligent CAN connection Network serial product easily without NI Fantastic array of stock and M Get going quickly with PSoC I2C SMBUS 32 JO lines 89 Mi Upgrade Legacy designs to USB from PC s USB port 299 a PC using this 28 cable 89 custom switching devices visual design environment Keyboard Simulator Instant Ethernet Ethernet 10 i i Temp RH Sensors PoKeys55T IZ110SR 1 W5100 bedRF Adeunis UPSICAP DLP TH1 USB board adds 55 I O and 5 x i No OS needed TCP IP offload El UDP IP controlled 24 digital Ready to go out of the box FPGA DSP Mil Analog input bluetooth wireless fr 10 bit VD inputs 1 x 10 bit analog O P I ICs improve system performance MI MO board 3 x 8 bit TTL ports designs for beginners and experts N modules 433 868 915MHz NET Board Easy OLED Display AWM6XX TX RX KK Systems USB COM Quantum 9p 9p or 25p 25p self pwrd Add 1 16 COMports via your Quickly add capacitive touch isolated RS232 RS4221485 PC s USB Port easily on off amp XI Y sensing ICs ome of our best selling unique Z genas wireless us U Industrial Non Contact Distance Sensors AY 11 K Distance Measurement Celebrating Our 10 Year Anniversary Get All Your In A Quick and 20 Sale On Entire Selection Of Oscilloscopes Probes Digital M
19. Part 2 TESTYQUR EO I PS 3 C Code for the File System CROSSWORD ZA george Male INDEX OF ADVERTISERS E E June Preview a VLIVVIN UF VAIL z Whistle While You Work PRIORITY INTERRUPT E 6 CIRCUIT CELLAR www circuitcellar com Hammer Down Your Power Consumption with picoPower THE Performance Choice of Lowest Power Microcontrollers Performance and power consumption have always been key elements in the develooment of AVR microcontrollers Today s increasing use of battery and signal line powered applications makes power consumption criteria more important than ever To meet the tough requirements of modern microcontrollers Atmel has combined more than ten years of low power research and development into picoPower technology picoPovver enables tinyAVR megaAVR and XMEGA microcontrollers to achieve the industry s lowest power consumption Why be satisfied with microamps when you can have nanoamps With Atmel MCUs today s embedded designers get systems using a mere 650 nA running a real time clock RTC and only 100 nA in sleep mode Combined with several other innovative techniques picoPower microcontrollers help you reduce your applications power consumption without compromising system performance Visit our website to learn how picoPower can help you hammer down the power consumption of your next designs PLUS get a chance to apply for a free AVR design kit E O Everywhere You Are 2008 Atmel
20. S May 2009 Issue 296 May 2009 Issue 296 Kuo Ss a RHEE by DJ Delorie Construct a USB GPIO Pod gar 2 USB JTAG Module In the first part of this article series DJ presented a general purpose input output GPIO pod that can plug into a USB port Now he describes how to download a JTAG programming application and program a CPLD circuit s I explained in the first part of this article series you can use a general purpose input out put GPIO module that plugs into a USB port on your computer to make up for the lack of a parallel port While the flexibility of having a microcontroller in this pod enables you to do many things the real advantage is that you can put a lot of logic even entire applications in the microcontroller This month I ll explain how to download an entire JTAG programming application into the module rll then describe how to use it to program a simple CPLD circuit from a Verilog program from my Linux workstation There are commercial devices that let you program JTAG devices over USB from Linux Then again there are devices that do a lot of the things you learn to do in Circuit Photo 1 A closeup of the JTAG adapter Most of the complexity is in the software the adapter serves to manage the wiring itself My project doesn t use TRST so it is left unconnected N A Cellar but it s no fun if you don t do it yourself right The module I built is a pure do it yourself sol
21. Systems 15 Front Panel Express LLC 28 Linx Technologies 76 Reach Technology Inc 7 Atmel 69 General Circuits 73 77 MCC Micro Computer Control 39 73 Saelig Co 33 CWAV 35 Grid Connect Inc 35 MachinePlER 11 SEGGER Microcontroller Systems LLC 68 CadSoft Computer Inc 5 HI TECH Software LLC 76 Maxbotix 40 Senix 14 Calao Systems 40 HobbyLab LLC 78 microEngineering Labs Inc 55 Sensors Expo amp Conf 76 CapTron Corp 75 2CChip 21 Mouser Electronics C3 Tech Tools 23 Comfile Technology Inc 30 31 ICbank Inc 78 NKC Electronics 2 3 Technologic Systems 78 Crossware Products Inc 1 Imagineering Inc C2 NetBurner 76 Technological Arts 76 Custom Computer Services Inc 78 Ironwood Electronics 71 Nurve Networks LLC 77 Tern Inc 75 DLP Design 32 34 JKmicrosystems Inc 78 Ontrak Control Systems 75 Trace Systems Inc 40 DesignNotes 75 JKmicrosystems Inc 12 PCB Pool 76 Triangle Research Int l Inc 14 EMAC Inc 49 Jameco C4 Parallax Inc 34 Xytronix R amp D Inc 63 77 Earth Computer Technologies 71 Jeffrey Kerr LLC 63 77 Phytec America LLC 32 Elprotronic 13 Keil Software 78 Picofab Inc DEVIEW ATTENTION ADVERTISERS of June Issue 227 July Issue 228 Theme Communications Deadlines Space Close May 12 Keystroke Communication Design a Customizable Virtual Keyboard Material Close May 19 Autonomous Vehicle Design Embedded Systems Sensor Technology amp Motor Control Theme SSI Controller for Linear Position Sensors Internet amp C
22. a multitask embedded product such as the Theremin see Listing 1 First use TTCOS_Init to initialize the TTCOS scheduler Line 6 Then add tasks to the sched uler s todoList by specifying each task s initial time delay and period with TTCOS_AddTask Lines 11 to 14 Next activate the scheduler s single interrupt timer TTCOS_Start Line 16 and send the system into a low power mode TTCOS_GoToSleep Line 20 The timer interrupt service Lines 27 30 routine uses TTCOS_Update Line 29 to increment the Run Me Now variable of each task based on the current time and the task s delay and period stored in the scheduler s to do list With the processor now out of Sleep mode the TTCOS_DispatchTask routine Line 21 activates all the tasks that need to run and the processor is given a bite of the poisoned apple and sent to sleep once again Line 20 For more details about all the code needed to develop a basic co operative scheduler see Michael Pont s book Patterns for Time Triggered System A free download is available at www tte systems com books CODE INSTRUMENTATION Building the Theremin required just four tasks to be added to the scheduler s to do list The LightSensorVolume and LightSensorFrequency tasks provide the tim ing information necessary to calculate the light sensors output frequency These are set to have a period of RUN_OFTEN There is one task Modif yAudioSet tings set to RUN_AS_NE
23. about p20 16 The TC1197 is about 26 46 Infineon Technologies AG www infineon com CIRCUIT CELLAR www circuitcellar com CO GAS SENSOR MODULE The CO Gas Sensor Module 27931 is designed to allow a microcontroller to determine when a preset CO gas level has been reached or exceeded Interfacing with the sensor module is done through a four pin SIP header and requires two I O pins from the host microcontroller The sensor module is mainly intended to provide a means of comparing carbon monoxide sources and being able to set an alarm limit when the source becomes excessive The module is built around the MQ 7 CO sensor and features a SIP interface Included in the kit is the module a potentiometer adjustment tool and com plete documentation The module requires 5 VDC at 165 mA Purge USB to JTAG o SEGGER JTAG g tink ARM7 9 Cortex M3 Fast 720kb s Download Speed Phase 50 mA Sense Phase The unit Serial Wire Debug SWD Support is 1 50 Hx 1 00 W x 1 00 D and Multicore Debugging Support Auto JTAG Speed Recognition operates over a O to 70 C range The J Link can be coupled with a The CO Gas Sensor Module costs number of available software 929 99 modules to fit your application needs Jelan S ec application used wi e J Link to program Parallax Inc internal and external flash delte www parallax com_ J Link RDI permits the use of the J Link
24. all Circuit Cellar readers to give Digital Plus a try Here s a short intro to Digital Plus 1 Digital Plus is a replica of the print magazine in digital form plus it includes digital only extras like bonus arti cles tutorials videos photos advertisements interviews and more 2 You can easily view Digital Plus in two ways One view it through an online flip book reader which does not require special software downloads Click on the icon to get instructions about using the flip reader Two down load each issue as an easy to print PDE Simply click on the Adobe Acrobat icon to download the PDE 3 An e mail will notify Digital Plus subscribers when a new issue is available New issues and some old are posted at www circuitcellar com DP If you want to subscribe to Digital Plus renew a sub scription or update your information feel free to visit www circuitcellar com DP at any time Enjoy C AH cj circuitcellar com A May 2009 Issue 296 THE MAGAZINE FOR COMPU TERS AEE ise ADVERTISING 860 875 2199 Fax 860 871 0411 www circuitcellar com advertise PUBLISHER Sean Donnelly Direct 860 872 3064 Cell 860 930 4326 E mail sean circuitcellar com ADVERTISING REPRESENTATIVE Shannon Barraclough Direct 860 872 3064 E mail shannon circuitcellar com ADVERTISING COORDINATOR Valerie Luster E mail val luster circuitcellar com Cover photography by Chris Rakoczy Rakocz
25. alphanumeric extension DOS file names Thus Windows XP directory names will often look like PROJEC 2 In our application these limitations do not pose any real inconvenience We use simple directory structures to move files from our NIMH Cortex data acquisition system to a Windows computer for editing or data analy sis With this in mind we did not implement complex directory pars ing at the command line Specifica tions like PJM DAY2 are not sup ported although specifications like DAY2 and P PJM DAY 2 are The VDRIVE2 firmware must be at version V3 64 or later Updating the VDRIVE2 can be done in two ways One you can download VPROG reflasher COM utility and CIRCUIT CELLAR www circuitcellar com the latest VDAP ROM file from the Vinculum download page on the FTDI web site The Reflasher COM utility runs from DOS or a DOS window and programs the VDRIVE2 via the serial port Alternatively you can rename the FTD file for the lat est release to FTRFB FTD put the file on the root directory of a flash memory drive and just plug the flash memory drive into the VDRIVE2 The VDRIVE2 will find the file and update its own firmware SOFTWARE IMPLEMENTATION The eight DOS commands for using the VDRIVE2 are in Table 2 Two commands FCONFIG and FBAUD provide ways to establish the serial port communications parameters with the VDRIVE2 FCONFIG is the only command implemented as a DOS batch file BAT The oth
26. and Electronics RobotKits Linefollowers Robotarms Hexapods Chassis High performance C programmable ATmega168 basedrobot withArduinosupport vec R nic N comp ponents A So ilca AN j Matar Shto Servocontrollers programming connector ATmega48 168 8 microcontroller 20MHzclock SolderPasteStencils From 25 Useourlow cost apar ek ld Cutyourowncustom chassis frontpanels andmore 1 8 7 POLOLU www pololu com 6000S EasternAve 12D LasVegas NV89119 A May 2009 Issue 226 Standards Make Sense 6 Standards improve quality and enable designers to share components across different projects Today ARM Cortex M profile processors combined ith the Cortex Microcontroller Software Interface Standard CMSIS and optimized middleware from the industry s largest ecosystem are setting the hardware and software standards for microcontrollers These standards enable leading vendors such as Luminary Micro NXP and STMicroelectronics to supply advanced microcontrollers while maximizing code reuse across multiple platforms Cortex M3 Microcontrollers Make Sense We based our award winning Stellaris microcontrollers on Cortex M3 to provide users with 32 bit performance while eliminating future architectural upgrades or software tool changes Jean Anne Booth Chief Marketing Officer Luminary Micro AU LUMINARYMICRO For more information visit www o
27. both as a matter of principle and to Dual OSC 10 MHz 3 3 V Supply On chip 1 9 V Power on Brown out reset reset Boot ROM 60 MHz 32 x 32 bit Multiplier RMW Atomic ALU Real time JTAG Control law accelerator Peripheral bus 12 bit 13 16 ch up to 4 MSPS ePWMx12 5x HR PWM Comparators up to 3x 10 bit DAC Figure 2 With on chip flash memory and RAM glue logic and a full complement of I O Piccolo is a contender for low cost single chip applications www circuitcellar com CIRCUIT CELLAR Instruction set wise Piccolo has something for everyone with RISC CISC and DSP all rolled into one 19 maintain software compatibility with earlier C2000 parts EASY DOES IT Historically one of the knocks on DSPs was that they paid little atten tion to the details beyond their num ber crunching mission burdening a design and the designer with the need for extra peripheral chips clock genera tion multiple power supplies and sundry glue logic It s here that Piccolo stands out from its predecessors with features like an on chip oscillator with PLL and missing clock detection a sin gle 3 3 V power supply with an on chip regulator power on brownout watch dog RESET and a vectored interrupt controller all in tidy surface mount packages Unlike traditional DSPs Pic colo is downsized with MCU like 38 48 64 and 80 pin package options Peripheral wise there s a full comple
28. but sifting through the press tea leaves reveals the CLA is an independ ent 32 bit floating point coprocessor that autonomously runs control loops e g PID Able to communicate directly with peripherals e g ADC ePWM and deal with interrupt requests the CLA is said to signifi cantly reduce overhead for the main processor see Table 1 SYMPHONY IN C Of course if you re already into DSPs TI has you covered when it EAGLE Version 5 Schematic Capture Board Layout Autorouter Windows Linux Mac ae Bi per moe roe EA Wwe i LN ti Foo e SII Professional 999 Standard and Light Editions have full functionality except 64x64 inch for the limitations mentioned 16 in the table 498 You can use EAGLE Light for evaluation and non commercial applications without charge Download it from our web site 996 996 1494 800 858 8355 196270 Pines Bivd Suite 217 Pembroke Pines FL 33029 Hotline 954 237 0932 Fax 954 237 0968 E Mail info ecadsoftusa corm comes to apps like motor control smart power supplies and such They ve got an effective develop ment and prototyping regime com prising DIMM like processor mod ules that plug into various applica tion specific motherboards and plen ty of software app notes and more to go with There s even something called DSP BIOS kind of a mini me modular RTOS comprising a library with hundreds of basic data acq
29. chroma color on baseband 1 Enable chroma color driver Aural subcarrier source 0 0 Use COG O s PLLA 0 1 Use COG 1 s PLLA 1 0 Use COG 25 PLLA 1 1 Use COG 5 s PLLA 0 0 Use COG 4 s PLLA 0 1 1 0 1 1 Use COG 55 PLLA Use COG 655 PLLA Use COG 7 s PLLA 0 0 0 0 1 1 1 1 N A VGroup Port drive 0 Group 0 P7 0 0 Group 1 P15 8 1 Group 2 P23 16 1 X d Group 3 P31 24 Reserve n a VPins Pin drive 0 1111 1111 0000 1111 1111 Driving lower four pins only NTSC Driving upper four pins only NTSC Driving all eight pins VGA Table 1 This 32 bit register defines how the VSU hardware is used The upper bits define the NTSUVGA modes resolution chroma and audio carrier source while the lower bits define which processor pins are used for output others to access the data it can indicate this with a lock flag Other cogs should respect this flag and cease access until it is cleared There are no interrupts on the Propeller Think of a cog as an interrupt routine that continuously executes its code independent of other cogs Every cog can read and write to every I O at any time You can use this to your advantage but without proper attention it can cause you headaches Any pin configured as an output by one cog will force the configuration of the pin to an output ev
30. degrades over time When the voltage is between 12 45 and 12 65 V it is estimated that approximately 75 or more of the power is still available Five green dots out of six indicate this stage Note that 12 24 V marks the 50 line Only four green dots are dis played at this point When 12 06 V is measured it tells you that only about 25 of the charge remains and three yellow LEDs are displayed notifying you that it might be time to start thinking about finding the charger When the measured voltage drops further but is still above 12 V two yellow LEDs describe this sad state of affairs The battery is effectively flat at this point While still above 11 89 V a single red LED will be lit to announce impending loss of battery power Anything below this is considered a battery failure and will be displayed as a blinking red light Below 11 5 V the unit stops displaying anything in an effort to save what little power might be left DUAL POWER One of the original requirements for the meter was to measure both 12 and 24 V battery systems because these were the most common for SLA batteries I had originally thought of N N9 using different resistors in the inbound voltage divider but this would have ultimately created two meters one for 12 V systems and another for 24 V systems My first thought to improve this was to use a jumper to select between the two ranges and have both sets of resistors installe
31. each scan line is disre garded by black and white sets as is the modulated and phase shifted color burst cycles during the active portion of each scan line The average value left of the color mod ulated signal remains as luminance levels for the black and white monitor producing levels of gray between a black 0 25 V and white 1 V A color monitor uses the phase difference between the color sync and the modulated color signal in the active portion of the scan line to deter mine color and the amplitude of the modulated signal to determine color saturation or intensity You saw earlier that the two video registers can configure the hardware to produce a composite video output signal containing all of the necessary syncs and modulations to do both black and white and color signal streams A cog driver can actually produce a signal with the full gamut of color However we ve determined that it requires a lot of RAM to hold high resolution color infor mation Because of the required RAM limits RAM is conserved by limiting the resolution to 1 or 2 bits per pixel One bit gives you black and white or two colors Two bits gives a few more colors to choose from but how does this value relate to a specific color The grid that makes up the screen tile locations hori zontal rows by vertical columns has a tile pointer map TPM associated with it There is a 16 bit pointer for each tile location Each pointer has double duty The top
32. eight coas Each cog has access to all I O pins and the hub s RAM and ROM as well as its own RAM May 2009 Issue 226 www circuitcellar com CIRCUIT CELLAR 0 es On Board USB to Serial Also available separately as the Propeller Clip or the Propeller Plug VCC VCCIO RESET OSCI OSCO FT232RQ we Red SA bi SA be Blue Electret Mic JP1 3 3v Fo o vop Ivdd Jumper PVSS OUTL SVSS OUTR C1P MAX4411 Stereo Resistors R21 R23 form a 1 V 75 ohm 3 bit DAC that is used to generate baseband and broadcast video Resistor R24 is only required for aural subcarrier in broadcast mode U5 LM2937IMP 5 0 VDD VDD Ri R2 10k Keyboard 100 VDD VDD R5 R6 10k 10k Removable crystal LED Indicators D3 D10 R13 R20 siii wa Yellow R32 240 J These three sets of tyvo resistors torm 1 V 75 ohm 2 bit DACS that are used to generate red green and blue Figure 2 The Propeller demo board schematic shows how simple resistors added to the Propeller s I O pins act as a DAC with a monitor s 75 Q input impedance creating an inexpensive interface for either NTSC or VGA video easily bridge the gap between NTSC and VGA So I took my Propeller demo board and went to work see Photo 1 The HYDRA is shown in Photo 2 The Propeller chip consists of eight independent processor units called cogs Each cog has its own 512 double words 32 bit
33. file copy FPUT or FGET will fail on occasion These failures are rare unless the computer hardware just cannot handle one of the high data rates For large files over a few megabytes it probably makes more sense to reboot the system to Windows and use the full speed of a USB port It takes about 50 minutes to copy a 30 MB file at 115 200 bps which is close to the theoretical min imum time about 46 minutes COMPILER amp SOURCE CODE The source code is posted on the Circuit Cellar FTP site Although the source code is rather generic C 19 and should work with any C compil er the code comes with a project file for compilation using Borland C version 1 1 The Borland compiler is available as a free download for non commercial use http dn codegear com article 21751 On the web site you will find a lot of information for installing and using the compiler For this project installation on a Windows XP computer is straightfor ward We use all installation defaults except the source disk C drive instead of a floppy disk To keep things simple the source code is unzipped to a new directory C TC FSOURCE a subdirectory of the Turbo C compiler root After everything is set up double click the TC EXE file in the C TC BIN subdi rectory to get character based Turbo C GUI If you want use the prop erties option of the DOS window to switch to full screen mode and flash back to the good old days of DOS
34. have any questions about this little circuit please don t hesi tate to contact me Dale Wheat is a full time freelance writer working primarily with embedded systems and shiny things that blink or beep Dale is married and the father of two adult children He lives near Dallas where he enjoys mowing two acres of grass in the summer and not mowing it in the winter To find out what he has been up to visit his personal web site dalewheat com www circuitcellar com CIRCUIT CELLAR Po ECT FILES To download code go to ftp ftp circuitcellar com pub Circuit_Cellar 2009 226 n I Buchmann Charging the lead acid battery Battery University www batteryuniversity com partone 13 htm The Electropaedia State of Charge SOC Determination www mpoweruk com soc htm D Lancaster Tech Musings www tinaja com glib muse152 pdf Maxim Integrated Products Inc Application Note 1798 Frequency Under sampling in Coulomb Counting Measuring Current Flow in Battery Appli cations 2002 www maxim ic com appnotes cfm appnote_number 1798 Application Note 1880 Charlieplexing Reduced Pin Count LED Display Multiplexing 2003 www maximic com appnotes cfm appnote_ number 1880 R2 D2 Builders Club http astromech net D Wheat http dalewheat com S OURCES PCB Artist software Advanced Circuits www 4pcb com ATtiny13 and STK 500 Atmel Corp www atmel com
35. having to work with assembly code so the Parallax folks created a higher level language called Spin It removes much of this burden by pro viding a bunch of useful functions While each cog executes on its own your application directs this operation and will determine exactly how a cog will be used For instance if your appli cation requires asynchronous serial com munication you might write a cog appli cation that samples the RX input looking for a start bit and upon reception uses the system clock to continue sampling the input at the proper data rate Collect ed bytes might be put into hub RAM available to any cog The hub continu ously does a round robin on all of the cogs It controls when a cog has access to the system RAM and keeps cogs from simultaneous access A cog may have to wait its turn which is a maximum of once every 16 clock cycles depending on whose turn it is If a cog needs to update multiple RAM locations prior to allowing CIRCUIT CELLAR www circuitcellar com S GC a SO rS ex Conference June 8 June 10 2009 Exhibits June 9 June 10 2009 Donald E Stephens Convention Center Rosemont Illinois www sensorsexpo com New Approaches New Technologies e New Applications e New Ideas 7 Don t Miss the Sensors Opening Keynote Cassini Five Years at t Saturn Investigation Scientist amp ae Baie Engineer Cassini Huygens Mission to Saturn amp Titan NASA S Jet Propulsion Laborato
36. having your input and being able to help many of you gain access to product samples from Circuit Cellar advertisers Sincerely Su K Sean Donnelly Publisher Circuit Cellar Authors note Your safety is your own responsibility You must use equipment and safety gear properly and determine whether you have adequate skill and expe rience Power tools electricity and the other resources used for these projects are dangerous unless used correctly and with adequate precautions including protective gear Some illustrative photos do not depict safety precautions or equipment in order to show the project steps more clearly Use the instructions and suggestions listed here at your own risk It is your responsibil ity to ensure that your activities comply with applicable laws You can download the Flectronics AVRSwitch html Figure 4 The completed circuit contains the transformerless power supply a TRIAC an Tom Struzik tpstruzik earthlink net has optional zero crossing signal and various other I O options The end result is a simple exper imental platform which can be easily configured to support many different uses most likely be at circuit ground not Earth ground and thus at 120 VAC potential Also be aware of your push buttons failure mode Do the plastic tops pop off to expose metal underneath Keep the unfused areas as small as possible That way if you short something out there s a better chance
37. my experimental transformerless power supply MAINS POWERED SUPPLY My first objective was to use the calculations in appli cation note AN954 to determine the required compo nent sizes I based the design on the high voltage capaci tor because its physical size cost and availability would control the overall design For example an X2 class capacitor is relatively large for its small farad value Higher value X2 capacitors increase rapidly in both size and cost which greatly limits the available component choices Application note AN954 also makes some safe ty suggestions which I incorporated into the basic design Finally note that while not currently Underwrit ers Laboratories approved I knew it would be possible to produce an enhanced design to meet UL approval requirements Read the Other Considerations section in the application note or visit the UL web page www ul com for more information After crunching some numbers I defined the basic cir cuit in Figure 2 By design this circuit can provide only about 10 mA of continuous current Drawing any more current will cause severe output voltage sag Unfortu nately I found that attempting to create a higher current design increased only the size of the X2 capacitor even more rapidly I read about alternative designs with higher available currents in the application note One such alternative involved adding a rectifier to the front end of this design However
38. ous After all if we have to drive current consuming audio amplifiers using an external power supply why is there a need to run the processor itself on batteries However it is actually a good design point to consider Suppose we want to run Theremin music as part of a stand alone hand held game application using head phones as output Ignoring other power con sumption issues by using faster interrupts in this situation we would be consuming more of the battery capacity than is really neces sary to power the processor core In Listing 7 a screen dump of a running Theremin musical instru ment we solved this problem by adding a RUN_ONCE task that switch es the system from using the inter nal timer interrupt to drive the scheduler to using the external audio Line 9 However that alone is rather an unsafe design decision as we have swapped from using a high ly reliable internal interrupt for a less reliable external interrupt If that external interrupt vanishes the whole system would hang In the current situation having the system lock up because the audio interrupt dies is not a practical con cern We need the audio chip to work in order to play the Theremin music If this chip dies we still have to pack up our gig and go home regardless of whether the system is running and has totally locked up However this does bring up a valid point Just how do you handle error conditions with a co operative
39. pdf view 153439 ETOGTSL230R html N May 2009 Issue 226 CIRCUIT CELLAR DIGITAL PLUS BONUS CIRCUIT CELLAR www circuitcellar com touched Originally there were two metal anten nae used to sense the position of the musician s hands These antennae were coupled to radio fre quency oscillators used to control circuitry that manipulated the Theremin s sound volume and fre quency Rather than using metal antennae we implemented two programmable light to frequency converters Changing light levels caused by shad ows were used to sense the position of the Theremin ist s hands Circuit Cellar columnist Jeff Bachiochi featured TAOS sensors see Figure 1 in his 2004 2005 arti cle series about a pulse oximeter design Light to Frequency Conversion Parts 1 2 Circuit Cellar 173 174 The easy to use sensors provide a train series of 50 duty cycle square waves whose fre quency is directly proportional to the light level falling on them Connect the sensor to a general purpose input output GPIO pin on any processor and you will able to sense the positions of a musi cian s hands by the amount of shadow that s cast Figure 2 shows the proposed hardware Two light sensors are connected to a processor s GPIO pins A speaker is plugged into an evaluation board s analog output channel As you learned in the first part of this article series it isn t difficult to use a co operative scheduler to prototype
40. pit v F2802_RaM FES ae OB80Hma p Ku S Files P iP D P Sy Projects ej SimpleDACtoADC pjt F2802x RAM AdcResult ADCRESULTO tore AP CSL1 761F002C MO DP 0x002C 8183 9200 MOV AL GO ti DP FOx0224 J Documents ite x DSP280x_EPwm_defines h J DSP BIOS Config JI Generated Files JJ Include Libraries Ane i 68 AL Sy Source zE j E N S RE l DSP2802x_CodeStartBranch asm ph AE 7 7 duty_cycle tel L DSP2802x_Global ariableDefs c a u E SimpleDACtoADC DevInit_F2802x c l SimpleDACtoADC Main c B DSP2802x_Headers_nonBIOS cmd Lu F28022 FLASH SimpleDA CtoADC CMD EJ F28022_RAM_SimpleDACtoADC CMD 5188 9209 MOV AL 9 68189 761F01A0 MOVW DP 0x01A0 18B 9609 MOV 9 AL 00818C D File View Bookmarks Build Complete Bil 0000001D Name 0 vae type 0 Errors 0 Warnings O Remarks Q dut E sh 5 FFFFFFFF u y_cycle 29 Uintl6 Please view the build output fr S ae Q adc_resuk 4078 Uint16 gt 00000000 amp Watch Locals Watch 1 PIM Buita J nn i ut enon nnnnnnnn HALTED s w breakpoint Line 164 Address N A CIRCUIT CELLAR www circuitcellar com THE SERIAL PORT LIVESI Everything you need to SERIAL l know about Monitor COM ports Bus address and don t cares USB virtual Bus data COM ports amp asynchronous serial ports for embedded systems Hardware amp software for RS 232 amp Watch for RS
41. sampling requiring a scheduler timer interrupt at 20 us intervals A GOOD DESIGN We have gone through the system architecture analysis and described the prototype system Now we are ready to Listing 6 We can avoid the LightSensor routine from blocking audio tasks by replacing the slow code of Listing 5 that waits till some input value changes Instead we need fast code that operates under the principle If no input value has changed I m leaving as quickly as possible and going elsewhere to do something more important void LightSensorTask Static int currentState HIGHI int newState currentState int pinState GPIOPin Input level switch currentState case HIGH1 Test for sensor going low if pinState LOW newState LONI break case LOWI Test for sensor going high if pinState HIGH newState HIGH2 Now at leading edge of light sensor pulse timel CurrentTime break case HIGH2 Test for sensor going low if pinState LOW newState LOW2 break case LOW2 Test for sensor going high if pinState HIGH newState HIGHI1 sensorPeriod CurrentTime timel break Update the task state currentState newState CIRCUIT CELLAR www circuitcellar com obo DUT JE I Een ee ES aa Ee ene eee as ao SS SS SE Ss the 1 accuracy needed for the LightSensor tim ings However we now had an internal time interru
42. sched uler This as they used to say in the cliff hanger movies will be covered in the next exciting episode There we will detail data acquisition issues using co operative schedulers il May 2009 Issue 296 CIRCUIT CELLAR DIGITAL PLUS BONUS EA happily printing out error messages or Mike Smith mike smith ucalgary ca has been contributing to Circuit Cellar since the 1980s He is a professor in comput er engineering at the Schulich School of Engineering University of Calgary Cana da Mike s main interests are developing new biomedical engineering algorithms and moving them onto multicore and multiple processor embedded systems in a systematic and reliable fashion He recently became a convert to the applica tion of Agile Methodologies in the embed ded environment Mention test driven development and his eyes light up In 2008 Mike had his Analog Devices Uni versity Ambassadorship renewed for the eighth straight year Lizie Dunling Smith is a fourth year undergraduate student at the University of Alberta Canada She will graduate in 2009 with a B Sc in engineering physics specializing in electrical engineering N ADSP BF533 Blackfin processor Analog Devices Inc www analog com TTSL230R Sensors TAOS Inc www taosinc com CIRCUIT CELLAR e www circuitcellar com LIRGUIT CELLAR mome U TODAY THE MAGAZINE FOR COMPUTER APPLICATIONS RENE W Te DA r lof 42 ka g9 sr S a B Ja
43. search bie x ation Daaru See FIS d os mote i Dy i 4 Oeson ee m det pm ati The Cs u ent La a m 5 LI puts are coded ims stead ot binary in Gray code order where only one bit alter have chang when the p tit k mest 9 the Video foi n Circuit cellars NewsDi Digital jus ume cenit CE fo agit a pring Cellar s flip book version of Dan Plus For al enhancement CLICK HERE for courtesy access unr at mygazines net By maintaining a Circuit Cellar Digital Plus subscription you et the first to view Circuit Cellar magazine each month And you ll get all multimedia material in the flip book version of the magazine along with a P DI your archives that you ll see it all Always be among the first to have access to Circuit Cellar each month And guarantee Renew or Subscribe to Digital Plus today CLICK HERE for subscription options Circuit Cellar Inc Subscription Service Toll Free U S 800 269 6301 860 875 2199
44. software scheduled pipelines incur Piccolo features an interesting mix of architectural styles as seen in the lay out of the main registers see Figure 3 The XT P and ACC registers do the DSP heavy lifting for the single cycle 32 x 32 multiplier and bar rel shifter On the other hand the 8 x 32 bit XAR general purpose registers lend a RISC like feel To streamline direct addressing the 16 bit data pointer DP register fronts a 6 bit offset contained in the instruction to reach any location in the lower 4M words of data space Of course much of the big iron addressing capability is underused in single chip devices While Piccolo is a Harvard design capable of simultaneous instruction fetch memory read and memory write access is made simpler by the fact memories are mapped into both TMS320F2803x C28x 32 bit 64 to 128 KB Flash memory CPU 20 KB RAM 6 program and data spaces That s helpful because it makes it easy to access data stored in flash memor y or run programs stored in RAM Instruction set wise Piccolo has something for everyone with RISC CISC and DSP all rolled into one As noted above the XAR registers support a measure of load store pro cessing yet also can serve as point ers that allow instructions to oper ate directly on memory The DSP DNA is apparent in all manner of number crunching embellishments such as saturation rounding and so on But overall Piccolo is quite CISCy
45. step over to using C in your embedded systems I like to see how many clich s I can get past my editors Last time I started a discussion about using a removable memory card either CompactFlash or Serial Digital in your next system and a file sys tem on those devices These cards offer a large capacity at a low price At some point in your system analysis you might decide that a file sys tem is the best way to manage all the data on the card If that s the case then here is another solution to add to your bag of tools I discussed the low level routines used to access and control these memory devices And I also pre sented one solution to the FAT file system design I found in the Circuit Cellar archives Refer to the following two articles PIC a CompactFlash Card M Samuels Circuit Cellar Online 127 2001 and Portable FAT Library for MCU Appli cations Jl Sham W Hue and P Rizun Circuit Cellar 176 20051 You ll find the original C code and the analysis output that has been generated using Source Publisher www scitools com The original code has documentation dated June 2004 Also I would like to point you to an Intel reference design Intel IXP42X Product Line of Network Processors and IXC1100 Control Plane Processor Using CompactFlash Don t let the title scare you It s a good article about interfacing to a Com pactFlash card and the code to support the inter face It s written from
46. that what you shorted will be behind a fuse Also keep the 120 VAC side of the circuit together and away from the 5 VDC side as much as possible This helps reduce the voltage differential between compo nents in case something shorts out FUTURE PROJECTS I plan to include a daylight sensor and a clock in the next version of my AVR switch But what ultimate ly makes it into the next version will depend on the project s space and power consumption require ments If you d like to experiment with your own AVR switch I have circuit boards and part kits You ll have to assemble everything and more importantly determine for yourself if this circuit is safe and appropriate I hope you find this information as useful and as interesting as I have Maybe your next project will also incorporate a transformerless power supply al www circuitcellar com CIRCUIT CELLAR been building and taking things apart from an early age He built his first Heathkit project at 12 and sold his first computer program at 16 Tom has a BSEE from Purdue University and currently works for a Fortune 100 chemical company in its engineering systems organization as an IT systems architect He continues to build software and hardware projects at home to keep his hands dirty One of Tom s current projects the Cat Faucet was recently covered by Engadget com p PROJECT FILES To download code go to ftp ftp circuitcellar com pub Cir
47. with an RDI compliant debugger J Link GDB Server is a remote NEW HINGED POWERSTRIP server for GDB Samtec has expanded its rugged PowerStrip High Power Interconnect family with a J Link Flash Download is a module hinged version of its 25 A PowerStrip 25 system The FMPS FMPT Series connectors Hees to coor you Peran in are ideal for applications that call for blind mating or where PCB real estate is tight kak Aash Hi a PETIT The hinged PowerStrip 25 Socket Terminal system FMPS FMPT Series is a unique J Link Flash Breakpoint permits system that allows for 90 or horizontal planar board to board interfaces and a 90 you to set an unlimited number of mating radius The design s flexibility allows the connectors to be mated at an angle ona breakpoints while debugging convenient for production and then rotated to the final permanent required orienta gt i A l J Link SDK is a standard DLL that tion It is available with up to eight power pins on 0 200 5 08 mm pitch and can extends the full functionality of the achieve a robust current rating up to 25 A per contact at 75 C Optional locking clips J Link to your proprietary application and a screw down configuration for the socket are also available The hinged PowerStrip 25 joins High Power 55 A PowerStrip 55 connector sys tems 25 A PowerStrip 25 connectors discrete wire cables and the 10 A Power Strip 10 modular connector system The full line of Rugged Power soluti
48. you want You may link with it and use it commercially But ANY change to the code must be released under the same license http efsl be If I look up more details on the LGPL it seems that if you keep the EFSL as a separate library and do not merge it with your code then your code does not become part of the LGPL license and you can keep it confidential However if you mix the EFSL with your source code the LGPL governs the entire package I am not a lawyer You should get proper legal advice if you proceed down this path Still I m convinced the LGPL can be made to work in our competitive embedded world I recently used the Intel application note to create a FAT file system on a project It worked well There were a few areas that were a bit unpolished and my design was perhaps not the greatest Specifically I needed to open each file from a directory one at a time and read the data in that file I stumbled my way through this The code is presently used by the factory for system configuration purposes and my solution was acceptable In all fairness this area of operation was not part of the Intel application note so this is not a criticism of that approach in any way Put in a more general way the functions missing are func tions like listing a directory using standard C functions like fopen fread and fwrite and managing buffers Also you may be looking for commands like mkdir rmdir and 1sdir to make de
49. 485 Wireless options and more Data size Serial Port Complete t 32 bidata 16 bit data Second Edition Jan Axelson ISBN 978 1 931448 06 2 39 95 Lakeview Research LLC _www Lvr com From the author of USB Complete Analysis Unit 2 Instruction Break point Bus Address Monitor Bus Data Monitor Action Bit number Binary representation Don t cares f Data memory reads C Data memon writes Program memon reade Program memory writes Cancel Help Photo 3 With a single chip MCU all the action is hidden inside behind the pins Piccolo includes an on chip bus analyzer that goes far beyond a simple breakpoint so you can see what s going on PIC SERVO MOTION CONTROL doesn t call C functions or modify C Clearly Piccolo will excel in tradi variables tional DSP number crunching applica In short debugging compiler opti tions all the more true by taking mized code is a pain although advantage of the unique control law you re welcome to try If you get accelerator But as well there s every really deep into it CCStudio reason to believe Piccolo can hold its includes a pipeline simulator that own in general purpose applications e controller chips may come in handy see Photo 5 too Indeed TI claims Piccolo delivers e controller boards THREE Ps So how does Picco lo measure up to other 32 bit flash memory MCUs when it comes to the three Ps perform ance power and pric
50. 5 V for the MAX232A and the VDRIVE2 Alternatively regu lated 5 V can be pilfered from any available USB port via J3 J3 is a type B USB connector VDRIVE2 via supplied cable May 2009 Issue 296 WwW N Part Number 895 VDRIVE2 Quantity Description Source 1 Vinculum VDRIVE2 USB flash memory drive interface Mouser Electronics C1 C2 C3 C4 C5 C6 H1 Single row 2 mm header 50 pins 399 4264 ND P825 ND SAM1176 50 ND 0 1 uF 50 V Ceramic capacitor Digi Key 2 2 UF 50 V Miniature electrolytic capacitor Digi Key Digi Key Break off eight pins for board Do not install a connector H2 Single row 0 1 header J1 Nine position female D connector PC mount right A32075 ND angle Digi Key CP 202A ND AE9925 ND J2 DC power connector PC mount 2 1 x 5 5 mm J3 USB B connector PC mount Digi Key Mount connector only if using a wall transformer Digi Key Do not mount connector if only using a wall transformer Ultra miniature slide switch Digi Key 360 2133 Use jumper instead of switch if only one of J2 or J3 is used MAX232A RS232 Driver receiver 16 pin DIP LM78LO5AC Low power 5 V linear regulator TO 92 Mounting screws for J1 4 40 x 3 8 Nut 4 40 D Sub hardware set MAX232ACPE ND MC78LO5ACPFS H781 ND H216 ND 609 1420 ND Digi Key Digi Key Digi Key Box of 100 only two needed Digi Key Box of 100 only two needed Digi Key ExpressP
51. 5 x 10 bit A D inputs 1 x 10 bit analog O P 2 ch 10 bit 2MHz scope spectrum analyzer 3MHz 8 bt wim gen 180 NET Micro box with CANbus Ethemet RS232 A D analog out 1 888 772 3544 www saelig com Small 2 2 x 2 2 pies cost NET Micro Framework dev system 1Hz to 7GHz from 782 1875 7 S aelig Unique electronics CIRCUIT CELLAR back issues available as CD ROM 13 2008 Issues 210 221 CD ROM 12 2007 Issues 198 209 CD ROM 11 2006 Issues 186 197 CD ROM 10 2005 Issues 174 185 Order Online vvvvvv circuitcellar com or call 860 875 2 199 Ethernet to 12C Around the office or around the World The Circuit Cellar college program SE puts quality engineering information MES in the hands of your students every month Sign up now to get car Toy K TT S class this semester BASIC INSTRUMENTATION To update your professor account or to find out more about our college program visit www circuitcellar com products collegeprogram d E Ni NI O oS ep OO OI N oo Down Across 2 An app s server 1 Weber 3 Fluid air resistance 6 Explosion in a star 4 Mini notebook 7 57 2958 degrees 5 Plus for loopback tests 9 10 8 Reduce OSC amplitude 12 Negatively charged ions 10 Positively charged ions 17 The RR 11 In 1882 Ediso
52. 8MB onboard 10 100 Ethernet up to 2 DIO lines up to 55 a SD card option T 2 USB ports a VGA video a COM ports up to 10 a options include a Programmable FPGAs onboard temperature sensor A D Converter 8 channel 12 bit Extended Temperature Battery Backed Real Time Clock USB Flash USB WiFi a Linux Real Time extension Debian An Over 20 years in business 7 Custom configurations and designs w Open Source Vision excellent pricing and turn around time a Never discontinued a product P a Most products stocked and available A Engineers on Tech Support for next day shipping Design your solution with one of our engineers 480 837 5200 Featured Products and PC 104 Peripherals TS TPC 7390 200MHz ARM9 Touch Panel Computer Low Power Industrial Quality Design Mountable aluminum frame 64MB SDRAM 128MB opt 512MB Flash w Debian Linux Programmable FPGA 5K LUT 7 Color TFT LCD Touch Screen 800x480 customizable video core Dedicated framebuffer 8MB RAM Audio codec with speaker Boots Linux 2 6 in about 1 second Unbrickable boots from SD or NAND Runs X Windows GUI applications Runs Eclipse IDE out of the box TS RELAY8 TS ADC16 Eight Software Controlled Relays ADC DAC and Digital I O 8 SPDT relays a Software controlled 16 16 bit ADCs a Up to 277 VAC 5A a 40mA draw per coil Up to 100Ksps 10us a Up to 30 VDC 5A a VO jumpers 1KB ADC RAM FIFO vish SS f p pra mitit i oot 3 Lv e sa oe08680 68
53. A is nearly three times faster than the processor core alone there are ways to deal with the challenge theoreti cally a minor caveat being possibly infinite com elimination eliminates redundant calculations And as pile time An effective compromise is for you the pro you might imagine there are a number of low level grammer to give the compiler some hints For instance instruction scheduling optimizations to keep that long the TI compiler has aliased_variable options that pipeline from stalling while preserving the intent e g enable you to tell the compiler that you re sure a par tic ordering of the programmer ular pointer is safe from aliasing Actually the DSP gurus have been at the front of the Just keep in mind that optimizers especially ones that pack leading the charge to fancier compilers and it move instructions around can make debugging more shows in CCStudio with some truly Poindexter high mind numbingly complicated than it already is Consid level optimizations You re probably familiar with ones er the common technique of viewing your compiled pro like loop unrolling eliminates branches and function gram as C source mixed with assembly language The inlining ditto but how about Alias Disambiguation problem is a piece of the assembly language associated C programmers love pointers and C compiler writers with a particular line of C code may be moved to a dif hate them Here s the alias dilemma Compil
54. CB Digi Key Printed circuit board Wall transformer 9 VDC at 125 mA Serpac series A plastic case black Order using ExpressPCB software and PCB file MI7141 ND SRA21B ND SR2005 DB9B ND Digi Key End panel vvith DB9 cutout for Serpac A 21 Digi Key Table 1 This is a complete listing of parts and parts sources A number of parts J2 C6 U2 SW1 wall transformer can be omitted when using the computer s USB source for power es 9 May 2009 Issue 296 making it easy to bring power through a standard USB peripheral device cable When using the USB port for power J2 U2 and C6 are not needed Switch SWI is shown for those who might want both options on the same board but more commonly a board will be assem bled for only one power option with a wire jumper in place of S1 You might want to mount the VDRIVE2 separately from the level converter board but we chose to package them together in a plastic box Serpac Series A see Photo 3 and Photo 4 A wide rectangular slot is cut into one end plate of the box to accommodate the VDRIVE2 The other end plate is replaced with one precut for the DE 9 Serpac A 21 see Table 1 Standard DE 9 hardware secures the connector to the end plate and provides a threaded fastener for the connecting cable The arrange ment is a tight fit and some of the internal plastic ribs and stand offs must be trimmed with a hobby knife but the final product is appeali
55. CIRCUIT CELLAR www circuitcellar com to the Verilog need only a make flash DJ Delorie dj delorie com who has been designing electronic circuits since command to have the Makefile builda high school earned an ECE degree at Clarkson University After holding jobs new bitstream and send it to the CPLD chip The Makefile rebuilds whatever is needed and runs the host XSVf program to send it to the CPLD designing PC motherboards and network management software he now writes embedded development tools for Red Hat DJ is also the creator of DIGPP and one of the contributors to the gEDA project MORE USES You now know how to use the CPU in the USB GPIO module to offload ESOURCES processing in order to optimize per Bin7 Project Page www delorie com electronics bin2seven formance for a task oriented purpose More than just fiddling bits it enables Xilinx Inc XAPPO58 Source Files ftp ftp xilinx com pub applications xapp you to put intelligence close to your xapp058 zip circuit in order to take advantage of the R8C s speed and peripherals I also Xilinx In System Programming Using an Embedded Microcontroller showed you how the host and pod pro XAPPOS58 2007 www xilinx com support documentation application_notes grams work together to create smart xapp058 pdf peripheral modules like the JTAG controller And last but not least I S described an example of how a smart OURCE pod can be used in a real life circuit
56. Compile is as easy as install Once Turbo C is running type ALT P to drop down the Project menu and select Open Project Navigate to the FSOURCE directory and select MAS TER PRJ You should end up back in the main Turbo C screen Type ALT C for the Compile menu and select Build All That will create MASTER EXE the only file you need Why is MASTER EXE the only compiled file Because all of the other EXE files are just clones of MASTER EXE with different names When the program is started it looks at the first parameter of the command line which is the file name of the program the program s file name determines what action to take You can manually make copies of MASTER EXE renaming each copy to match the commands or you can use the batch file MAKE BAT to generate the entire set Consolidating the object code to CIRCUIT CELLAR www circuitcellar com Listing 1 The file name for each command is hard coded in MAIN C Change the string in the strncmp function and recompile MAIN to rename a command if Istrncmp szCommand else else else else else else else else g_eCmd COMMAND UNKNONN a single program simplifies develop ment in many ways but the down side is that you cannot rename the file operations Thus if you do not like the program name FPUT EXE you might be tempted to rename it to for example TOFLASH EXE However the renamed program will just give you an error message To change the nam
57. EDED to update the volume and frequency information used to generate the Theremin sound This information is used by the final task OutputSound which is RUN_MORE_FREQUENTLY www circuitcellar com st CIRCUIT CELLAR Possible future extensions TAOS TSL230R Light sensors to monitor musician s hand positions Light intensity calibration through push buttons Output using L evaluation boards 4 audio DA A Figure 2 The initial plans are to use the light sensors to control the sound frequency and volume but video manipulation in time vvith the music is possi ble qiven the evaluation board s capabilities to output the audio signal For this initial prototype vve chose approximate values for the time periods RUN OFTEN RUN AS NEEDED and RUN_FREQUENTLY needed in the project based on initial project characteristics However this prototype is just the first stage in a full blown Theremin project Therefore it was useful to have a tool capable of validating our design assumptions when the hardware and software actually interacted The tool had to be able to display a state histo ry to show when each task ran and how the various tasks interacted with each other In particular we wanted the tool to be able to automatically recognize when one task blocked the expected execution of another task To make this tool work we made some changes to TTCOS_UpdateTask which was called by the TTCOS scheduler time
58. ELAY 2 EVERY_20_MS HUNDRED_MS_DELAY 3 EVERY_20_MS Use switches SW3 and SW4 to provide coarse adjustment of background beat tempo Display information on evaluation board s LEDs TTCOS AddTask Down_Shift_SW3Button TTCOS_AddTask UpShift_SW4Button TTCOS_AddTask DisplayLEDShift HUNDRED_MS_DELAY 4 EVERY 20 WSs HUNDRED_MS_DELAY 5 EVERY 20 MS 4 HUNDRED_MS_DELAY 6 EVERY_20_MS DSP tasks to automate the beat tempo in response to the Theremin music being played 11 and linearize the light sensor reading TTICOS AddTask DSPTasks if TFIGOS SEart J i while 1 1 TTCOS_GoToSleep TTCOS_DispatchTasks return Q www circuitcellar com st CIRCUIT CELLAR HUNDRED_MS_DELAY 7 EVERY_10_MS Activate scheduler timer interrupt service routine which calls TICOS_Update to update task s Run Me Now semaphore Wait in low power mode for an interrupt The interrupt service routine calls TICOS_Update Run all the tasks in the system according to whether their delays nave expired Make compiler happy May 2009 Issue 226 CIRCUIT CELLAR DIGITAL PLUS BONUS input value would be updated every 20 us Hovrever it could have been argued that having this higher inter rupt rate meant that we were wast ing battery power as we were often unnecessarily waking the processor from its TTCOS_Sleep low power mode In some ways worrying about power consumption seems superflu
59. Hanover NH 03755 5650 or call 800 269 6301 Postmaster Send address changes to Circuit Cellar Circulation Dept P O Box 5650 Hanover NH 03755 5650 Circuit Cellar makes no warranties and assumes no respons b lity or liability of any kind for errors in these programs or schematics or for the consequences of any such errors Furthermore because of possible variation in the quality and condition of materials and workmanship of read er assembled projects Circuit Ce lar disclaims any responsib lity for the safe and proper function of reader assembled projects based upon or from plans descriptions or information published by Circuit Cellar The information provided by Circuit Cellar is for educational purposes Circuit Ce lar makes no claims or warrants that readers have a right to build things based upon these ideas under patent or other relevant intellectual property law in their jurisdiction or that readers have a right to construct or operate any of the devices described herein under the relevant patent or other intellectual property law of the reader s jurisdiction The reader assumes any risk of infringement iability for constructing or operating such devices Entire contents copyright 2009 by Circuit Cellar Incorporated All rights reserved Circuit Cellar is a registered trademark of Circuit Ce lar Inc Reproduction of this publication in whole or in part without written consent from Circuit Cellar Inc is prohibited
60. IFO eliminates interrupts Wide analog input and output ranges 40 C to 85 C Standard Gal Order 24 7 fast and easy FAN vvvvv shi 04 com Apex Embedded Systems E help stx104 com 608 256 0767 x24 ezL D The Smart Display makes integrating a GUI ez Versatile M Mac D module USB SPI R5232 Interfaces Bright 250 Nit LED Display 800 x 600 Integrated Touch Screen LUA Scripting Language capable For stand alone embedded apps Memory 3 8 MB t SD to 2G ezLCD s are also available in 2 7 3 5 5 6 6 4 10 4 AAAS et AI Call for Custom Display Configurations 1 i di ci he TT Ni ALITTI FIKLIELELULUUT tdi Me et wa a u SS OT ae E LL ALLELE ii A et ES e Directly work with Thermocouples Strain g gauges tee d ADC DAC UARTS 300 100 M BaseT FAT file sys ti am and CompactFlash i I Os solenoid relays CompactFlash LCD Ethernet ers Er C C rogr rammable 80MHz x86 A USB motion control Custom www circuitcellar com CIRCUIT CELLAR it ADCs D a AC RS232 I Os Standalone spc sc non a E IE phyCORE COTS Single Board Computers shorten time to market reduce development costs forgo substantial design shu and risks Windows Embedded CE and Linux Board Support Packages processor dependent a 170unit benchmark price at 1K for ARMI based SEC phyGoORE LPCS250 ARM LMX ARMIT LMXI
61. MAGAZINE FOR COMPUTER APPLICATIONS Dear Design Community Circuit Cellar would like to thank the following companies for their sponsorship of our 2008 Sample Pool product evaluation program A wide cross section of our readership received tens of thousands of dollars worth of hardware and software development tools because of the generosity of these sponsors and their recognition of the value of Circuit Cellar s audience e Crossware Products Inc Keil Vesta Technology Inc FlexiPanel Ltd saelig Co INC Reach Technology Inc Luminary Micro Inc e Custom Computer Services INC SEGGER Microcontroller System LLC Multilabs Schmartboard microEngineering Labs Inc e ADM Designs LLC e Total Phase Inc The 2008 Sample Pool program was initiated through News Notes Circuit Cellar e newsletter TO subscribe to this free newsletter visit www circuitcellar com newsletter Although some of the newsletter material is archived on our site certain programs are only available through the email portion of this monthly publication Please note Circuit Cellar is now preparing for its latest readership survey and is currently signing up sponsors for another Sample Pool program in conjunction with the survey s promotion Watch for additional information about how you can participate In this year s survey through Circuit Cellar s May edition of News Notes and www circuitcellar com I look forward to
62. MOJ IBJJIIJINIJII MMM USB JTAG Module p 24 DOS in the 21st Century p 36 Bridge the Gap Between NTSC and VGA p 52 GIRCUIT CELLAR THE MAGAZINE FOR COMPUTER APPLICATIONS 226 May 2009 MEASUREMENT amp SENSORS MCU Based SLA Battery Measurement Modern DSP Technology Transformerless Power Supply C Code tor a FAT File System 0 74470 75349 0 5 95 U S 6 95 Canada U a SECURE SERIAL TO ETHERNET SOLUTION The complete secure hardware _ and software solution Low cost e Simple Ethernet connectivity for serial devices e Works out of the box no programming is required e Enable data encryption to prevent unauthorized monitoring SSH SSL Secured e Customize to suit any application with development kit Features part Need a custom solution2 10 100 Mbps Ethernet Customize with the NetBurner SB70LC Development Kit for only 99 e SSH SSL TCP UDP modes e DHCP Static IP support Customize any aspect of operation including Web based configuration web pages data filtering or custom network applications Two TTL serial ports Kit includes platform hardware ANSI C C compiler TCP IP stack web server e mail protocols RTOS flash file system Eclipse IDE debugger cables and power supply Kit enables communication with peripherals that use SD MMC Flash Card including SDHC SPI I C or the gener
63. Our level converter circuit board is shown here It has a header for the VDRIVE2 on one end and a board mounted serial port connector DE 9 on the other end your computer as a test environment for learning about the VDRIVE2 and even for embedded code development Photo 2 shows the populated circuit board The schematic is in Figure 1 Table 1 has a complete descrip tion of the parts including the parts for power and pack aging A nine pin D sub connector Jl which is techni cally a DE 9 but often called a DB 9 mounts directly on one end of the PCB for connection to the computer seri al port The other end of the circuit board has a single row 2 mm pitch header HI The header matches the jumper cable that comes with the VDRIVE2 For tight spaces you can cut one connector off of the jumper cable and solder the cut wires directly to the circuit board An alternative header socket H2 is on the side of the circuit board it has the same connections as H1 but with 0 1 spaced pins H2 can be used for soldering the cut VDRIVE2 wires or to gain access to the VDRIVE2 signals for testing Like the two con nector alternatives two alter natives are provided for power ing the board as well The lay out has holes for a circular con nector J2 commonly used for wall power transformers bricks Any DC brick rated for 9 to 15 V at 100 mA will work A low power three ter minal regulator LM78L05 U2 drops this voltage down to
64. Pods Programmable Multifunction Logic Analyzers Oscilloscopes Signal Generators and Protocol Analyzers www usbee com USBee D reared by bugs Inspired by engineers XBW AG o0 jevidia 10V Max IG CTI mA USBee Suite For the USBee SX AX ZX and DX SERGI Tar IFEI I N ES OH Ban ili T Ki hee amim ons 54991167ms 3 USBee Test Pods starting at 139 E TM www USBee com USBee Powerful Debugging Small and Portable M USB based Electrical Engineer is May 2009 Issue 296 the pod to the circuit before you pro gram the pod If you haven t done so already build the JTAG application and program it into the pod This only has to be done once unless you put some other application into the pod see Listing 2 If you haven t built the host side application build that too This builds a small host side program called xsvf that does nothing but send the CPLD bitstream to the pod cd host xsvf make Many of the pod applications will be built this way some software that runs on the pod and some software that runs on the host As this example shows minimizing the amount of data that needs to go over the USB bus can yield amazing performance gains To build the CPLD image you ll need to download and install the Xil inx WebPACK application This includes everything you ll need to pro gram CPLDs I used the GUI to do the initial design and then wrote a Make
65. RAM i e 16 x 32 512 bits Similarly you can create special characters called tiles A tile is used to create a background You can think of a tile as a piece of a puzzle The puzzle picture is a grid of horizon tal and vertical positions on the screen where these pieces may be placed The number of horizontal and vertical positions depends on the screen and tile resolutions For instance if each tile is 8 pixels x 8 pixels and the screen is 2 56 pixels x 200 pix els then you can fit 32 tiles horizontally 256 pixels per scan line eight pixels per tile and 25 tiles vertically 200 lines eight lines per tile The tile bitmap of an 8 pixel x 8 pixel tile would require 16 bits eight pixels x two color bits per row times eight rows or 128 bits four double words For a gamer the screen might be a bird s eye view of a maze The entire picture could be drawn using only two tiles a wall tile and a floor tile Various mazes could be displayed by rearranging the two tiles in different patterns Again this reduces the amount of work associated with computing and storing a screen of information You can use tiles to dynamically change the way a screen is displayed however another object has been developed to operate in a more useful way It is a sprite While a tile and a sprite may have the same dimensions and pattern the lat ter has the ability to be placed anywhere on the screen and not just at the grid locations of tiles One colo
66. S HYDRA Development kit Nurve Networks www xgamestation com Propeller Parallax www parallax com A May 2009 Issue 226 by George Martin JESSONS FROM THE TRENCHES Nasi FAT File System Review pata 2 May 2009 Issue 296 C Code for the File System Now that you re familiar with the FAT file system George approaches the subject from a different angle By presenting you with a general purpose FAT file system he challenges you to remove the features you don t need and customize your application n DIY Signal Generation Neal Martini writes I have been using C to program my past few projects It was a little painful coming up to speed but now I am a real convert Cir cuit Cellar 219 2008 He went on to explain how C helped Isn t it great that everyone is reading my arti cles about the C programming language and con verting Actually I don t believe my work has had much effect just yet If you look at the articles in Circuit Cellar closely you will see a movement toward structured design This can be demonstrat ed in two ways one with the use of structured languages e g C and two in the flowcharts Years ago assembly language was king and convo luted flowcharts that looked like plates of spaghetti were the norm Today designs are much more refined structured So quit hiding your head in the sand Bite the bullet take that the plunge move toward the light and
67. T ARMS LPC3250 ARM L ARMS LPO2294 ARM Ba v vj PXA320 PXA270 PXA255 MPCS554 MPCS5200B MPCS6S MPC555 ColdFire 1 MCF5485 Blackfin ADSP BF537 E Rapid Development Kits start at 399 include SEC Carrier Board software docu as well as kit specific cables adapters and LED E SBC module casily ports from Carrier Board to user target hardware E Carrier Board serecs as target reference design WWW phytec com Be Www phycore com FE nm E N i Ff r wi Bus Monitors Protocol i Ea Analyzers ZTS A e Host Adapters Na ae L s Multiplexers Battery Software Tools Micro Computer Control Cka i iradem urk af E Philips corporation Applications May 2009 Issue 296 N R May 2009 Issue 296 CUSTOM MEMBRANE KEYBOARDS SWITCHES TO 2 WEEKS TURNAROUND e VERY COMPETITIVE PRICING e Ex 5 4 switch keyboards for 395 00 e PCB backed switches e Custom metal backplates assembilies e Electronic assemblies graphic overlays Electronic file transfer capabilities Picofab Inc 47808 Blvd Henri Bourassa Charlesbourg Quebec Canada GIH 347 Tel 418 622 5298 Fox 418 622 9996 Email sales picofab net ARM7 MODULAR TOOLSET Add support for Atmel NXP or STMicro ARM7 variants to Base Package to suit your requirements and budget a C C a Code Wizards a Debugging Q Simulation Advanc
68. The preemptive scheduler state history display plug in of your own evaluation kit s IDDE is cer tainly a good place to start NEW THEREMIN PROTOTYPE When we planned the four tasks for the Theremin Listing 1 we assumed that each of the LightSensor tasks would have the format in Listing 5 to capture the timings for the beginning and end of the pulses output by the TSL230R sensor The first two while loops were used to find the leading edge of the light sensor pulse timel The other while loops were used to find the end of the pulse time2 These edge times could be used to determine the light sensor frequency and allow the ModifyAudioSettings task to update the volume and frequency information of the Theremin As you can see in the state history in Photo 1 and it s obvious in hindsight there was an issue with the infre quent LightSensor wait for signal transition tasks blocking the more frequent audio OutputSound task top track showing EventBlocked orange This form of coding scheduler tasks with wait loops was not particu larly co operative The time that the sensor tasks spent waiting for external events continually blocked the more frequent audio event This meant that the audio stream could be disrupted and the Theremin would sound terrible rather than capable of providing the eerie sounds needed for all of our lucrative movie soundtrack contracts This issue is common in embedded applications that us
69. a hardware point of view more than a software file system point of view I also discussed the support that the C language has for file operations I did not go into much depth about C file I O support That could be another multipart article series If you ve never written such routines I recommend that you download a free as in free beer copy of Turbo C or any other C environment You need to work with these procedures Keep in mind that Borland did a good job of protecting the designer from him self or herself For example if you open a file and then exit the program Turbo C takes care of the details and closes the file so that your disk does not become corrupted But if the power fails on your PC while a file is open look out You need to design for these issues Actually this is a good test to see if your program can recover the file s that were open when the lights went out I recommend CTL ALT DEL as a gentler method to crash the Turbo C program than switching off the power Jeff Bachiochi recently presented a two part arti cle series about connecting an SD card to a PIC CIRCUIT CELLAR www circuitcellar com processor Access SD Memory Cards Parts 1 2 Circuit Cellar 221 222 2009 Most of the articles I ve come across don t give you much information detail or control over the FAT file system This is not a criticism it is just an observation As practical embedded system designers geeks we
70. age sag I then selected an isolated gate TRIAC For smaller loads the TRIAC could operate without a heatsink but for larger loads it would need a heatsink I placed my final design in a plastic box with a metal lid The metal lid made a good heatsink But because of the trans formerless power supply the TRIAC had to be an isolated tab version Otherwise the TRIAC tab and thus the heatsink metal lid would have also been energized With the processor and TRIAC in place I included two digital switch inputs in the circuit one zero cross ing interrupt one analog input with an adjustable potentiometer one dig ital output with a display LED and the basics of a two wire interface Because the entire circuit was at mains potential any wiring leaving the circuit was also at mains poten tial So to help improve the safety of the switch inputs I placed cur rent limiting resistors on both sides of the switch inputs The chosen resis tor values were the highest values pos sible that still allowed the processor to detect the switch closure Putting everything together resulted in the cir cuit shown in Figure 4 Remember Even with these precautions you still need to install the box and cir cuit so that no one can come into direct contact with potentially ener gized components One of this transformerless power supply s advantages was that it had a built in zero crossing signal Howev er with the capacitive version of
71. al purpose digital I O interface The NetBurner Security Suite Option includes SSH v1 v2 and SSL support ga F pe 7 p P dl BD J E E rr PP Ni TT SE E D aa a d E l e F w 72 b 2 s z DT an KA n JE J LN h d eae Per an E ve a ae wee D E in gi i wait J Ch LIME Networking in One Day Dan ei e eh ATI mals i g Sake 4 i q ai a d SUCKS ah mdgejel jejtje a pe E Overseas Manufacturing Bleje dite Bjele e M Delivery Imagineering Inc enjoys the we l i s reputation of being one of the is i Se most experienced amp successful Pi Significa t offshore PCB suppliers a Price Saving I I 1 CAM USA Our Illinois based DFM office has eight fully staffed CAD CAM stations Within hours of receipt of new Gerber files our highly experienced DFM engineers conduct thorough and precise analyses Ll kul i Li See Se ee eee ee ee ee ee es ee ee li U i ie 5 w t Quick Turn Production Imagineering offers small volume production in 5 6 days and medium to large volume production in 2 3 weeks Overseas Manufacturing ee MET IES E ee ee oe E a Q F t TE H Shipping Logistics Capabilities Up to 30 Layers Blind Buried Vias Di Electric Thickness pie impedance Control HDR Tested logistics We do it all for you pe Plated Edge Holes and deliver door to door or For details pleas aure Upto 6oz Copper v
72. all those bit changes Moving the application to the pod s CPU makes the bit twiddling fast especially if I inline the pod specific instructions which saves even the function call overhead By avoiding the overhead the programming time is reduced to 12 s about 40 times faster SAMPLE CPLD CIRCUIT I got the idea for the circuit from a Multi Channel Modules OR 97532 Normal Normal all host uflash uflash xsvf pod elf Normal ID LD ad Normal ID ID d Program Program Usenet posting The original poster was asking for the best way to turn an 8 bit binary number 0 255 into three seven segment digits 000 through 256 Although there were other sug gestions involving ROMs or special TTL chips I suggested an inexpensive CPLD At that point it occurred to me that such a project would be a use ful way to teach myself about CPLDs and Verilog The project was well defined eight binary inputs repre senting a number from 0 to 255 and 2 1 logic outputs to directly drive three seven segment LED displays Other pins would be used for other features if I had space in the chip FOR COMPUTER APPLICATIONS Make sure you re signed up to receive Circuit Cellar s monthly electronic newsletter News Notes will keep you up to date on Circuit Cellar happenings Stay in the loop Register now It s fast It s free www circuitcellar com newsletter SS CIRCUIT CELLAR www circuitcel
73. ame mangled g_History__3VDk allow the VDSPHistory dll plug in to generate timing information for the co operative variable and delete the C version scheduler Information stored in the newTimingStruct can be used to provide detailed run then the plug in will no longer rec time statistics to determine whether the code meets design requirements ognize the history table The new g_History__3VDK label can be seen define DOLIST_ENTRY_EMPTY 0 in the symbol table but somehow enum READY_TO_RUN TASK_BLOCKED TASK_RUNNING TASK_COMPLETED TASK_OVERRUN that is not enough to allow the dll to work typedef struct Additional minor annoyances were unsigned long int eventTime iated with the lack of access to oe E anes a unsigned int eventType the VDK plug in internals This unsigned int taskStatus meant it was not possible to modify r History ruci the picture legend to display such typedef struct words as taskCreated rather than unsigned long minRunTime threadCreated see Photo 1 Nor unsigned long maxRunT ime vras it possible to customize the dis i I i i unsigned long taskSpecification play axis labels to display the actual TimingStruct task names The first issue can be Listing 4 Software instrumentation highlighted can be added to TTCOS_DispatchTasks to record the run time statistics for each task TimingStruct TimingInfoLNUMBERTASKS pragma always_inline inline void RunStatistics int taskID unsig
74. and powers up the outlet Three minutes later if the door is not closed the outlet shuts off o you need a low cost way to directly to mains voltages Now make your mother run a simple 5 V circuit from happy by being safe and responsible Have fun and let s 120 VAC power without bulky and continue expensive transformers or converters If so a transformerless power supply may THE PROBLEM be just what you require This design started from my dissatisfaction with both Before I begin review the circuit in the Smart Home Systems X10 and Insteon light switch Figure 1 Do you see something of con controllers I never could get a reliable signal out to all cern Do you understand why your of the modules Plus I really needed only a simple mother would warn you against building open close sensor and maximum on timer functionality this circuit I thought there should be an easier solution Having If you said no stop right here and done some recent work with an Atmel AVR processor it read no further This is by no means a seemed a simple answer would be to use an AVR proces beginner s circuit It should be considered sor monitoring a switch and controlling a TRIAC an experimental design I make no claim Here s a quick preview of the end of the story just to that this design is safe You are responsi give you an idea of the potential applications I built an ble for knowing and implementing all of AVR switch with my transformerless p
75. ap Fa ai hag T a ne m o o cc ADR M A M O t f ro fessic f a ci sui ite men shar T p 1 i 7 bit ga S p Hardware Capture amam n E a u ER Na A i i a i Mg p Software Ar alysis LepGes Automatic Real time Hardware PATTERN Compression eliminates the neec S to reduce oo Our n vve sot Verte sTABLE makes dead time insignificant oe dge and Patterr Tiader s on all models p anaman Advanced Model also includes Range gt lt J 25 lt anc Stable Matches with as l Duration and 4 flexible cascadable iz sequencers with pass counters Gent n jane Pattern Searches with Match amp Duration Specialized Sequential Searches s j j E for Serial and State Mode Signals Display I C Synchronous SPI R E E a DGES Asynchronous RS 232 State Sass Boolean Bus and Analog Darg FE Single or Dual Waveform Views Resolution Zoom in Wave Viev WS Time based Link Grou inate all views Specialized Exports from Date Tables and List Views Multi Signal Data Tables Drag amp Snap Markers Click to Center function Snap Previous Next function Print or Save Images with comments USB 2 0 480 Mbps USB 1 1 compatible 12 Mbps See our Memory Emulators From 179 00 UitechiTools www tech tools com 972 272 9392 sales tech tools com Picmicro MCU Programmera Very Flexible easy to configure Advanced t
76. application The entire software package com prised several interrupt driven func tions The first routine Main was nothing more than an empty loop The OI nit routine did just that it took care of initializing the proces sor Onl ime was a simple routine to look at the ADC value and select the appropriate maximum on time A minimum ADC value equated to a 5 minute delay while increasing values gave a longer delay up to a max imum of 59 minutes The interrupt service routine INTO vect was the heart of the software It was driven by the zero crossing sig nal from the trans formerless power supply The routine was respon sible for determining the remaining on time and debouncing the two switch inputs It also used the current TRIAC state the input switch states and the remaining maximum on time to determine the next TRIAC state If the routine determined that the TRIAC should be on it started Timer with the necessary delay time to com pensate for the zero crossing detector s phase shift Then the Timerl compare interrupt service routine TIMER1_CMPB_vect turned on the TRIAC and restarted Timerl for the TRIAC latching delay When the Timerl compare routine triggered again the TRIAC was released Remember at this point the TRIAC would stay latched by itself until the next zero crossing This also meant that in the future if I wanted to mod ify the software to support dimming the basi
77. ation of the bat tery meter in production see Figure 2 I will describe more about the cali bration procedure when I cover the firmware in detail The wiper pin of R9 leads into pin 3 of U1 the main brain of the circuit I used one of my favorite Atmel AVRs the ATtiny13 for its small size ease of programming versatile peripheral set and low cost The pri mary features that helped me select this part for the design were an on chip ADC with up to 10 bits of accuracy an internal clock low current requirements and reprogram mable I O lines TELL THE WORLD The AVR is happy to meas ure the incoming voltage and store the answer in a register or RAM location That s not interesting at all I wanted to add a simple but effective dis play using a minimum num ber of parts I also wanted the line of LEDs arranged as a bar graph would give a good report with a sin gle glance the more LEDs lit the more power was left in the battery Somewhere along the line I decided to spice it up and use multicolor LEDs to reinforce the message green was good yellow foretold doom and red would announce failure I sup pose multicolor is a bit of a reach as the LEDs I finally included were technically bipolar LEDs a red Figure 3 This is the geometric version of the LED array and a green LED die mounted inside the same package Current applied in one direction would course through one die and illumina
78. cer tainly monitor data with the conven tional Watch Window But you can also capture data as a graph and Code Composer Studio can even run it through an FFT for you see Photo 4 Pretty cool PI be frank and admit with the complexity of modern toolchains kicking the tires is just that It would take quite a while to get up to speed and actually test drive all of the advanced features The best I can do is tell you I ran through some of the demo projects and ever ything worked as advertised As someone who has always been interested in computer architecture within the thousands of pages of chip tool and application documen tation my attention was captured by the Optimizing Your Code chapter in the C C compiler manual I learned long ago that any discussion of an architecture s merits is moot unless compiler quality is factored in It was fun and interesting to see all the hoops the compiler jumps through to tweak your code I mean www circuitcellarcom gt CIRCUIT CELLAR potential optimizations Many of these are pretty obvious and old school such as dead code removal i e remove code that is not reach able and common sub expression it s almost as though the compiler folks would just as soon get rid of the application programmer and do it all themselves There s a laundry list of dozens of Photo 1 if it walks like an MCU and talks like an MCU The MCU controlSTICK highlights t
79. city blood death and mayhem That same reason made me give up listening to the 11PM one hour TV news programs too much of Tf it bleeds it leads Back in Connecticut I have a similar newspaper disconnect but for different yet related reasons I still fol low the same morning regime with USA Today and a non Hartford local paper But because Hartford is a much smaller city at least the local TV channels get over the blood and guts earlier and still have 15 minutes of a half hour news program worth watching Unfortunately Sunday is a total washout no newspapers But wait There are plenty of Sunday papers in the Northeast so why not The reason is content not the infor mation delivery speed or cost For me the rejection of support for various newspapers and magazines is because of bad content and better competition not because of faster availability of the same information elsewhere I used to get the Hartford paper seven days a week along with the Sunday New York Times At first I just got irritated that the news presentations and political coverage were increasingly one sided but when the opinion pieces and news stories became indistinguishable I had to draw the line I wasn t going to pay for lousy in my opinion con tent I wasn t passing on buying the paper version so I could then go to their web sites and read the same content for free I simply didn t believe in the credibility of their content anymore The Interne
80. com So I started over again this time on a schematic only design I had built a small five LED Cylon scanner and needed a schematic to put up on my web page It just need ed to be lines dots and text I had already laid out a PCB without the benefit of a schematic because it was that trivial This proved a good exercise in learning the user inter face of PCB Artist The next step in PCB fu was to learn to make my own symbols In PCB Artist all components are sym bols with a schematic view a PCB footprint and a link associating the two Once you can build your own symbols effectively the sky s the limit I m still a long way from being an expert but I can rough out a board in 1 hour or so and have pro duction quality work in a few hours more As I mentioned before the software also enables you to order PCBs online I am constantly amazed by this wonderful world of ours The PCBs arrived the same day as the last of the components so I got busy soldering I used through hole parts exclusively on this design and the boards were straightforward to assemble The finished PCB is 1 500 x 1 500 see Photo 2 The components are mounted on one side of the board and the LEDs are mounted on the other side so that the meter can be flush mounted in an enclosure if desired The meters are available for sale on my web site www dalewheat com They are also available on the sites of the other vendors If you
81. controls the length of the bar graph The center button selects alternate color sets for the bar inside the graphs frame Think of the variable associated with the bar s length as data coming through the USB port or other alternative connections such as SPI PC TTL serial or a parallel port controlled by a spare cog While most of the examples in LaMothe s book use a composite NTSC output you can find enough stuff inside about VGA to get started experimenting with some useful out puts You can certainly start writing your own drivers for another microcontroller but Propeller has some good things www circuitcellar com CIRCUIT CELLAR going for it With the internal PLL and an external 5 MHz crys tal the Propeller can clock at up to 80 MHz With eight cogs it s like having eight programs executing in parallel Each cog has its own cog and also has its own VSU that makes out putting streaming video or audio a snap While the resolution might be limited by the RAM available the Propeller makes transitioning from NTSC to VGA a simple matter of software FARE THEE WELL Our broadcasting buddy NTSC brought us closer to our world We ve seen world disasters war and poverty as well as disaster relief the Olympic games and men land ing on the moon Thanks to NTSC we ve experienced pos itive and negative events together as one world Digital broadcasting won t improve the standard of living for those in need but
82. cs were there It would just involve lengthening the phase shift delay as required to control the TRIAC turn on point Input ports PAO and PAI were defined as the inputs for the switches PAO was intended to act as a door open door close switch This means shorting PAO to DC ground moves the TRIAC state to off and floating PAO moves the TRIAC state to on Switch input PAI was intended to act as an On Off push button Each press and release of a push button Neutral Figure 5 This is a simple isolation transformer would toggle the TRIAC state Yes the software was designed so that both PAO and PAI could be used at the same time ADC2 was used to sample the potentiometer to determine the maxi mum on time Output port PA4 was designed to control the indicator LED while output port PA7 was used to drive the TRIAC gate If you decide to try your hand at building this circuit after reading this article there are a few other consider ations to keep in mind Skip in cir cuit programming capability other wise I guarantee that at some point you will accidentally hook up your in circuit programmer while the cir cuit is connected to the mains I m not sure if you and your PC will sur vive that connection Always use your isolation trans former if there is even the slightest possibility that you or your equipment could come into contact with the cir cuit It s still a dangerous circuit Remember to measure Your v
83. cuit_Cellar 2009 1926 I j s R Condit AN954 Transformerless Power Supplies Resistive and Capaci tive Microchip Technology Inc DS00954A 2004 S D Souza TBOO8 Transformerless Power Supply Microchip Technology Inc DS91008C 2008 Microchip Technology Inc TBO94 Dimming AC Incandescent Lamps Using a PIC1OF20 DS91094A 2005 More information on kits and discussion forums on this project Sixerdoo dle Electronics AVR Switch www JenRathbun com Electronics AVR Switch html Underwriters Laboratories Inc www ul com S OURCES ATtiny26L Microcontroller Atmel Corp www atmel com TNY266PN TinySwitch II Power Integrations Inc www powerint com SRO86 Switching regulator Supertex Inc www supertex com sample code at www JenRathbun com SA May 2009 Issue 996 ON N May 2009 Issue 226 ROM THE BENCH by Jeff Bachiochi A World Without NTSC Bridge the Gap Between NTSC and VGA NTSC will soon be a thing of the past 5o what will you do in a world without the NTSC Jeff answers that question and more Read on to learn how he is using a chip to bridge the gap between the NISC and VGA formats he United States Federal Communications Commission FCC has mandated that most broadcasters cease transmitting NTSC in favor of digital television What will happen in a world without NTSC I was raised on NTSC My uncle Ray was the first in my
84. d just in case I finally decid ed to have the required duplication in software where it would weigh less and take up less shelf space The firmware is actually checking the various waypoints down the dis charge curve and also exactly double those voltages This makes the meter autoranging within an admittedly small set of ranges It also makes it hard for the end user to order the wrong meter or to con figure it incorrectly Note that I did n t say impossible Those of you with customers of your own will understand what I mean I added an overvoltage condition test for inputs of over 30 V The 6 Several That s it The final version of the firmware is contained in a single file of approximately 300 lines of C code and takes up 99 4 of the ATtiny13 s 1 KB flash memory The file and its corresponding object file in Intel HEX format are posted on the Circuit Cellar FTP site SHOW amp TELL Once I had a working prototype of my new meter I just had to show it off to some fellow robot builders Last summer I brought the battery meter along with some other blinky toys that I had been working on to an R2 Build Day hosted by Jerry Chevalier of the R2 D2 Builders Club Several of the robot builders expressed interest in the meter and that got me thinking about making a real PCB and offering it for sale I had been playing with Advanced Circuits s PCB Artist software for several months but had not real
85. d product amp High level R5232 interface Easy to program e Low cost In stock Add color graphics to any 8 16 bit embedded system Easy fast and flexible Up and running in hours RZACI 4 www reachtech com 510 770 1417 842 Boggs Avenue Fremont CA 94539 ss M ja PCB Fab amp Assembly Since 1997 Assembly at Low Prices IPCE Design Fab amp Assembly Cable Assembly IBox Integration Functional Testing IProduct Development ISO Certified 301 869 6100 sales captroncorp com Program in Assembler BASIC C and Forth www TechnologicalArts com 1 World Leading Driver Free Win Mac Linux USB Chips AID VO SPI 2C fi vt BASIC programming Ww USB Status amp Control l E USB DAQ USB DAQ FileSys sensing amp logging USB to UART 2C SPI and I O expanders No microcontroller programming required Add USB to your products in a day www hexwax com Mouser Farnell Digikey Amazing PIC programmer Most devices supported ICSP SOTP amp copy limits m at Digikey snes 32 amp Mouser tte va www flexipanel com Actual siz patents pending Make sure you re signed up to receive Circuit Cellar s monthly electronic newsletter News Notes will keep you up to date on Circuit Cellar happenings Stay in the loop Register now It s fast It s free www circuitcellar com newsletter CESPICEMCU C Compiler Version 4 100 Op
86. d steal A May 2009 Issue 296 CIRCUIT CELLAR DIGITAL PLUS BONUS NO_DELAY RUN_MORE_FREQUENTLY list and scheduler timer ji Theremin frequency control Theremin volume control Adjust audio parameters Generate and output audio Activate scheduler timer interrupt service routine which calls TTCOS_Update to update task s Run Me Now variables Wait in low power mode for an interrupt Then run all the tasks in the scheduler s to do list according to whether their delays have expired RunMeNow gt 0 Make compiler happy Only ISR operating in the co operative scheduler Update the Run Me Now variables for each task so much time from the processor core that deadlines could be missed This means that the presence of the instru mentation actually introduces defects into the system s performance With many processors it is possible to minimize this possibility by caus ing the compiler to always_inline the code for the StatusHistory see Listing 2 and RunStatistic see Listing 4 functions In lining improves performance as it reduces many of the redundant operations that occur when subroutines are called e g moving a value from one register to another register by the call ing function only for the value to be moved back to the original register by the called function The Blackfin processor has a large amount of internal instruction mem ory and the inst
87. d to pins Each always block corresponds to some logic gates and other logic modules are brought in by reference module top ibin nen en blank Izblank polarity oseg2 osegl osego 7 0 ibin nen en blank input Izblank input polarity output 6 0 oseg2 output 6 0 osegl output 6 0 osego input input input input vire vire vire vire vire nen en blank Izblank polarity 1 0 bcd2 3 0 beds 3201 Dedo wire wire wire reg 7 0 ibinh blank2 blankl blanko z2 Al reg reg reg reg reg wire 6 0 oseg2t wire 6 0 oseglt wire 6 0 osegot Latch in the input value always ibin nen en begin if en amp nen ibinh lt ibin else ibinh lt ibinh end Convert it to BCD bed bO ibinh bedz bcdl beat Calculate leading zero suppression always bcd2 bcdl begin 1z2 lt bcd2 0 1 Q 1zi lt tbedl 0 122 2 Qi end Calculate blanking always QO 1z2 1z1 lzblank begin blank lt blanki lt blankQ lt end blank Izblank amp 1z2 Izblank amp 1z1 blank blank blank Convert to seven segment format sevenseg012 s2 bcd2 oseg2t sevenseg sl bcd1 oseqlt sevenseg SO bcd0 osegot Apply blanking and polarity and output blanker digit2 oseg2t polarity blank2 oseg2 blanker digitl oseglt polarity blankl osegl blanker digitO osegot polarity blanko ose
88. dded applications ven the smallest embedded project can read and write USB flash memory drives thanks to the Vinculum VDRIVE2 flash memory drive reader module from Future Technology Devices International The VDRIVE2 module with its built in USB socket snaps into the front panel of your project and talks to a micro processor through either a SPI port or a serial port see Photo 1 All of the complexities of talking to a flash memory drive attachment FAT16 support and so on are handled by its FTDI VNCIL flash memory drive host controller chip which provides simple commands for directory listings file transfers and other operations es You can get a VDRIVE2 off the shelf from Mouser Electronics for about 25 Although the VDRIVE2 was intended for microcontroller use our embedded application uses DOS Much of this article will apply to both WHY DOS DOS may be dead in the desktop computing world but it lives on as an important operating system for embed ded applications One of the great advantages of DOS is that small tweaks can turn it into a true real time oper ating system that is perfect for low volume cost sensi tive applications that require too many resources for a microcontroller At the National Institute of Mental Health part of the NIH Andrew uses an open source data acquisition and control program called NIMH Cortex It is a real time DOS application developed for behavioral brain researc
89. development of an interesting multitask audio device a modern Theremin In Time Triggered Systems Part 1 Co Operative Schedulers 101 I Mike Smith described how I rediscovered the idea of controlling multiple embedded processor tasks through the use of a co operative sched uler Circuit Cellar Digital Plus 225 2009 One often stated advantage of these schedulers is that they can be programmed to provide complete predictability of when each task is run This is possible for two main reasons One reason is that only one interrupt is ever active at the same time within the system The other reason is the ease with which the developer can specify when each program task would run This predictability can be put to great use in safety critical systems where reliability and other known performance issues are important In the first article I also showed that this complete pre dictability did not occur automatically even when the system just involved a series of trivial tasks e g a series of flash ing LEDs The problem was associated with time jitter This is the undesirable delay in the execution of one task that occurs when two tasks are simultaneously prepared for running within the co operative operating system It is analogous to the changes in execution times that occur in a preemptive scheduler when the execution of one task is switched out or interrupted by another task When the sys tem just i
90. e Of course per formance depends on the application being performed Photo 4 TI may not call Piccolo a DSP but if you should happen to stumble across a signal Code Composer Studio has got you covered with Graph Property Dialog Graph Tithe Start Address Page Acquisition Buffer Size Indes Increment Display Data Size DSP Data Type Q value Sampling Rate Hz Plot Data From Left shifted Data Display Autoscale DC Value Aves Display Time Display Unit Status Bar Display Magnitude Display Scale Data Plot Style Grid Style Cursor Mode single Time Single Time Dual Time FFT Magnitude Complex FFT FFT Magnitude and Phase FFT Waterfall Constellation Eve Diagram Image 1 Lett ta Right es On 0 On amp On Linear Line ero Line Data Cursor Cancel Help unique signal centric debug features www circuitcellar com st CIRCUIT CELLAR Learn PLDS the fun way with comes with everything you need to take gon from mystery to mastery with Learn to turn software into hardware GAMESTATION coM PLDs and programmable logic May 2009 Issue 996 NI N May 2009 Issue 226 Leci Pipeline Lusplaji shi _ Cycle Sten J ad les PREAD ALARF Total Cycles 0 3735 eee ade e4 3061 e3 adales MOVL ajk n ACL ADDE ACCA ADD ACC 471 PipeLine Stall Register Conflict 25 better Dhrystone performance than a Corte
91. e co operative schedulers For example how do you put out the contents of a long buffer over a serial peripheral inter face SPI without blocking other tasks We found the answer is actually fairly straightforward when we adapted Photo 1 The inclusion of a single global C variable was all that we needed to enable an Analog Devices VDK State History plug in to display the co operative scheduler s timing information We can see that the AudioQutput task top line is continually being blocked by the wait till done loops in the timing LightSensor tasks www circuitcellar com st CIRCUIT CELLAR ideas from Pont s book First we needed to re express re factor the task in terms of the following series of states of the input GPIO input signals enum HIGH1 LOW1 HIGH2 LOW2 We then recoded the LightSensor task to perform either an operation in response to a transition between two states e g input changes from low to high or simply to exit the task see Listing 6 With this new format two advantages became immedi ately apparent One the waiting for a sensor input to change no longer occurred inside a task a situation which could possibly cause slow tasks that timed signals to block the faster occurring audio tasks Two the waiting occurs inside the TTCOS_GoToSleep subroutine with the proces sor in a low power mode This approach offered considerable power savings with a hand held Theremin product Ph
92. e clock will get you to that definition If you haven t used one of these pro grams yet this should impress you If you are used to this richness of informa tion then just read on Code review and SourcePublisher deserve a complete article Perhaps you will write that one Starting with the config h file you can see the various definitions used in the project The first is HW_ENDPOINT_NIOS This sets the code up for compiling all that is needed to run on the NIOS evalua tion board You could add HW_END POINT_CCI for this code to run on the Circuit Cellar evaluation board if there was one That s also another article Next you ll see BYTE_ALIGNMENT commented out This is for the Big endian and Little endian issues Next are cache definitions I m glad to see this early on in the definitions I bet memory allocation is on everyone s list of things to look out for A bit further on e N you ll find DATE_TIME_SUPPORT defined Do you need to keep the file date and time up to date in our system Well here s the flag to do just that I bet you ll have to hook into routines that provide a time structure from your hardware to this code Notice that all these definitions come with well written comments A really nice piece of work As you look through this code why don t you offer to add more comments to clean up any unclear portions It s an open source community project In debug h you ll find definitions f
93. e control systems George is a charter member of the Ciarcia Design Works Team He s currently working on a mobile communications system that announces highway info He is also a nationally ranked revolver shooter p ROJECT FILES To download code go to ftp ftp circuitcellar com pub Circuit_Cellar 2009 1926 nia G Martin FAT File System Part 1 Open Files and Perform Operations Circuit Cellar 224 2009 niques Circuit Cellar 128 2001 Structured Design Part 1 An Introduction to Structured Tech Intel Corp Application Note Intel IXP42X Product Line of Network Proces sors and IXC1100 Control Plane Processor Using CompactFlash 2004 SourceForge Embedded Filesystems Library http efsl be Wikipedia Structured Systems Analysis and Design Method http en wikipedia org wiki Structured_Systems_Analysis_and_Design_ Method S OURCE Source Publisher Scientific Toolworks Inc www scitools com products sourcepublisher CIRCUIT CELLAR e www circuitcellar com ezL D The Smart Display makes integrating a GUI ez Versatile Programming LCD Module USB SPI RS232 TTL Interfaces Bright 350 Nit LED Display 320 x 240 Integrated Touch Screen LUA Scripting Language Capable For stand alone embedded apps Memory 3 8 MB SD to 2G ezLCD s are also Aavailabletin KUFR 5 6 6 4 8 05 JO Sk aN il S Eo s aj e E Call for Custom Di
94. e day Bill is visiting Joe s shack and notices that Joe has a tee adapter on the transmitter s antenna jack and in addition to the cable to the antenna there is a second piece of coax attached to the tee that doesn t seem to go any where It appears to be about a foot long Bill asks Joe about it who laughs and says Oh that helps keep me legal What s going on here David Tweed contributed the four problems and answers in this issue M2M Solutions GSM GPRS modules and modem series OEM Modules Wireless Device Servers R5 232 Stand Alone and Long range options low cost Wireless Mesh Networking Logger From Part 15 to Part 90 Compliant Narrow Band FM UHF Multi Channel ey ST A i OEM Modules and USB ZigBee Sticks Mesh Networks OEM Modules and USB ZigBee Sticks Mesh Networks www lemosint com 866 345 3667 sales lemosint com zx May 2009 Issue 226 EX Q Ra SA TAAA AS May 2009 Issue 296 by Dale Wheat Smart Lead Acid Battery Meter An MCU Based Gauge for SLA Batteries Think sealed lead acid SLA batteries are a thing of the past Think again They are bound to be around for years to come Dale designed a State of charge meter for his SLA batteries His multicolored LED meter simplifies battery charge testing echargeable batteries are found in almost all portable mobile and mission critical electronic equipment New technologies are storing more ener
95. e differences have become blurred to the point that what a chip is called has little to do with its instr uction set complexity Microcontroller i e MCU and microprocessor i e MPU are other schizophrenic labels though still meaningful at the extremes For example an 8051 is clearly an MCU while the x86 under the hood of your PC is clearly an MPU But in the middle are a vast array of parts with aspects of both MCUs e g on chip flash memory and I O and MPUs e g exter nal bus This month let s contemplate another acronym de jour DSP The term itself has semantic ambiguity After all don t MCUs and MPUs process digital signals Historically DSPs were differentiat ed by their multiple busses and high speed math capabilities as typified by the classic MAC multiply and accumulate operation at the heart of signal processing e g filter inner loops But these days virtually every 32 bit MCU or MPU has a measure of those capabilities as well Indeed if anything the trend has seen classic DSPs on the defensive For instance long time Circuit Cellar contributor Pro fessor Michael Smith wrote an article titled To DSP or Not To DSP Will a RISC Chip Do It Better in Circuit Cellar 28 That was way back in 1992 May 2009 Issue 226 Q Or But DSPs aren t dead They ve just been hiding retro marketed with new labels such as Digital Signal Controller Along the way DSP sup
96. e names and time and date support The EFSL has the structure shown in Figure 1 The design ers describe this as a linear object model And you perhaps thought objects were used only in object oriented languages such as C or Visual Basic That is not so You can use objects in regular old C This is a good way to help you tran sition into those object oriented designs and languages Con tinue reading for a description of the EFSL FILE amp FILESYSTEM OBJECTS The File and Filesystem objects in the EFSL design deal with handling file system specific details The module file c contains functions dealing with files such as fopen fread and fwrite The module fs c contains general file system functions supported by the functions of dir c and fat c Note that file c uses these functions heavily The Partition object is responsible for translating partition relative addressing into disc based LBA addressing The func tions in the Partition object are partition specific These include searching FAT type partitions and read write func tions to partitions They are found in the module partition c The Disc object holds the partition table and has a direct link to a cache manager The disc c file contains the func tions regarding the entire disc such as loading the Master www circuitcellar com CIRCUIT CELLAR File system I O Manager Figure 1 This is the EFSL structure Boot Record MBR and performing read write tests
97. e of a command you will also have to change the name in the source code of MAIN C shown in Listing 1 Change the file name in quotes and then update the number of characters to match the new name Do not exceed the 8 3 12 character DOS limit After updating MAIN C repeat the Build All step above and then copy MASTER EXE to the new command file name A BETTER INTERFACE A combined hardware software solution provides an affordable way to read from and write to flash mem ory drives while in DOS In this implementation inexpensive hard ware obviates the need for resident drivers While version 1 of the soft ware can be a little awkward when the flash memory drive has complex directory structures the source code and information presented here pro vide a pathway to better user inter faces It is easy to envision a Norton Commander like interface or some other classic semi graphical charac ter based user interface for selecting and operating on files and directories We hope to hear from readers who take on this part of the challenge Because USB ports have such blazing speeds compared to their serial prede cessors large files are best managed by setting up dual boot operating www circuitcellar com s CIRCUIT CELLAR FDIR EXE if strncmp szCommand FPUT EXE 8 if strncmp szCommand FGET EXE 8 if strncmp szCommand FCD EXE 7 if Istrncmp szCommand FREN EXE 8 if Istrncmp
98. ecently started playing with it I read demon had only moved into the shad ing a Parallax Propeller chip sitting on GPFTPPH but it wasn t until I saw ows I continually collect products and my shelf for a few years along with the FCC s writing on the wall that I technologies that I think have potential Andre LaMothe s Game Programming understood how the Propeller could Pin directions il i I i Pin outputs Ne Fee O O Ul U U k cljjpjjo Povver up detector approximately 10 ms NIINIIN N O1 Od N 0 Reset delay approximately Video generator no N A Brown out detector I O Output register I O Direction register I O Assistant A PLL VO Assistant B PLL U k 512 x 32 RAM U U jj NI 00 Processor vllo Dd ro po po Ol limilce 0 70 70 0 0 U YYY aeseleeeseleeek k oO Clock PLL Sune 1x 2x selector AX 8X 16X MUX Lock bits 8 16x must be 4 28 MH Crystal i ANRE SOFTRES oscillator System counter DC 80 MHz PERENA ee 4 8 MHz OSCENA Configuration Data bus with clock PLL teach Adeti OSCMODE CLKSEL Clock System counter Pin inputs ee N oO 0 P21 P8X32A Q44 AYWWXZZ Configuration 2 W sja Oo OY S co SS OO No N KOD lt lt PERRE miicojlt OHS allo U N O Hub and cog interaction Figure 1 The Propeller block diagram shows the interaction between the hub and
99. ed software tools since 1984 Tools for Embedded Development www crossware com info crossware com Order online at www melabs com USB Programmer for PIC MCUs RoHs P TEA Compliant oe aks Programs 3 LT PIC MCUs including low voltage 3 3 devices 89 95 as shown Includes i ot os Prog im Software for Windows 98 Me SK amp P Includes Programmer Software USS Cable and Programming Adapter for E to 40 pin DIF With Accessores for 779 94 Serial LCDs 2 line x 16 39 95 4 line x 20 49 95 Quantity Discounts Available Q o RIGOL Im rece ELECTRONICS Beyond Measure Rigol Technologies DS1000E series Up to 1GSa s and 1Meg memory SOMHz and LOOMHz models TFT LCD USB Advanced triggering Edge Pulse Video Slope Alt Zeroplus LAP 16032U Logic vY f Analyzer 5 16 channel 100MHz USE 2 0 1 20 _ SPI i2c UART 7 segment 2 free additional protocols Open Source Hardware Arduino Freeduino Seeeduino boards Arduino Shields TF BlinkM e Arduino Duemilanove 30 HWW MNK CELECTAONCS COM Be SESS SOL OM TiTa Loan SHE iG QUALITY PRODUCT FAST DELIVERY COMPETITIVE PRICING 10 pcs 3 Days 1 or 2 Layers 249 Aluminum Backed PCB 7 1 K LN L a Sider 10 pcs 5 Days 4 Layers 695 lup to 30 sq in each includes Tooling Artwork LPI Mask amp Legend LPI Mask J Thre ough Hole w SM Elect AR
100. ee that the audio chip Listing 7 In this working code for a prototype Theremin many problems were solved by adding a task Line 9 to switch control of the co operative scheduler from the internal timer interrupt to the external audio interrupt In this project tasks were added to enable the recording and playback of musical beats to accompany the Theremin music Lines 19 to 26 The DSPTasks code is used to automate the match between the beat tempo of the recorded music and the beat of the music generated by the Theremin This software task must meet strict timing requirements if it is not to block the other more hardware oriented tasks int main void TICOS Init ORIGINAL TICK TIME IS 10us Start the scheduler using internal timer interrupts InitHardware Switch from internal timer interrupts to external audio interrupts to control the scheduler TTCOS_AddTask SwitchToAudiolInterrupt Wait a while to ensure the system i Play Theremin music on one channel TTCOS_AddTask Audiolask NO_DELAY RUN_ONCE s stable and recorded background beats on another HUNDRED_MS_DELAY EVERY_TICK fi Read Light Sensors that control Theremin volume and frequency TTCOS_AddTask ReadLightSensors Use switches SWl and SW2 to control TTCOS AddTask RecordShlButton TTCOS_AddTask PlayBackSW2Button HUNDRED_MS_DELAY 1 EVERY_TICK recording and playback of background beats to accompany music HUNDRED_MS_D
101. en if another cog is trying to use the pin as an input Any cog outputting a high on a pin will force the pin high even if another cog is outputting a low to the same pin The hub s RAM 0000 7FFF will hold your application after it is transferred at boot time The hub s ROM code consists of 256 printable characters and graphics 8000 BFFF Log and Anti log tables that help convert between base 2 and floating point COO0 DFFF a sine table for 0 to 90 with 0 0439 resolution SE000 SEFFF and the bootloader Spin interpreter FOOO FFFF VIDEO HARDWARE Each cog has its own video hardware consisting of two con figuration registers and the ability to stream data using Pro peller output pins via the video streaming unit VSU Note that while the primary use here is video don t overlook the audio possibilities The digital outputs are meant to interface to an external DAC producing composite NTSC video output Because a composite monitor presents a 75 Q load discrete resistors can be used to implement a DAC see Figure 2 The VCFG 32 bit register is used to configure the VSU ina number of modes fi e Composite Baseband Composite Broadband 55 25 MHz channel 2 or VGA see Table 1 The VSCL 32 bit register contains two values the number of CTLA PLL clocks per pixel PixelClocks and the number of clocks per frame FrameClocks see Table 2 A CTRA PLL clock is based on your XTAL value the PLL multipl
102. er commands are exe cutable files EXE FCONFIG sets environmental variables in a conven ient way providing some helpful error checking Here are two exam ple FCONFIG commands fconfig com 2 baud 115200 fconfig address Ox2E8 irq 5 baud 9600 The first example selects COM port 2 at 115 200 bps The port and inter rupt addresses are the standard ones for COM port 2 The second example explicitly sets nonstandard address es FCONFIG does not try to initiate communications with the VDRIVE2 FBAUD does FBAUD initiates a search for the VDRIVE2 device tries to establish a new data rate then DOS Command Purpose reestablishes communications at the new rate Allowed data rates are 2 400 9 600 19 200 38 400 57 600 and 115 200 A power up reset places the VDRIVE2 at 9 600 bps FCD is used to change the default directory on the flash memory drive When first inserted the flash memo ry drive is set to the root directory FCD can return the flash memory drive to its root directory using just a backslash as the command line parameter just like the DOS CD command Other operations are sim ilar to the DOS CD command with two exceptions as noted above FCD does not try to manage complex tree commands and FCD will not report the current default directory path FDIR also does not report the cur rent directory path FDIR with no command line parameters lists the entire contents of the current direc tory without any furthe
103. er writers ferent location The compiler has an interlist option that want the flexibility to move instructions around willy keeps the listing sane by restricting the optimizations nilly And they could if it weren t for those darn data Similarly watch out if you mix inline ASM with your dependencies For example if the program is C code especially if it messes with C variables func tions and so on For example if your ASM code calls a a al a2 C function you may find the compiler didn t know that E function was needed and optimized it away The compil b bl b2 er offers a FUNCTION_EXT_CALLED pragma you can ms use to explicitly mark functions that should be pre Z at b served There s also a CALL ASSUMPTIONS option The first two statements can be moved around and even their order can be reversed The only restriction is the last statement has to remain last because z s value depends on the prior set ting of a and b Easy enough But what if instead of referencing the variable by name the pro grammer referenced it using a dynamically calcu lated pointer to i e address of the variable Photo 2 Programmers will feel right at home with Code Com poser Studio TI s full featured C C IDE for Piccolo May 2009 Issue 296 NI that tells the compiler vyhether your ASM code does or Ke File Edit view Project Debug GEL Option Profile Tools DSP BIOS Window Help icles pg SimpleDACtoADC
104. erformance with built in temperature compensation across a wide range of ambient temperatures Tempera ture compensation enables the sensor to self correct for the temperature in its environment and maintain the highest accuracy in changing conditions This robust sensor resists harsh environments with a rugged IP67 NEMA 6 housing and fully encapsulated electronics and its 30 mm threaded barrel and a selection of mounting brackets allow simple installa tion Additionally models are available with a single analog or user configurable discrete output and all models provide highly visible LED status indicators for power signal strength and output The sensor starts at 249 for U S orders and depends on the configuration needed Banner Engineering Corp www bannerengineering com www circuitcellar com CIRCUIT CELLAR S KEIL An ARM Company Development Solutions for ARM 8051 amp XE166 I rollers C and C Compilers Royalty Free RTX Kernel Vision Device Database amp IDE Vision Debugger Examples and Templates Complete Device Simulation Keil PK51 PK166 and MDK ARM support more than 1 700 microcontrollers www keil com dd RTX Kernel Source Code TCPnet Networking Suite Flash File System USB Device Interface Examples and Templates CAN Interface Keil RL ARM and ART X 166 high
105. ersion Emulation Quick Gustom Designs for all package types BGA OFN MLF QFP SOIC PLEC k Monwooe 1 800 404 0204 ELECTRONICS www ironwoodelectronics com Phone 719 520 5323 Fax 719 520 1867 Box 60039 Colorado Springs CO 80960 BASIC Compilers for PlCmicro Easy lo Use BASIC Commands Windows 9x Me 2K xP Interface Ly PICBASIC Compiler 99 95 BASIC Stamp 1 Compatible Supports most 14 bit Core PICs Built in Senal Comm Commands PICBASIC PRO Compiler 249 95 32 bit signed vanables and math operations supports Microchip PIC10 PICT2 PICTA PICT6 PICT and PIC18 microcontrollers Direct Access to Internal Registers Supports In Line Assembly Language Interrupts in PICBASIC and Assembly Built in USB l2C RS 232 and More Source Level Debugging See our full range of products including books accessones and components at www melabs com CIRCUIT CELLAR www circuitcellar com ADVERTISERS The Index of Advertisers with links to their web sites is located at www circuitcellar com under the current issue Page Page Page Page 77 AAG Electronica LLC 57 Embedded Developer 29 LPKF Laser 8 Electronics 41 Pololu Corp 25 AP Circuits 72 ExpressPCB 71 Lakeview Research 78 Pulsar Inc 42 ARM 27 ezPCB 77 Lawicel AB 19 25 Rabbit A Digi International Brand 75 All Electronics Corp 76 FlexiPanel Ltd 15 77 Lemos International Co Inc 76 Rabbit A Digi International Brand 77 Apex Embedded
106. es an STRONG SILENT INDUSTRIAL PC i i 0 eight character alphanumeric LCD with 128 segment I C LCD Ideal for a variety of embedded applications the AMOS driver and a P89LPC932 8 KB flash microcontroller Also 3000 is a robust custom designed system ee on the 2 TA Included are an LM75B K temperature sensor and two ultra compact and versatile EPIA P700 Pico ITX board Mea ee for user ee An i MN suring only 13 5 cm x 4 5 cm x 13 1 cm the AMOS 3000 PEER ATE S E A E A Nels AS is strong durable and heat efficient yet it is tiny enough microcontroller is user programmable via a 10 pin ICP head to fit in the palm of your hand The system can be installed er The RTC DEMO PCF2123 is available from stock for 69 o E pa U aes board powered by either a 1 GHz C7 processor or an ultra low voltage 500 MHz Eden processor coupled with the VX7O00 unified digital media chipset supporting up to 1 GB of DDR2 50 DIMM system memory The system has a certi fied operating temperature of 20 to 60 C vibration tolerance of up to 5 Grig and a shock tolerance of up to 50 G Storage is provided through a 44 pin IDE interface for Disk on Module Flash drive An optional storage sub system expansion chassis offers sup port for a standard 2 5 SATA drive An on board RJ 45 connector pro vides Gigabit networking while the VT1708A brings HD audio Additional features include four USB 2 0 ports on board GPIO port COM port and progra
107. es have a relatively flat discharge curve Lithium based chemistries are the most Terminal voltage State of charge 12 65 100 12 45 75 12 24 50 12 06 25 11 89 or less Discharged Table 1 This is the state of charge versus voltage for a sealed lead acid battery at rest These values were taken from Battery Universi ty a series of informative on line articles about rechargeable bat teries by Isidor Buchmann and sponsored by Cadex Electronics CIRCUIT CELLAR www circuitcellar com ATtiny13 Bi color LEDs red green Figure 1 This is the smart SLA battery meter originally drew this using Advanced Circuits s free gratis PCB Artist software It enabled me to enter the schematic lay out the PCB then quote and order PCBs all from the same program This is a redrawn version notorious for steady stable voltage output Curse them and their dependable high energy densities We will eventually use a variation of this method to determine lt P00 0 125 0 000 0 125 DIA SA TYP Six places 0 125 oa TYP Two places Figure 2 Here are the mechanical dimensions of the prototype PCBs This will allow you to have a custom panel machined that will fit like a glove The produc tion version of the PCB will have the same dimensions but will have rounded corners www circuitcellarcom gt CIRCUIT CELLAR the state of charge after combining it with so
108. esh ije l asr NI Kr e U LUI PULSAR INC 9901 W Pacific Ave Franklin Park IL 60131 847 233 0012 Fax 847 233 0013 www pulsar inc com Email sales pulsar inc com micro inginecring abs Qac Development Tools for PIC Microcontrollers LAB X Experimenter Boards waa Pre Assembled Boards peer Available for 8 14 18 28 wae and 40 pin PIC MCUs 2 line 20 char LCD Module 9 pin Serial Port Sample Programs Full Schematic Diagram Pricing from 79 95 to 349 95 I Double Sided with Plate Thru Holes Circuitry for Power Supply and Clock Large Prolotype Area Boards Available for Most PIC MCUs a Documentation and Schematic Pricing from 8 95 to 19 95 USB Data Acquisition ADU208 USB Relay I O Interface CETTE LEE 54 be Rr I A iki PT Ly tl el el lid yd k eel bel be Hat ene TOC ee GE RPeeeP Perea FEATURES 8 5 AMP relay outputs 8 ISOLATED digital inputs PortPowered AuxSVOCoutput 189 00 QTY 41 Other Models ADUZ00 4 Channel Version with R232 139 00 ADR218 Solid State Version 8 Channel 225 00 ADU100 3 CH 16 Bit ISOLATED Analog Inputs PGA 4 digital Vo R5232 and 5 4MP Relay Output 199 00 ONTRAK CONTROL SYSTEMS INC PH 705 671 2652 Fax 705 671 6127 www ontrak net Connect to SMT Pads IC SMT Pads Become Connection Interface with SMT Emulation Industry s widest selection for SMT Pattern Interconnect Technology allows Test Prototype Packak Gonv
109. ess of where it started Other combina tions of clocked 1 and 0 bits maneuver the state machine into other states where it can stay as long as the TMS Figure 1 The JTAG adapter module is simple R5 and RO feed half the tar get VCC to P1 0 which is an ADC input on the pod The rest is just blinky lights and connections bit remains low Two of these states are key One lets you shift bits into the instruction register via TDI and shift its previous value out via TDO The other lets you shift bits through the data register In most chips the instruction register selects which data registers out of many are used and allows a wide range of functionality After a register is selected either the instruction register or one of the data registers you can access it through the TDI and TDO pins The state machine first loads the register with data from elsewhere on the chip Then much like a SPI port the old data is clocked out of TDO while new data is clocked into TDI Once this is done the state machine stores the reg ister s data elsewhere in the chip per forming whichever action is indicated Aside from a few well defined com mon functions each chip has its own set of registers and functions that it documents However they all follow the standard JTAG interface for accessing those registers and func tions Chip manufacturers will often provide a configuration file that describes these functions Software
110. family to have a color TV I remember saying to my uncle s dismay I prefer black and white to color look how awful the picture is The grainy fuzzy rainbow colored objects were tough to watch And I ll admit now that this may have been due to early set design and fringe recep tion Back then we were considered fortunate if wy hy II Photo 1 You can start experi menting with the Parallax Pro peller processor for 80 using the Propeller demo board we could receive all three major networks Today s TVs or should I say those of the recent past do a great job at receiving broadcast signals Strong sta tions give crystal clear pictures I don t know the exact numbers but many viewers have now given up their antennas for cable or dish connections Their broadcasts are already digital Their receiver boxes translate the ones and zeros into NTSC out put so we can connect our legacy TVs For those of you still using an antenna for reception the new digital broadcast transmissions can not be received directly by legacy TVs They require a converter box to stupefy the new broadcast format down into an NTSC output that can be used by the outdated equipment I m not going to debate the pros and cons of the new digital broadcast format Instead I want to point out that this means an end to using inexpensive NTSC TVs and monitors as display devices All of this may have started back with Don Lancaster s desig
111. file to automate it There are additional Easy Embedded Linux 169 a Qty 1 Audio In Out 2USB 2 Serial Ports 8 10 100 Ethernet Battery backed Clock Calendar instructions on the FTP site but in a nutshell compile the Verilog into a standard intermediate form compile that file to the specific chip and then convert that file to the format needed for programming In my case I used the XSVF format SVF is a standard vector format but it s a text file XSVF is a binary format that s specifi cally designed to be easily interpreted by a small application That small application is the one I put in my pod Building the XSVF file is simple with makefiles cd cpld make This created a bitstream file bin7 xsvi with binary encoded instructions on how to program the CPLD to do what I wanted it to do After all the parts were built and the pod was pro grammed I could use it to program the CPLD sudo NOSt XSVT XSVT bin7 xsvf What exactly happened here Well the sudo command provided access to the USB hardware needed by the FTDI libraries The xsvf host program used the FTDI libraries to open a channel to the pod and take it out of reset which started the pod s program The host sent a few commands to tell the pod to check the circuit s V and verify that it matched the pod s V p The host then read the XSVF bistream file and sent it across the USB line to the pod which interpreted th
112. g for automated high volume lower cost pick and place assembly www circuitcellar com CIRCUIT CELLAR The SSSO1RT and SS461R sensors are designed for potential use in industrial applications e g speed and RPM sensing tachometer flow rate sensing valve damper position brushless dc motors variable speed drives motor and fan control and robotics con trol medical applications e g motor assemblies and medication dispense control and transportation motion control applications e g RPM sensing tachometer motor and fan control electric window lifts convertible roof positioning and transmission positioning The 59361RT and SS461R sensors feature a 5 V E supply voltage capability for lovv voltaqe applications The sensors are available in two package styles providing application flexibility The SSSO1RT s miniature SOT 25 surface mount package utilizes a tape and reel format The 55461R s flat TO 92 X style is available in bulk 1 000 units per bag N Please contact your Honeywell distributor for X pricing www honeywell com E A ws Honeywell International May 2009 Issue 296 KA May 2009 Issue 226 PROGRAMMABLE SMART CARD The BasicCard 2C3 12 is the first programmable smart card with 2 KB of EEPROM for a price less than 1 30 This micro processor based smart card is programmable in Basic Applications like E Purse Identification Card Medical Card Gift and Loy
113. ge output or read input over the USB interface turns out to be expensive Programming the WIRELESS BRING YOUR PRODUCT QUICKLY AND LEGALLY TO MARKET RF Modules Low Cost TX RX amp TRX Modules gu wee uot afty Long Range Modules OEM Products Handheld TXs GEL FUQIN A closer look at Linx innovation LOW COST LONG RANGE TRANSCEIVER REMOTE CONTROL TRANSCODER IC Up to 8 inputs Bi directional control Transmitter ID output Automatic confirmation A Secure 2 possible addresses Latched and or momentary outputs Direct serial interface Low power consumption PLL synthesized architecture RSSI and power down functions Compact surface mount package No extemal RF components except antenna 159 Ort Lane Merlin S TECHNOLOGIES Add INSTANT wireless analog digital capability to your product ee FCC PRE CERTIFIED amp ready to customize for your application Function Modules Listing 2 This is a sample session of building and downloading a pod application cd pod xsvf make make Nothing to be done for t SU0O sef version VER 1 00 Status Seq Ready Status Seq Ready OOF FOO done Erase Erase XC9500XL which has only a 28 KB bit file takes almost 8 minutes Vary ing the pod s CPU clock or the data rate between the FT232R and the R8C has almost no effect on this time It s all USB packet overhead for
114. go endmodule top CIRCUIT CELLAR e www circuitcellar com PRREERR y a fh HARE Ae he Cer Tr J j conten Photo 2 My CPLD prototype At the top is a 3 3 V power supply On the left are two DIP switches to provide manual input to the CPLD shown center mounted on a DIP adapter At the right is the LED display and above that is the pod with the JTAG adapter module Having programmable pins on the CPLD means wiring up the circuit the easiest way which can be seen here as short neat connections ERRED We add value to PCBs when others just sell it Design M One Sion Mania ti Sonyles fae Flgasonj Cornago nani Bros Proko oi ajo rt Component Prototype TP n note titled Xilinx In System Pro gramming Using an Embedded Micro controller XAPPOS8 I used the core files as is but wrote my own version of ports h and ports c to correspond to my pod s hardware I had to provide two interfaces First I had to provide a source for the CPLD data This data was created by the Xilinx WebPack utility which produces among other things a Xilinx Serial Vector Format XSVF file The file is a set of binary commands describing how to program the CPLD The host application feeds this data across the USB link so the port on the pod has a serial UART driver that reads this data The second interface is the I O for the JTAG signals I simply mapped these to GPIO signals on port 3 Con veniently
115. gy in less space than ever before Sealed lead acid SLA batteries are far from the leading edge of available options they are heavy poison ous and lack energy density compared with newer options Despite these apparent drawbacks they are everywhere Like COBOL they will be with us for some time SLA batteries are especially popular in hobby robotics as well as hobby electronics in general Their ubiquity in surplus chan nels makes them an easy choice for begin ning roboticists Low initial cost and dependable well documented performance endear them to novices and seasoned profes sionals alike It also doesn t hurt to find that many standardized sizes and capacities are still being produced all over the world and will be for the foreseeable future Charging characteristics increase their appeal A constant voltage charger is often a good first project for the curious electronics hacker Off the shelf charging solutions abound and remain competitively priced A FUEL GAUGE How much charge is left in the battery I m glad you asked There are several methods available for determin ing the state of charge SoC or conversely the depth of discharge DoD I think I ve seen those acronyms before somewhere The most direct method is to simply measure the bat tery voltage and say Lo here is the remaining charge Fortunately for battery users and unfortunately for us battery measurers most batteri
116. h It supports low speed analog channels each with a 1 ksps conversion rate lots of digital I O and a few specialized interfaces e g touchscreens and it comes with a companion program for near Photo 1 The Vinculum VDRIVE2 USB flash memory drive reader snaps easily into a front panel It has a built in microprocessor that manages the flash memory file system with simple serial or SPI port commands so just about any embedded controller can access a flash memory drive CIRCUIT CELLAR www circuitcellar com real time display of simple graphics objects on a separate computer You program NIMH Cortex in C Once you get past the learning curve it is a powerful tool for automating experiments One thing we really miss on our DOS system however is a USB flash memory drive reader USB disk support can run under DOS refer to www bootdisk com usb htm for examples but large applications like NIMH Cortex don t tolerate the termi nate and stay resident TSR and other drivers that eat up scarce DOS resources We have circumvented the DOS memory problem by using the VDRIVE2 In this article we will describe our mixed hardware software solution for a DOS flash memory drive reader writer that can be assembled for less than 50 and doesn t use resident memory HARDWARE The VNCIL chip has a built in UART but the chip provides only 5 V logic signals RS 232 serial ports require 5 to 15 V so a level converter is needed for t
117. h 4MB Il SPlandnon standard 4 wireand 3 vvire f RF amp EMF Spectrum Analyzer fy Handheld Palm PC based Alan owne analyzers and generators 699 200MHz sampling memory 299 i serial protocol interfaces up to 50 Mbps 1Hz to 7GHZ for WiFi mikes etc mf 2 7GHz Spectrum Analyzer Saelig CEO 12C Xpress i i CAN Gateway RF Generator U www saelig com 77 0 o pat Q x lt 9 gt z 12C Xpress PS3423 I KLARI MOD emPC x133 APSIN3000 RF Testing 1 EMI Tents USB2 0 speed 16 bit digital pattern fif Versatile USB 2 0 I2C protocol i Kits turn your PC into vehicle PA Janz Full featured standalone f High res extremely low noise f Portable RF test enclosures 8 or arbitrary waveform generator exerciser and analyzer electrics diagnostic tool fanless industrial Linux PC portable 3GHz RF generator shield ng tents with extemal frame Wireless Data Loggers Multiparameter Loggers Electronic DC Load 60 100 120MHz AWG TorqSense Configurable patented USB output Log and display temp hum volt Mini logger with built in temp hum i Standalone USB temp hum volt IM Const current resistance 60 100 120MHz USB 14 bit ARB f non contact SAW dig tal rotary torque event time or pulse counting data pressure 3 axis accel sensors current loop data logger 49 IM conductance voltage amp power modes M with USB RS 232 LAN GPIB transducers with integral electronics USB to 12C FTDI USB ICs CAN USB ial i i PSoC Starter u i
118. he VDRIVE2 A Maxim Integrated Products MAX232A4 is the most common chip for this job It needs only four 0 1 uF capacitors and a decoupling capacitor to provide buffering and bipolar voltage boost We designed a small PCB using the free layout tools from ExpressPCB Two copies of the circuit board layout fit onto a single 2 5 x 3 8 board the size used for the ExpressPCB MiniBoard Service Using our layout file you can electronically order three boards six copies of the circuit for about 60 The layout file is posted on the Circuit Cellar FTP site Alternatively you can delete one copy of our circuit from the layout and lay out another project Then your 60 will get you three converter boards and three of your design Just don t forget to leave space between the lay outs for cutting each board If you plan to use the VDRIVE2 with a SPI port a level converter is not neces sary However a level converter will enable you to use USB B Connector U2 IN OUT GND DC power LM78LO5AC 8 to 15 V C5 2 2u Power source C3 O 1u Header 2mm centers Header 0 1 inch centers Figure 1 The level converter schematic shows two power options wall transformer or USB port power The circuit can be assembled for one or both power options www circuitcellar com CIRCUIT CELLAR daguana a a Photo 2 The VDRIVE2 has 5 V TTL CMOS signals It needs a level converter to interface directly with a serial port
119. he fact Piccolo shown here along with a Future Technology Devices International chip that handles the USB interface is well suited for low cost single chip applications QUALITY PCB amp SERVICE PROTOTYPE TO PRODUCTION instant online quote shopping cart ordering system China competitive prices free electrically test http www pcbcart com sales pcbcart com 86 571 87013819 86 571 87036705 No 76 GuCui Road Hangzhou China WWW PCBCART COM 2 May 2009 Issue 996 Operation C28 60 MHz C28 CLA 60 MHz Now the compiler has to try to establish the possible Feedforward control cycles run time values a pointer can or can t take on in 482 482 0 order to guarantee dependencies aren t compro Feedback control cycles 1 081 0 550 mised Two different pointers may point to the Total control Law cycles 1 563 4821550 same variable the alias and the compiler has to figure out whether that is or isn t possible the Megahertz used 20 kHz loop 32 MHz 10 11 MHz disambiguation Table 1 The control law accelerator CLA in higher end Piccolos can handle I m no expert so it all seems like magic to me I closed loop control by itself freeing the main processor for other tasks In do remember discussing the subject of alias disam this example provided by TI the combination of the C28x processor core biguation with a compiler expert once He told me and the CL
120. he mill MCU Higher end Piccolos will also include what TI calls a control law accelerator CLA I don t have specs No other PCB design tool gives you more value per dollar Boards designed under EAGLE are developed in one man businesses or in large industrial companies Most of the top companies are our customers The crucial reason for selecting EAGLE is not usually the low price but rather the high end functionality along with the ease of use And EAGLE users appreciate the outstanding level of support which at CadSoft is always free of charge and is available without restriction to every customer These are the real cost killers Version 5 is even easier to use especially for beginners due to an enhanced user interface Version 5 Highlights Stand alone schematic editor available Automatic signal contact cross references using frame coordinates Right mouse click for more consistent Windows UI User definable attributes for parts Schematic sheet management Hiding approved DRC and ERC errors PRINT preview and text searchable PDF output Improved search engine for help And much much more Light Standard Max number of 1 99 schematic sheets Max board size Max of signal layers 2 4 4 3 2 inch 6 4x4 inch Layout or Schematic Editor Layout and Schematic Editor 249 498 498 Layout Editor and Schematic Editor and Autorouter 747 Cadsoft Computer Inc yet
121. he mini charger is shown in Photo 4 As I expected there was no large transformer or recti fier involved instead it was a miniature switching power supply Unfortunately even with the small ish inductor the overall size was still too large for the space I had to work with Thus after estimat ing the size of a complete solution the mini switcher was removed from the list If you are still interested in a mini switcher for your own project check out the TinySwitch II family of parts from Power Integrations A TNY266PN is shown on the left in Photo 4 A small 4 to 15 W power supply is possible Another interesting part I ran across during my Internet searches was a Supertex SR086 87 adjustable off line inductorless switching regula tor This is a true inductorless power supply that works by switching a transistor on or off when the rectified AC is below or above the desired output voltage This part can source only 100 mA which was sufficient for my purposes but it had one major problem The circuit called for a rectifier that would cause the DC outputs to float relative to the AC mains Therefore I would not be able to drive a TRIAC directly from the processor outputs May 2009 Issue 226 A OY A gt May 2009 Issue 926 Photo 3 The low parts count enables the transformerless power supply processor and TRIAC to all fit in a 1 75 x 2 5 enclosure Using an optoisolator to drive the TRIAC
122. ier and the CTRA PLL divider When using NTSC the active pixel area of a scan line is 52 6 us If you want to divide this into 256 pixels that s approximately 205 ns pixel 52 6 us 256 pix els If the CTRA PLL clock is running at 40 MHz that s 25 ns 1 40 000 000 The closest you could come to 205 ns would be to use a count of eight CTRL PPL clocks That would be 200 ns PixelClocks 08 If you were using 2 bit four color mode you would be storing 16 pixels worth of 2 bit infor mation in each 32 bit double word This means that the FrameClocks value would need to be 16 pixels x Pixel Clocks in this case 8 FrameClocks 080 With these registers set up the cog has all of the timing information it needs to automatically output a stream of data via selected output pins But what about the data that needs to be moved The data will come from a RAM buffer The Propeller has 32 KB of RAM for system use This includes variable storage program storage and stack space so you have only a fraction for video data Just how much is necessary and how does it all fit together From the VCFG and VSCL regis ters you have defined a single scan line as having 256 pixels Actually 256 colored pixels is beyond the bandwidth of NTSC But let s not worry about that right now Each pixel will require 2 bits of data to determine which color or shade of gray will be displayed at that pixel location This will require 512 bits of data per line
123. igit price tags At the same time we ve all seen the headlines for 1 chips from other 32 bit flash memor y MCU suppliers There s no free lunch and you get what you pay for If you need only a plain vanilla MCU that s probably what you should use But if you can take advantage of even just one of its advanced features notably the num ber crunching capability or the advanced peripherals e g HRPWM CLA Piccolo may hit just the right note in your application l Tom Cantrell has been working on chip board and systems design and market ing for several years You may reach him by e mail at tom cantrell circuitcellar com R EFERENCE 1 Texas Instruments TMS320C28x Optimizing C C Compiler 2 007 http focus ti com lit ug spru 514c spru514c pdf OURCE controlSTICK Evaluation kit and Piccolo microcontroller Texas Instruments Inc www ti com CIRCUIT CELLAR e www circuitcellar com PNICOE PRODUCTS BREE SUPPORT Versatile USB 2 0 12c protocol exerciser and analyzer A ch 2 GSals DSO 5 7 TFT color LCD b w to 200MHz A complete USB serial converter in a DB9 shell 26 2 ch trigger standalone USB bench scope 325 599 Packet Master USB 1 1 2 0 analyzers and generators 699 Analog input bluetooth wireless modules 433 868 915MHz Drop in solution connects PC to I2C SMBUS 32 I O lines 89 USB board adds 55 I O amp
124. ime to market and design risk These engineering k et ee services can range trom technical support to design of target S FL Si P set E TE a arnt S Sy ee de aa Q SEN EJ VS hardware and BSP adaptation to complete turn key solutions Find out more at WWW circuitcellar com network Decode Signal Transmissions p 40 FLLAP TT MNTZATION Software p 30 UIT C EMBEDDED PROGR A Recipe for a Killer Embedde Application er Embedde Time Domain Reflectometry Explained ji More on Programmable Robotics Solar Data Logger Design Ka amp n uit Cellar Digital Plus launch HA Event circ Date March 23 2009 May 31 2009 You hold in your hands a ticket to access Circuit Cellar magazine s new edition Time Tri e Triggereq Systems F Co Operative Schedulers 101 is your chance to e Read Circuit Cellar BONUS ARTICLES not available in print iis l l l l i bee ala Of articles Mi 5 e Enjoy audiofvideo enhanced project articles and present EEE ea E E E 5 E E interestin e Archive Circuit Cellars print magazine as a PDF for your cently an Overseas joined m 3 Sint design library Bring your friends to this limited time public preview of Circuit means more content super fast there Was a shk a UART Bat S BONUS Cellars new venue delivery of your favorite publication and many additional features As a current reader
125. ines and time domain reflectometry TDR in Circuit Cellar issues 224 and 225 Lets explore that topic a little further Problem 1 Suppose we use a step waveform instead of a narrow pulse to excite the trans mission line circuit shown below What sort of waveform would you expect to see at point A A Vo Q 4 ad a a Problem 2 Can you reconcile your answer to the previous question with the waveform created by pulse excitation that Robert Lacoste discussed in Circuit Cellar 2257 What s your EQ The answers are posted at www circuitcellar com eq You may contact the quizmasters at eq circuitcellar com he sh A T ONT PANELS amp ENCLOSURES nI Tai P r iai si NCustomizeditronbpanels Can be easily desig ned With our free software Eront Panel Designer Cost effective prototypes and production runs e Wide range of materials or customization of provided material Automatic price calculation A E e Fabrication in 1 3 or 7 days re ui es Sample price P Mis t 43 78 plus S amp H iu FRONT PANEL www frontpanelexpress com EXPRESS 206 768 0602 www circuitcellar com CIRCUIT CELLAR Problem 3 Suppose you have a circuit that is capable of producing step waveforms with very fast rise times How can you use a transmission line to convert the steps to narrow pulses Problem 4 Joe is a ham radio operator and he likes to operate on the 6 m band 50 to 54 MHz On
126. input requests in a reasonably responsive manner That now leaves us with the audio OutputSound task For the Theremin application imagine the flow of this task something like the following A sound signal is pre sampled and stored in an array that can be accessed as a circular buffer For an initial proto type we stored a single period of a sine wave and had 00 May 2009 Issue 296 CIRCUIT CELLAR DIGITAL PLUS BONUS the Theremin use the sine wave samples to generate a pure musical tone Each time the OutputSound task is acti vated a value from the sound array is sent to the evalua tion board s DAC at a volume determined by the Light SensorVolume task timings Then the pointer into the sound array is adjusted based on the values recorded by the LightSensorFrequency task A large adjust ment to the pointer position could be made if we want to generate a high frequency sound from the stored sine wave A smaller step through the stored sound array will generate lower frequency tones We will get a distorted sound signal if we just set RUN MORE FREQUENTLY 0 5 ms which will generate a low 2 kHz audio sampling rate An eerie distorted sound might just be appropriate for our Theremin However this audio sampling rate would probably be insufficient if we want to generate the Theremin sound accompanied by a sampled music signal beat So we can make a design decision to set RUN_FREQUENTLY to handle a 48 kHz audio
127. isit our vebsit 4 I or call usa piine pacing 1 Mas Conductive Epoxy hillediMias Aluminum Metal Gore Boards and many others ITAR ISO 9001 2008 With Imagineering there is no need to deal with multiple suppliers language barriers customs headaches and shipping Significant Price Saving Our global buying power combined with the capabilities of our overseas manufacturers translate into tremendous savings to our customers Over the past 5 years 70 000 protdtypes have been successfully delivered from overseas to over 5000 customers inc 847 806 0003 www BOBhet com email sales PCBnet com 24 YEARS IN BUSINESS AND STILL GOING STRONG Embedded Single Board Computers High End Performance TS 7800 with Embedded Ruggedness 500 MHz ARM9 Low power 4W 5V 128MB DDR RAM 512MB high speed 17MB sec onboard Flash 12K LUT programmable FPGA verior Q OO MO a Internal PCI Bus PC 104 connector e eee YA 2 host USB 2 0 480 Mbps Gigabit ethernet 2 SD sockets Sty mh 10 serial ports a 110 GPIO ha TS 72xx i era 2 Ae Sleep mode uses 200 microamps Boots Linux in lt 2 seconds Linux 2 6 and Debian by default Low Price Low Power High Reliability 200 MHz ARM9 using Linux development tools Power as low as 1 4 Watt im 15 7200 8 boards over shown with optional A D 2000 configurations ii converter lash SE Fanless no heat sink SDRAM up to 128MB WE Flash up to 12
128. istorylndex 0 35 HistoryStruct HistoryInfoLMAXHISTORY 36 31 pragma always_inline 38 inline void StatusHistory unsigned long eventlime 39 historyIndex Update history index 40 if historyIndex gt MAXHISTORY and perform circular buffer operations 41 historylndex 0 42 43 HistorylInfolhistoryIndex eventTime eventTime 44 45 HistorylInfolhistoryIndex taskID taskID 46 HistoryInfoLhistoryIndex taskStatus taskStatus 47 48 49 void TTCOS_Update void 50 int taskindex 51 52 for taskindex 0 taskIndex lt NUMBERTASKS taskIndex 1 53 if Tasks taskIndex pointerToTask DOLIST_ENTRY_EMPTY 77 Is there a valid task in the todoList 54 55 if Tasks taskIndex taskDelay 0 If taskDelay is non zero then task is not ready to be run 56 Tasks taskIndex taskDelay simply decrement the remaining delay time5 Inline write to history operations to minimize instrumentation impact int taskID int taskStatus Enter event status information Part of scheduler interrupt service routine 57 58 else 60 If the task is READY_TO_RUN 59 Tasks taskIndex RunMeNow then increment the RunMeNow flag 61 if Tasks taskIndex RunMeNow gt 1 Check to see if task has been blocked from running 62 63 64 65 66 if Tasks taskIndex taskPeriod RUN_ONCE Prepare periodic tasks to run again 67 TasksLtaskIndex taskDelay TasksLtaskIndex taskPeriod 1 68
129. it can carry on the tradition of NTSC by help ing us understand more clearly in HD that we are no bet ter than the least of our brothers And so we say goodbye to NTSC It s been good knowing ya If you check your endangered species list you might find that the CRT is hovering around the top Not many bulky lead shielded glass tube TVs or computer monitors are being manufactured This is a case of less is more LCDs have less weight and require fewer watts Although we might see a continuing variety of interfacing connectors for now all conform for the most part to the all encom passing VGA UXGA covers 1080p standard Who would ve thought we d have access to streaming TV pro gramming via a cell phone Cartoonist Chester Gould gave Dick Tracy the first two way wrist radio in 1946 thanks to Al Gross s work on the walkie talkie al Jeff Bachiochi pronounced BAH key AH key has been writing for Circuit Cellar since 1988 His background includes product design and manufacturing You can reach him at jeff bachiochi imaginethatnow com or at www imaginethatnow com ee 1 D Lancaster TV Typewriter Radio Electronics Gernsback Publications New York NY 1973 2 Winnipeg Free Press Born Too Soon 2001 www comsoc org socstr org operation awards assocpress html R ESOURCE A LaMothe Game Programming for the Propeller Pow ered HYDRA www parallax com www xgamestation COM S OURCE
130. lar com After some searching I chose the Xilinx XC9500 family of CPLD chips They were available with a variety of voltage requirements packages and logic cell counts Also they were inexpensive The smallest member of the family was only 1 per chip and available online It turned out that the smallest chip wasn t big enough for this project so I chose the second smallest the XC9572XL It is a 3 3 V part with 72 logic cells that s available in a 44 pin TQFP While the definition of logic cell varies from manufacturer to manufacturer in general each cell includes some form of flip flop and a wide range of combinatorial logic AND and OR gates multiplexers and so on The program you download into the chip decides which gates and other signals are connected to each other Another advantage of this fami ly is that the program is stored in the chip itself so no other supporting logic is required once the chip is pro grammed I chose Verilog to describe the cir cuit I wanted again as a way to learn Verilog Alternatives to Verilog are VHDL and schematics but Verilog was simpler for this project than VHDL and more powerful than schematics The full Verilog sources for this project are posted on the Cir cuit Cellar FTP site There are three source files which correspond to two independent modules and the logic that ties them together Each source file defines one or more logic blocks in the form of modules Like soft
131. lete and list a directory And consider how do you format memory cards Well it looks like the EFSL either provides these functions 9 May 2009 Issue 996 May 2009 Issue 296 directly or gives you the hooks need to implement them rather easily USING EFSL How do you use the EFSL I would create a directory to hold the library make that directory part of your proj ect and then perform a compile and link Remember If you mix the EPFSL code with your code then the entire work becomes covered by the LGPL To figure out what is in the EFSL I put the library through a documentation program I use Source Publisher from Scientific Toolworks A compressed file sp_EFSL zip is posted on the Circuit Cellar FTP site The file unzips into a directory named sp_EFSL The direc tory includes the output from the Source Publisher program The index html file is the starting file I ran Source Publisher on the EFSL library and enabled every feature Perhaps I should be brought up on charges for excessive documentation but I m sure I can talk my way out of that one From the index you can view the Navigation Menu read the Understand Reports for the project another utility offered from STI view the Globals Used Report view the Globals Report view the code and view the metrics All of these reports contain hyperlinked refer ences So if you are not sure of the defi nition of a constant variable or routine on
132. level of timing precision a real issue because just how accurately do you need to measure the period of a sig nal If it is really necessary you can set the accuracy to better than any specified x us by simply adjusting the fre quency at which the co operative scheduler timer causes interrupts TIMING REQUIREMENTS Up to this point we have described the timings of tasks very loosely RUN_AS_NEEDED RUN_OFTEN and N May 2009 Issue 296 CIRCUIT CELLAR DIGITAL PLUS BONUS Listing 5 The most obvious form of the LightSensorTask involves while loops to wait while the input signal changes between four states In a co operative scheduler this waiting would block other tasks that need to execute more frequently void LightSensorTask while GPIOPin HIGH Wait while GPIOPin LOW Wait Now at leading edge of the sensor pulse timel CurrentTime while GPIOPin HIGH P WAV 27 3 while GPIOPin LOW Wait sensorPeriod CurrentTime timel RUN_MORE_FREQUENTLY To get practical definitions of these timing intervals we need to think in detail of what we are trying to do The pianist in our choir often uses eighth notes and when playing flat out plays tunes with 160 beats per minute quarter notes per minute Let s use that number as a starting point and ignore possible carpal tunnel syn drome for our Theremin ist This would suggest that we set arou
133. lg com Color LCD Scope Amazing in 1 Scope 180 CircuitGear CGR 101 is a unique new low cost PC based instrument which provides the features of E standalone USB A 2 ch 1GSa s 25GSa s equiv M 25MHz 2 ch 116 logic scope Seven devices oe USB povvered compaci box bench scope 325 599 MI 50 100 MHz scope 595 795 ill and logic analyzer 699 2 ch 10 bit 20MSa sec 2MHz oscilloscope 2 ch spectrum analyzer 3 MHz 8 bit arbitrary waveform standard function generator with 8 digital I O lines It also 200kHz2 ch 10 itscope 2chspecrumfy functions as a Network 7 10 25MHz USB powered scope in a l m analyzer 16 ch 8MHz logic analyzer Anal yzer a Noise probe Up to 100MS s 193 308 IR 5 ch sig gen 8 ch pattem gen 199 Generator and a PWM 1 2GHz RF Generators ixed Si Output source all for less than 180 What s more its open source software runs with i Windows Linux and Mac e a ee se l ma low fS pe i OS s Only 180 range with 5 10 25MHz 297 EMC Spectrum Analyzer 5022S PDS6062T DS1000E DS1022CD PD 1022MN HDS2062M PS2104 PS2105 PoScope with Probes PS2203 4 5 R1040 TGR2050 EMC Spectrum Analyzer T really like this scope adapter it s really meant for teaching electronic experi ments but its ideal for engi neers too Tesigear ke B12 1 480 500AG LAP 16128U MC RF amp EMC Spectrum Packet Master USB 1 1 2 0 Intuitive full featured 16 c
134. ly of the robot builders expressed interest in the meter and that got me thinking about making a real PCB and offering it for sale LEDs light up in an alternating red wig wag pattern that screams out uh oh uh oh to let you know you ve hooked up the meter to the wrong wires One additional waypoint is coded into the firmware to allow quick and easy calibration of the meter Then exactly 7 50 V is detect ed which is below the normal oper ating range but still high enough to keep the voltage regulator happy a special pattern of two yellow LEDs is lit on the meter To calibrate attach an accurate 7 50 V source I happen to have one and adjust the potentiometer R9 until the LEDs light up with the right pattern 19 gotten the hang of it yet I would tell myself to start out simply and work my way though a complete if trivial example It never failed that I would eventually start trying to get all fancy and do a lot of things at once and would inevitably work myself into some indescribable corner where I would get frustrated and just end up walking away It s ironic because Advanced Circuits s Drew Peterson lives to help people with PCB Artist questions The trick is to be able to describe the problem you re having If you can describe it Drew can help you out If you can t other than It is not doing what I want it to do then you re kinda stuck CIRCUIT CELLAR www circuitcellar
135. ly changes color directly proportional to the actual pressure applied The precise pressure magnitude psi or Kd cm is easily determined by comparing color variation results to a color correlation chart conceptually similar to inter preting Litmus paper Pressurex can also be scanned through one of Sensor Products s optical imaging systems The film which is available in eight different pressure ranges is used in the design manufacture calibration and quality control of many products Pressurex is flexible which enables it to conform to curved spaces It is ideal for invasive intolerant environments and tight spaces that are not acces sible to conventional electronic transducers A 27 0 mm x 5 m roll of Pres surex costs 698 Sensor Products Inc www sensorprod com ULTRASONIC SENSORS FEATURE EXTENDED RANGE AND COMPENSATION The U GAGE T3OUA is an ultrasonic sensor for challenging applications With its extended functional range and advanced temperature compensation the TSOUX sensor withstands hostile environments providing superior ultrasonic sensing to solve even the toughest application challenges The TSOUX sensor features a robust U GAGE housing to resist harsh environmental conditions and provides a variety of model options to meet a broad range of application requirements The T3O0UX ultrasonic sensor is available in a choice of three ranges for reliable sensing from 100 mm to 5 m and delivers high accuracy p
136. ly optimised royalty free middleware suites www keil com rtos www keil com 1 800 348 8051 May 2009 Issue 296 EA s QUICK CONNECT WIRING SYSTEM The new M16 powerfast wiring system is specifically designed for machine power distribution and motor control The quick con nect M16 powerfast system provides a time and cost saving replacement for traditional hard wiring installations and complies with NFPA 79 Electrical Standard for Industrial Machinery These two three and four pin connectors and tees provide up to 18 A in a compact form factor The cordsets are offered with Tray Rated exposed run PVC flexlife cable All connectors deliver IEC IP 67 protection and are rated for 600 V and up to 18 A Tees are available with simple connectors or with branches Like most TURCK cordsets the M16 powerfast line offers male or female options straight connec tors standard and custom lengths and pigtails or extensions To complete the system fully encapsu lated mating receptacles with nickel plated brass housing and 0 5 to 14 NPT 0 575 to 18 NPT M18 and M20 mounting threads are available Prices are dependent on the configuration please contact TURCK directly TURCK Inc www turck usa com Embedded amp Network System on Module Internet Applignce Engine SOoM 9307 SLAN Sc H PowerTul e EP9307 ARM9 200Mhz CPU e 3 Serial Ports 4 2 SPIS e Up to 40 Digital GPIOS f e 3 USB 2 0 Host Por
137. me other knowledge we have that is specific to lead acid batteries Once upon a time before SLA batteries were sealed the specific gravity of the electrolyte could be measured and used as a good indication of the state of charge You dipped an industrial looking turkey baster containing floaties into the different cells and slurped up a sample elec trolyte using the high tech squeeze bulb on the end If you had a steady hand and good lighting you probably didn t spray battery acid on your clothes and skin Unfortunately I often did I don t test those kinds of batteries any more A more detailed method to determine SoC is to measure how much energy has gone into the battery during the charge cycle and then keep track of how much energy is then taken out dur ing usage Counting coulombs requires both current and voltage measurements to be inte grated over time and must take into considera tion temperature and age of the battery In reali ty temperature and age really have to be consid ered in any comprehensive methodology Sever al coulomb counter circuits are available from Maxim Integrated Products Linear Technology Texas Instruments and others Also if you can count individual coulombs per second you know how many amps are flowing in a circuit because that is the textbook definition but you knew that Although there is no linear relationship between voltage and state of charge there are well known wayp
138. ment comprising the usual suspects GPIO pins with an input glitch fil tering feature serial ports UART SPI PC have it your way and three general purpose 32 bit timers Picco lo s signal centric aspirations are served by multichannel high speed up to 4 6 Msps 12 bit ADC with flexible triggering and auto sequencing options These features are all well and good but except for the for midable number crunching capability they re otherwise little different than those found on a typical 32 bit flash mem ory MCU which is after all the point All else being equal for those who aren t already in a committed relationship with Piccolo s C2000 predecessors it would seem there s little compelling reason to switch But maybe all else isn t equal consid ering the advanced I O capabilities embodied in Piccolo s on chip enhanced control peripherals which include enhanced ePWM and high resolution HRPWM PWMs input capture eCAP and quadrature encoder May 2009 Issue 296 Q N Q 0 May 2009 Issue 296 eQEP Naturally the enhanced I O modules are a big plus for traditional DSP apps e g motor control but may find favor in other high frequency timing centric applications For exam ple using a fancy Micro Edge Posi tioning technique the HRPWM offers edge timing resolution on the order of 150 ps Yes that s picosec onds with a p Try that with your run of t
139. mmable watchdog timer Sys tem LED indicators are provided for power and HDD activity The AMOS S000 has a list price of 5380 Future Desians Inc www teamfdi com Internet pioneers with 15 years experience Instant online Quotations amp Ordering From Singlesided to 6 layers ML VIA Technologies Inc Leadtimes from 48 hrs www via com tw Full DRG included on all orders High Quality prototypes at LOW cost s Simply send your layout files and order online www pcb pool com TollFree USA 1877 3908541 Email sales pcb pool com Ej van PIG q Fon OfCad Grapnicede ay sos EJ tvec SY an N p N _ _ EX N CIRCUIT CELLAR www circuitcellar com SENSOR FILM MEASURES LOW CONTACT PRESSURES Pressurex Zero is an easy to use tactile pressure indicating sensor film Pres surex Zero characterizes contact surface pressure down to an extremely low 7 2 psi 0 5 Kd cm It is simply placed between contacting or mating surfaces to instantly and accurately measure and map pressure magnitude and distribution Variations in contact surface pressure are immediately visible by the impression made on the film The range for Pressurex Zero is 7 2 to 28 PSI 0 5 to 1 97 kd cm Pressurex comes in the form of a thin plastic sheet 4 or 8 microns physi cally similar in thickness to paper and is available in eight different pressure ranges When placed between contacting surfaces it instantaneously and per manent
140. n nected by a bidirectional LED to every other corner This makes four LEDs around the periphery of the square as well as two across the diagonals My schematic skills omit the symmetrical beauty of this circuit and hint only at the possibilities We have 12 LEDs six red and six green They look just like regular LEDs when they are not illuminated Some bipo lar LEDs have three legs one for each die and a common terminal I used the two legged variety of the 3 mm persuasion where each leg is attached to both the anode of one LED and the cathode of the other Instead of wiring a current limit ing resistor to each LED I wired them to the I O lines This way there are only four resistors for all 12 LEDs This works out well as there is only one LED on at a time even when it looks like they are all illuminated Because the current through any LED must flow through two resistors the value of each resis tor is half of what is required to limit the current through the LED I calculated a maximum of 20 mA through each LED I could probably have upped that number as the duty cycle is at most 1 6 To illuminate any single LED the I O pin that is connected to its anode is programmed to be an out put and to drive that output high The corresponding cathode pin is also programmed to be an output and to drive its output low The other two I O lines are told to sit down and shut up A more technical and accurate way to describe it
141. n s network provided 110 V to customers in 18 cdm this borough 19 Si 13 Examine an older system replace problem parts 20m G 0221415 10 alo 15 Unidirectional communication 16 Diode 1904 The answers are available at www circuitcellar com crossword May 2009 Issue 296 Bs T DLE THE DIRECTORY OF P Y PRODUCTS AND SERVICES AD FORMAT Advertisers must furnish digital submission sheet and digital files that meet the specifications on the digital submission sheet ALL TEXT AND OTHER ELEMENTS MUST FIT WITHIN A 2 x 3 FORMAT Call for current rate and deadline information E mail adcopy circuitcellar com with your file and digital submission or send it to IDEA BOX Circuit Cellar 4 Park Street Vernon CT 06066 For more information call Shannon Barraclough at 860 875 2199 The Vendor Directory at www circuitcellar com vendor is your quide to a variety of engineering products and services USB Add USB to your next project it s easier than you might think e USB FIFO up to 8 mbps e USB UART up to 3 mbps e USB Microcontroller boards pre programmed with firmware e 2 4GHz ZigBee amp 802 15 4 e RFID Reader Writer Absolutely NO driver software development required www dipdesign com DLP Desiqn Full Speed t writes your USB Code PN NEW HiDmaker FS for Full Speed FLASH PIC18F4550 Creates complete PC and Peripheral Both PC and Peripheral programs programs that talk to each
142. n of the TV typewriter that appeared on the cover of Radio Electronics mag azine in September 1973 NTSC is a composite video standard used by the first personal computers TRS 80 and Apple and video game systems Coleco and Atari As higher resolutions were required the composite video sig nal was separated into multiple components allow ing finer control of the video format While S VGA uses discreet signals each color is still basically analog One of the newer standards the Digital CIRCUIT CELLAR www circuitcellar com Video Interface DVI combines DVI D Photo 2 The HYDRA game console A MGA Solo oes NIGGA Ge digital mode and DVI A VGA in analog is based on the Propeller chip The REA Mudo Connector mode Of the advertised interfaces on experimental console comes com w Te Fal Duplex 1 Su today s TVs such as HDMI compo plete with a P52 mouse a P52 key nent VGA S Video RE and compos board a game controller a power ite which option do you think will be A ha U shi the book Game Programming for the first to go on future models the Propeller Powered HYDRA and a CD for 200 PROPELLING I spent most of my early hard earned pocket money playing Space Invaders and Asteroids at the local hangout I thought I had since shed my addiction for future spotlight time in one of my for the Propeller Powered HYDRA I for gaming Little did I realize the monthly raves For instance after hav r
143. nARM com 7 The Architecture for the Digital World N May 2009 Issue 226 A ARM Ltd AD158 01 09 D A combined hardware software solution provides an affordable way to read from and write to flash memory drives while in DOS file path construction while access to files on the flash memory drive are limited to the current default directory of the flash memory drive Once again there is an opportunity for you to program a more general purpose interface that supports more complete file path constructions for the flash memory drive and renam ing files as they are copied FREN lets you manually change a file name on the flash memory drive and FDEL can delete a file FPUT FGET and FREN will overwrite only a des tination file if a y option is added as the first command parameter Note that the option h will list instruc tions for any of the commands The most challenging part of the source code development was manag ing the FIFO of the UART during serial port transfers The limited computa tional power of the VDRIVE2 and the wide variation in personal computer hardware require careful coding of the serial port handshaking The FIFO of the computer UART must be enabled and disabled at critical moments to maximize throughput without over running the VDRIVE2 buffer at high data rates The VDRIVE2 provides an acknowledge handshake so errors are always trapped Even with the careful handshake a
144. nd forth VGA Up to this point I ve been discussing the power of the Propeller to work with NTSC video output VGA video is actually less demanding than NTSC because the sync signal is digital in nature and separated from the color informa tion The color information is broken down into the three primary colors and each has its own signal The pixel clock is internally generated by the VGA monitor and will sup port 640 x 480 pixels The VGA output consists of separated horizontal and vertical syncs plus separate R G and B ana log outputs Resister DACs can be used for each color simi lar to the DAC used for NTSC Whereas the NTSC output requires 3 to 4 bits the VGA output requires 8 bits As for the VSU it doesn t care which monitor is connected on the outside as long as the timing configured into the video con figuration registers is correct for the monitor type Photo 3 is an old VGA monitor DB15 connection I had connected to a Linux system here in the shop It shows what can be done with just the Propeller demo board or Hydra game console If you do the math on 640 x 480 you ll find that there isn t anywhere near enough RAM for this resolution even at only 1 bit pixel However by using 32 x 16 tiling the RAM requirements are minimal I used the embedded character set to design a three but ton screen with a linear bar graph A mouse input enables button pushing which in turn increases or decreases a vari able that
145. nd six note selections per second as our target for the LightSensor tasks However that does not mean that we select 0 13 s 6 Hz for the RUN_OFTEN interval The LightSensor task must sense four signal transitions for each note selection These timings directly impact on the note sound and we don t want any sour off key notes This indicates a probably required accuracy of around 1 That means that RUN_OFTEN should be around 1 3 ms as a maximum While worrying about what value to use for RUN_OFTEN we uncovered a missed design issue The actual value depends on the settings of the light sen sor s frequency selection pins see Figure 1 We need the light sensor to put out a signal whose frequency we can accurately measure with the LightSensor task Our Theremin ist will probably start a career in a dark sleazy night club before becoming world famous and appearing on the well lit stage at Carnegie Hall in New York Due to the varying light conditions we need to add a new task Adjust LightSensitivity to use the processor s GPIO output pins to control the S1 and SO sensitivity select pins on the TAOS TSL230R light sensor see Figure 1 This task can be set to RUN OCCASIONALLY We can imagine this task responding to pushes on two but tons INCREASE_SENSITIVITY and LOWER_SENSI TIVITY connected to a processor s GPIO input pins That suggests that RUN_OCCASIONALLY could be set to around 0 1 s 10 Hz to respond to the user s
146. nd their days and nights dream ing up innovative embedded apps they don t scream old school ideas either Yes we re up to something here Basically we ve assembled a group of articles about new ways of developing and tweaking proven older technologies to meet modern design goals For instance on page 16 Dale Wheat describes an MCU based meter he built for SLA battery charge testing DJ Delorie finishes his USB GPIO pod series with information about downloading a JTAG programming application to program a CPLD circuit p 24 In DOS in the 21 Century Andrew Mitz and Jon Daley explain how they use DOS as an operating system for embedded applications p 36 Turn to Tom Struzik s article on page 44 to learn how he saved money by using a transformerless power supply rather than expensive transformers or converters in a recent light switch design project On page 52 Jeff Bachiochi describes how he uses a Propeller to live in a world without NTSC After say ing farewell to NTSC check out George Martin s article about C code for the FAT file system p 60 Tom Cantrell ends the issue with an article about new ways for tackling DSP apps p 65 The part he presents isn t your father s DSP Just so I don t feel left out let me describe a new twist on an old technology It is called Circuit Cellar Digital Plus which is the newest version of Circuit Gellar s ever evolving elec tronic edition I encourage
147. ned long taskDuration Record minimum and maximum run times if taskDuration lt TimingInfoLtaskID minRunTime TimingInfoLtaskID minRunTime taskDuration if taskDuration gt TimingInfoLtaskID maxRunTime TimingInfoLtaskID maxRunTime taskDuration Indicate that outside of project specifications if taskDuration gt TimingInfoLtaskID taskSpecification StatusHistory Currentlime taskID TASK OVERRUN void TICOS_DispatchTasks void 1 Dispatches runs the next task if one is ready int taskIndex unsigned long int taskStart for taskindex 0 taskIndex lt NUMBERTASKS taskIndex 1 if TasksLtaskIndex RunMeNow gt 0 77 Check for a task ready to run Add status information about running the task and collect run time information TasksLtaskIndex pointerToTask Run the task and record duration Tasksitaskindex RunMeNon Indicate that the task has run Remove RUN_ONCE tasks from todoList if TasksLtaskIndex taskPeriod RUN_ONCE TICOS Deletelask taskindex May 2009 Issue 296 CIRCUIT CELLAR DIGITAL PLUS BONUS CIRCUIT CELLAR www circuitcellar com solved by ignoring the problem and a Notepad text window can be superimposed on the state history pic ture to solve the labeling issue in the near term see Photo 1 If you want to build a scheduling GUI for a co opera tive scheduler we would recommend the route of cre ative adaptation
148. ng The end plates and remaining stand offs provide plenty of support for the circuit board and VDRIVE2 No additional mounting screws are needed Cuts in the box s sloping sidewalls provide access to the power connectors Look at the VDRIVE2 datasheet before completing your assembly The three pin jumper on the back of the device UART SPI should be set for pull up Once assembled connect one of the power sources and con nect your computer s serial port You can use a modem program in either DOS or Windows e g HyperTerminal running at 9 600 bps to chat with the VDRIVE2 You can even plug in a flash memory drive and get a directory listing with simple text commands Refer to the Firmware manual for examples SOFTWARE CONSIDERATIONS Our reason for using special hardware was to preserve DOS memory by avoiding resident drivers Thus from the outset the plan was to produce a set of DOS com mands for each aspect of talking to the flash memory drive read write directory listing and more These primitive commands could be used on their own or serve as the backbone for an alternative user interface perhaps a Norton Commander style interface Photo 3 This shows how we packaged the VDRIVE2 together with the level converter circuit board The fit is tight so the VDRIVE2 cable is wired directly into the H2 pads rather than through a connector CIRCUIT CELLAR www circuitcellar com PRODUCTC BLUPPORT 6 Vww eae
149. nvolves two minimalistic tasks the possible pres ence of time jitter in a co operative scheduler can be deter mined using simple back of the envelope calculations as I explained However if you are developing a more compli cated project that involves a design with many interacting tasks and if real timing and safety concerns are present a more sophisticated automated tool would be better than a scrap of paper In this article Lizie and I will cover the topic of adding a graphical user interface GUI to the co operative scheduler to obtain detailed timing information on how tasks inter act with each other during the development of a multitask audio project We will explain how to use this tool to check the solution for a project where long tasks have the potential of blocking short tasks when running within a co operative scheduler THE THEREMIN The Theremin or aetherphone is a musical instrument with a number of unique firsts in its background It is the earliest electronic musical instrument 1913 and the first musical instrument that could be played without being Figure la tThis is the TAOS TSL250R light to frequency converter www circuitcellar com library print 1204 Bachiochi173 3 htm b This chip has two pins 50 51 to control its light sensitivity over a range of 1 to 100 and two pins 52 53 to control its frequency sensitivity over a range of 1 Hz to 1 MHz http pdfl alldatasheet com datasheet
150. o ViewPort communication rate 115 kbps e Simple vision processing Additional Features for ViewPort Ultimate 32386 149 00 e High speed Propeller to ViewPort communication rate of 2 Mbps e Advanced OpenCV powered computer vision add state of the art vision to your project e Designer development kit for customizable instrumentation layout the rich interface using drag and drop ViewPort can be integrated into any Propeller Spin program It requires one dedicated Propeller cog and a single line of code at the start of your program It s easy to get started with plenty of tutorials videos and documentation in the software Also a Propeller Education Kit Lab featuring ViewPort is available for free download from the Propeller forum at www forums parallax com LOL 1 Order the ViewPort Software Standard NS or Ultimate at www parallax com or call our Sales Department toll free at 888 512 1024 Mon PA Fri 7 a m 5 p m PDT www parallax com Propeller Spin Parallax and the Parallax logo are trademarks of Parallax Inc Prices are subject to change without notice A z S GIRGUIT CELLAR THE MAGAZINE FOR COMPUTER APPLICATIONS RLCLE by Mike Smith amp Lizie Dunling Smith Time Triaqered Systems Part 2 A Tool for Automating Analysis Now that you re familiar with the topic of co operative scheduling it s time to move on to the topic of adding a GUI to a co operative scheduler The end goal is the
151. oints down the discharge curve for lead acid batteries These voltage levels are only truly representative of the state of charge after the battery has been allowed to rest for at least 8 hours They are summarized in Table 1 MEASUREMENT CIRCUITRY Figure 1 shows a simple data acquisition circuit that can be used to approximate the state of charge of an SLA battery The input signal powers the entire circuit The battery voltage is brought in via Jl From there it is split into two paths The first goes to an LM317L adjustable positive voltage regulator that is set to approximately 5 V using R5 and R6 I chose this for its wide input range excellent output stability small size abun dant availability and low cost The regulator s output is filtered by Cl Overall this is a mun dane power supply circuit Its only special feature is that it will withstand a high input voltage and automatically shut itself down if it overheats The other path for the incoming power signal is to a voltage divider composed of R7 R8 and RO RO is a potentiometer allowing the calibra tion of the incoming signal to a known value May 2009 Issue 296 my N Photo 1 This is the first prototype of the battery meter built on a solderless breadboard The extra resistors represent doing it the hard way when you don t have an exact value in stock when inspiration strikes This is handled in software to allow quick and reliable calibr
152. olt meter and oscilloscope are your friends Before you make a connec tion measure the potential between the connection points Is it really 5 VDC or did the 120 VAC sneak in It s much better to measure often rather than smoke parts Construct your circuit so that no external component can be touched For example use in wall magnetic reed relay switches such as those found in alarm systems for external switches Remember that despite the fact that the processor is running at 5 VDC it is actually at a 120 VAC potential For any external push buttons make absolutely sure that there are no exposed grounded or other metal surfaces Those metal surfaces will TR2 ISO Hot I I I I t I ISO Neutral CIRCUIT CELLAR e www circuitcellar com What s the difference Electronic components work no matter what price you pay Jameco carries everything you expect at prices below what others charge But the price savings don t stop there Jameco offers additional savings with its array of house brand and factory overrun products The Jameco difference begins with the industry s highest quality catalog and is backed by the industry s longest warranty plus much more Over 100 000 skus AM ECO e 99 of catalog products ELECTRONICS ei gi EA 4 are in stock right now Low price guarantee 1 800 831 4242 Ns al sag lt lt Order your FREE catalog today at www Jameco com Price CIRCUIT CELLAR THE
153. omplicated than the three to five stage unit you ll find on a typical 32 bit MCU It s arguably a bit of architectural F2803x 128 KB Flash memory 60 MHz with CLA 128 KB Flash memory 60 MHz with CLA 64 KB Flash memory 60 MHz with CLA 64 KB Flash memory 60 MHz with CLA e 40 60 MHz C28x CPU e Starting from 38 pins overkill because the slowest Piccolo runs at blue collar 40 MHz but makes more sense when you realize Piccolo should and does maintain a measure of compatibility i e assembly source with higher end C2000 parts that run at hundreds of megahertz Longer pipelines can be more haz ardous for example when one instruction tries to read an operand not yet written by the preceding one and Piccolo is no exception Howev er the TI design features a measure of hardware interlocking that will keep you out of trouble Ideally you or more likely the C compiler will schedule instructions to avoid haz ards but if not the pipeline will automatically stall Notably this does not incur the code bloat of F280xx e Increased on chip memory e More functional I Os e Enhanced safety features e Control law accelerator e CAN LIN AECQ100 100 pin Figure 1 The TM5320F280xx Piccolo family is the latest addition to TI S venerable line of C2000 DSPs er make that MCUs S May 2009 Issue 226 CIRCUIT CELLAR www circuitcellar com delay slots i e NOP insertions that purely
154. onnectivity THE DARKER SIDE High Speed Signal Transmission Preemphasis Equalization amp More ABOVE THE GROUND PLANE Solar Data Logger Part 2 Data Points Call Shannon Barraclough now to reserve your space 860 875 2199 SILICON UPDATE Easy E mbed An Alternative Approach to Embedded Programming e mail shannon circuitcellar com FROM THE BENCH Location Notification A Look at Anisotropic Magnetoresistance Sensors MT May 2009 Issue 226 www circuitcellar com st CIRCUIT CELLAR RIORITY INTERRUPT by Steve Ciarcia Founder and Editorial Director It s All About the Content Stupid A lot has been written about the demise of newspapers and commercial publishing companies The popular opinion is that newspapers in particular are going down the drain because the same information is available faster and cheaper via the Internet I suppose there is some merit to that conclusion but it sure doesn t jibe with my explanation for not reading as many newspapers these days Let me explain OK I m one of those anachronistic people who still do read real newspapers When I m away at the cottage I read USA Today and a local paper every morning On Sundays I get the local paper and the Sunday edition from the nearby metropolis I used to get a second large city paper on Sundays along with the big city daily newspaper but I cancelled them after getting very tired that 90 of the editorial was always about big
155. ons also includes Power Mate Mini Mate and Q Series High Speed Power connectors and cables and a variety of Rugged Power woe 2 Headers and Sockets isolator which A nin i iti can be used to JTAG Isolator It costs about 0 25 per 25 A pin in quantities offer E eur target hardware and the J Link This Samtec Inc is essential when the development tools are not connected to the same www samtec com ground as the application Itis also useful to protect the development tools from electrical spikes that often occur in some applications such as motor control applications Special Offer Includes the J Link 3 Link GDB Server and the J Link Flash Download www segger us com ncu html J Link Non Commercial NCU Bundle NN www segger com May 2009 Issue 296 www circuitcellar com CIRCUIT CELLAR May 2009 Issue 296 aig i a mp 7 al O T REMOVE BATTERY k WHEN iu OSH my Gt MM is aloe ut HHR PELET vi a E a a I sa l LI i 1 Ka WOE CT RA A PEF AENEAN 5 nes SLL ray E Z SEGMENT PaSLPCOI2 ud ot s O a aje a JEA LETSE LL PCF21253 DEMO BOARD The RTC DEMO PCF2123 is a stand alone demonstration platform for the new NAP SPI based PCF21235 With a typical standby current of only 100 nA at 2 0 V the PCF2125 is the lowest power real time clock Currently available The unit is powered by a single 3 V coin cell battery and includ
156. or adding debug functions to the code Again you can tailor this to your sys tem requirements In the other h files you ll find definitions that will look familiar if you ve been reading my articles on C or you re already using C language It s sort of like an old pair of shoes It s comfortable and gives you the confidence to incorporate this work into your project I don t mean to bore you with all these details because you just want a prepackaged answer to your FAT file system issue But you ll probably find that you need to tailor some portion of any design to fit your needs And isn t it great to have such a complete solution LOOKING AHEAD As I mentioned earlier I plan to use this library in a project I m working on At that time Ill report on just how fast some of these routines operate and the size of the generated code If there are any areas of the C lan guage short of homework assignments you would like me to cover in more detail just send me e mail and Ill try to address your comments in an upcoming article Remember Circuit Cellar writers like me are doing this for you lil George Martin gmm50 att net began his career in the aerospace industry in 1969 After five years at a real job he set out on his own and co founded a design and manufacturing firm www embedded designer com His designs typi cally include servo motion control graphical input and output data acquisition and remot
157. or the different programs using the VDRIVE2 but things get messy when trying to change the data rate of the VDRIVE2 If the VDRIVE2 has been set to one baud rate e g 9600 and then you change the environmental variable to a new baud rate the old baud rate informa tion is lost Multiple environmental variable sets could be employed one for program tracking and one for user requests but this approach was eschewed out of personal preference Rather we chose an algorithm that hunts for the proper data rate if communication with the VDRIVE2 is lost The algorithm is useful for other occasions such as when the Photo 4 This is the complete assembly with the VDRIVE2 on one end and the level converter power connectors accessible from the side The serial port connection not visible is opposite the VDRIVE2 VDRIVE2 is first powered up Perhaps the most vexing problem associated with implementing read write programs for the VDRIVE2 is dealing with the directory structure of the flash memory drive The VDRIVE2 does not keep track of the current default directory Without a resident program it is difficult albeit not impossible to keep track of the current directory Our pro grams require you to take responsi bility for knowing the current default directory after one or more change directory commands To complicate matters the DRIVE2 supports only 8 3 eight character alphanumeric name followed by up to three character
158. ose instructions so as to use the JTAG lines to program the CPLD Note that the pod and host used hardware flow control to control the datastream and the pod had a 256 byte buffer to hold incoming data Once the programming was done the host program read any diagnostic text from the pod and printed it and the pod released the CPLD The CPLD of course started running the logic design programmed into it Once programmed I could disconnect the pod from the circuit Done The first time you do all this there s a lot of set up However edits introducing X 300 16MB FLASH 32MB RAM 200Mhz Arm9 CPU 16 Digital I O Watchdog We brought you the world s easiest to use DOS controllers and now we ve done it again with Linux The OmniFlash controller comes preloaded with Linux and our development kit includes all the tools you need to get your project up and running fast Out of the box kernel support for USB mass storage and 802 11b wireless along with a fully integrated Clock Calendar puts the OmniFlash ahead of the competition Outside Curent Tampaershara Jd f Call 530 297 6073 Email sales jkmicro com On the web at WWW jkm icro com Filly Gates Charge in HI dispa Tima Thus T Mar 3059 TE Boe 435 750 5999 WEB ENABLED THERMOSTAT TEMPERATURE LOGGER THERMOMETER High Low y Lee Bia M at ay GeF oe oe KETEG rt CO sales ControlByWeb com JK microsystems www ControlByWeb com
159. other over understand your data items even odd USB Ready to compile and run sized ones and give you convenient e Large data Reports variables to handle them 64 000 bytes sec per Interface PIC18F Compilers PICBASIC Pro Easily creates devices with multiple MPASM C18 Hi Tech C Interfaces even multiple Identities 8 l Automatically does MULTITASKING PIC16C Compilers PICBASIC Pro Makes standard or special USB HID MPASM Hi Tech C CCS C devices l PC Compilers Delphi C Builder NEW Developers Guide for USB HID Visual Basic 6 Peripherals shows you how to make HIDmaker FS Combo Only 599 95 devices for special requirements DOWNLOAD the HiDmaker FS Test Drive today www TraceSystemsinc com 301 262 0300 120 i Wire 186 processor e 33 MHz W DOS w Flash File system 44 Digital VO lines w CPLD Console Debug Serial Port 1 34V DC or 5V DC power 2 Serial Ports Accepts 8MB DiskOnChip e 2 16 bit Timers 512K DRAM amp 512K Flash Watchdog Timer Expansion options with Peripheral Boards Electronic and Electro mechanical Devices Parts and Supplies Wall Transformers Alarms Fuses Relays Opto Electronics Knobs Video Accessories Sirens Solder Accessories Motors Heat Sinks Terminal Strips L E D S Displays Development kit includes Flashlite 186 controller 3 Separate Buses Borland C C ver 4 52 TEME Seah Sals Seea p PUEY FREE Email Tech Support Bat
160. oto 2 shows that this new no waiting policy ensured that the faster tasks were no longer blocked by tasks wait ing for slow signal changes We also show an undocument ed feature of the VDK state history plug in By using cycles since the program started instead of the number of interrupts as a time measure in the HistoryTable we got a quick and clear indication of the exact execution time of each task CO OPERATIVE VS PRE EMPTIVE Is this suggested co operative approach any better than simply measuring times using interrupts generated each time a GPIO pin senses an edge in the light sensor input signal Why not just use a pre emptive type scheduler where tasks activated by their own external interrupts interrupt other tasks The answer depends on what is meant by better If there is only one light sensor and thus only one interrupt the pre emptive scheduler always will be more accurate as we identify the sensor signal edge precisely as the exact time when the input interrupt is triggered Compare that accuracy with the co operative scheduler where an individ ual task can never provide precision greater than an integer multiple of the timer interrupt On the other hand the uncertainty in timing with every task in the co operative scheduler remains the same regard less of the number and timing of input signals that are present This precise knowledge can be put to real advan tage in many situations Is this
161. ower supply My the necessary safety precautions when AVR switch controls lights I placed inside a pantry see working with this or any circuit connected Photo 1 The AVR switch resides inside an outlet box in the inside wall just over the door The outlets on the right half of the box go to small under cabinet lights mounted along the inner pantry wall The AVR switch monitors a reed relay embed ded in the door frame directly below the outlet box When the door is opened the AVR processor senses the reed relay and powers up the outlet Three minutes later if the door is not closed the outlet is turned off Refer to the simple timed light switch in Photo 2 On the left side of the wall Figure 1 This is the basic dangerous circuit plate this AVR switch configuration has CX1 R2 Neutral an E May 2009 Issue 226 CIRCUIT CELLAR e www circuitcellar com Photo 1 This AVR switch is mounted next to the receptacle that it controls Opening the door powers up the receptacle and turns on the lights inside the Kitchen pantry a push button and a small LED nightlight Pushing the button turns on the light Pushing it again turns off the light If I leave it on for longer than 45 minutes the light automatical ly turns off As a result my lights no longer stay on all day and my electric bill is under control As you can see in Photo 3 the AVR switch is compact The AVR processor is at the top The transformerless p
162. ower supply components are at the bottom THE SEARCH FOR A SOLUTION At the beginning of this project the idea was to use a low power AVR processor to control a TRIAC A quick Internet search turned up numerous examples of how to use a microcontroller with a TRIAC to control a 120 VAC load One example is presented in Microchip Technology application note TB094 Dimming AC Incandescent Lamps Using a PICIOF20 I thought this would be easy so I started listing components a proces sor a TRIAC a transformer a rectifier a capacitor a zero crossing detector a TRIAC optoisolator and the list went on It quickly became apparent that this would never fit in the 1 5 x 2 5 x 1 area inside a standard ai Photo 2 in this variation the AVR switch turns the lights on when the push button is pressed and automatically turns the lights off if the maxi mum on time is exceeded www circuitcellar com st CIRCUIT CELLAR wall outlet box I needed something smaller and simpler The largest components obviously compromised the power supply A typical wall wart power supply with its transformer and rectifier would have taken up all the space by itself Thus the problem became how to make a tiny power supply I then remembered I had a handful of unused cell phone mini chargers lying around They were small so I thought perhaps there was an answer inside A victim was selected so I could find out The circuit board from t
163. proper opera tion of my transformerless power supply prototype If you build this isolation trans former think the component selec tion through and don t overload the transformers Remember 100 mA at 120 VAC becomes 0 5 A in the 24 VAC winding so plan accordingly This can really become an issue if you plan on testing your circuit while it s actually controlling a load A 60 W bulb could pull over 2 5 A through the 24 VAC windings Fuse appropriately and check the VA rating of the transformers Be careful Check your numbers and double check your setup before you proceed Remember that you still have 120 VAC potentials in the circuit even with the isolation transformer AVR POWER SWITCH With my experimental transformerless power supply designed I needed to add an AVR processor and a TRIAC to finish my AVR power switch Because this was intend ed to be an experimental platform I added a few expansion options to the circuit that is at least as much as I could shoe horn into such a small space I chose an Atmel ATtiny26L The L variant had an operating range down to 2 7 V with an idle current of 0 18 mA Again low power con sumption was critical because the transformerless power supply could provide only a small amount of con tinuous current Another benefit was that with the wide operating range it was possible to draw a little more current from the power supply and still survive the resulting volt
164. pt at 50 kHz servicing an external device that acquired sam ples at a 48 kHz rate That made for rather tight design constraints There were two obvious hammen j seris ss IT iiai ee Pees solutions The first was to Photo 2a We can get a clear indication of the execution time of each task by using cycles since the pro Gram started rather than the number of interrupts time measure normally used by the VDK State History display plug in We can even use at no extra expense the plug in s zoom feature for really close up shots speed up the scheduler timer to provide 100 kHz interrupts 10 us The sec with great timing detail b On the right we see the processor switching from the low power idle mode ond was to switch the co track 2 into the ISR track 3 where the AudioOutput task top track is prepared to run The proces Operative scheduler to use sor drops out of its idle mode to run the loop in main bottom track The AudioQutput task is then the external audio inter dispatched top track before the processor goes back to sleep track 2 rupts rather than the inter nal timer Both approaches have pros and cons code for a finished product or are we The 20 us scheduler interrupt nec Using an internal 100 kHz timer What practical issues have we over essary to handle the audio sampling interrupt ensured that we could meet a looked rate looked easily capable of providing timing guarant
165. put pins Programmable logic uses a constraint file to determine which internal signals go to which pins In this case bin ucf maps all the pins to their signals But if your layout is flexible you can let the tools choose which pins get which signals based on the internal layout of the design and how it relates to the available pins Some pins for example are connected to the chip s internal clock grid and the I O pins each have an associated logic cell block that they prefer to be connected to As long as the chip permits it you can even fix board layout problems by going back to the chip and moving or redefining pins An added bonus is that you can migrate the design to a different a and ET e Flash file system e 4 Chan 12 Bit A D e 1MB SRAM e 512KB FLASH e 4 Isolated Inputs e 4 Hi Current Outputs 2 External RS 232 8 2Internal RS 232 e Bat Backed Clk Cal _ o Cell Modem Option e Internal GPS Option e Metal Case Option e 7ma Standby Option Its easy and cost effective to do mobile or solar powered data collection and asset monitoring with the JK micro s Data Mover With the ability to integrate a Cellular M lodem GPS and DOS PC based embedded controller in a single rugged enclosure you can capture and transmit your data quickly easily and at low cost Inexpensive development kits including Borland C C and One PC and 8 programmers PovverBasic area available now Call or email
166. r ISR see Listing 2 This function was responsible for determining when a given taskDelay had decremented to zero see Listing 2 Line 55 When this occurred the task s RunMeNow semaphore variable was incremented this indicated that the task was now in the READY_TO_RUN state Activated by a RunMeNow sema phore s value great than 1 additional software instrumen tation Lines 61 to 64 indicates whether or not the task had been prevented from running by another task if RunMeNow gt 1 StatusHistory CurrentTime taskIndex TASK_BLOCKED Line 61 The StatusHistory function see Listing 2 Lines 38 to 47 added the new task status information into HistoryInfo which is an array of HistoryStruct structures arranged as a ring circular buffer see Listing 3 Information must be recorded to prepare for the time when the task status changes between READY_TO_RUN TASK_RUNNING and TASK_COMPLETED This together I May 2009 Issue 226 CIRCUIT CELLAR DIGITAL PLUS BONUS Listing 1 The proposed Theremin musical instrument code appears as four tasks in the co operative scheduler s to do list Three tasks change the Theremin s volume and frequency based on the shadows cast by the musician s hands A fourth task uses this information to produce the eerie sound that is typical of the Theremin Hinclude Theremin h todoList TasksINUMBERTASKSI int main void TILOS ATE Tick TIME _ Is 10us InitHa
167. r details FDIR with a specific file name will display the file size of that file Sim ple DOS wild cards will work as expected e g FDIR DAT but more complex wild card constructs are not implemented This limited directory functionality could be greatly expanded We encourage you to think about writing a more con venient user interface using our source code as a starting point The file operation commands are FPUT FGET FDEL and FREN We thought about implementing an FCOPY command rather than FPUT and FGET but having separate com mands lets us use the file path parsing capabilities of DOS Access to files on the DOS system can use any legal FCONFIG BAT Set COM port address data rate and IRQ in the environment FBAUD EXE Establish communications with VDRIVE2 at selected data rate FCD EXE Change default directory FDIR EXE List current default directory FPUT EXE Copy a file from the current DOS directory to the flash memory drive FGET EXE Copy a file from the flash memory drive to the current DOS directory FDEL EXE Delete a file on the flash memory drive FREN EXE Rename a file on the flash memory drive Table 2 This table lists the eight DOS commands for accessing files on the flash memory drive FCONFIG is a batch file the others are all exactly the same EAE files with different names www circuitcellar com CIRCUIT CELLAR biPololu Robotics
168. r of a sprite s pixel pattern is used as a transparent indicator that can let any tile color show through The sprite can be magnified to become a multiple of its original size And most important ly it has a depth associated with it that enables it to pass in front of or behind other sprites creating a 3 D effect While all of this is based on the tile sprite generator written to run within a cog this and many other Spin drivers written by the Parallax folks and other contributors like Andre LaMothe are available at www parallax com A BIT OF COLOR If you have seen black and white TV you may have been able to visualize color because your brain can take your Photo 5 This photo of my VGA monitor s screen shows the simple display of three buttons with a horizontal gauge on a background of random characters and graphics The red spot is the mouse cursor used to select a button The buttons change a variable whose value determines the gauge s length This data could come from an inter nal cog running a sampling application or from an external processor using the Propeller strictly as a display device real experiences and alter those sights broadcast in black and white It was an extraordinary engineering feat to add color information to the standard black and white trans mission signal without negatively affecting all the existing black and white receivers A color sync signal hidden in the horizontal blanking portion of
169. range The WaveAce improves troubleshooting and shortens debug time by providing unique features such as long memory a color display extensive measurement capabilities and advanced triggering A streamlined time saving user interface provides quick access to all important controls With its USB host and device ports the WaveAce easily connects to a memory stick PC or printer The variety of standard acquisition modes and advanced triggers simplifies capturing even the most complex waveforms making the WaveAce a valuable tool for design debug and troubleshooting C0 May 2009 Issue 296 The new VlaveAce is available in two chan nel models with bandwidths of 60 100 200 and 500 MHz All models have color displays With a maximum sample rate of 2 Q5 s and up to 8 kpts ch memory the VlaveAce is a performance leader in this class of portable oscilloscopes The long memory enables users to capture full sam ple rate acquisitions that are two to three times longer than the competition Improving how a user can understand and analyze waveforms the WaveAce has 32 built in automated parameters including advanced timing parameters for skew phase and edqe to edqe measurements between channels Additional features such as Pass Fail testing user definable digital fil ters and a waveform sequence recorder all simplify and shorten debug time Prices for the WaveAce series start at approximately 1 200 LeCroy Corp w
170. rdware Add basic Theremin Tasks TTCOS_AddTask LightSensorFrequency TTCOS_AddTask LightSensorVolume SHORT_DELAY Init scheduler to do initial delay and task period NO DELAY RUN_OFTEN RUN_OFTEN TTCOS_AddTask ModifyAudioSettings LONGER_DELAY RUN_AS NEEDED TTCOS_AddTask QutputAudio TTCOS Start while 1 TTCOS_GoToSleep TTCOS DispatehtTasks 35 return Q EX_INTERRUPT_HANDLER TTCOS_Interrupt 1 J3 Acknowledge_TTCOSInterrupt TICOS Update with statistical information about the minimum and maximum task run times can be obtained by adding addi tional software instrumentation to the TTCOS_DispatchTasks func tion that s responsible for running each task see Listing 4 Lines 98 to 104 The software instrumentation code used to store status information and timing statistics in the TimingInfo structure can be left in the run time code for use after the product has been released It can form the basis of a tool that performs system diagnosis during start up or it can be part of a database uploaded over the Internet for more detailed problem solving analy sis something akin to Microsoft s Do you want to send in an error report now However there is always a problem to be faced with any software instru mentation whether it is used during development or post release analysis The actual process of storing too much detailed status information coul
171. re expensive than simply posting an article online But no one would read Circuit Cellar in any form whether in print or online if they didn t trust us in the first place I know we owe the trust we have earned to the smart engineers programmers and scientists who write the excep tional editorial we publish In turn they know we go to extreme efforts to remain both a viable venue for enlight ening their interests as well as enhancing their professional careers Right now the entire publishing industry is in flux as it tries to deal with evolving delivery technologies Like many magazines Circuit Cellar has an online component In our case we view Digital Plus as a complement and enhancement to our print venue and not an escape from print When the dust settles the commercial publishing survivors will be the ones regardless of venue with superior content We intend to be among them steve ciarcia Qcircuitcellar com CIRCUIT CELLAR www circuitcellar com i lore Channels 36 More Memory 4x Advanced Match circuits 8 t6V lena Threshold 2 a ee rot 1 95555 ma Pie bike E isani Fir sht ee ee ee ee NDANI dinin HIKRONIHHIHI ANNIE e ri i N da Li Ei O Atyp y TH 1 Li e A u RA c UEA CT a sa HoA j ej po yj av s F TF J E ca oes ATE H HUEY THE MLA LE nm g H oma ie ao 8 ak Hm Are Ww H
172. riggering Multi Circuit amp C anc unction n i Operation SH ET YVVA oF Ta AZo Ze eA ela Sie tale wel E varel Ulan nate ViewPort is the premier debugging environment for the 8 cog Propeller multicore microcontroller This versatile tool combines an integrated debugger with powerful graphics that show you what s going on within the Propeller chip Monitor variables over time with the built in oscilloscope or change their value while your Propeller is running Solve hardware problems with the logic analyzer at sampling rates up to 80 Msps Add intelligence to your programs with the fuzzy logic module Add vision processing to your application Features for ViewPort Standard 32388 59 00 e Spin code debugger breakpoint pause continue profiler interpreter call stack e Virtual oscilloscope variable timescales trigger cursors auto measurements e Virtual logic analyzer capture state of all 32 pins at up to 80 Msps with trigger e Virtual spectrum analyzer analyze signals in the frequency domain e Fuzzy logic engine easily integrate and tune fuzzy logic with the control panel e Edit Spin variables use PC based controls to calibrate and control your project e Monitor variables log and analyze variable values over time e Real time data acquisition integrate PC for acquisition and control SCADA e Share logged data as Matlab text xls image files or stream to the Internet e Low speed Propeller t
173. rom CRD To Wago gT 1 i Y ba s 4 al di ti a PCB PolyLEDs il 1 Mi E 4 i UT ki So re Vili WV LI Mi J ni LedEn Qin inc LZ4 4xxx10 Serially Connected MCPCB SHARP MICROELECTRONICS OF THE AMERICAS GM5BW High Power White LEDs The ONLY New Catalog Every 90 Days Experience Mouser s time to market advantage with no minimums and same day shipping of the newest products from more than 390 leading suppliers k WWW KINGBRIGHTUSA COM W High Brightness LEDs 4 a tti company The Newest Products For Your Newest Designs www mouser com _ Over A Million Products Online 800 346 6873 May 2009 Issue 296 multicolored bar graph could easily express more than the five original charge states If the input voltage is above 13 5 V I assume that the battery is being charged To announce this I have the LEDs do the happy dance where an upward sequence of green LEDs is marched up the bar graph This is similar to what you may have seen on many cellular phones during their recharge period except that mine is greener and happier If the voltage is between 12 65 and 13 5 V the graph shows six of six bars or green LEDs in this case This represents a fully charged bat tery with 100 of its capacity avail able You have to remember that in the real world a battery has 100 of its rated capacity only once if you re lucky early in its life and that it slowly
174. rumentation does not involve making many inline calls However for other processors the number of processor clock cycles used during the software instrumen tation process could be a real issue In such situations the equivalent of the following C embedded assembly language macros could be useful Hdefine StatusHistory A B C asm nop Hdefine RunStatistics A B asm nop When the compiler expands these macros the software instrumentation is reduced to trivial do nothing nop instructions These will be removed as redundant code by any half way intel ligent optimizing compiler and then the core can run at full speed TASK STATUS amp TIMING INFO We ve covered the topic of adding software instrumentation to provide task status and timing information So now that you have all of these details what are you going to do with them Our initial idea was to do something simple such as add a breakpoint to stop the TTCOS_Update code whenever a task was blocked from running when CIRCUIT CELLAR www circuitcellar com Listing 2 The scheduler timer interrupt service routine Listing 1 Lines 29 31 calls TTCOS Update This function is responsible for determining which tasks are now ready to run Software instrumentation highlighted can be added to document the predictability present in the system in particular whether one task has been blocked from running by another task 34 volatile int h
175. ry JPL A World of Interconnected Sensors President of Sensing amp Control Honeywell Automation amp Control Solutions This Year s Conference Program Covers 18 Tracks e Sensor Interfaces amp Sensor Integration e Sensor Systems Design e RF Sensing e Wireless Sensor Networks e Energy Harvesting e Energy Conservation e Low Power Sensing e Harsh Environments e Position Sensing e Fiber Optics e Machine Health amp Predictive Maintenance e Smart Materials e Novel Approaches to Measurement amp Detection e Environmental Monitoring e Business Trends amp Issues e Wireless Standards e Location Aware Sensing e Novel Approaches to Biodetection Register Today for Your Conference Pass at the Early Bird Rates Or Sign Up Now for a FREE Expo Hall Pass Visit www sensorsexpo com or call 877 232 0132 or 972 620 3036 Outside U S Don t Forget to Use Your Source Code 303M Proaueed QUESTEX ea SANSOTS 1s Microcaip Ks CIRCUIT CELLAR E D IA THE MAGAZINE FOR COMPUTER APPLICATIONS Or Q May 2009 Issue 226 Video configuration register VCFG n a VMode Enable Disable VSU VGA Mode NTSC Mode Broadband on upper pins baseband on lower pins NTSC Mode Baseband on upper pins broadband on lower pins CMode colors shades 0 Two color mode 1 Four color mode Chroma 1 Broadcast 0 Disable chroma color on broadband 1 Enable chroma color driver Chroma 0 Baseband 0 Disable
176. s no soldermask no silkscreen Believe it or not they were built in under 24 hours Every one perfect every time to my scribbled notes as to pin placement and LED array wiring see Figure 3 I played with various combina tions of highs and lows and ins and outs Once I could light up individ ual LEDs to my satisfaction I wrote a routine to scan through a memory map of LEDs and light them or not over and over too quickly for the eye to detect This produces the illu sion of multiple LEDs being illumi nated at the same time This became the main loop of the final firmware Now I had a medium waiting for a message The next step was to read the ADC peripheral and determine what voltage was being presented for analysis Naturally reading it once was not going to be adequate due to sampling noise and other error terms so I set up the on chip Timer Counter peripheral to inter rupt periodically and in the interrupt service routine set about to oversam ple the ADC input Eight successive samples are read and summed then divided by eight to give a rough arithmetic average This number is compared to a series of preset values to determine how many LEDs of each color to light up This is where the values from Table 1 come into play I broke down the basic thresholds from Table 1 and added a few more of my own devising because my CIRCUIT CELLAR www circuitcellar com The Newest Optoelectronics w Products f
177. s of RAM The last 16 bytes of this RAM are special function regis ters that enable the cog to access all I O pins its own counters and a video generator The RAM is used to hold code and local VARs Each cog executes its own code independently yet all cogs run from the master clock The Propeller can take oscillator or XTAL input or use an internal RC oscillator to drive the internal clock directly or through a 2x 4x 8x 16x PLL for a maxi mum clock speed of 80 MHz Note that in addition to eight cogs there is an additional device called the hub see Figure 1 Besides handling the R May 2009 Issue 226 basic reset brown out and master clocking the hub has its own memory both RAM and ROM with 8 000 double words each Hub ROM contains character definitions math functions a bootloader and a Spin interpreter During reset the bootloader loads COGO with some code that checks for communication enabling you to take control checks for an exter nal EEPROM and loads it into the hub s RAM or shuts down all operations If an application has been transferred into the hub s RAM then the SPIN interpreter is loaded into COGO and begins to execute the application in the hub s RAM Like all microcontrollers the Pro peller has a number of assembly instruc tions that make up its vocabulary You may want to write your application code or parts of it in assembly lan guage However there are those who detest
178. splay Configurations www earthicd com CIRCUIT CELLAR Designer s Notification Network Circuit Cellar design contest entrants have received thousands of valuable development tools and product samples Because of their contest participation these engineers receive advance e mail notice from Circuit Cellar as soon as new samples become available Now you too can benefit from this early notification Welcome to the Designer s Notifica tion Network Print subscribers are invited to join the Network for advance notice about our new sample distribution programs PAYU E Inside great products Behind great ideas phyCORE System on Module technology provides a production ready hardware and software solution that enables product engineers to bring new ideas to market in the most timely and cost efficient manner pnyCORE LPC3520 provides state of the art power management a Floating Point Unit and rich peripherals nas USB io Ethernet and an int sven LCD controller These features render the LPC 1750 suitable for embedded ee oyment requiring hi a oerormance and integration crossed with low power consumption offers Graphics of the CE Over SECUTITY z chitecture nt tUn L and a rit Hi pe SN zE g DDR me mory supp rt ana Ethernet t at make sith oevice deal candidate for a wide varie ty 0 embedded pal cations Design Services PHYTEC offers hardware and software design services which can further reduce t
179. szCommand FDEL EXE 8 if Istrncmp szCommand FTER EXE 8 if Istrncmp szCommand FBAUD EXE 9 GJ g eCmd COMMAND_FDIR g_eCmd COMMAND FPUT g_eCmd COMMAND_FGET g_eCmd COMMAND_FCD g_eCmd COMMAND_FREN g_eCmd COMMAND_FDEL g_eCmd COMMAND_FTER g_eCmd COMMAND_FBAUD for DOS much of the code is reusable for microcontrollers with C compilers or as an example for other embedded applications If you build the level converter you have a great set of tools for experimenting with the VDRIVE2 l systems that enable you to defenes trate DOS for Windows when more serious file transfers are necessary For smaller files the VDRIVE2 and the new DOS commands are an ideal solution Although the software was written Authors note This research was supported by the Intramural Program of the National Institute of Mental Health National Institutes of Health Andrew Mitz arm nih gov is a Ph D research scientist at the National Insti tutes of Health where he studies the electrical activity of the brain He received his Bachelor s and Master s degrees in electrical engineering from Washington University and the University of Maryland before entering a medical research program at Emory University Andrew s laboratory work involves instrumenta tion of physiological signals e g muscle activity heart rate eye tracking and microvolt recordings of brain cells He has worked on the development of man
180. t is the most open and uniquely diverse source of mass media ever developed Part of its uniqueness is that it fosters a low cost interchange of ideas and published materials At one time we sat around the campfire and swapped stories Now kids sign on to a variety of social networks to hear and exchange tall tales The beau ty of the Internet and the worry for traditional publishers is that the Internet is interactive and not meant solely to push content in one direction to a captive audience Information on any subject to any depth of analysis desired and with virtually any degree of correctness is available on demand In my opinion a lot of the financial problems in publishing are coincident with bad economic conditions but certainly many newspapers and magazines are feeling a lot more heat simply because readers no longer trust their content The fact that readers might seek alternatives on the Internet is a consequence of smart people seeking a better source It is too simplistic to attribute all print publishing failures merely to cheaper and faster access on the Internet Similarly moving from a print venue to an online one doesn t alleviate the issue of crappy content In my opinion publishing survival whether using print the Internet PDFs wireless e paper or whatever is all about readers valuing the credibility and content of the message and not solely about the delivery medium Don t get me wrong printing paper is a whole lot mo
181. t without blinky lights and the LED on the pod itself is used to give feedback about the hard ware flow control used by the serial port software Second I needed to be able to monitor the target circuit s supply voltage see Figure 1 Because the pod can run at either 3 3 or 5 V and the target circuit can run at any voltage I used one of the pod s ADCs to compare the target s voltage with the pod s voltage The reference voltage is set by the pod to its own sup ply voltage I used a pair of resistors to divide the target s supply voltage in half and feed it into the ADC If the volt ages match the resulting ADC value should be about 128 on a scale of 0 255 or an 8 bit conversion If the pod is running at 3 3 V and the target at 5 V the result will be 5 3 3 times high er or around 194 If the voltages are the other way the result will be 3 3 5 times as high or around 84 If the tar get is not yet powered up the result will be zero While the R8C 20 does not have 5 V tolerant inputs when run ning at 3 3 V this at least enables me to find out quickly if the voltages are mis matched Mostly it just checks to see if the target is powered up at all protect ing the target from damage The pod s software is a port of the JTAG programming application as provided in Xilinx s 2007 application Listing 1 This is the top module for my CPLD project The signals named on the line with module top correspon
182. te it while reversing the current would light up the other side Alternating the cur rent rapidly would produce the illu sion of both LEDs being lit simulta neously This is alleged to be yellow but it only looks yellow if you look at it quickly and sideways at the same time It is yellow esque at best Five or six multicolor LEDs would give enough of a range to make a useful display Because each LED package is two distinct LEDs I would have to come up with a way to drive a dozen or so LEDs with a small microcontroller FANCY LED MULTIPLEXING Normally 12 individual LEDs would require at a minimum 12 dedicated output driver lines to be able to individually and randomly address any LED The ATtiny13 has six I O lines available Using a mul tiplexing technique sometimes referred to as charlieplexing I was able to drive the 12 LEDs using only four output pins Maxim application note 1880 credits Charlie Allen with championing this technique within the organization Maxim Integrated Products offers several devices that will perform that trick for you Don Lancaster wrote about it in his Tech Musings column in August 2001 and gave several exam ples www tinaja com I m sure I thought of it long before but I must have neg lected to write it down in my journal Dang The number of LEDs that can be addressed depends on the number of I O lines that you re willing to throw at it The formula is n n 1
183. teries Magnets Cameras 5V amp 3V System Serial Driver library Panel Meters Switches Speakers Simple ASCII Interface AC Adapter and cable Peltier Devices and much more Cross Platform All OS Call 530 297 6073 Email sales jkmicro com On the web at www jkmicro com www allelectronics com Free 96 page catalog 1 800 826 5432 www i2cchip com JK microsystems May 2009 Issue 226 www circuitcellar com CIRCUIT CELLAR 15 Q Q May 2009 Issue 226 Free Training for Rabbit Developers Learn More at Rabbit U com LV MaxSonar Ultrasonic Ranging is EZ LV MaxSonar Products e High quality Low cost e Low power 3V 5 5V lt 4mA avg e Easy interfacing Serial pulse width amp analog voltage outputs e Reliable and stable range measurement No dead zone LV MaxSonar EZ e Choice of beam patterns e Tiny size lt 1 cubic inch e Light weight lt 5 grams LV MaxSonar VVRT1 P67 e Industrial packaging e Weather resistant e Standard fitting 6 e Quality narrow beam www maxbotix com The 69 PLC Work as Stand Alone Ladder Logic PLC Or as Smart Remote I Os of PC PLCs R5485 allows 256 units to be networked Incredibly Easy to Programi Our software is used by many colleges for teaching PLCs Get Free Ladder Logic Simulator Tel 1 877 874 7527 PLC specialist since 1993 Add a color touch interface to your embedde
184. that uses JTAG to talk to these chips will often read these configuration files to understand how to access these functions When multiple devices are in the JTAG chain TDO A N AP CIRCUITS Versatile Device with I O Options As low as 9 95 Two Boards Two Layers Two Masks One Legend each Unmasked boards ship next day Rabbit RIO Programmable O Application Kit for www circuitcellar com CIRCUIT CELLAR www apcircuits com Raye QPC memcer ASSOCIATION CONNECTING ELECTRONI INDUSTRIES E GTAONIOS INDUSTAIS May 2009 Issue 296 N Nn N Q May 2009 Issue 296 chained to TDI programming utilities can use the configuration for the chips they re not programming to learn how to bypass those chips and access the one they re interested in Do you really need to know all this to use JTAG Not really Aside from telling inputs from outputs you don t even need to know this to port the programming application to the pod However it helps you understand that there is a lot of bit twiddling going on JTAG POD MODULE To simplify connections to the project I created a JTAG programming module for the USB GPIO pod see Photo 1 Aside from bringing out the specific JTAG signals I needed there are two other functions this module provides First I added a couple of LEDs to provide some visual feedback of what the JTAG protocol is doing After all I can t have a projec
185. the design the zero crossing signal had a substantial phase shift I was not planning to use any dimming func tionality so the zero crossing signal May 2009 Issue 226 A N A Q0 May 2009 Issue 226 Neutral 1N4005 Figure 2 This is a basic capacitive transformerless power Supply wasn t necessary However because this was an experimental platform and the signal was available I included it anyway One result of that decision was that I could also use the zero crossing signal to short en the time the TRIAC gate needed to be powered As a result the over all circuit current demand was reduced To implement the TRIAC control the software was designed to turn on the TRIAC immediately after the zero crossing and to leave it turned on only until sufficient cur rent was being conducted through the TRIAC to latch the gate At that point the TRIAC gate could be released and the TRIAC would stay energized A second issue associated with the zero crossing signal was a tendency to ring when there were switching transients present on the incoming 120 VAC line I tried to compensate for this But if the circuit is used in a noisy environment there may be some false triggering of the zero crossing interrupt SOFTWARE The sample software for the AVR power switch platform was written in WinAVR C It was relatively straightforward to write Code size and performance were not really issues with this
186. timized String Handling e IDE Compilers include NEW Menu Manager Coming Summer 2009 Support for NEW Enhanced Mid Range PIC16 Devices Prices start at 150 262 522 6500 x35 sales ccsinfo com www ccsinfo com PIC16CC CIRCUIT CELLAR www circuitcellar com VVeather Instruments for PCs L ln electr nica Solve complex aa acquisition pionen iii positio ming amp cntro www aagelectronica com The original Gontrollor Arga Network CAN to A5232 serial convertor t L L3NIIN CAN232 Features Free sample programs es in si CANUSB Features Small size 2 7 by La Froo Activex u 100 Bandwidth up to 125Kbit PC MAC amp Linux support S Both 11 amp 29 bit ID support Both 11 amp 29 bit ID support 32 Receive FIFO Simple CAN logger included Works u Free Threaded Windows DLL pto 1Mbit CAN br ia Simple ASCII protocol inmware upgradab SB Supports RTR Frames Sample programs in C C VB Delphi C PureBasic etc Max 220Kbaud RS232 N ae Firmware upgradable kn No need for external No drivers needed i Works up to 1Mbit CAN 05 independant Supports RTR Frames CE Approved USB 2 0 Full Speed Free USB drivers i CE Approved N A I environmental acceleration transients pressure vibration sonar ISH PH Linux Driver sana Guaranteed in stock Many newly added features 16 bit analog inputs and outputs Million sample F
187. ts bag i e 12S Audio Interface e Up to 64 MB Flash amp 128 MB RAM e Graphic LCD Interface with 2D Acceleration e Linux with Eclipse IDE amp WinCE 610 e 8 12 Bit A Ds amp 4 16 Bit Timer Counterss e Small 144 pin SODIMM form factor 2 66 x 2 38 The SoM 9307 uses the same small soji form factor utilized by other EMAC SoM modules and is the ideal processor engine for your next design All of the ARM9 processor core is included on this tiny board including Touchscreen a Interface Flash Memory Serial Ports Ethernet 12S Audio Interface PWMs Timer Counters A D Digital I O lines and more Like other modules in EMAC s edadea Computer 8 _ SoM product line the SoM 9307 is designed to plug into a custom or off the shelf Tinycore form factor 36 x 41 Be Carrier board containing all the connectors and any additional I O components that may be required The SoM approach provides the flexibility of a fully ATMEL AT91SAM9G20 E 400MHz customized product at a greatly reduced cost Single unit pricing starts at 150 e http www emacinc com som som9307 htm Since 1985 he j ee USB Device Serial DBGU amp 2 Expansion Ports Evi e p SINGLE BOARD www calao systems com T N Phone 618 529 4525 e Fax 618 457 0110 e Web www emacinc com IN May 2009 Issue 296 EX CIRCUIT CELLAR e www circuitcellar com Test Your Edited by David Tweed Robert Lacoste recently vvrote about transmission l
188. uisi tion storage and control functions But you don t need to be a rocket XT 32 P 32 ACC 32 ARO 16 XARO 32 AR1 16 XAR1 32 AR2 16 XAR2 32 AR3 16 XAR3 32 AR4 16 XAR4 32 AR5 16 XAR5 32 AR6 16 XAR6 32 AR7 16 XAR6 32 PC 22 RPC 22 STO 16 ST1 16 lERI16 DBGIERI 16 IFR 16 Figure 5 RISC CISC or DSP The Piccolo architecture combines aspects of all three CIRCUIT CELLAR www circuitcellar com scientist or have a budget like NASA to kick the tires Let s check out the Piccolo MCU controlSTICK which definitely qualifies as an impulse buy at just 39 If you haven t caught on to the fact Piccolo can impersonate an MCU Photo should make it clear There you can see that the control STICK comprises little more than the Piccolo itself along with a Future Technology Devices International chip to handle the USB inter face If it walks like an MCU and talks like an MCU The same goes for the Texas Instruments Code Composer Studio which at least at first glance looks like a typical MCU toolchain with a dizzying array of menus and win dows to play with see Photo 2 Indeed if anything Code Composer Studio takes it a step further with advanced analysis capabilities that leverage Piccolo s on chip debug hardware see Photo 3 Scratch a bit further under the surface and you ll find unique vestiges of Piccolo s DSP heritage For example you can
189. ultimeters Function Generators Voltage Testers Capitance Meters Analog Multimeters Test Leads amp More T N a Pu a p s a 1 Pi a Tt E O ff pri I f i k I What Your Electroni Hobby Stores Used To Be 1 800 957 6867 USB Oscilloscope for 169 50 Logic and Spectrum Analyzers Generator www HobbyLab US muni unin nn nn L i Poy pet Bebetatalbsae se LI z e 2 2 Ab g 1 ek dl ic _ ee eee oh eS ike et Le E KM in pe VT e pl 7 Ta M al oka k sh j EAE E E ae m I GJONI FJ es pe Be AA a fobs T E pi aa E tmini Se ie F ale z EMANO I pe NI I May 2009 Issue 296 www DesignNotes com A number of issues arose before and during development that were related to the problem of operating without a resident driver A resident driver can remember the data rate and other serial port settings entered earlier by the user Programs not loaded into memory need another way to avoid Korsakoff s syndrome The two standard options are envi ronmental variables and configura tion files We chose to use environ mental variables You can place SETENV commands in the AUTOEXEC BAT file for boot up configuration but we recommend using our batch file that takes the parameters on the command line and checks for valid environmental variable names Environmental variables provide memory f
190. us tries The new XC864 series is designed for cost sensitive motor control applications The XC864 series combines in a small footprint TSSOP 20 package a standard 8051 core with on chip flash memory of up to 4 KB and powerful on chip peripherals The XC864 series features an internal clock source and embedded voltage regulator supporting single voltage supply of 5 5 or 5 0 V The AELOXM series of MCUs are designed for use in real time industrial drive applications such as servo drives HVAC com pressors and blowers pumps advanced sensing and power supplies The KEL6xM series provides additional advanced safety features for SIL3 applications and 64 pin devices the XE162M series with a small footprint The highly configurable serial interface USIC supports multiple protocols such as Asynchronous and Synchronous Serial Inter faces ASC SSC 1C LIN and communication to SD memory cards The IC1167 and TC1197 are designed for use in demanding real time industrial applications such as multi axis controllers for up to five three phase complementary PWMs They support mul tiple modulation strategies such as Space Vector Control or Direct Torque Control and provide mul tiprocessor support for reliability and safety In quantities of 20 000 units the 8 bit micro controller XC864 costs about 1 05 per unit The price of the 16 bit XE16xM series starts with the XE162M at about 7 each The unit price of the 32 bit microcontroller TC1167 is
191. us for more details Call 530 297 6073 Email sales jkmicro com On the web at www jkmicro com JK microsystems N May 2009 Issue 226 UJ package just by writing a new con straint file and rebuilding PROGRAMMING DEMO Now that I ve covered all the parts let s focus on how they fit together I built the CPLD circuit the circuit on some protoboard see Photo 2 I plugged the JTAG adapter module into the USB pod and wired it into the pro toboard matching TDI to TDI TCK to TCK and so on I labeled mine to match the pin names but keep in mind that if you have to chain two or more devices together you connect TDO to TDI with the pod s TDI con nected to the first device in the chain and its TDO to the last While the JTAG module connects to the circuit s V p bus it neither powers the circuit nor draws power from it The V p pin on the module only measures the V p through a resistor divider and an ADC Our CPLD does not use the TRST pin so I have not connected it to anything The R8C tristates all I O pins at reset so it s relatively safe to connect USB Flash Programmers for Texas Instruments MCUs MSP430 Chipcon CCxx C2000 DSPs can assign unique serial number up to eight programmers can be connected to one PC and program target devices simultaneously Programmers eee JTAG I SBW dl nok J is 5 or BSL L CIRCUIT CELLAR www circuitcellar com USBee Test
192. ut case IDE Interface Power Adapter Offer full source code schematic f iEhank wwwiicbank com module the inputs and outputs are the pins on the chip There are eight inputs for the binary number and 21 outputs for the LED segments There were enough pins and logic cells left over to add a pair of latch enable pins two types of blanking display and leading zero and an output polarity control pin While Verilog looks like generic software programming code it s describing hardware You can follow the interconnections in top v as I coded the logic blocks from the input pins through to the output pins First I latched the input pins into a register called ibinh input binary held I connected this register to the BCD decoder b0 returning the three digits as bcd2 bcdl and bcdo0 Next I added logic to detect when leading zeros were present 1Z2 1z1 the third digit is always on and to com pute the blanking signals bl ank2 through blanko I also connected note that I write connected instead of passed I m talking about wires here the three BCD values to three instances of the seven segment decoder I used two of the full decoders and the one partial one for the hundreds digit The results of these decoders each have to pass through modules to determine if they re inverted noninverted or tris tated blanked The results of these last modules are connected to the chip s out
193. ution You can use it for more than just this one task which saves money in the long run too JTAG OVERVIEW The Joint Test Action Group JTAG is a specification created for testing densely populated circuit boards In addition to testing many chips have extended their JTAG interface to include other operations such as programming or debugging The JTAG interface consists of five logic sig nals Reset optional Clock Mode Select Data In and Data Out The signals are abbreviated TRST TCK TMS TDI and TDO There are three types of operations which CIRCUIT CELLARS www circuitcellar com in combination yield all the opera tions the chip defines Not all chips include a TRST pin because it isn t always needed When it is included you can reset the chip s JTAG module by pulsing TRST low When it is not present the JTAG mod ule can be reset by clocking in a reset command to the TMS port Note that this doesn t reset the chip just the JTAG interface The TMS pin controls a state machine vyhich selects the mode in which the interface operates Chips that support JTAG use the same state machine so a project with multiple JTAG chips can tie all the JTAG inter faces together TRST TCK and TMS in parallel and TDI and TDO chained in series and control all the chips at once The state machine is designed so that a reset sequence of clocking five 1 bits on TMS always returns it to the idle state regardl
194. ware functions each logic block has a set of parameters that represent its inputs and outputs Unlike software func tions these inputs and outputs are electrical connections representing wires To use one logic block in anoth er module you instantiate a copy of the block in your own logic When you do this you give each instance its own name and specify which signals in your module will connect to which inputs and outputs in that instance Think of modules as a definition of a chip and instantiating one as buying a chip to use First I needed a way of decoding the binary number into a three digit deci mal number In bcd v there is a large www circuitcellar com CIRCUIT CELLAR case table with one entry for each input combination Each case describes the three output digits I actually used a script to generate this rather than type it all in by hand but at least I didn t need to try to figure out the logic behind each output bit the Xilinx tools did it all for me Next I needed a way to map the binary encoding of a digit into a seven segment encoding for that digit There are two of these in sevenseg v as the hundreds digit has only three possible values Adding a smaller table for that digit reduces the amount of internal logic needed Again I used a case table to describe each combina tion with default entries not all bina ry inputs are valid of don t care to help reduce the logic needed
195. where n is the number of I O lines So four I O lines would give you 12 LEDs i e 4 x 3 That translates to six bipolar LEDs The next step up would be five I O lines and 20 normal LEDs or 10 display to produce meaning ful information even with no user manual handy A single schematic showing all the possible combinations of connec tions between the four I O lines That s how you light up 12 LEDs with only four I O lines bipolar LEDs That s too many The next step down May 2009 Issue 296 CIRCUIT CELLAR www circuitcellar com EX 970 Sweet Introducing the MiniCore Series of Networking Modules Smaller than a sugar packet the Rabbit MiniCore series of easy to use ultra compact and low cost networking modules come in several pin compatible flavors Optimized for real time control communications and networking applications such as energy management and intelligent building automation MiniCore will surely add sweetness to your design e Wireless and wired interfaces e Ultra compact form factor e Low profile for design flexibility e Priced for volume applications Mimitore ROMS FO 2900 Spafford Street Davis CA 95618 E would be three I O lines N May 2009 Issue 226 and six normal LEDs or three bipolar LEDs That s too few Six LEDs is just right Imagine the four I O pins are wired to the four corners of a square Now each square corner is co
196. with my mains powered oscilloscope and if I was CIRCUIT CELLAR www circuitcellar com Photo 4 This is a TinySwitch ll miniswitcher extremely lucky I might have seen a 115 VAC signal However it was much more likely that I would have simply fried everything The dilem ma was that the signal ground on the oscilloscope was at Earth ground If I had tried to connect both grounds together the 115 VAC potential difference between the two grounds would have resulted in sub stantial current The solution would have been an isolation transformer This would have effectively kept the two grounds separated and enabled me to connect the oscilloscope signal ground to the circuit DC ground and observe the 5 VDC output However even with the isolation transformer in place there would still be 120 Photo 5 This is an opened Smart Home Systems X10 light switch www circuitcellar com st CIRCUIT CELLAR VAC in the circuit So it still would be a danger ous circuit Unfortunately I didn t have an isolation trans former handy so I had to improvise by wiring two step down transformers secondary to secondary see Figure 3 With a pair of 120 24 VAC transformers wired back to back the 120 VAC input was converted to 24 VAC and then back to 120 VAC on the output side More importantly no DC current could flow between the input and output With my improvised isolation transformer I could then verify the
197. world where youre only a few clicks away from buying the right device or tool for your next job So fasten your seat belts and log in today we guarantee this site will put you in pole position inthe time to market race ConWergence PROMOTIONS E TECN Feete OV Co May 2009 Issue 226 of view leaving about 244 maximum viewable lines Gamers will limit themselves to approximately 200 lines to be sure their environment is not chopped off at the top or bottom So at 200 scan lines you need 12 8 KB of data space 512 bits scan line x 200 lines 8 bits In many circum stances you would like to use double buffering which means two equal size video buffers That would mean 25 6 KB of RAM That sure doesn t leave much room for the application TILING Earlier I mentioned that there are 256 character graphics stored in ROM Each character is made up of 16 bits hori zontally x 32 bits vertically Two characters are combined to make use of the 32 bit double word data format When the even or odd bytes of horizontal data are displayed on 32 separate scan lines a picture of that character appears on the screen If you want to print a character to the screen you need a single byte to define the chosen character The appli cation doesn t need to figure out what data is required to form a character on the screen All that is waiting for you to access it via a ROM address This might require 1 byte pointer instead of 64 bytes of
198. would be to say that they are programmed to become inputs and not activate their internal pull up resistors They effectively become tristated at this point and do not contribute to the current flow in the LED array Each LED has its own pattern of ins outs highs and lows WRITE THE SOFTWARE I built a prototype of the circuit using a solderless breadboard see Photo 1 I used an Atmel STK 500 to program the ATtinyl3 Being an eight pin DIP it was relatively easy to pop it in and out of the prototype for programming Anything larger would have wanted its own program ming cable attached The AVR devices have the nice capability of in system programming or ISP This allows the part to be pro grammed and reprogrammed in situ without having to remove the part from the circuit and placed in a device programmer I wrote the code in C I used the WinAVR port of the GCC compiler collection which works well with Atmel s AVR Studio These are all free programs in various senses of the word GCC is libre or free as in speech while AVR Studio is gratis or free as in beer The first task was as usual in embedded development to light a single LED This was a little more complex than the normal embedded Hello world monochrome monopixel I had to constantly refer Photo 2 This is the assembled PCB These boards made by Advanced Circuits are their BareBones special double sided plated though hole
199. would have been possible but it would have increased the parts count and thus the overall physical volume Still striv ing for the minimum size and parts count my search continued Finally I wondered how the original X10 modules fit a complete power supply into such a small space This seemed like a potential path to a solution so I decided to dissect one see Photo 5 Inside the X10 module was a notable absence of any type of transformer power regulator or rectifier it included mainly resistors and capacitors It appeared that the inductor on the right see Photo 5 was used only for reducing the output noise caused by the X10 dimmer functionality Few components were left to make up the actual power supply The X10 module was the essence of a minimal design So the question became How did X10 build this transformerless power supply It turned out that the phrase transformerless power supply was a good Internet search term I found various designs that all focused on a simple capacitor used to siphon power from the AC mains One find was a tutori al on transformerless power supply design published as a Microchip technical brief TBOO8 Tranformerless Power Supply I also found a Microchip application note AN954 Transformerless Power Supplies Resis tive and Capacitive that actually went into the calcu lations for the various component sizes This finally appeared to be a solution I now had the beginnings of
200. ww lecroy com NEW PRODUCT News Edited by John Gorsky CIRCUIT CELLAR www circuitcellar com LOVV POVVER COMPUTER CAPTURES amp TRANSMITS REMOTE DATA The DataMover offers an economical solu tion to remote data capture and transmis sion By integrating an optional GPS receiver GPRS cell modem and Sleep mode power controller in a die cast aluminum enclosure the DataMover is capable of logging and transmitting data from remote or inaccessi ble locations With power consumption of less than 1 W during operation and less than 4 mW in Sleep mode the DataMover can be battery or solar powered with minimal expense The DataMover single board computer comes standard with R5 252 R5 485 serial ports conditioned analog to digital converter inputs driver outputs optically isolated inputs and simple TTL I O The software supplied includes drivers and a read write file system The DataMover controller is 142 in 100 piece quantities Development kits are avail able for 229 JK microsystems www jkmicro com HALL EFFECT MAGNETIC POSITION SENSORS The SS361RT and SS461R are bipolar latch Hall effect magnetic position sensors with enhanced sensitivity which enables the use of less expensive magnets in some applications The SSS61RT sensor s small footprint takes up less space on the printed circuit board typically allowing for a reduction in costs Additionally the 59361RT sensor is supplied on tape and reel allowin
201. x M3 based MCU Power consumption is equally system and application dependent The specs Photo 5 Code Com poser Studio includes a Piccolo simulator that lets you see what s going on under the hood Execution Mode Simulation c Emulation shovy active povver consumption of about 2 mA MHz which is a little higher than generic 32 bit flash mem ory MCUs but not bad considering DOWNLOAD our free CAD software DESIGN your two or four layer PC board SEND us your design with just a click RECEIVE top quality boards in just days expresspcb com the horsepower on tap Besides the clock rate a key factor is which if any of the Piccolo peripherals aren t used and can be powered down For example turning off the CAN module saves ll mA and in fact simply dis abling the CPU clock output pin XCLKOUT saves a whopping 15 mA Standby current consumption in the lowest power mode i e everything off is on the order of 100 uA which is somewhat higher than typical MCUs but certainly not a showstopper My conclusion is that the slightly higher Piccolo power consumption would only be an issue in the most batter y life sensitive applications Finally there is price I don t have an official price quote but the press release says Piccolo starts at less than 2 in volume In terms of historic pricing for DSPs that s quite a bargain considering high end parts such as TYs own C6x line can have triple d
202. y Photography www rakoczyphoto com PRINTED IN THE UNITED STATES CONTACTS Information www circuitcellar com subscribe E mail subscribe Gcircuitcellar com Subscribe 800 269 6301 www circuitcellar com subscribe Circuit Cellar Subscriptions PO Box 5650 Hanover NH 03755 5650 Address Changes Problems E mail subscribe circuitcellar com 860 875 2199 Fax 860 871 0411 E mail info circuitcellar com Editorial Office Editor Circuit Cellar 4 Park St Vernon CT 06066 E mail editor circuitcellar com New Products New Products Circuit Cellar 4 Park St Vernon CT 06066 E mail newproducts circuitcellar com 860 875 2199 E mail reprints circuitcellar com H Authors e mail addresses when available are included at the end of each article CIRCUIT CELLAR THE MAGAZINE FOR COMPUTER APPLICATIONS ISSN 1528 0608 is published monthly by Circuit Cellar Incorporated 4 Park Street Vernon CT 06066 Periodical rates paid at Vernon CT and additional offices One year 12 issues subscription rate USA and possessions 23 95 Canada Mexico 34 95 all other countries 49 95 Two year 24 issues sub scription rate USA and possessions 43 95 Canada Mexico 59 95 all other countries 85 All subscription orders payable in U S funds only via Visa MasterCard international postal money order or check drawn on U S bank Direct subscription orders and subscription related questions to Circuit Cellar Subscriptions P O Box 5650
203. y real time embedded systems including robotics In his free time Andrew collects and repairs antique radios and supports emergency communi cations through amateur radio He has also developed devices for people with disabilities Some of Andrew s designs are now in commercially shipping prod ucts and many end up as publications in a wide variety of professional and hobby magazines His favorite moments in embedded design are at the begin ning and the end of each project The middle Andrew says is often quite maddening Jon Daley is an embedded software engineer who currently can be found alter nating between the two extremes of assembly language and ajax php for his startup company Lime Daley Wherever he is you can find him at http limedaley com or circuitcellar jon limedaley com Po ECT FILES To download code go to ftp ftp circuitcellar com pub Circuit_Cellar 2009 226 S OURCES FTDI VNCIL Host controller chip and VDRIVE2 reader module Future Technology Devices International www ftdichip com NIMH Cortex NIMH Laboratory of Neuropsychology www cortex salk edu May 2009 Issue 226 A GJ S Zili by Tom Struzik Transformerless Power Supply Instead of buying expensive transformers or converters to run your simple circuits try using a transformerless power supply Tom used one to construct a switch that controls lights in a pantry When the door is opened a processor senses a reed relay

Download Pdf Manuals

image

Related Search

Related Contents

Télécharger le PDF - Entraide Naturo-Lait  Liebert GXT2 User's Manual  User Manual Oracle FLEXCUBE Direct Banking Android Tablet  Fisher-Price K3800 User's Manual  Bosch UPA-1220-50  MPG1 - Pressure Calibration  RD 27-100 RD 27-120  Mod: G17/TF8-N  Royal Sovereign CS-923 laminator  Samsung MW73E User Manual  

Copyright © All rights reserved.
Failed to retrieve file