Magnetic Encoder Actuator Series

For decades, our talented team of engineers has been defining and developing advancements in actuator technology. The Magnetic Encoder Series, for instance, boasts industrial-strength gears with heavy-duty, long-life motors and PWM, TTL standard or optional RS-485 protocol capabilities. Available in a wide range of sizes with high- resolution, 32-bit programmable digital circuits, Hitec Commercial Solutions actuators meet the most rigorous demands for a plethora of commercial applications. Inquire about our customization and modification options, tailor-made for your specific projects.

• Magnetic Encoder Position Sensors • Sizes Ranging From 13mm ~ 33mm • Wide Voltage Operation • Precise Repeatability • High-Resolution Programmability • Customization Options Available

Servo Actuator Engineering Reimagined

Hitec Commercial Solutions, Inc. | 12115 Paine St., Poway, CA 92064 | (858) 748-6948 | www.hitecnology.com

Full Page.indd 2 12/4/2017 8:26:19 PM The Best Value in Electronic Test & Measurement

SDS1000X-E Series Digital Oscilloscopes • 100/200 MHz Bandwith • 2 and 4 Channel • 1 GSa/s Sampling Rate • Next Generation SPO Technology • Up to 400,000 wfm/s Waveform Capture Rate $ • 7” TFT-LCD Display 379+

SDG6000X Series Waveform Generators • 200, 350 and 500 MHz Bandwith • 16-bit Resolution • 2.4 GSa/s Sampling Rate $ • IQ Modulation 1499+

SSA3000X Series Spectrum Analyzers • All-Digital IF Technology • Frequency Range from 9 kHz up to 3.2 GHz • -161 dBm/Hz Displayed Average Noise Level (Typical) • -98 dBc/Hz @10 kHz Offset Phase Noise (1 GHz, Typical) • Total Amplitude Accuracy < 0.7 dB $ • 1 Hz Minimum Resolution Bandwidth (RBW) 1595+

SDM3000X Series Digital Multimeters • 4 1/2 - 6 1/2 Digit Resolution • True RMS AC Voltage & AC Current Measuring • 200mV-1000V DC, 200uA-10A DC • Built-in Cold Terminal Compensation for Thermocouple $ • EasyDMM Sensor Measurement Control 389+

SPD3000X Series Linear Programmable DC Power Supplies • 4.3” TFT-LCD Display • Real Time Wave Display • 3 independently Controlled Isolated Outputs • [email protected], 2.5V/3.3V/[email protected], Total 220W $ • Output Short/Overload Protection 389+

www.saelig.com•[email protected]•1-888-7SAELIG (1-888-772-3544)

Full Page.indd 3 1/2/2018 9:21:44 PM TOC - Feb 18_TOC NV Mar 15.qxd 1/2/2018 4:41 PM Page 4 February 2018 14 Build the IoT Sump Pump 22 The Arduino Graphics Interface Although the device described here will send a text as a sump pump warning, this project applies to pretty much — Part 1 anything with an appropriate sensor. An open door or See how to turn an Arduino Due and a leftover analog window, a tripped laser beam, a pressure change on a oscilloscope into a high resolution computer graphics pressure plate, a proximity sensor, etc., could all be display. converted into a text message warning. ■ By Ed Andrews WA9UQN ■ By Mirza Kolakovic 30 Light Bulbs, LEDs, and Circuit 19 Rebuilding a Tektronix THS7X0 Junctions Portable We’ll take a look at some specific electrical properties of both light bulbs and LEDs, and use them to discuss Oscilloscope junctions in DC circuits. Battery Pack ■ By Tom Bensky When batteries fail, they can 36 A Digital Analog — Part 4 be replaced or rebuilt, but it’s This installment in a usually at considerable recurring series expense. Here’s one examines the more application where a very complex circuits expensive battery pack can be from 555 Timer IC easily rebuilt at a fraction of Circuits by Forrest the replacement cost, Mims, which are returning the device to useful variations on audio portable service. oscillators. ■ By Kevin O’Connor ■ By Larry Cicchinelli Columns 06 Q&A 52 The Design Cycle Reader Questions Answered Here Advanced Techniques for Design Topics discussed this month: Engineers • Neuter the Spray Smartphone App Programming for • A Clearly Better Baby Monitor Remote Control 09 Open Communication This month, we’ll add Basic for iPhone (B4I) and Basic for Android (B4R) to your Design The Latest in Networking and Cycle, and put your iPhone to work as a Wireless Technologies remote control device. We’ll write the iPhone Connected Cars are Coming code using B4I and code up an I/O pin switch Cars are already loaded with communications server using an inexpensive WEMOS D1 mini technology. AM, FM, and satellite radios are and B4R. common, as is a GPS receiver for the navigation system. In the coming years, we’ll be seeing new wireless systems incorporated into every vehicle for improving Departments safety and for aiding in the implementation of self-driving cars. Here’s an update on this communications 05 DEVELOPING 46 NV WEBSTORE PERSPECTIVES 60 TECH FORUM technology. Electronics Padawans 64 CLASSIFIEDS 12 NEW PRODUCTS 64 ELECTRO-NET 48 Near Space 13 SHOWCASE 64 AD INDEX Approaching the Final Frontier Total Solar Eclipse Near Space Flight: Part 2 Subscription Information A lot of data was collected on my eclipse near space Nuts & Volts — PO Box 15277 flight; unfortunately, not as much as I hoped (some North Hollywood, CA 91615-9218 experiments failed to record data at the appropriate time). Call 877-525-2539 or go to www.nutsvolts.com Still, there was enough data for a second article and I’d Subscribe • Gift • Renewal • Change of Info like to share three of the results with you. For more details on subscribing, see our ad on Page 62.

Nuts & Volts (ISSN 1528-9885/CDN Pub Agree #40702530) is published monthly for $26.95 per year by T & L Publications, Inc., 430 Princeland Court, Corona, CA 92879. PERIODICALS POSTAGE PAID AT CORONA, CA AND AT ADDITIONAL MAILING OFFICES. POSTMASTER: Send address changes to Nuts & Volts, P.O. Box 15277, North Hollywood, CA 91615 or Station A, P.O. Box 54, Windsor ON N9A 6J5; [email protected]. 4 February 2018 Bergeron - Developing Perspectives - Feb 18_Dev Perspectives - ReadFeed Feb15.qxd 1/2/2018 4:44 PM Page 5

by Bryan Bergeron, Published Monthly By Editor T & L Publications, Inc. 430 Princeland Ct. DEVELOPING Corona, CA 92879-1300 PERSPECTIVES (951) 371-8497 FAX (951) 371-3052 Webstore orders only 1-800-783-4624 Electronics Padawans www.nutsvolts.com t’s great to have enthusiastic self- as possible. Subscription Orders Imotivated students — of any age — In my experience, this doesn’t Toll Free 1-877-525-2539 that are into electronics. The mean shielding the student from Outside US 1-818-487-4545 challenge — at least based on my failure. Far from it! You want your P.O. Box 15277 experience teaching teenagers — is student to fail — gracefully — and North Hollywood, CA 91615 making the students appreciate the come back for more. On each repeat FOUNDER relatively long process of mastery. attempt, students should be Jack Lemieux As the Jedi Padawans sensitized as to what they need to PUBLISHER demonstrate in Star Wars, acquiring do, how to do it, and how much time Larry Lemieux the first 80% of knowledge and skills they’ll have to do it in. [email protected] may take a few weeks or months, but If you’re the parent of a ASSOCIATE PUBLISHER/ getting a handle on the remaining Padawan, then you can do your part ADVERTISING SALES 20% usually takes years of study and by recognizing when your son or Robin Lemieux practice under the leadership of a daughter needs help. They may resist [email protected] master. actual hand-holding, but probably EDITOR To the uninitiated student, this won’t say no to a modest budget for Bryan Bergeron often seems absurd. They may have parts, tools, and equipment. [email protected] learned how to rid the planet of alien I went through a good half CONTRIBUTING EDITORS invaders and conquer dozens of dozen or so microcontrollers when I Fred Eady Kristen McIntyre Lou Frenzel Paul Verhage planets in a matter of weeks using a was first learning the limits of the Ed Andrews Larry Cicchinelli PlayStation or Xbox. technology. I still manage to Tom Bensky Mirza Kolakovic How much longer could it take occasionally fry the analog input to a Kevin O’Connor to learn the nuances of, say, a processor when I’m working with CIRCULATION DEPARTMENT microprocessor? Or, mixed 3V and 5V devices. [email protected] how to design and work with surface- No Padawan’s path to mastery SHOW COORDINATOR mount components? can be complete without the sharing Audrey Lemieux Well, if you’re new to electronics, of skills and knowledge with others. then you’ll soon find that — as in just Today, it’s more likely to come about WEBSTORE MARKETING COVER GRAPHICS about every other endeavor — there’s through social media than face-to- Brian Kirkpatrick an art involved, and mastery of that face meetings. Still, there is value in [email protected] art takes time and focused study. sharing with others going through the WEBSTORE MANAGER/ This isn’t to say that you can’t same process. PRODUCTION start enjoying the hobby from day Mentors are invaluable, but the Sean Lemieux one; it’s just that you’ll have to match hive mind of dozens or hundreds of [email protected] your expectations with your eager learners who are also willing to ADMINISTRATIVE STAFF experience. share has value as well. Re Gandara For example, don’t expect to be Best of all worlds is a mentor- able to repair your flat screen moderated forum or actual meeting, Copyright © 2018 by T & L Publications, Inc. All Rights Reserved computer monitor without a year or where students provide the creativity All advertising is subject to publisher’s approval. We two of experience, preferably under and the mentor provides a degree of are not responsible for mistakes, misprints, or the guidance of a master or mentor. “grounding” in what’s likely to typographical errors. Nuts & Volts Magazine assumes no responsibility for the availability or condition of If you’re a mentor to someone succeed. advertised items or for the honesty of the advertiser. new to the hobby, then you may Whether you’re a Padawan or The publisher makes no claims for the legality of have your hands full. You’ll have to helping one along their journey any item advertised in Nuts & Volts. This is the sole responsibility of the advertiser. Advertisers and their keep the overall objectives in mind — toward the mastery of electronics, agencies agree to indemnify and protect the publisher teaching, for example, the concept of may the EMF be with you. NV from any and all claims, action, or expense arising from resonance in an LC circuit — while advertising placed in Nuts & Volts. Please send all editorial correspondence, UPS, overnight mail, and making the experience as enjoyable artwork to: 430 Princeland Court, Corona, CA 92879. February 2018 5 Q & A ■ WITH KRISTEN A. McINTYRE In this column, Kristen answers questions about all aspects of electronics, including computer hardware, software, circuits, electronic theory, troubleshooting, and anything else of interest to the hobbyist. Feel free to participate with your questions, comments, or suggestions. Send all questions and comments to: [email protected].

that this basic circuit is not augmented for some common dimmer problems, like hysteresis and RF • Neuter the Spray noise. An SCR (Silicon Controlled Rectifi er) has the property that once turned on by a current fl owing • A Clearly Better Baby Monitor into the gate, current will fl ow from the anode to cathode even if the gate current is removed, and until the anode-cathode current goes away or the Neuter the Spray voltage relationship reverses, reversing the current. So, you I have a kitchen mixer that comes up to full turn it on and it stays stuck on (or latches) until a reversal, power gradually after it’s turned on to prevent which is what we care about in this case. ingredients from being fl ung around. I also Figure 2 shows a transistor equivalent circuit of an Qhave a router with the same feature to prevent SCR. Note that this is not a practical circuit, but instead is jerking when it’s turned on. Each of these tools takes about just a way of showing how it acts. Real world transistors a second to come up to full power but is much easier to would not be happy with the amount of base-emitter use because of this feature. I also have a hand (immersion) current in this confi guration. blender that I use in the kitchen that doesn’t have this A TRIAC is a pair of SCRs that are connected back-to- capability and more often than not it sprays ingredients all back so that we can have current fl ow in both directions, over when I turn it on. with the same property where one or the other SCR gets I want to make a device to plug the hand blender into stuck on until a voltage reversal. that will bring it up to full power gradually (over a second, Since the input waveform is a 60 Hz (or 50 Hz) sine more or less.) The hand blender is rated at 400 watts, 120 wave, roughly, we can decide when to turn on the TRIAC volts, 60 Hz. What approach would you take to implement in the cycle, and it will stay on until the next zero crossing. such a device? If we turn it on early, we get an almost unmodifi ed 60 Greg Cook KE7DO Hz waveform. If we turn it on late, we get just part of the cycle. You can see an example of the input (in blue) and This is a very interesting question. Since I don’t output (in red) waveforms in Figure 3. The red waveform know much about the internal construction of is near zero until the turn-on point, and then it tracks the the hand mixer (for example, the motor type), input blue waveform. Athe best approach might be to use a dimmer style circuit to bring it up slowly. This can be done externally without using an external switch to turn it on, I think. If we’re really clever, we can use the load itself to activate the circuit. A basic light dimmer looks something like what we have in Figure 1. The circuit operation is actually fairly simple if you understand how a TRIAC (or its simpler cousin, the SCR) functions. It assumes that we can control whatever the load is by a form of pulse-width modulating the AC line, ■ FIGURE 2. Silicon Controlled though it’s not precisely a pulse. Note ■ FIGURE 1. Basic TRIAC dimmer circuit. Rectifi er equivalent circuit. 6 February 2018

McIntyre - Q&A - Feb 18.indd 6 1/2/2018 6:36:17 PM QUESTIONS and ANSWERS Post comments on this article and find any associated files and/or downloads at www.nutsvolts.com/magazine/issue/2018/02. In this column, Kristen answers questions about all aspects of electronics, including computer hardware, software, circuits, electronic theory, troubleshooting, and anything A related device is a DIAC, which is like a pair of else of interest to the hobbyist. Feel free to participate with your questions, comments, or back-to-back non-linear diodes (actually Shockley diodes, not to be confused with Schottky diodes) that are off until suggestions. Send all questions and comments to: [email protected]. a certain voltage threshold is reached. When they turn on, they become like negative resistors, where the higher the current, the lower the voltage across them becomes. This that this basic circuit is not augmented for some gives us a threshold device that is useful for triggering a common dimmer problems, like hysteresis and RF TRIAC. noise. It allows a capacitor to be charged up to a higher An SCR (Silicon Controlled Rectifier) has the voltage to control when we turn on the TRIAC, and then property that once turned on by a current flowing discharged rather rapidly to both turn the TRIAC on into the gate, current will flow from the anode to suddenly and with more current, and reduce the capacitor cathode even if the gate current is removed, and voltage for the next half-cycle. until the anode-cathode current goes away or the Going back to Figure 1, you can see that the gate voltage relationship reverses, reversing the current. So, you of the TRIAC is controlled by the input waveform itself, turn it on and it stays stuck on (or latches) until a reversal, mediated by the DIAC. The TRIAC turns on at some point which is what we care about in this case. in the cycle, determined by the charge on C1. It stays Figure 2 shows a transistor equivalent circuit of an on until the cycle reverses, and then the whole process SCR. Note that this is not a practical circuit, but instead is repeats with all of the voltages and currents reversed. What n FIGURE 4. Blender speed ramp-up proposed circuit. just a way of showing how it acts. Real world transistors we want to do is impose a slow time constant on this would not be happy with the amount of base-emitter circuit that will make it start with a late turn-on, and then Here’s a brief explanation. We charge C2 and C3 current in this configuration. eventually move to an early turn-on. on each half cycle with opposite polarities, but the time A TRIAC is a pair of SCRs that are connected back-to- It took me a bit of thinking to come up with an constant is much slower than C1/R1/R2, so that it might back so that we can have current flow in both directions, easy way to do this. I think I tried maybe five different take a few seconds to charge up. I’m not too sure of the with the same property where one or the other SCR gets approaches. I have the final idea inFigure 4. My thought right values here, but you want to adjust the time constant stuck on until a voltage reversal. is to use a pair of transistors to modulate the current in the of C2/R4 and C3/R6 so there is sufficient time at the low Since the input waveform is a 60 Hz (or 50 Hz) sine TRIAC/DIAC trigger circuit. I tried using a second TRIAC speed before it goes to the high speed. I did a simulation wave, roughly, we can decide when to turn on the TRIAC and even a pair of SCRs to change the first one from a late with those values and it gave me a several second ramp-up. in the cycle, and it will stay on until the next zero crossing. phase turn-on (motor slower) to an early phase turn-on R3 and R4 discharge C2/C3 so that the circuit will If we turn it on early, we get an almost unmodified 60 (motor full speed) at some threshold by causing more reset in a few seconds. Those voltages cause Q1 and Q2 to Hz waveform. If we turn it on late, we get just part of the current to flow into C1 early in the cycle. It started taking alternately pull up or down on the trigger circuit, changing cycle. You can see an example of the input (in blue) and too many parts, so I went back to tried and true current its time constant, and thus the phase of the TRIAC’s output (in red) waveforms in Figure 3. The red waveform control, which can provide a gradual increase instead of turn-on. is near zero until the turn-on point, and then it tracks the an instant threshold change. It’s a fun circuit to try to think I’ve added some inductive compensation in the form input blue waveform. about because you must consider the 60 Hz commutation of C4 and R5 since we’re driving a motor. You also would of the top and bottom rails. want to add a fuse. All of the diodes and transistors would need to withstand the worst case commutation peak voltages of around 360V (~125 * √2 * 2), and still be able to handle a little bit of power. Be conscious of secondary breakdown. I’m a little worried that there will be enough voltage between line and load at the commutation spikes to keep it in high speed mode. That can be fixed with a little more thought if it happens. The drive current for the transistors is minimal, so it might be okay, but I’m not sure. Keep in mind that I haven’t built this circuit, though I’ve simulated some portions of it, so proceed with caution. Also, you are dealing with the AC mains, so be very careful. There are lethal voltages here and significant power is going through the TRIAC. Make sure you choose n FIGURE 2. Silicon Controlled n FIGURE 3. Dimmer input and output waveforms - capacitors and TRIACs that can handle sufficient voltage, Rectifier equivalent circuit. Wikipedia CC BY-SA 3.0 user Wtshymanski. current, and power. February 2018 7

McIntyre - Q&A - Feb 18.indd 7 1/3/2018 7:53:24 AM QUESTIONS and ANSWERS

A Clearly Better Baby Monitor means a full wave dipole would be only 8 cm, which is pretty small. We can perhaps enhance the amount of We have a baby monitor system and it works captured electromagnetic wavefront, and by that improve pretty well — except when I move it to the the gain by attaching a resonant wire. garage. Then, it becomes very “static-y.” Is there I managed to find an article on iFixit that describes Qa way to legally modify it to have greater range? fixing the antenna. You can check it out athttps://www. The unit is a VTECH DM221. ifixit.com/Guide/VTech+Safe+And+Sound+DM221+An- Herb Ruiz tenna+Replacement/52562. It tells us where the antenna Seattle, WA is. The antenna is a bent piece of wire that’s near the handle and is mounted roughly horizontal when the device To steer clear of violating FCC Part 15 is standing upright. With that in mind, let’s get some wire. regulations, it’s probably best to try to improve Try cutting a piece of wire (anything convenient is fine the receive side as opposed to the transmit — the type isn’t that important) for a full wavelength (about Aside of the monitor. The transmitter is probably six inches long). We’re going to try to couple some of the very low power, so any significant attenuation through your RF to that at a low impedance part of the antenna, which house will cause the receiver’s digital demodulator to not should be about one-quarter wavelength in from one side. be able to decode the modulation without errors. Affix the wire with tape or some other suitable adhe- This particular system has a “parent unit” that can sive at about 1.5 inches from one wire end and centered transmit as well as receive, using its Talk Back feature, so I on the top of the parent unit, and then raise the long don’t advise transmitting with any modifications in place. end. Either hang it from something or attach it to some The thing that would be easiest to modify is the antenna non-metallic support — even a wall. That should passively system. Looking at the user manual, this device operates couple the radiator to the internal antenna. Ideally, that just below the 2 GHz band. There is no specified power for will improve your signal-to-noise ratio enough to make the the transmitter. audio decode better. Playing with the orientation of the Antennas for that band can be quite small since the wire or its height might also yield improved results. NV wavelength is only about 16 cm (about six inches). This

8 February 2018

McIntyre - Q&A - Feb 18.indd 8 1/2/2018 6:31:52 PM ■ BY LOU FRENZEL W5LEF OPEN COMMUNICATION Connected Cars are Coming Embedded radios promise to improve safety.

ars are already loaded with communications technology. AM, FM, and satellite radios are common, as is a GPS receiver for the navigation system. Some vehicles C also have digital HD radio capability. Then, there is Bluetooth connectivity for hands-free operation of your phone or for patching your music to the vehicle sound system. Cellular technology is also common in some newer vehicles; GM’s OnStar is one example. Embedded Wi-Fi to LTE hot spots is another.

But that’s not all. In the coming years, we will to-vehicle (V2V). Vehicle to nearby road side units is be seeing new wireless systems incorporated into referred to as vehicle-to-infrastructure (V2I). A vehicle-to- every vehicle for improving safety and for aiding in everything is known as V2X. the implementation of self-driving cars. Some of this With V2V, cars will be able to tell others nearby their technology has already been defi ned, but decisions about exact location as well as their speed, brake, or turn status what standards to use and when are still up in the air. Here and other factors. The vehicles will also get traffi c, road is an update on this communications technology. conditions, weather, and other information via V2I roadside units or remotely from a V2X network. Why Connect Cars? With this added information, the driver can make better decisions. Even automatic actions in Advanced Why do we want vehicles to speak to one another? Driver Assistance Systems (ADAS) can take place, The main reason is to improve safety. Statistics say that enhancing the driver’s ability and managing errors. Overall, about 35,000 to 40,000 people are killed each year safety should be greatly improved. in auto accidents and millions of others are injured. The government -- in this case, the National Highway DSRC is Ready Now Transportation Safety Administration (NHTSA) -- believes that communications between vehicles and other sites can DSRC stands for Dedicated Short Range aid signifi cantly in reducing the death rate and injury level. Communications. It’s one of the wireless technologies Figure 1 illustrates the concept where cars are talking developed for and approved by the NHTSA. DSRC is a to one another automatically and to nearby information variant of Wi-Fi designated by its IEEE standard 802.11p. sources. Direct car-to-car communications is called vehicle- It operates in 75 MHz of spectrum in the 5.9 GHz unlicensed band and uses OFDM modulation. Seven 10 MHz channels have been defi ned, and data rates can range from about 3 Mbps to

Figure 1. Eventually, all vehicles will have some V2X communications capability. However, V2X will not work successfully until the majority of vehicles have it.

27 Mbps. The range can be as far as 300 meters to one kilometer. Figure 2 shows the basic components of a DSRC system. The radios transmit a Basic Safety Message (BSM) ten times a second. It contains the GPS location, speed, direction, brake status, turn February 2018 9

Frenzel - Open Communication - Feb18.indd 9 1/2/2018 2:33:05 PM THE LATEST IN NETWORKING AND WIRELESS TECHNOLOGIES Post comments on this article and find any associated files and/or downloads at www.nutsvolts.com/magazine/issue/2018/02.

Figure 2. The major subsystems of a DSRC system are shown here.

built. In addition, C-V2X has a clear upgrade path as it will follow the LTE standard as it morphs into the forthcoming 5G New Radio cellular standard being developed. That may be a moot point as the NHTSA has already proved and blessed DSRC. Recently, however, the Trump administration cancelled the mandated inclusion of DSRC or other V2V technology, sighting over-regulation. While the idea has not been killed off completely, it has been relegated to a long-term objective. We may see it status, and other similar information. Nearby vehicles get again. This will give C-V2X more time for testing and the message and send out their own. All the cars within a investment, meaning that it could eventually be chosen given area know where everyone is located and what they over DSRC. are doing. It’s not clear at this time what standard the auto Intelligent software will determine potential conflicts manufacturers will adopt. and generate warnings to the drivers. Some vehicles may tie the DSRC outputs to the ADAS that may further activate ADAS and Self-Driving Cars automatic braking or engage steering control. Fully automated vehicles (AVs) — commonly referred Cellular V2X to as driverless vehicles — actually do drive themselves. There are various stages of autonomy as shown in the DSRC has been around for years, and it has been accompanying Table 1. In the simplest form, AVs are tested and approved by the NHTSA. Chips and modules basically an extension of ADAS that are common on many are for sale because it’s all ready to go. However, only one vehicles. model of Cadillac has one installed. The rollout has been ADAS include things like: stalled because a competitive technology has been put yy Back-up camera. A dashboard screen really aids when forth by several companies. going in reverse. Called cellular-V2X or just C-V2X, the technology is yy Lane departure warning. Cameras follow the white and based on the current cellular radio standard Long Term yellow stripes, and signal when you stray. Evolution (LTE). The C-V2X version of LTE permits direct yy Blind spot detection. Detects objects and vehicles on V2V, a broadcast mode, as well as connections to the either side. existing cellular networks to access networks that may be yy Adaptive cruise control. Speed is automatically relevant. adjusted to the prevailing traffic. As for specs, C-V2X operates in the same 5.9 GHz yy Automatic braking. Activates brakes when objects are spectrum and has a similar range and data rate. One detected; front or back. touted feature is a lower latency (delay or response) time Additional ADAS features include: than DSRC. It too will transmit and receive the BSMs and yy Tire pressure monitoring. generate warnings and vehicle action. yy Adaptive lighting. Automatic high beam control and C-V2X has not been as widely tested as DSRC. rotating headlights for curves. Nevertheless, it’s a proven wireless standard that should be yy Driver monitoring. Detects drowsiness or inattention, more than competitive. and initiates a warning or active correction. yy Automatic parking. Makes parallel parking easy. What Technology Wins? yy Night vision. Infrared cameras let you see in the dark. It’s difficult to predict which standard will win the All of these features are designed for safety. They help automotive marketplace. Both will serve the purpose the driver with warnings, or may actually take control from well. C-V2X has the advantage of being able to use the the driver when the driver fails to react to a potential crash existing cellular network infrastructure for V2I and V2X situation. applications. A DSRC infrastructure would have to be ADAS are implemented with a mix of sensors. These 10 February 2018

Frenzel - Open Communication - Feb18.indd 10 1/2/2018 2:33:27 PM THE LATEST IN NETWORKING AND WIRELESS TECHNOLOGIES

include: AVs sometime in the future. yy Video cameras. These provide good detection of For the elderly, handicapped, blind, or other objects and color, but often have poor night time compromised drivers, AVs may be a real solution to their operation. transportation needs. For people who enjoy owning certain yy IR cameras. These detects heat, giving extra detail -- cars and driving, AVs aren’t really a practical idea. especially at night. AVs are more of a transportation appliance and not a yy Radar. Short range radar can detect vehicles over a source of image, skill, pride of ownership, and driving fun narrow view for several hundred feet and can help represented by real cars. The NHTSA’s claim that AVs will measure speed. save lives has yet to be proven. yy LIDAR. Light detection and ranging. Radar with infrared (IR) light. Uses IR laser to generate a 360 Looking Ahead degree view over a short distance to aid in object recognition. Some final thoughts from my perspective: yy Ultrasound. Ultrasound detectors operate a short yy ADAS work great! I have most of the basic features distance, but provide positive detection of objects. in my new SUV and they do indeed add to safe driving in today’s demanding, competitive, and brutal driving In the coming years, the current ADAS will eventually environment. The backup camera and automatic braking be complemented by the V2X communications capability, have saved me multiple times. The adaptive cruise control providing even greater safety. Even though the most recent makes highway driving easier. mandate has been cancelled, we should see another yy It takes time to learn the various ADAS features mandate in the future as V2X will be needed for self-driving and adapt to the warnings and responses. The goal of vehicles as well as for enhanced ADAS. manufacturers should be to maximize the benefits while not overloading the driver with distracting warnings. What Makes AVs Work is Software Human interface design is critical. yy Will V2X communications systems increase the It takes in all the sensor and communications distractions with more and different warnings? information, attempts to identify objects and a wide range yy Will drivers need training to learn the use of ADAS, of driving scenarios, then makes decisions about braking, V2X, and other safety systems? Who will offer this? accelerating, steering, or otherwise. yy Will AVs actually save more lives? Or, when AVs are This “sensor fusion” software uses artificial intelligence mixed with human drivers, will there be more collisions techniques including machine vision, machine learning and dust-ups than ever? with neural networks, and deep learning. This software yy What do the insurance companies say about all this? requires massive data processing capability which currently Who is to blame in an AV accident? The passenger, the is being provided by multicore processors and/or graphics other passenger, a driver, the car manufacturer, or? processors from Intel, AMD, Nvidia, and a few others. yy Bottom line, I am all for ADAS and V2X systems. From AVs are not ready yet, but manufacturers are frantically my experience, they will and do make us safer. It won’t developing them. Most estimates put availability out five surprise me if AVs end up as a minor auto market niche. years or more. Surveys indicate that potential buyers would yy All the R&D related to AVs is positive as it will not yet purchase an AV; a lot of consumers say they are accelerate improvements in the sensors, processors, and afraid of them. Yet, the push is on, and we are going to get software that can be used elsewhere. NV

Table 1. Source: Society of Automotive Engineers Level Degree of Automation 0 No automation. A human driver performs all tasks. 1 Driver performs all functions, but ADAS may provide partial control of steering, braking, and acceleration. Partial automation. Automated systems control braking, steering, and acceleration, but driver is still “on call” to 2 monitor conditions and take control if necessary. Conditional automation. Automated driving systems handle all driving activities, but the driver must still be 3 available to take control as required. High automation. Automated driving systems perform all driving tasks. Driver may still control the vehicle if 4 needed. 5 Full automation. No driver needed, but a driver may take over if required. February 2018 11

Frenzel - Open Communication - Feb18.indd 11 1/2/2018 2:33:42 PM NV New Products - Feb 18_Mar15 -NV - NewProducts.qxd 1/2/2018 4:46 PM Page 12

■ HARDWARE ■ SOFTWARE NEW ■ GADGETS PRODUCTS ■ TOOLS

SERVO TO SHAFT COUPLERS ervoCity is now offering both a 24- Stooth (C1) spline and a 25-tooth (3F/H25T) spline servo to shaft clamping couplers for $4.99. These patented servo to shaft couplers offer a simple and solid way to attach a shaft in-line with the output spline of a servo. CASCADING X-RAIL SLIDE KIT lso available from ServoCity is their Acascading X-Rail slide kit for $119.99. This kit provides the mechanical pieces necessary to build a winch-driven extendable arm. Fasten a motor or HS-785HB servo to the first stage of the slide kit and spool up the provided synthetic cable to get up to 34.5" of arm extension. The cascading X- Rail slide kit uses bearings throughout; each stage is supported by standard V-Wheels that lock into the chamfered guides of the X-Rail. The synthetic cable is routed over ultra smooth V-bearings so the torque provided by the servo or motor can be transformed into linear thrust rather than lost due to friction. The arm at full extension is rated for a 2 lb load; this makes it ideal for adding a gripper or grapple hook.

1.25” WINCH PULLEY

he 1.25" winch pulley available for $4.99 from ServoCity works well Twith string or heavy-duty fishing line such as their synthetic cable. The pulley is able to fasten to any hub or component with the 0.770" Actobotics hub pattern. The included screws protrude through the pulley 12 February 2018 NV New Products - Feb 18_Mar15 -NV - NewProducts.qxd 1/2/2018 4:46 PM Page 13

by 0.250"; the proper length when going into an Actobotics clamping or set-screw hub. The pulley has For more information, contact: multiple cut-outs to give you options on how to fasten ServoCity www.servocity.com your string onto the spool and begin winding it up.

UPDATED FIELD • Dual-color indicator shows ready/ 2540C series include: busy states and flashes error codes PROGRAMMER • In-Circuit Serial Programming • Eight inch wide screen color LCD E Labs 2018 Field Programmer (ICSP) connector for interface to display Mhas been updated to make this project board • Compact footprint and lightweight useful tool even better. • Full-featured software included with • 70, 100, and 200 MHz models The new Field Programmer now support for ICSP-capable PIC® • 1 GSa/s sample rate interleaved includes a USB power input. When MCUs • 14 Mpts maximum record length power is not available from the target • Flash firmware easily upgradeable • 16 digital channels with logic board, the Field Programmer (and the to add support for future devices analyzer (MSO upgrade) target) may be powered by a USB 5V • Compatible with Microchip hex • Serial bus decoding supporting I2C, source through a USB micro adapter format files (after conversion using SPI, UART/RS232, CAN, and LIN (phone charger). the supplied software) protocols (Decode upgrade) This allows the Field Programmer • Built-in function and arbitrary to be used for production For more information, contact: waveform generator comes programming, supplying power to ME Labs, Inc. standard on all models each target in turn. The target supply www.melabs.com • 60,000 wfms/s maximum voltage is selectable for 5V or 3.3V. This updated version is available MIXED SIGNAL Continued on page 58 starting at the same price of $119.99. Quantity discounts are available. OSCILLOSCOPE Field Programmer features &K Precision announces the next include: Bevolution of their mixed signal oscilloscpe 2540 series, with the • Can be powered by built-in USB 2540C series DSO and MSO models. micro connector (default of 5V, The front panel boasts a large 8" switchable to 3.3V) wide screen with 256-level color gradient, two analog channels, and logic analyzer. The logic analyzer software and 16-channel logic probe are included in the initial purchase of MSO models or can be upgraded in the field for DSO models. The 2540C consists of features customers have come to expect from modern digital oscilloscopes. These features Stock Drive Products include FFT, masking, pass/fail Setting Ideas Into Motion testing, waveform history, serial One-Stop Shop for triggering, and menu help. M The powerful 25 MHz function generator also comes EXEXPLORE standard in all models (a $400 DEDESIGN value). Additionally, the 2540C BUBUY ONLINE series delivers advanced features and upgradable debug w no minimum requirement capabilities for a wide range of applications. Price is $979. Key features of the new February 2018 13 Kolakovic - IoT Sump Pump - Feb 18_Blank Project NV.qxd 1/2/2018 4:49 PM Page 14

BUILD IT YOURSELF By Mirza Kolakovic Build the IOT SUMP PUMP (or Pretty Much Anything IoT)

■ FIGURE 1. IoT sump pump. Call me Noah. For I am here to save you from the flood. Or, at least save whatever sort of precious treasure you store in your basement.

14 February 2018 Kolakovic - IoT Sump Pump - Feb 18_Blank Project NV.qxd 1/2/2018 4:49 PM Page 15

Post comments on this article and find any associated files and/or downloads at www.nutsvolts.com/magazine/issue/2018/02.

y campaign against infiltrating water began when I moved to a location with a Mhigher water table that required the assistance of a sump pump to keep water out of the basement. This is particularly worrisome during the snow melts and heavy rains of the spring. As every sump pump will one day expire, backup systems are needed to prevent basement flooding. The device I created provides a first line of defense against a flood. It will alert the user via text message that the water level has risen above the sump pump’s ■ FIGURE 2. Project big picture. maximum level, thereby indicating a pump failure. This alert could potentially enable the user to return home will text me to let me know. and drop in a replacement pump prior to any flooding occurring. Email to Text Although the device described here will send a text as a sump pump warning, this project applies to pretty much To avoid utilizing third-party servers/gateways to send anything with an appropriate sensor. An open door or an email or text, I use CC3200 SDK and my Gmail window, a tripped laser beam, a pressure change on a account. The way it works is that on CC3200, I run an pressure plate, a proximity sensor, etc., could all be SMTP client that connects to my Gmail account. Once converted into a text message warning. connected, it sends an email message to my mobile carrier’s SMS gateway, which sits on the mobile network Project Overview that delivers the message. All you need is a phone number and an SMS gateway domain name. My goal for this project was to design a device that In my case, the Verizon SMS gateway domain is will monitor the sump pump water level and text me if the vtext.com. So, I send an email to [email protected], water level gets too high. The device design parameters where 1234567890 is my phone number. All email and included: must be battery powered; have Wi-Fi capability; Wi-Fi settings for the project are stored in a config.h file. and the ability to send an email or text. I chose to go with Texas Instruments’ CC3200 LaunchPad, which is the Hardware Design evaluation board for the CC3200 Wi-Fi wireless microcontroller (MCU). LaunchPad comes with a built-in CC3200 is a SoC (system on chip) that consists of an in-circuit debugger, LEDs, switches, ARM M4F core for application sensors, and two 20-pin connectors. software processing, SimpleLink (the For water level sensing, I Wi-Fi network processor subsystem), selected a reed switch commonly 256 kB RAM, and peripherals. used in aquariums. The switch is SimpleLink has its own dedicated hermetically sealed in the body of ARM MCU that completely off-loads the device, while a magnet is the application MCU. It also located within the float ring. The includes 802.11bgn radio and a bracket for the reed switch was cut TCP/IP stack. This arrangement from a 1/8 in x 2 in x 4 ft piece of simplifies development significantly. aluminum from a local hardware The application MCU runs at 80 store. MHz. User code and user files are The entire design runs off two stored in an external serial Flash (1 AA batteries. To limit the load MB). ROM comes factory current and extend battery life, the programmed with device device is mostly hibernating. It initialization firmware, a bootloader, wakes up immediately if the reed and a peripheral driver library. The switch closes, and it also wakes up power-up sequence is as follows: every eight hours to check the After a PoR (power-on reset), the battery voltage and read the switch. device gets initialized, then the If it finds that the reed switch is ■ FIGURE 3. CC3200 hardware bootloader loads the application closed or the battery level is low, it overview. code from the serial Flash into on- February 2018 15 Kolakovic - IoT Sump Pump - Feb 18_Blank Project NV.qxd 1/2/2018 4:49 PM Page 16

The CC3200 ADC is 12-bit/eight-channel, out of which four channels are available for user applications. The sampling rate is fixed at 16 µs per channel, and the channels are sampled in a round-robin fashion. The pins tolerate a maximum of 1.8V, but full scale is 1.467V. To keep it simple, I chose to implement a divide-by- two resistive divider. Since this will always be connected across the battery terminals, I went with one meg resistors to keep the current consumption low. The drawback to this approach is that the sampling capacitor current will be severely limited, thereby affecting ADC readings. To fix this problem, I placed a 100 nF capacitor across the lower leg of the resistive divider. The CC3200 internal sampling cap is 12 pF and is switched on for 400 ns. So, a much larger 100 nF external cap will supply enough current for the sampling cap to reach the final voltage value of the divider in time to get ■ FIGURE 4. CC3200 functional block diagram. correctly sampled. The simulation in Figure 5 shows the voltage on the sampling cap with and without the 100 nF chip SRAM and jumps to the application code entry point. external cap. There are only a few minor modifications needed for Also, I knowingly compromised the voltage range LaunchPad: measurement and bandwidth. This means the ADC input will get full scale when the battery voltage is 2.9V. Also, 1. Add a resistor divider across the battery terminals the voltage change on the pin will be slower. In this and connect to ADC (analog-to-digital converter) pin 58. application, that didn’t matter since I was only interested 2. Open J2 and J3 so that the yellow and green LEDs in a low point in the battery voltage range. If the battery are not ON in Hibernate mode. voltage dips below 2.4V, a text will go out as a warning to 3. Open J13 to supply the board from the J20 battery replace the batteries. connector. Assuming two AA batteries (not at full capacity) and 4. Depopulate R3 to disable the D1 LED. an average load current about six times higher than 5. Depopulate R20 to disable the D4 LED. expected, the batteries should last well over a year: 2,000 6. Connect the reed switch to wake-up input GPIO mAh/0.1 mA = 20,000h ~ 833 days. (general-purpose input/output) #13. Whenever the reed switch input is sampled, it’s also debounced. The pin is pooled every 10 ms, 100 consecutive times. Only if it reads “1” every single time will it return “success.” This will prevent a false alarm. To preserve the batteries, the device is kept in Hibernate mode. In this state, most of the SoC is powered down except the RTC (real time clock) and 2x32-bit OCR registers. ■ FIGURE 5. Voltage on the sampling capacitor with and without an external capacitor in Before the voltage divider. hibernating, the 16 February 2018 Kolakovic - IoT Sump Pump - Feb 18_Blank Project NV.qxd 1/2/2018 4:49 PM Page 17

software enables two wake-up DriverLib as much as possible and sources: RTC (every eight hours) all the DriverLib calls are linked to and GPIO #13. The reed switch ROM (functions with “MAP” in and LaunchPad switch SW3 are prefix). The main function both connected to GPIO #13. initializes the board, reads the Upon wake-up, the core resumes sensors, sends an email if its execution in the ROM needed, and goes into bootloader. While hibernating, the hibernation when done. Every measured current out of the time the device wakes up, it goes battery was close to 8 µA. through the same routine. The first thing the application Software will do is initialize the board. This takes care of setting up the ports Design and pins, UART, and Hibernate The software development mode. Next, it will check the was done using Code Composer battery voltage level. If the Studio (CCS): a free integrated battery voltage level is low, the development environment (IDE) ■ FIGURE 6. application will send an email with a compiler/debugger. CCS is Code flow. warning. It will also read the reed a very powerful tool, but it takes switch. If the switch is off, the some time to get to know it. board goes into hibernation. There are lots of videos on CCS The board will again wake up on the web, so I won’t go into in eight hours (or on a closed details on how to use it here. switch). However, if the switch is on, the application will CC3200 has three SOP (Sense On Power) pins. The send an email, disable wake-up input, and set the timer to state of these pins defines what mode CC3200 will be in wake up in 60 minutes. This will avoid email after power-up. SOP[2:0]=0b000 instructs the bootloader bombardment. to load the application from the serial Flash to the internal If the sump pump gets fixed by the time the board MCU RAM. SOP[2:0]=0b100 instructs the bootloader to wakes up, then everything continues as if nothing enter “download” mode. This mode is used to program happened, and the board goes into hibernation for the the application to the serial Flash. This is done with the next eight hours. However, if the sump pump reed switch help of a UniFlash tool. is still on, an email goes out again. Once the image is programmed, J15 can be removed If everything goes right with the AP connection and and the board reset. At that point, the application code is an email gets sent, all three LEDs will turn on before going to get loaded from the serial Flash to SRAM and hibernation. If there is a problem with the connection to executed. During development/debugging, I have J15 on the AP, an orange LED will flash. If there is a problem with (SOP[2:0]=0b100), which will keep the bootloader in sending an email, a green LED will flash. “wait” mode so the application won’t be automatically running. Additional The application is non-OS based. The logic is very simple and robust, which keeps code to a minimum but Considerations still accomplishes the objective. Also, I used CC3200 An SMTP client is part of CC3200 SDK, and it will create a socket, connect, authenticate, create, Texas Instruments CC3200 LaunchPad and send packets to an SMTP server for you. I www.ti.com/tool/CC3200-LAUNCHXL#buy won’t go into details on how the SMTP protocol Uxcell DC100V 75 mm stainless steel float switch works here, but there is an excellent “Email” https://www.amazon.com/gp/product/B01LZ098GO/ref=oh_aui_detail example included with SDK. Also, you should page_o01_s00?ie=UTF8&psc=1 check out the original SMTP spec created in Enclosed two AA battery holder 1982, RFC 821. https://www.radioshack.com/products/radioshack-enclosed-2-aa- Needless to say, you’ll need a Gmail battery-holder account. You must set your username, password, Capacitors: 10 nF and two 100 nF phone number, and your AP access parameters Resistors: 1K ohm and two 1 mohm PARTS in the config.h file. In addition, you may have to 1/8 in x 2 in x 4 ft piece of aluminum bar LIST change your Gmail account settings and enable Velcro™ and zip ties access for less secure apps. Also, I have my AP February 2018 17 Kolakovic - IoT Sump Pump - Feb 18_Blank Project NV.qxd 1/2/2018 4:49 PM Page 18

that I can still get warnings. This project was done using CCS 7 and CC3200 SDK 1.2. Necessary files for this project are available in the article downloads or at https://github.com/ mkolakovic/ IOTSumpPump. You may need to change project settings and redefine paths to your CCS and SDK libraries. All development software is free, available for download, and ■ FIGURE 7. Code Composer Studio 7 IDE debug session. without limitations. on a battery backup unit in case of a power outage so Now for the real world problems: Try not to place the board too close to the pump power cable because EMI generated by the pump motor and radiated from the power cable could interfere with the board. If you must install it closer, the input debouncing is robust enough to function. The worst that can happen are false wake-ups affecting battery life. This assumes you have no issue with Wi-Fi in the installation location. You could try putting the board in a metal enclosure, but then you’ll need a whip antenna (that would be just fine). Another issue is running the reed switch cable in parallel and next to the power cable. This could cause high voltage transients from the pump power cable to couple to the reed switch cable. Since there is no TVS on the CC3200 reed switch input, transient could potentially damage the SoC. A TVS on the reed switch input is something I will definitely be adding to this project. So, go ahead and see a movie or meet a friend for coffee, even if it’s pouring outside. Because if your pump decides to go kaput, you’ll get a text warning and will be able to keep all the awesome stuff that you’ve got in the basement safe and secure. NV References www.ti.com/tool/cc3200modlaunchxl www.ti.com/lit/ds/swrs166/swrs166.pdf www.ti.com/lit/ug/swru367c/swru367c.pdf www.ti.com/product/CC3200/datasheet/detailed_ description https://en.wikipedia.org/wiki/SMS_gateway http://processors.wiki.ti.com/index.php/CC32xx_Email_ Demo_Application https://www.ietf.org/rfc/rfc2821.txt 18 February 2018 O'Connor - TEK720 - Feb 18_Blank Rough NV.qxd 1/2/2018 4:50 PM Page 19

By Kevin J O’Connor Rebuilding a Tektronix THS7X0 Portable Oscilloscope Battery Pack

We are accustomed to using portable battery powered devices in most aspects of modern life. With some devices, the batteries are not accessible, rendering the device useless when they fail. Others — such as portable drills — have replaceable battery packs. When they fail, they can be replaced or rebuilt at considerable expense. Seldom is the rebuild option tractable for the do-it- yourself type person. However, I have one application where a very expensive battery pack can be easily rebuilt at a fraction of the replacement cost, returning the device to useful portable service.

The Tek 7x0 Further, the pack is held in place in the scope by spring pressure Series Scopes similar to that of a flashlight; this One of the best portable works to our advantage in devices on the electronics bench fabricating a rebuilt unit. over the last 20 years was the Figures 2a-2c show external Tektronix THS700 series (Figure views of several OEM and 1.) Not only are the THS700s aftermarket battery packs. Note portable, but the dual channel the metal band near the inputs are independently negative end. This isolated to 600V. This is quite circumferential terminal is valuable in debugging off-line connected by a metal strap to electronics in a safe manner. the positive end of the top THS7X0 scopes can be had battery and facilitates charging for $500-$1,000 on the used the pack in an external charger. equipment market. However, the At the bottom of the THS700 battery packs — four C-size NiCd battery chamber is the negative cells — are only good for about terminal spring; the positive three years. OEM replacements terminal is visible as a tab from Tektronix resellers run contact about 1.5” above the about $200, and after-market bottom. While the locking cap packs cost $80-$100. FIGURE 1. Tektronix THS720 scope. has a metal inner surface, there is no electrical connection to the Battery Pack Description scope at this point. Most battery packs are fairly complex arrangements of Disassembly tabbed buttonless sub-C size cells all welded together. The THS7BAT turns out to be much simpler construction. The The only item we want to salvage from the old pack is 4.8V pack contains four C-size cells in a straight stack. the metal band with its connecting strap. Before removing, February 2018 19 O'Connor - TEK720 - Feb 18_Blank Rough NV.qxd 1/2/2018 4:51 PM Page 20

Post comments on this article and find any associated files and/or downloads at www.nutsvolts.com/magazine/issue/2018/02.

FIGURE 2B. OEM rechargeable batteries. battery pack B. Don’t waste the effort using NiCd chemistry. Most newer NiMH batteries will work with any charger designed for FIGURE 2C. NiCD or NiMH, and OEM battery pack C. there is no memory effect. FIGURE 2A. OEM battery The THS700 trickle pack A. charges at about 50 mA, measure the distance from the bottom of the battery to so it can’t overcharge C-size cells. the bottom of the band and the width of the Four C-size NiMH cost about $20 for 3,000 mAh circumferential band. To remove the band, carefully peel capacity (Fry’s Electronics and RadioShack.) This is about the strap from the positive terminal with needle-nose pliers 50% more mAh than OEM packs! You will also need and slide the band off the bottom of the battery pack. about 8” of 1” diameter heat-shrink tubing. Properly dispose of the spent NiCd batteries. Figure 3 shows the preliminary assembly of the new batteries and the final assembly in the tubing. Slide the Assembly new cells into the tubing (paying attention to polarity), and trim the tubing to extend about 1/8” beyond the ends To build a new pack, you will need four new C-size of the assembled batteries. While applying a slight pressure to push the cells together, shrink the tubing carefully with a heat gun. The new cells are likely fully charged, so take care not to short anything! The old band will not fit over the new shrink tubing, so cut the band open near the point where the circumferential ring strap is welded onto the linear strap. Fit the band over the negative end of the pack and locate it based on earlier measurements. FIGURE 3. Rebuilt battery pack. You want the circumferential strap to center on the internal side contact once assembled. Use vinyl tape to hold the band in place, overlapping the band by 1/8” or so at either edge. Refer to the photos, or better yet take some of your own prior to disassembly! Now comes the only tricky part; see Figure 4a for reference. With the band positioned at the bottom, the strap must be soldered to the positive end button of the top battery. With a hot FIGURE 4A. Rebuilt battery pack FIGURE 4B. Rebuilt battery pack soldering iron, quickly positive end view. positive end view. wet the top button 20 February 2018 O'Connor - TEK720 - Feb 18_Blank Rough NV.qxd 1/2/2018 4:51 PM Page 21

FIGURE 5. Rebuilt battery pack in scope.

with solder. Next, fold the strap over to position the contact point. Wet the strap contact point with solder, but do not solder the button yet. You want to insure wetting on the strap first. You may need to roughen the surface a bit. When satisfied, quickly solder down the strap to the button. Four hands can be a big help! A length of tape along the strap will hold it down. Figure 4A shows the finished positive end of the $79 MedeaWiz ® $79 rebuilt pack, while Figure 4B shows Special price! Sprite Special price! the negative end. Triggered HD 1080p Video Repeater No black when Testing No black trigger when Measure the voltage from the ed! looping! negative end to the band. It should Multiple be 4.8V-5V depending on the charge trigger state. Gently fit the pack into the Serial port options battery chamber. 3v or 5v The fit is certain to be tighter levels Simple than the OEM battery, but it should serial fit fine. Position the cut in the band Multiple control away from the internal side contact. baud rates Serial port control of up to 200 files - With status feedback Press and lock the cap into position. Video / Audio looping with a direct pushbutton / PIR trigger input Your THS700 model should Simple 1 byte serial control - Arduino, Pi, Picaxe, Propeller, Stamp, PLC power-up and run for several hours, Purchase Download Manual [email protected] www.MedeaWiz.com so test out several charge/discharge Phone: (618) 797-9951 Team Kingsley LLC We ship world-wide cycles. Remember, the internal Like the Sprite at facebook.com/MedeaWiz for a chance to win one! charger does not appear to be a “fast” charger, so allow 10 hours or more for a full charge. Figure 5 shows the new battery pack inserted Introducing the into the scope. New for 2018 UPDATED Field Programmer

Caveats

I haven’t tested the rebuilt battery pack in a Tektronix external charger. The batteries are not welded 3 PBP™ PICBASIC PRO Compiler together, and the external charger applies no in-line pressure as does the THS700. Finally, if your pack seems stuck Our new UPDATED Field Programmer has all the in the THS700, extract by grabbing Order and details at: features of our PC-based programmers and can the soldered strap with pliers. melabs.com now be carried in the palm of your hand!

So far, I have rebuilt two battery • Stand-alone programmer stores files on packs and am very satisfied with the SD/MMC card. 3-4 hours of operational life between • Draws power from the target board or from charges. NV www.melabs.com USB power adapter.

February 2018 21 Andrews - Arduino Graphics Interface Part 1 of 2 - Feb 18_Blank Rough NV.qxd 1/2/2018 4:54 PM Page 22 The Arduino By Ed Andrews WA9UQN Graphics Interface Turning an Arduino Due into a Vector Graphics Display Part 1: Design Concepts and Hardware Fabrication The early days of electronic computers used teletype machines and line printers, and later, alphanumeric screens and keyboards as their primary input-output devices. As computer usage grew beyond census and accounting applications, the need for improved graphical displays and output devices became apparent.

raphical display terminals using large screen cathode ray tubes (CRT) soon evolved. These displays were essentially G“up-sized oscilloscopes” whose X-Y beam deflection was driven by a computer. Figure 1 shows a specialized XY CRT terminal that was part of SAGE (Semi-Automatic Ground Environment): an early air defense system deployed in the US. By the late ‘70s, Tektronix, Hewlett- Packard, and others sold general-purpose XY graphics terminals able to show graphs, charts, and line drawings of all types. While a far cry from what we take for granted today, these were important stepping-stones in the evolution of computer graphics and display technology. Arduino Graphics Interface FIGURE 1. SAGE air defense system used an XY interactive graphics terminal. As an undergrad electrical engineering student some eons ago, I worked on a MODCOMP (Modular a real time clock (RTC) module and interactive controls to Computer Systems, Inc.) 16-bit minicomputer that featured turn the AGI platform into a “CRT CLOCK” (Figure 2) or a large 19” Hewlett-Packard XY graphics display screen. A other high resolution computer graphics display device. few months ago, I began to wonder: Would it be possible In this article, we’ll focus on the overall concepts, to replace those half dozen racks of circa 1975 circuit design, and hardware fabrication. In Part 2, we’ll minicomputer hardware with one of today’s $50 credit- integrate the hardware to XYscope: the software control card sized computers? and plotting library that enables an Arduino Due CPU + The answer proved to be YES! What resulted, I call the analog oscilloscope to become a high resolution XY Arduino Graphics Interface, or AGI for short. With AGI, graphics display. Let’s get started! you can transform a leftover analog oscilloscope into a high resolution computer graphics display and gain AGI Block Diagram & Operational valuable insights into computer graphics, digital-to-analog conversion (ADC), and advanced Direct Memory Access Overview (DMA) hardware and software techniques. It’s easy to add The block diagram of the AGI is shown in Figure 3. 22 February 2018 Andrews - Arduino Graphics Interface Part 1 of 2 - Feb 18_Blank Rough NV.qxd 1/2/2018 4:54 PM Page 23

Post comments on this article and find any associated files and/or downloads at www.nutsvolts.com/magazine/issue/2018/02.

You can see that a pair of digital- display resolution of 4096 x to-analog converters (DACs) 4096. This exceeds even HD TVs inside of the ATMEL SAM 32-bit and beautifully renders smoth CPU (the heart of an Arduino step-free lines, arcs, and Due) is used to drive the X and Y characters. axes of an analog oscilloscope. Easy to Use — To display Rather than use the normal graphical images, the AGI oscilloscope Amplitude vs. Time programmer simply creates a list display mode, we run the scope of XY integers to define the in X-Y mode. That is, the internal individual points to be plotted. A oscilloscope time base that small background process usually drives the X axis is not automatically sends the point-list used, but rather all XY to the CRT. information for deflecting the Ready to Use — A graphics CRT beam comes directly from and control library of simple the Arduino through the AGI subroutine calls makes it easy to circuits. create and load graphic and To create graphical images alphanumeric content into the with AGI, the programmer need XY point-buffer. The AGI Library only build a list of 12-bit X-Y FIGURE 2. AGI can become a CRT CLOCK! includes: integers that make up the individual points we want to show. One after the other, • Plot POINT, LINE, RECTANGLE, CIRCLE, ELLIPSE, the DACs of the Due receive and convert each XY integer CIRCLE-ARC-SEGMENT, ELLIPSE-ARC-SEGMENT coordinate pair into small X-Y voltages that drive the CRT • Plot CHARACTER, TEXT_STRINGS, INTEGER beam about the oscilloscope screen. The block diagram NUMBERS, FLOATING POINT NUMBERS shows that we also provide a blanking pulse (a.k.a., Z axis blanking) as a third signal to the scope. Complex Graphics Possible — The display list can As with all CRT type displays, one must repeatedly contain up to 15,000 X-Y points so that complex objects send the whole display list to the screen to keep the can be rendered. points visible and refreshed. Even though the points are Fast — The Due is a very fast processor that can very actually flashing at a very high rate, human Persistence Of quickly calculate and store points into the XY display list Vision (POV) causes the displayed image to appear stable array. There’s plenty of processor time available to make and flicker-free. changes in the list, making animated graphics easy. Educational — The AGI is a great introduction to Key AGI Features graphical coordinate systems, X-Y point/vector style computer graphics, and DACs. High Resolution — By using 12-bit DACs, we have a AGI is also a solid demonstration platform to learn

FIGURE 3. Arduino Graphics Interface block diagram.

February 2018 23 Andrews - Arduino Graphics Interface Part 1 of 2 - Feb 18_Blank Rough NV.qxd 1/2/2018 4:54 PM Page 24

and utilize counter-timers and DMA technology. AGI Oscilloscope Requirements Overall plot quality is influenced by the quality and While It’s Pretty Cool, there are performance of the oscilloscope and CRT used. This project works well only with analog oscilloscopes; digital scopes Some Limitations will only produce poor looking output. There are many analog scopes manufactured by The AGI uses an analog oscilloscope for its graphics Tektronix, HP, Phillips, Leader, GW-Instek, and others that output display. You’ll have to dust off your old analog will work well. Used models are often available starting at oscilloscope or perhaps buy a vintage unit off eBay. The less than $50. Look for these key features as you evaluate Oscilloscope Requirements sidebar details the features scope candidates: • Screen size: Larger is better! you need to look for when evaluating possible scope • For best display quality, scope frequency response candidates for use with this project. Since we use an should be 10 MHz or more. oscilloscope as the display screen, the size and display • Scope must support an X-Y operating mode. color is fixed by the cathode ray tube inside the scope. — Scopes that support XY mode typically have panel markings that clearly show XY inputs and settings. While each individual point is displayed on the screen as either ‘full ON’ or ‘full OFF,’ variable brightness is easily achieved by varying the point-density of the dots that make up each graphic feature (more on this in Part 2). Why an Arduino Due? At first, I labored over the multitude of CPU boards available, but it soon became apparent only one board would “Due.” (I know, it’s a terrible pun.) Even though the Beagle Bone and Raspberry Pi families have faster CPUs and more memory, only the Arduino Due CPU includes a pair of DMA-driven on-chip DACs.

Getting XY Data Out to the Scope • Scope must have a Z axis or “Intensity Drive” input. — Check the rear panel of the scope to find this While programmed I/O using an Arduino feature. analogWrite() command is a common way to output data to the DACs, the AGI uses DMA techniques. We’ll discuss this further in Part 2, but for now, suffice it to say that we connect the DMA hardware inside the Due to a COUNTER-TIMER which automatically sends the X-Y data array out through the DACs to the oscilloscope screen at very high speeds. DAC Performance

For the AGI project, the Due provides two DAC outputs; each of which translates a 12-bit unsigned integer into one of 4,096 different analog voltage levels. As measured at the processor DAC pins, the CPU outputs a voltage of 0.5V when converting the integer value 0, and outputs 2.75V when converting the integer value 4095. Dividing this 2.25 volt peak- to-peak voltage range by 4096 means that each step or bit change at the DAC input results in a 550 µV change at the DAC output. These signals are buffered by the AGI circuits before they are sent on to the oscilloscope for display. In addition to resolution, DAC speed is also

FIGURE 4. DAC speed and AGI timing signals. 24 February 2018 Andrews - Arduino Graphics Interface Part 1 of 2 - Feb 18_Blank Rough NV.qxd 1/2/2018 4:54 PM Page 25

important. Speed is defined as the time it takes for the Finally, the Z axis signal Z-Drive (TP10) is used to turn DAC to change its output voltage in response to a change the CRT Spot on (logic 1 = “unblank”) every time a new at its digital input. A perfect DAC would have zero point pair is ready for display on the screen. The CRT Spot conversion time, but reality falls short. The rise times, fall is then turned off (logic 0 = “blanked”) just before the X-Y times, and settling times of the DACs are important to the signals are “moved” to the next point to be plotted. AGI project as they define the rate that can be used to Blanking the beam in this way keeps the display crisp and send points to the scope screen; this, in turn, sets the free of DAC settling times and other point-to-point maximum number of points we can display within our transition artifacts. target POV window of 20 ms. Given the DAC rise and fall times, it’s possible to Since DAC speed is not specified in the ATMEL SAM determine the highest DMA_CLK frequency we can use. datasheet, I wrote a small AGI program to drive the DACs My tests show reliable high quality graphics plotting can from 0 to 4095 and then back to 0, so that I could make be achieved at DMA_CLK frequencies up to 800 kHz. my own “worst case” full-scale speed measurements. Above 800 kHz, the DAC rise and fall time delays begin Using an oscilloscope to monitor the DAC outputs, to distort the graphics display, appearing as incorrectly Figure 4 shows that a full-scale change in output of the plotted points on the oscilloscope screen whenever DAC from 0 to 4095 in one step takes slightly over 300 adjacent members in the XY list are far away from one ns. Similarly, the step going from 4095 back to 0 is seen to another. be about 300 ns as well. Figure 4 also shows a few other aspects of the overall timing. First off, observe that the Using a Timer to Trigger CRT DMA_CLK (TP17) signal (one of the Due Counter-Timers) drives the rate of the DMA transfers and therefore the Refresh pace of digital-to-analog conversions. As noted, we need to repeat the DMA transfer over Next, note that the X and Y conversions follow each and over again to keep the CRT scope screen lit up. To do other in time, with the DAC0 signal (the X axis value) this, the AGI uses a second timer to create a “Time-to- changing first, followed one DMA_CLK cycle later by the Refresh” interrupt once every 20 ms. Every time we DAC1 signal (Y axis). Analog sample and hold circuits are receive this interrupt, a new CRT screen-paint cycle is used to time-synchronize the X and Y signals to one initiated. This repaints the screen 50 times per second, another before they are sent out to the oscilloscope as the above discernable POV flicker rates. X-Drive (TP8) and Y-Drive (TP9) signals for display. With the DMA_CLK frequency set to 800 kHz, it’s

FIGURE 5. AGI power supply circuits.

February 2018 25 Andrews - Arduino Graphics Interface Part 1 of 2 - Feb 18_Blank Rough NV.qxd 1/2/2018 4:54 PM Page 26

FIGURE 6. Analog Circuit section of AGI Details and circuitry. Theory of Operation The AGI schematic is shown shortly in Figures 7-9. I’ve included many test points (TPxx) in the design to facilitate testing and troubleshooting. POWER SUPPLY — Any wall wart that can supply 12-15 VDC at .5 amps can be used to power the AGI circuitry. As shown in Figure 5, onboard linear possible to send about 10,000 points to the screen within regulators provide clean low-noise regulated +9.75V and the 20 ms target refresh interval. When more than 10K +5.0V outputs to power both the AGI analog circuits points are present in the display list, the software driver (9.75V) as well as the logic and Arduino Due CPU (5.0V). will automatically extend the refresh interval as needed so Construction Note: Both voltage regulators U1 and all points can be displayed. Depending on the phosphor U2 get warm and must be mounted to heatsinks. The two decay characteristics of your oscilloscope screen and your devices must use insulating hardware if they share a personal POV sensitivity, you will probably notice the common heatsink or if either heatsink is grounded. Use onset of image flicker when plotting more than about large heatsinks to dissipate more heat if driving the AGI 12,000 points. power input with more than about 12 VDC.

FIGURE 7. Timing and logic.

26 February 2018 Andrews - Arduino Graphics Interface Part 1 of 2 - Feb 18_Blank Rough NV.qxd 1/2/2018 4:54 PM Page 27

X-Y BUFFER AMPS — In Figure 6, you can see that the DAC0 (X axis) and DAC1 (Y axis) signals from the Due are received and buffered by high frequency op-amp U4. Potentiometers are provided at this stage so that signal gain (amplitude) and offset (screen position) for X and Y can be independently set. The gain pot on each output will vary the amplitude within a 1.0V to 4.0V P-P range. The centering pot varies the signal offset so that it can reside anywhere within a .2V to 4.75V window. Final display adjustment will be a combination of these AGI pots, as well as the oscilloscope gain and centering controls; FIGURE 8. My first breadboard prototype. my scope works well with AGI outputs adjusted to 1.5V P-P centered about +2.5 VDC. Due is programmed to be the DMA_CLK. This signal SAMPLE AND HOLD CIRCUITS — As seen in Figure 4, drives the internal DMA operations, but as shown in the DAC0 and DAC1 outputs are not simultaneously output Figure 7, also comes to the outside world through CPU by the Due CPU; the X value is converted first, followed by pin D2. This signal is fed to U6a and U8b to create all the the Y value one DMA_CLK cycle later. Analog switch U5a-b, needed AGI timing signals. Flip-flop U6a divides the hold capacitors C9 and C13, and buffer amps U3a-b make DMA_CLK by 2 to create a signal that represents a point up the pair of Sample and Hold (S/H) circuits that align and pair transfer completed signal or POINT_CLK. The synchronize the X-Y point pair voltages, so they change POINT_CLK_NOT signal is then combined to generate the together when they’re sent to the oscilloscope for display. S/H_PULSE and the SHOW_POINT signals. As depicted in The X and Y buffer amps are followed by transmission gates the timing traces of Figure 4, the S/H_PULSE signal is used U5a-b and output op-amps U7a-b which work together to to “grab and hold” the X-Y voltage pair. Then, the form two independent S/H circuits. SHOW_POINT pulse is sent to the Z axis of the So, how do these S/H circuits work? Looking at the X oscilloscope (a.k.a., “Z-Drive”) to unblank each point after axis path, it shows that whenever transmission gate U5a is it has settled down and is ready to be illuminated. turned on, the X axis voltage output of U4a is connected Build Note: Jumper PL6 is used to select the to C12 and buffer amp U3a. When U5a is turned off, C12 “blanking polarity” and is set to match the blanking logic stores (a.k.a., “remembers”) the voltage, holding the X axis used by our particular oscilloscope. voltage stable even though the DAC output itself begins to BLANKING SYNCHRONIZATION — It might seem a change in response to the next conversion cycle. bit unusual to see the analog output of DAC0 (X axis) also U5b, C10, and U3b perform the same S/H function connected and as a digital input to gate U8f. While this for the Y axis signal. looks a little weird, it’s a vital part of the X-Y axis signal DATA CLOCK TIMING — COUNTER_TIMER_0 of the synchronizing process.

Introduction to Digital-Analog Conversion https://www.allaboutcircuits.com/projects/digital-to- https://www.allaboutcircuits.com/textbook/digital/chpt- analog-conversion-with-the-sam4s-peripheral-dma- 13/digital-analog-conversion controller DMA D/A Conversion with a SAM4S Microcontroller: The The Beauty of Brsenham's Algorithm Timer/Counter http://members.chello.at/easyfilter/bresenham.html 27-Apr-16 Robert Keim https://www.allaboutcircuits.com/projects/dma-digital-to- An Overview of Digital-to-Analog Converters and analog-conversion-with-a-sam4s-microcontroller-the- Specifications timer-cou https://en.wikipedia.org/wiki/Digital-to-analog_converter Understanding & Using the SAM4S Digital-to-Analog Design Spark - Free PCB Layout Software Converter https://www.rs-online.com/designspark/pcb-software 4-May-16 Robert Keim

References https://www.allaboutcircuits.com/projects/understanding- Arduino IDE, Source of Due Hardware, Arduino Libraries and-using-the-sam4s-digital-to-analog-converter https://www.arduino.cc Digital-to-Analog Conversion with the SAM4S Peripheral AGI Hardware Details, Software Library, Sample DMA Controller Programs 9-May-16 Robert Keim https://github.com/Ed-EE-Eng/XYscope

February 2018 27 Andrews - Arduino Graphics Interface Part 1 of 2 - Feb 18_Blank Rough NV.qxd 1/2/2018 4:54 PM Page 28

digital output port D3 called CRT_OFF. When D3 is set to TRUE (logic 1), the CRT beam is forced off no matter what the other signals are doing. When D3 is set to FALSE (logic 0), the CRT beam is ENABLED to flash on for every point plotted to the screen. The AGI control code drives this signal pin to the CRT_ON state at the start of every refresh cycle, and then drives the pin to the CRT_OFF state at the end of every refresh cycle. To prevent CRT image burn, this signal is also set to CRT_OFF when the software screen saver routine built into the AGI software times out. A Few Guidelines and Cautions Due LOGIC VOLTAGE LEVELS — We are constantly reminded not to mix 5V and 3V logic! At first glance, it appears that I have broken this rule since some 3.3V Due outputs are directly connected to a few AGI 5V logic gate inputs. What’s up with that? Actually, it’s okay to connect 3V outputs to 5V logic inputs; 5V logic devices will properly interpret FIGURE 9. AGI circuit board. 3V logic levels. This type of direct connection is allowed, but only as long as there are NO pull-up You see, the AGI circuitry needs to synchronize the resistors to +5V. S/H_PULSE and SHOW_POINT signals to the actual XY_list USE CAUTION: NEVER EVER connect external 5V data being sent out of the DACs. To do this, the AGI logic outputs directly to Due logic inputs; doing so will software routine XYscope.plotStart( ) loads a defined full- over-voltage the input circuits and permanently damage scale pulse pattern into the first few locations of the XY_List the CPU chip. array, immediately ahead of the actual points generated by ANALOG OUTPUT LOADING — In pouring through the application code for display. This synchronizing pulse the Internet for background information, I saw numerous signal comes through the DAC0 port and is detected by concerns and problems connecting to and using the U8f, inverted by U8a, and then combined with CRT_OFF DAC0 and DAC1 pins of the Due. It turns out that when (gate U7c) to become the X_SYNC_NOT signal. configured as analog DAC outputs, these pins have limited In conjunction with gate U7d and flip-flop U6a, a analog drive and minimal short circuit protection. This perfectly synchronized POINT_CLK_NOT is created that is means that even a momentary short to ground or power used to then generate the SHOW_POINT and the will ‘fry’ the DAC output pins. Unfortunately, I can confirm S/H_PULSE signals. this sensitivity! USE CAUTION: DAC outputs should only You also see another signal coming from the Due on be connected to high impedance (>2K ohm) loads and never shorted to POWER or GROUND. Use extreme care when placing scope probes on or off the CPU DAC pins. Building the AGI You can’t go wrong purchasing an authentic Arduino Due board for this project FIGURE 10. Connecting the AGI to the Due. from 28 February 2018 Andrews - Arduino Graphics Interface Part 1 of 2 - Feb 18_Blank Rough NV.qxd 1/2/2018 4:54 PM Page 29

www.arduino.cc (about $50 each). However, since the Coming Up in Part 2: Getting Going Due design is open source, Due-compatible boards are also available from several other places. Once you have with the AGI Software the Due in hand, the AGI interface circuit must be built. I Just like any other Arduino project, the AGI system prototyped the AGI circuit using a solderless breadboard can be programmed using the Arduino Integrated (Figure 8) and later built a more robust point-to-point Development Environment (IDE). In Part 2, we’ll focus on soldered-wire version. the software by looking at CRT_SCOPE: a test and An extensive AGI Parts List and detailed build and checkout program that you can use to get your build up test document can be found with the article downloads. and running. We’ll also use this program as a vehicle to While the Parts List shows Digi-Key part numbers, nothing demonstrate how easy it is to use XYscope: the Arduino is exotic, and most of the parts can be sourced from AGI software support library. nearly any distributor or surplus channel. You can get ready for Part 2 by downloading and Feel free to substitute alternate parts as needed to installing the Arduino IDE, Due board definition files, Due utilize your “on-hand stock room.” However, I will add timer library, and the AGI library. If this is your first that it did take me a while to get the CA3020 op-amps to Arduino Due project, I suggest you start out with some behave well running off of a single power supply. If you basic “hello world” and “blinking LED” test programs to do substitute the op-amps, be sure to choose alternates get the IDE set up, compiling, and properly connected to that can run from a single power supply while also having your Due. Check out the References for links to the IDE stable high frequency (>3 MHz) performance. Slow audio- and a few others that you might find interesting. grade op-amps such as the LM392 will not work. See you next time! NV Once the circuit design was solid, I used Design Spark PCB V8.0 to create a small two-layer PCB (printed circuit PARTS LIST board) for the AGI project. Design Spark is a well featured circuit board package that is ITEM # REF DESIGNATORS QTY VALUE/NOTES PACKAGE 1 C10, C12 2 470 pf DSC available free from RS Components. Like all 2 C11, C13, C14, C15, C16, C4, C5, C8, C9 9 .1 μF DSC PCB software, Design Spark has a bit of a 3 C2, C7 2 330 μF DSCV learning curve. 4 C3, C6 2 47 μF DSCV While it may not be the best choice for 5 D1 1 1N4004 DIOD05 someone new to PCB layout, once you 6 L1, L2 2 LED 3 MM GRN DSC understand how “it thinks,” DESIGN SPARK 7 P1, P2, P3 3 Can use chassis mnt BNC USER performs quite well. 8 PL1 1 Can use soldered wire SIP 9 PL2 1 Can use soldered wire DSC The completed AGI PCB is seen in or alternate connector Figure 9. Since I wanted to keep things 10 PL3 1 Can use soldered wire SIP simple and easy to build, I opted to use 11 PL4 1 Can use jumper wire DSC only through-hole components for this 12 PL5 1 Can use soldered wire DSC project. I made the AGI PCB a little larger 13 PL6 1 Can use jumper wire DSC than a standard Arduino board so that the 14 Q1, Q2 2 IRFD9120 DIL Due could be easily mounted on top of the 15 R1, R11, R4, R8 4 4.7K DSC 16 R10, R13 2 10K USER AGI circuit board using 4-40 spacers. 17 R12, R2, R3, R5 4 10K DSC Figure 10 shows that the connections 18 R14, R6 2 100K USER between the AGI and the Due are easily 19 R15, R16 2 1K DSC accomplished with just a few wires. With 20 R7 1 220 DSC this scheme, you remain free to add any 21 R9 1 1.5K DSC shield board that you might need atop the 22 SW1 1 USER Due. I found the PCB version of the AGI 23 TP1, TP10, TP11, TP12, TP13, TP14, 18 OPTIONAL DSC TP15, TP16, TP17, TP18, TP2, TP3, TP4, provided a huge performance improvement TP5, TP6, TP7, TP8, TP9 over my earlier hand-wired builds. 24 U1 1 LM317 DSC The large bottom layer ground plane 25 U2 1 LM7805 DSC on the PCB greatly reduced the noise 26 U3,U4 2 CA3240 DIL sneaking into the analog circuits which 27 U5 1 CD4066 DSC improved overall image quality. You will 28 U6 1 CD1013BE DSC find a complete set of Gerber PCB files 29 U7 1 74HC00 DIL 30 U8 1 74LS14 DIL with the downloads so that you can have 31 PC1 1 20180805R0 2-LAYER PCBs made by your favorite circuit board 32 CBL1 3 BNC CBL TO SCOPE CBL fab house. (builder supplied) February 2018 29 Bensky - DC Junction Circuits - Feb 18_Blank Rough NV.qxd 1/2/2018 4:57 PM Page 30 Light Bulbs, LEDs, and Circuit Junctions

In this article, I'd like to look at some specific electrical properties of both light bulbs and LEDs, and use them to discuss junctions in DC circuits. I'll start by posing a question. Take a look at the circuits FIGURE 1. Two light bulbs with different power ratings, driven in parallel by a in Figures 1 and 2. In Figure 1, power supply. two light bulbs (with different power ratings) are wired in parallel across a battery. In Figure 2, two LEDs (of different colors) are wired similarly. The question is, if these circuits are turned on, what would happen? FIGURE 2. Two LEDs of different colors, driven in parallel by a power supply.

Circuit Junctions 7.15W resistor. Using Ohm’s Law (I=V/R), the total current drawn from the battery will be I=9V/7.15W=1.26A. This To begin answering these questions, let’s discuss a means 1.26A will flow from the positive battery terminal basic feature in many electronic circuits: a junction, which and into the junction at A. So, what happens to it now? is a place where two or more wires (or connections) come It splits. Some will flow through the 10W and some together. Take a look at the circuit in Figure 3, where a 9V will flow through the 25W, but in what amounts? We supply is driving two resistors, connected in parallel to it know that “current follows the path of least resistance,” so and each other. When analyzing this circuit, one can does this mean all of it will flow through the 10W? Or, will imagine a current coming from the positive lead of the some flow through the 25W too? battery in the direction of the dotted arrow as it traverses Since “what flows in, must flow out,” we know that the wire. The question is: What does the current do when the sum of currents through the 10W and the 25W must it comes to the junction at point equal 1.26A, for these are the A? only two paths for the current As you ponder your answer, exiting the junction. Since the know that whatever current flows 10W and 25W are in parallel, they into a junction must also flow both have the same voltage out, as junctions do not store or across them (9V here). Thus, the otherwise “hide” current. So, if current through the 10W will be 1.5A flows into a junction, 1.5A (from Ohm’s Law) must flow out. I=9V/10W=0.9A, and that W W In the circuit, the 10 and FIGURE 3. The resistor analog of Figures through the 25 will be 25W resistors are in parallel, and 1 and 2, emphasizing the current I=9V/25W=0.36A. in combination, they’ll form a junction at A. Note that 30 February 2018 Bensky - DC Junction Circuits - Feb 18_Blank Rough NV.qxd 1/2/2018 4:57 PM Page 31

Post comments on this article and find any associated files and/or By Tom Bensky downloads at www.nutsvolts.com/magazine/issue/2018/02.

0.9A+0.36A=1.26A. So, indeed smoke, and the like. current flows through both If the 0W resistance was resistors, but 2.5 times more increased — even by a minute flows through the smaller 10W amount — we’d then start to see resistor than the larger 25W the current distribute itself along resistor. all three paths. Neat, huh? Let’s I like this result as it get back to the circuits with the emphasizes how current and light bulbs and LEDs now. resistance are inverses as per Ohm’s Law. It gives us a mental The Light Bulbs grasp on the meaning of this sacred law: At a given voltage, With the light bulbs of more current will flow through Figure 1, we’ll start with their paths of smaller resistance; this labels: a 1W and a 2.5W. The provides our first hint about how FIGURE 4. The gray inset is the equivalent “wattage” likely indicates the circuit, if a zero ohm jumper wire were junctions behave. So, perhaps inserted as shown. brightness of the bulb (as per its our adage could be changed to specification, if run at 6V). We “current follows the path of least resistance, but in inverse expect the 2.5W bulb to glow brighter than the 1W bulb. proportion to the resistance of the path.” How does this fit in with the circuit junction at A? Albert Einstein was famous for doing “gedanken” Along with Ohm’s Law, there’s a power equation in experiments, or experiments of pure thought. Let’s do one electronics, commonly stated as P=IV or P=I2R. Note again here to further think about junctions. more mathematical combinations of I, V, and R (but Suppose we put a very low resistance (let’s say 0W) different than Ohm’s Law). The P here is “power” and is in jumper wire across the 15W resistor, and add the 50W watts, given that I is in amperes and V is in volts. We focus resistor as shown in Figure 4. What would happen to the on power here because that’s what light is: some amount current now? of energy-per-second (or power) flowing away from the Well, now we have a three-fold junction at A. Current bulb. flowing out of the battery travels through the 50W on its So, on the one hand, since the bulbs in Figure 1 are way to the junction, where it will flow out, and possibly in parallel (or at the same voltage), P=IV means the more into 1) the 10W; 2) the 25W; and/or 3) the jumper wire. current, the brighter the bulb since P is proportional to I at The current that flows into the junction will “see” all three a given V. This means more current should flow through paths. Which will it choose? the 2.5W bulb as it leaves the junction, since we expect it In this extreme gedanken case (involving a 0W wire), to be brighter. all current will flow down the 0W path. It’ll behave as if On the other hand, using P=I2R, we see a stronger the 10W and 25W weren’t even present, as absolutely no (squared) dependence on current, but now there’s an R in current will flow through them, for why would current there, so does a higher resistance lead to move power at a “choose” to flow through any resistance at all when it can given current? However, a higher resistance would allow flow through a 0W path? less current flow (I and R are inverses). What gives? The circuit will behave We know that light bulbs like the inset circuit in Figure work when a resistive 2, and the battery will supply filament inside of them gets I=9V/50W=0.18A to it. We so hot that it glows. So, let’s added the 50W resistor to start by putting an ohmmeter avoid (even in a thought across the leads of a bulb to experiment) shorting out the measure the resistance of its power supply, which is yet filament. The 1W bulb gives another experience with about 5.5W, and the 2.5W Ohm’s Law. Without the bulb about 3.9W. So, the 50W resistor, the jumper filament in the higher wire would present 0W wattage bulb has less across the 9V supply, and resistance. the current demand would In Figure 1, doing a be I=9V/0W which “equals” similar analysis for Figure 3, ¥ , blown fuses, overheating FIGURE 5. Two bulbs in parallel. The 2.5W bulb we’ll find that 1.5A flows components, melting wires, is clearly glowing brighter than the 1.0W bulb. through the 2.5W bulb, and February 2018 31 Bensky - DC Junction Circuits - Feb 18_Blank Rough NV.qxd 1/2/2018 4:57 PM Page 32

1.1A through the 1W bulb. Thus, To test all of this, I fastened about 1.3 times more current two bayonet-style bulb holders will flow through the 2.5W bulb onto a scrap piece of wood (as as it leaves the junction than will shown in Figure 5) to hold the flow into the 1W bulb. 1.0W and 2.5W miniature bulbs. Here, P=IV indeed provides The red clip lead is from the a clear picture of why the 2.5W positive of the power supply, bulb is brighter: its filament has FIGURE 6. By slowly ramping the voltage and the yellow is to ground. The less resistance, and at a given of the power supply, this circuit would white, lead, and (soldered) green voltage, it draws more current allow one to acquire a voltage vs. current wire complete the parallel dataset for the "device." (via Ohm’s Law), and since light configuration. The 2.5W bulb is power (P) is proportional to I, the bulb will be brighter. clearly brighter. This might all seem obvious at this point, More current leaving the junction at A will “choose” to but there’s a bit more to these light bulbs. Let’s dig flow through the 2.5W bulb than through the higher deeper. resistance of the 1W bulb. Current vs. Voltage

In electronics research, a useful first step in understanding an electrical device is to acquire “I-V” data for it: “I” stands for current, and “V” stands for voltage. Such data means to apply a given voltage across a device, then measure the current it draws at that voltage. If this is done for a sequence of voltages — for example, from 0 to 10V in steps of 0.5V — a data set can be obtained, then graphed. A simple I-V data acquisition circuit is shown in Figure 6. You’ll need two meters to do this: the one labeled “A” is an ammeter (or a “voltmeter” set and wired in current measuring mode); and the one labeled “V” is a voltmeter (or a second “voltmeter” set and wired in voltage measuring mode). A device to be characterized is inserted for the “device” in the figure. The arrow through the battery symbol means an adjustable voltage supply, and FIGURE 7. Current vs. voltage data acquired for the resistor R is used to protect the unknown device, in a resistor inserted for the "device" of Figure 6. case it itself has a very low resistance. (I actually omitted it in the work here.) If you build this tester, it’s fine to cobble it together using clip-leads and alligator clips. Just try to keep the wires neat, and work carefully to insert your meters properly. I’d build the circuit first and be sure the bulb glows. Then insert the ammeter, again being sure the bulb glows and that you see a current reading. Lastly, clip the voltmeter across the bulb (and be sure it still glows). In Figure 7, I-V data is shown for a resistor placed in the device of Figure 6. I turned the voltage on my power supply all the way down to zero, and recorded zero current. I then turned the voltage up to 0.5V and read about 0.0011A, and so on. I typed the data into a two- column spreadsheet and made an XY-scatter graph. From the graph, I see that the higher voltage placed across a resistor, the more current it draws. This sounds a lot like Ohm’s Law, in that I=V/R (I is proportional to V), and since the data looks linear, I’ll find a “trend line” for it. FIGURE 8. Current vs. voltage data acquired for When I did so, the slope came out to be 0.00212A/V. 2.5W and 1.0W light bulbs. What of this? 32 February 2018 Bensky - DC Junction Circuits - Feb 18_Blank Rough NV.qxd 1/2/2018 4:57 PM Page 33

Well, since I=V/R, this number must be 1/R, so 1/R=0.00212 A/V, or R=471W. Indeed a 470W resistor was inserted for the FIGURE 9. Two light bulbs with device. We different power ratings, driven verified that in series by a power supply. Ohm’s Law holds nicely for a resistor, and were able to use the I-V data to FIGURE 10. When driven in series, the bulb with determine the actual resistance of the device. Electrical the higher watt rating glows very dimly. devices showing a linear I-V curve for DC voltages are called “ohmic.” Well, supposing we operated the circuit at 6V, let’s Now, what about the incandescent light bulb? I-V examine an I-V curve for each bulb. From each curve, curves for both are shown in Figure 8, and they are we’d determine what current each draws at 6V and use obviously not ohmic over their entire operating range. Ohm’s Law or R=V/I to compute the resistance of each. One might identify a few linear ranges, but clearly their From Figure 8, the 2.5W bulb is consuming about 0.38A resistance (or the slopes of their I-V curves) is not at 6V, while the 1.0W bulb is consuming about 0.15A. constant. This is due to heating of the filament as a bulb From this, the resistance of the 2.5W bulb is glows. Ohmic resistance generally goes up with R=6V/0.38A=15.7W and 6V/0.15A=40W for the 1W bulb. temperature, owing to increasing thermal vibrations of the Note how the resistance of the “hot” filaments has gone crystal lattice making up the filament material itself. The up relative to the “cold” ohmmeter measurements above. vibrations make it harder for electrons to pass (presenting Thus, at 6V, we may think of the two bulbs as the them with more resistance). resistors in Figure 3, and using the same analysis, find that So, what would we see in the circuit of Figure 1? a current of 0.53A will flow into the junction and will split into 0.38A for the 2.5W bulb and 0.15A for the 1W bulb. Parts List The power dissipated by the 2.5W bulb — some into light 2.5W, Trade #1810 bulb, mcmaster.com, 9527T186, $9.38 for and most into heat — would be P=(0.38A)2(15)=2.1W, and a pack of 10. that by the 1W bulb P=(0.15A)2(40)=0.9W. Indeed the 2.5W bulb draws more current from the junction, and will 1.0W, Trade #57 bulb, mcmaster.com, 1505K21, $4.48 for a pack of 10. glow brighter (Figure 5). The wattages quoted by the manufacturer are likely Mini-bayonet base lamp socket, allelectronics.com, LS-9, the “nominal” ones used to maximize their usage lifetime. $0.35/each. (We could drive the bulbs a bit harder here.) However, we see that in actual operation at 6V, the resistance of the Mini-jumpers, allelectronics.com, MTK-10 $2.95. 2.5W bulb is still lower than that for the 1W bulb. Thus, Blue, green, and red LEDs, allelectronics.com (LED-215, the 2.5W bulb will draw more current, and glow brighter LED-2, LED-1). (P=IV). Just for fun, suppose the bulbs are wired in series, as Jumper wires, allelectronics.com, JMM-100, $4.45 for a shown in Figure 9. Series means the same current travels pack of 10. through each bulb. Such circuits do not have any Solderless breadboard, allelectronics.com, PB-400 $4. junctions. When operating the circuit at 6V, the total measured current draw was 0.13A, with 5.1V across the Two voltmeters with current measuring capability, 1W bulb and 0.9V across the 2.5W. harborfreight.com, #90899, $5.99/each. Note these voltages add to 6V (as they must), with Adjustable power supply (various options), the larger voltage drop across the 1W bulb (V=IR, and it allelectronics.com, PS-1503, $99. has the higher filament resistance). The power dissipated by the 2.5W bulb will be less than that of the 1.5W bulb Varistor, allelectronics.com, VA-14, 3/$1 (be sure to at this current, owing to its smaller filament resistance purchase a varistor that works within the range of your (remember P=I2R). power supply). Thus, in series, the bulb with the higher watt rating Resettable fuse, allelectronics.com, RXE-065, 3/$1. will actually glow dimmer than that with the smaller watt February 2018 33 Bensky - DC Junction Circuits - Feb 18_Blank Rough NV.qxd 1/2/2018 4:57 PM Page 34

and the straight lines are trend lines to aid the eye. Since LEDs are diodes, we see a typical “diode” I-V curve: no significant current for a few volts, then suddenly a rather rapid “turn on” and surge of current that gets comparatively very large for small increases in the driving voltage. Looking carefully, we see that the red LED turns on (starts to draw current) around 1.6V, and the blue at around 3V. To figure out the LED circuit in Figure 2, we need to study the I-V curves carefully, and keep in mind that the two LEDs are wired in parallel; meaning the voltage across each will always be the same. We know the blue LED won’t turn on until 3V develops across it, and if we look at the red LED’s I-V curve, by 3V. Not only would it be on, it would be consuming around 0.1A. This is quite a large potentially damaging current for a miniature LED. When running this circuit, the red LED was quite FIGURE 11. The breadboarded circuit of Figure 2. bright already by 2.5V, and I could only begin to see the faintest light emerging from the blue LED at about 2.7V. Owing to the steep slope of the red LED’s “on” curve, rating as can be see in Figure 10, where the 2.5W bulb is however, small increases in driving voltage led to rather barely glowing relative to the 1W bulb. large increases in current. For the sake of the red LED, Should we ask the manufacturer for a refund? No, continually upping the driving voltage trying to reach 3V sorry. Bulb wattage ratings assume parallel connections. would not be a good idea. Thus, the circuit behavior in The same holds for incandescent light bulbs we use in our Figure 2 is best described as a case where — within homes at 110V AC. A 100W bulb, for example, would reasonable operating specifications — the red LED will glow dimmer than a 60W bulb in a series AC circuit. light, but the blue will not. I hope you see the advantage of the I-V curves for The LEDs something “exotic” like an LED. The steep slope of the I-V curve is readily revealed, helping to explain why the blue We’re now well equipped to handle the LED circuit. LED in Figure 11 stays off unless we make the red LED We’d still like to know what will happen if the circuit in really sweat. Figure 2 was wired up (as shown in Figure 11). Let’s approach it as a research scientist and look straight to the Challenges I-V curves for a red and a blue LED, shown in Figures 12 and 13. Here, the black dots are the actual I-V data points, Here are a few things for you to work on. First, the

FIGURE 12. The I-V curve for a red LED. FIGURE 13. The I-V curve for a blue LED. 34 February 2018 Bensky - DC Junction Circuits - Feb 18_Blank Rough NV.qxd 1/2/2018 4:57 PM Page 35

turn-on voltage for a green LED is lower than that for blue. supply was not a good idea. See if you can acquire an I-V curve for a green LED, and Lastly, by seeing the steepness of an LED’s I-V curve, predict how it might behave in Figure 11 instead of the hopefully you see why LEDs are most often used in blue. conjunction with a series resistor in an actual circuit. Second, the emission wavelength of an LED can be Typically, a safe operating current for an LED is discovered using the trend lines found for the “on” region determined, and the value of the resistor is chosen to drop of an LED’s I-V curve to precisely determine the turn-on enough voltage across itself (at that current as per V=IR) voltage of an LED (use the trend line equation to find to limit the voltage drop across the LED to some safe level. what V makes I=0). NV From this V, find the emission wavelengths for a green, blue, and red LED. (Hint: For a photon, E=hc/l, where E is the photon’s energy, h is ALL Planck’s constant, c is the speed of light, and l is its wavelength. Note also that E is related to the turn-on ELECTRONICS voltage of an LED). Compare your results with those on the Wikipedia www.allelectronics.com Order Toll Free 1-800-826-5432 LED page. Third, the slope of the blue LED’s VOICE RECORD / EXPERIMENTER'S DELIGHT/ trend line is 0.122W and for the red PLAY MODULE CHARGER BOARD is 0.08W. Thinking of the LEDs then Multiple-message record / Originally a charger for loosely as “resistors” of these values, playback device offers a 14.4V 2600 maH voice recording, non-volatile storage, and LI-ION/LI-POLYMER what behavior would you expect as playback capability for 8-20 seconds. battery. The board has lots the voltage was slowly turned up Features on-board microphone and internal of useful parts including a from zero if they were connected in audio amplifier which can drive an 8 Ohm 100uh, 4.3A inductor, a MOSFET, two volt- series? 0.5W speaker directly. $ 00 age regulators and two TO-220 heatsinks. CAT# EX-57 Can you explain Figure 11’s CAT# ME-63 6 each $ 50 10 for $1.20 each behavior based on what you now 1each know about junctions and these 15A TERMINAL STRIP numbers? Cinch # 6-140. THROUGH-BEAM PHOTO- Fourth, acquire a “varistor” and 6-position, ELECTRIC SENSOR PAIR 15A/250V rated “resettable fuse” (see the Parts List) SICK Optics WS15-D1130 / barrier strip. WE15-A1130. and study I-V curves for them. 0.375" center-to-center spacing. Photo-electric sender CAT# TSC-206 $ 20 and receiver pair detects Conclusions 10 for $2.00 each 2each the presence of an object when the beam between I hope you saw the value in the two is interrupted. acquiring I-V curves for the light 12 VDC GEAR MOTOR Useful in automation, alarm bulbs, and particularly for the LEDs. I Great little motor for systems and door annunciators. When the motion / robotics beam is broken, the receiver produces always find it enjoyable to figure out projects. 520 RPM @ a current that can be used to trigger an some way of generating raw data 12 Vdc, 250 mA (no load rating). audio-visual signal or relay operated device. that I can then study to learn more 1” diameter x 2.25” long. 6mm flatted shaft. 5 Meter range. $ 00 about something. CAT# DCM-475 CAT# OSU-1130 15 pair My original motivation for this $ 75 25 for $3.75 each article came years ago, when I was 4 each 100 for $3.50 each 12 VDC FLASH ASSEMBLY working on a project with different Bright xenon strobe assembly. colored LEDs. THERMOELECTRIC Approximately 80 flashes Putting them in parallel across a (PELTIER) DEVICE per minute. 12Vdc oper- ation. Horseshoe flash power supply was simple but Solid-state heat pump that can be tube (31.5 x 16 x 6mm) a heater or cooler, depending on puzzling because the different mounted on 65 x 75mm pc direction of current. 40 x 40 x colored LEDs wouldn’t light properly. board. On/off switch. Easy to connect. 3.6mm. Umax – 15.4V. See hook-up diagram on-line spec sheet. I now know why, and it appears Qcmax – 62.2W. $ 10 for CAT# FSH-13 that driving (different colored) LEDs -50° to 180°C. 495 $ 50 in parallel directly from a DC power CAT# PJT-13 each $4.80 ea. 10 for $4.00 each 4 each February 2018 35 Cicchinelli - An Analog-Digital Part 4 - Feb 18_Blank Rough NV.qxd 1/2/2018 5:01 PM Page 36 A Digital Analog — Part 4 When a PIC can Replace a 555

This installment will examine the more complex circuits from the “555 Timer IC Circuits” by Forrest Mims which are variations on audio oscillators. Some will use the PIC replacement from Part 1 (December 2016), while others will develop specific programs using a PIC to emulate a particular implementation of a 555.

By Larry Cicchinelli To post comments on this article and find any associated files and/or downloads, go to www.nutsvolts.com/magazine/issue/2018/02.

Engineers Mini-Notebook 555 Circuits by Forrest M. Mimms, III ©1984. Also see www.forrestmims.org.

ust as a quick review, the first article in this series combination that has a ratio within 10% of 0.45 (2.5/5.5). described a general-purpose 555 replacement using a Values of 2.7K and 5.6K, ratio = .48, will work just fine. JPIC microprocessor: the 12F1572. The second article (May 2017) reviewed the circuits and their PIC Mims Circuit 14 equivalents, which used the 555 basically as a mono- stable multivibrator. Part 3 discussed the less complex One of the applications of Circuit 14 (Schematic 1) audio oscillator circuits. shows the 555 being used as a metronome which uses References to the PIC replacement refer to version 1.4 of the program. This version makes three enhancements to the original: all astable modes (modes 4-6) use pin 4 as a gate input; mode 5 replaces the off- time function with period; and mode 6 is a metronome. Many of the circuits in this article refer to a piezo element or buzzer. The units required for these circuits are usually of the internally driven type which are polarity sensitive and are labeled with a + sign for the positive terminal. Where I have modified component values in any circuits, I show the original values in parentheses. Also, those components marked with an asterisk (*) are additional components not in the original. A note about the resistor values for selecting the Range and/or Mode for the PIC 555 replacement: The ratio of the resistors is what is important as long as the parallel combination is less than 10K. For instance, the schematics show 2.5K and 5.5K when selecting Range and/or Mode 5 (or Mode 2). You can use any resistor SCHEMATIC 1. 555 metronome or tone oscillator. 36 February 2018 Cicchinelli - An Analog-Digital Part 4 - Feb 18_Blank Rough NV.qxd 1/2/2018 5:01 PM Page 37

the 2.2 µF capacitor and the piezo element. If you use a piezo element without an internal driver (as specified in the book), you will get a click for each beat. I prefer a tone which requires one with the internal driver. You may want to increase the value of R2 somewhat to make the on time longer. With the 1K resistor of the original schematic, I had a pulse width (output low) of about 850 µs. A 10K resistor yields a pulse width of about 15 ms and doesn’t change the frequency much while enabling the tone to be heard. I added R4 just to ensure at least some resistance when the pot resistance is zero. I added C3 because without it, the piezo element (Digi-Key #668-1458-ND) SCHEMATIC 2. PIC 555 metronome. emitted noise. Using a 2.2 µF capacitor for C1 gave me a better range for the metronome than the 1 µF specified in the book. With the circuit as shown, the frequency ranged from about 0.5 Hz to 30 Hz. You may want to experiment with the values of C1, R1, R2, and R4 to give you a good tempo range and tone. Using the formula for the frequency of a 555 astable, the following values will give a beats per minute range of 8 to 120: R1=1M, R2=10K, R4=50K, and C1=10 µF. Using Mode 4 or 5 of the PIC 555 replacement will give you the same results as using a 555. However, during the Christmas holidays this past year, I found out that one of my grandsons started playing the trumpet. This sounded like a good excuse to develop an electronic metronome using PICTURE 1. PIC 555 metronome waveforms. the PIC 555 replacement. Mode 6 has been added with the following The beats per measure is determined by R7 and a modifications to the “standard” I/O of the PIC 555 look-up table. The basic value is obtained in the same way replacement: that the Mode and Range are determined — using the three most significant bits of the A/D reading. The • Pin 5 controls the beats per measure. software allows eight discrete values: 0–7. However, that • Pin 6 controls the tempo or beats per minute. value is then used as an index into a table to get the • Pin 7 changes to an output after getting the range, actual beats per measure. There are currently seven values to drive a downbeat LED. implemented: 0, 2, 3, 4, 6, 8, and 12. The value of 0 is used to indicate no downbeat. The eighth value is also 12 The normal tone frequency of the beats is 400 Hz, so as not to leave it blank. while the downbeat frequency is 800 Hz; refer to Picture 1 shows the output with four beats per Schematic 2 for my implementation. measure. The bursts are about 100 ms. The bottom trace One LED is driven by the same signal as the speaker, is the downbeat LED signal which surrounds the while another is driven by the downbeat signal. Using the downbeat tone. You can see that the tempo is quite high switch, you can enable or disable the LEDs. You can since the period of the tones is 250 ms — equivalent to 4 increase the value of R13 and R14 if you use high Hz — so the tempo would be 240 beats per minute. I did brightness LEDs. This will reduce the current drain and will this purposely to make getting the ‘scope picture easier. be important if you run from batteries. With the resistors shown, the tempo range is about 25 February 2018 37 Cicchinelli - An Analog-Digital Part 4 - Feb 18_Blank Rough NV.qxd 1/2/2018 5:01 PM Page 38

to 540 beats per minute. R10 affects mostly the high-end tempo, so if you want to decrease the maximum tempo all you need to do is increase its value. If you want to use a piezo element, you can connect it to the PIC output, but you should put a pot in series with it to control the volume. Since the output of the PIC is a tone, the piezo device should not be of the internally driven type. If you need more volume, you can use the transistor driver shown in the schematic. A few comments about the circuit. Diode D1 in the speaker driver circuit adds a little bias to R6 to reduce the amount of pot rotation needed before you get any sound out of the speaker. I mounted a holder for three AA batteries on the back of my unit, but I would not recommend PICTURE 2. FFT of 100 Hz, 50% duty cycle square wave. prolonged use with batteries since the current drain can easily exceed 100 ma with a reasonable speaker volume. Provision is made for an external power supply via H2. Any DC voltage between 7V and 35V will work with the regulator. However, voltages higher than about 15 may require a heatsink. I mounted a standard DC power socket such that the batteries must be removed to connect external power. H3 is used to allow an audio jack to connect the output to an external amplifier. The other application of Circuit 14 is that of an audio oscillator. The value of C1 should be .01 µF to increase the frequency to the audio range. The range of frequencies with the components shown in Schematic 1 is approximately 120 Hz to 7 kHz. One of the issues of the 555 in this type of circuit is that as you vary the resistance of R1 to get different frequencies, you are only modifying the PICTURE 3. FFT of 100 Hz, 75% duty cycle square wave. charge time (output high) of C1 while the discharge time (output low) remains constant. The audible effect of this is that as the frequency is lowered, the duty cycle is increased, and the sound produced has more harmonics. Pictures 2-4 show this using FFT displays. Picture 2 shows 100 Hz at 50% duty cycle. Note that the amplitude of the 3rd and 5th harmonics are decreasing in about 10 dB steps, while the even harmonics are down about 30 dB. The higher odd harmonics continue the trend. Picture 3 is 75% duty cycle, and shows both even and odd harmonics are high but are decreasing about 3 dB per harmonic. Picture 4 is 90% duty cycle and shows that all harmonics are very close to the same amplitude as the 100 Hz fundamental. You can use one of the circuits (Schematic 3) PICTURE 4. FFT of 100 Hz, 90% duty cycle square wave. from Part 3 for the PIC audio oscillator equivalent of 38 February 2018 Cicchinelli - An Analog-Digital Part 4 - Feb 18_Blank Rough NV.qxd 1/2/2018 5:01 PM Page 39

Mims Circuit 14. Using Range 1 allows the frequency to be adjusted within a useful audio range. Keep in mind that with the PIC emulating a one-shot, the pulse width — or period — is the parameter being controlled. This means that a small change in control voltage at the high frequency end (lower voltages) will yield a large change in frequency. The narrowest pulse width is about 30 µs, giving a period of about 60 µs (16.66 kHz), with a resolution of 10 µs. The next lower frequency is about SCHEMATIC 3. PIC 555 voltage controlled audio oscillator. 12 kHz, period = about 82 µs. Note that the period resolution is double the pulse width resolution. Another solution for a PIC based audio oscillator is the NCO discussed in Part 3 of this series (and shown here in Schematic 5). Although the schematic is for a toy organ (discussed next), you can replace the resistor network on pin 5 with a simple divider or potentiometer. Mims Circuit 15

Circuit 15 (Schematic 4) shows the 555 being utilized as a toy organ using different value capacitors to develop the different frequencies. With all switches open, the output will be high. As soon as one (or more) of the switches is closed, the 555 will start to oscillate. Schematic 5 shows an easy way to implement a toy organ using a PIC NCO with the program NCO_Toy_Organ.asm SCHEMATIC 4. 555 toy organ. (available with the downloads). The purpose of the diodes is to enable the output by grounding the gate when the associated switch is closed. Range 0 for the NCO is the most appropriate for an audio application: 7.5 Hz to about 7.5 kHz. If you want a higher maximum frequency but still stay within the audio range, you can modify the program so that the A/D value is doubled. This will make the lowest frequency and step size about 15 Hz, and the highest frequency about 15 kHz.

GRAPH 1. PIC NCO frequency vs. control voltage. February 2018 39 Cicchinelli - An Analog-Digital Part 4 - Feb 18_Blank Rough NV.qxd 1/2/2018 5:01 PM Page 40

The formula for the frequency can be obtained from Graph 1 and simplified a little: Freq = (7852 x V/Vcc) — 9.69 By manipulating these two equations, the value for n as a function of frequency can be derived as: n = (Freq + 9.69) ⁄ (7852 — 9.69 — Freq) Notice that n is independent of Vcc, and that the maximum frequency is about 7,842 Hz. For instance, if 200 Hz is wanted, then n = .0274. Letting Rb = 10K, then Ra = 274 ohms. The spreadsheet NCO Toy Organ.ods in the article downloads uses the above formula to calculate the Ra value for several frequencies using 10K for Rb. The schematic shows the values as calculated by the spreadsheet for seven frequencies. The PIC replacement (mode 4 and range 1) can be used for this application as well. Using the same approach as with the NCO, the formula for n can be derived as: SCHEMATIC 5. PIC NCO toy organ. n = 1 ⁄ ((.02048 x Freq) — 1) If Rb is fixed at 10K, the formula for Ra is: Ra = 104 ⁄ ((.02048 x Freq) — 1) Note that with this circuit, the lower resistor values give shorter periods thus higher frequencies — just the opposite of the NCO. There will be three differences using the 555 replacement as compared to the NCO:

• The calculations for the resistor values since the control voltage is controlling the period. • The high frequency resolution is not very good. See the discussion about resolution in the PIC Mims Circuit 11 section. • The gate circuit needs to have an inverter since the gate is high true. SCHEMATIC 5A. PIC 555 toy organ. See Schematic 5a. If you want a little bit more complex solution with a step size of 9.4 Hz (closer to 10 Hz), you can multiply the Mims Circuit 17 A/D reading by 1.25 by dividing the reading by four (two right-shift operations) and then adding the result to the Circuit 17 (Schematic 6) is a 556 connected as a original value. Since the NCO has a linear frequency vs. chirp generator. Section 1 of the 556 is an astable voltage curve, it becomes easy to calculate the ratio of the multivibrator. It has a frequency range from under 1 Hz to two resistors required for any frequency: let Ra = lower about 60 Hz. resistor, Rb = upper resistor of the voltage divider, and Ra Based on the formula from a 555 spec sheet, using = n*Rb. The formula for the control voltage is: the R2 and C1 values shown in the schematic, the width Vcontrol = (Ra x Vcc) ⁄ (Ra + Rb) = n x Vcc/(n + 1) of the pulse low time for the astable section is PW = 0.693*R2*C1 = 3.46 ms. I measured 3.38 ms which is 40 February 2018 Cicchinelli - An Analog-Digital Part 4 - Feb 18_Blank Rough NV.qxd 1/2/2018 5:01 PM Page 41

quite close to the calculated value. The second section of the 556 is wired as a mono- stable multivibrator and should have a quite short output pulse. The formula for the pulse width of the monostable section is PW = 1.1*R3*C3 = 110 µs. When the trigger signal goes low, the 555 output immediately switches high and the capacitor starts to charge. However, since the trigger is low for longer than the calculated pulse width, the capacitor does not charge completely. It only charges to about 0.7V due to Q1 being on. Picture 5 shows the results with and without Q1. A is the triggering pulse from the astable; the actual triggering edge is off the screen to the left. B is the voltage across C3 when the transistor is in place. You can see that the capacitor voltage is clamped at about 0.7V until the triggering signal goes high, at which time the capacitor is allowed to complete its charging. The capacitor charges only to the threshold voltage, which then enables the internal discharge circuit. C shows the capacitor voltage with Q1 removed. It SCHEMATIC 6. 556 chirp generator. charges to the power supply voltage since the discharge circuit is disabled, as long as the trigger is low. The slope of the discharge is due to the finite amount of current the discharge circuit can pull from the capacitor. Using the formula cv=it, the current calculates to about 14 ma: .01 µF * 5V/3.55 µs. The only difference between having the transistor in the circuit vs. out of the circuit is that with the transistor, the output pulse is about 97 µs wider that without it. This is somewhat shorter than the 110 µs calculated previously due to the capacitor starting from .7V rather than 0. Since the output pulse width on pin 9 is basically the same as the trigger pulse from pin 5 — except that it’s inverted — the same effect can be achieved with a 555 using the same timing PICTURE 5. 556 chirp generator capacitor charge and components as Section 1 of the 556 by connecting discharge. the piezo element between the output and Vcc. If Mims Circuit 18 you use the circuit as a warning device, you can use the Reset input to enable and disable the oscillator. Circuit 18 in the Mims book (Schematic 8) — called a To use the PIC replacement, you can work SCHEMATIC 7. PIC 555 the circuit shown in chirp generator. Schematic 7. The schematic shows Range 3 (1 ms to 1 sec) and mode 5 which are probably the best for this application. You can adjust R6 to give you the desired tone/chirp duration, and R5 to set the repetition rate/period. If you use mode 4, then R5 would adjust the time between chirps. February 2018 41 Cicchinelli - An Analog-Digital Part 4 - Feb 18_Blank Rough NV.qxd 1/2/2018 5:01 PM Page 42

pin 9 was about 200 µs and adjusted R1 such that the input and output frequencies were the same at 2 kHz. I then rotated R3 through each of the step frequency changes and measured its resistance. The results are shown in Graph 2 which closely matches Mr. Mims results. As you can see, the output frequencies are sub multiples of the 2,000 Hz fundamental. Section 1 of the 556 is wired as an astable multivibrator with a SCHEMATIC 8. frequency range of about 282 Hz 556 stepped to 12.8 kHz. Section 2 is a tone monostable triggered by Section 1, generator. with an output pulse width range of about 16 µs to 5 ms. The operation of Section 2 is that of a frequency divider (see Part 2 of this series for a detailed explanation). For any single setting of R1 (period), as R3 is changed, the output frequency will be constant until a pulse width threshold is reached (N*period), at which time its output frequency will jump to its next value. GRAPH 2. 556 stepped tone generator: Changing the period of Section 1 will frequency vs. R3. change the output frequencies of Section 2 at which it jumps. You should also note that even though the monostable Stepped Tone Generator — took me a while to understand frequency does not change until the threshold is reached, what was happening. the tone sound will change because the duty cycle of the As it turns out, that although the graph is correct, the pulse is changing. text is incorrect — the frequency rises and the step size Using two PIC 555 replacement ICs will operate (DF) increases as R3 is reduced. exactly in the same way if you set one to mode 4 or 5 To duplicate Mr. Mims results, I used a 50K pot for R3 (astable) and the other to mode 0 (monostable). Also, the to get better resolution. I set R3 so that the pulse width on program of Mims Circuit 21 (discussed later in this article) will yield similar results if all you want is an output that steps among several frequencies. Program NCO_SteppedTone Gen.asm in the downloads emulates this circuit by implementing essentially two 555s. One uses the NCO of a 16F18313 to emulate a 555 astable mode; the second uses a timer to enable emulation of a 555 in its monostable mode. Schematic 9 shows the circuit which duplicates the stepped tone generator where R1 changes the SCHEMATIC 9. PIC stepped tone generator. astable frequency and R3 changes the 42 February 2018 Cicchinelli - An Analog-Digital Part 4 - Feb 18_Blank Rough NV.qxd 1/2/2018 5:01 PM Page 43

SCHEMATIC 10. monostable pulse width. 556 three-state tone generator. Mims Circuit 19

Circuit 19 is titled as a Three-State Tone Generator; refer to Schematic 10. Both sections of the 556 are wired as astable multivibrators. The components of Section 1 cause it to operate at a frequency of about 2.1 Hz with close to a 50% duty cycle, while those of Section 2 cause it to operate at about 960 Hz with a 66% duty cycle. With the switch in position 1, the output of Section 1 is used as a gate for Section 2. Section 2 will output its 960 Hz signal only while the output of Section 1 is high; about 230 ms. With the switch in its center position, the output of Section 2 will be a continuous signal. When in position 3, the output of Section 1 will affect the charge and discharge of C2, so that Section 2 will output two different frequencies. The difference between the frequencies is affected by the value of R3. The smaller the value, the larger the effect. You can do the same thing using two of the PIC 555 replacements. However, program NCO_3_StateToneGen.asm (also with the article downloads) uses a single SCHEMATIC 11. PIC three- PIC16F18313 to emulate the same state tone generator. circuit with somewhat more flexibility; see Schematic 11. Pins 5, 6, and 7 are an astable with separate on-time a need to change any of the operating characteristics. The and off-time controls, and a frequency range of about 0.1 switch and its three positions duplicate the operation of Hz to 100 Hz. To get this low frequency range, I used one of the timers to generate a 200 Hz interrupt. In the Interrupt Service Routine (ISR), I count the number of interrupts in order to determine when to turn the pulse on and off. Initially, I wanted to use one of the PWM systems but was unable to get the low frequencies I wanted and still maintain a higher CPU clock frequency. Pins 1, 2, and 3 are an astable which uses the NCO system to generate a square wave with a frequency range of about 7.5 Hz to 8 kHz. The source code in the downloads is well documented and should be easy to modify if you have SCHEMATIC 12. 555 sound effects generator. February 2018 43 Cicchinelli - An Analog-Digital Part 4 - Feb 18_Blank Rough NV.qxd 1/2/2018 5:01 PM Page 44

the 556 implementation. Mims Circuit 21

Circuit 21 (Schematic 12) is a sound effects generator. Both 555s are wired as astable multivibrators. However, the second 555 is also used as a VCO. IC1 has a frequency ranging from about 2.4 Hz to 10 Hz, and its output drives an R-C circuit which is used to modify the control voltage of IC2. The output of IC2 is a tone which decreases in frequency as C2 is charging, and then increases as C2 discharges. SCHEMATIC 13. PIC sound IC1 controls how far C2 charges and discharges effects generator. by varying the charge time — IC1 pin 3 is high. The discharge time is constant. IC2 develops the basic tone output. Without the VCO circuit (components connected to IC2 pin 5), the frequency varies from about 400 Hz to 12 kHz. I have made several modifications to the circuit which give it more options for the sounds it produces. The larger value of C2 causes the frequency change to be slower. Increasing R2 allows C2 more time to discharge, and the addition of R9 and D1 allows C2 to discharge more fully, yielding a wider range of frequency variation since there will Schematic of be a substantially lower minimum breadboard. voltage on C2. Program NCO_SoundEffects.asm uses the NCO peripheral of the 16F18313 to generate a wide range of sound effects. Schematic 13 shows the controls which allow you to create the various sound effects. The operation — except for the speed control — is quite simple: The program ramps between two frequencies in discrete steps. SW1 allows you to choose among ramp up, ramp down, or a bi-directional ramp. R3 sets the lower frequency limit with 15 Hz resolution up to about 3.8 kHz. R2 sets the high frequency, but it’s an offset from the low frequency. For R2 and R3 (the frequency controls), the program uses only the upper eight bits of the A/D reading. For R1, ramp speed, only the upper six bits are used. SW1 is also an analog input with only the upper Top view of PIC 555 replacement breadboard. two bits of the reading being used. 44 February 2018 Cicchinelli - An Analog-Digital Part 4 - Feb 18_Blank Rough NV.qxd 1/2/2018 5:01 PM Page 45

The ramp speed, R1, is a bit more complex. There are can be seen in the file Breadboard.jpg in the downloads. two parameters which change with the R1 setting: the The board has a 7805 regulator and a sizable area for step size in Hz, using bits 9-7 of the A/D reading; and the breadboarding. It’s a mix of thru-hole and SMD parts, and step duration, using bits 6-4. has a programming header compatible with a PICKit-3. Both the step size and duration bits are used as NV indices into tables of eight values each, so they can easily be changed if you want. With the R1 tap at ground, the (If you want a single board, you can email me at step size is 15 Hz and the duration per step is 100 ms. [email protected]. If you want to get three boards, you can Rotating the pot a little changes the duration to 50 ms order them from OshPark at oshpark.com/profiles/K3PTO.) while keeping the step size the same. Basically, for each step size, the program will change the duration from its maximum of 100 ms to its minimum of 1 ms. After reaching 15 Hz and 1 ms, the next setting will be a step size of 30 Hz with a duration of 100 ms. The maximum step size is currently a value of 25*15 Hz = 375 Hz, so the maximum speed is attained with the R1 tap at 5V and yields a step size of 375 Hz with a step duration of 1 ms. All the inputs can be varied during program execution. However, they are read and applied only at the end of each ramp cycle. Also, although the pots are shown as 5K, they can be any value up to 10K which is the specified maximum source resistance for the PIC A/D. Since I used the 16F18313 in a number of these sample circuits, I decided to migrate the PIC 555 replacement from Part 1 of this series to this processor. You can find the code (PIC_555-16F.asm) with the downloads. I have recently designed a breadboard for the PIC 555 replacement using the 12F1572 or 16F18313. The schematic and board layout Resources

All schematics are drawn using DipTrace www.diptrace.com All parts purchased are from Digi-Key www.digikey.com My website www.qsl.net/k3pto Circuit Boards https://oshpark.com/profiles/K3PTO

February 2018 45 NV Webstore - Feb 18_NV Webstore June 2016 working.qxd 1/2/2018 5:11 PM Page 46

For complete product details, visit us online!! The Nuts & Volts WEBSTORE

GREAT FOR DIYers! Arduino Project Handbook, Vol. 2 Electronics Workshop Arduino and Raspberry Pi Sensor by Mark Geddes Companion for Hobbyists Projects for the Evil Genius Each project by Stan Gibilisco by Robert Chin includes cost and In this practical Learn to quickly build time estimates, guide, electronics your own electronic simple instructions, expert Stan gadgets that monitor, colorful photos and Gibilisco shows you, measure, and react to circuit diagrams, a step by step, how to the real world — with troubleshooting set up a home no prior experience section, and the workshop so you required! This easy-to- complete code to can invent, design, follow guide covers the bring your build to build, test, and programming and life. With just an repair electronic electronics essentials Arduino board and circuits and gadgets. needed to build fun and a handful of Electronics Workshop educational sensor-based projects with components, you’ll make gadgets like a Companion for Hobbyists both the Arduino and Raspberry Pi. Arduino rainbow light display, noise-level meter, provides tips for constructing your and Raspberry Pi Sensor Projects for the Evil digital piano, GPS speedometer, and workbench and stocking it with the tools, Genius features step-by-step DIY projects fingerprint scanner. This collection of components, and test equipment you’ll that use inexpensive readily-available parts. projects is a fast and fun way to get started need. Clear illustrations and interesting You will discover how to use touch, with microcontrollers that’s perfect for do-it-yourself experiments are included temperature, moisture, light, sound, and beginners, hobbyists, parents, and throughout this hands-on resource. motion sensors — even sensors that educators. $24.95 $25.00 detect the presence of a human! $24.00 Hacking Electronics: Learning Programming the Raspberry Pi, Beginner's Guide to Reading Electronics with Arduino and Second Edition: Getting Started Schematics, 3E Raspberry Pi, Second Edition with Python by Stan Gibilisco by Simon Monk by Simon Monk Navigate the roadmaps Up-to-date hacks that An updated guide of simple electronic will breathe life into to programming circuits and complex your Arduino and your own RaspPi systems with help from RaspPi creations! projects an experienced This intuitive DIY engineer. With all-new Learn to create inventive art and demo circuits guide shows how to programs and fun games wire, disassemble, you can build, this on your powerful hands-on, illustrated tweak, and re- Raspberry Pi with no purpose household guide explains how to programming experience understand and create devices and required. This practical integrate them with your RaspPi and high-precision book has been revised to fully cover the electronics diagrams. Arduino inventions. You’ll discover how to new Raspberry Pi 2, including upgrades to build an Internet-controlled hacked electric Find out how to the Raspbian operating system. DIY identify parts and connections, decipher toy, ultrasonic rangefinder, remote- projects include a hangman game, RGB controlled robotic rover, audio amp, slot element ratings, and apply diagram-based LED controller, digital clock, and information in your own projects. car brakes and headlights — even a smart RasPiRobot with an ultrasonic rangefinder. card reader! $30.00 $15.00 $25.00 How to Diagnose and Fix Programming PICs in Basic Programming Arduino Everything Electronic by Chuck Hellebuyck Next Steps: Going Further by Michael Jay Geier If you wanted to learn with Sketches A Fully Revised how to program microcontrollers, then by Simon Monk Guide to you've found the right In this practical guide, Electronics book! Microchip PIC electronics guru Simon Repair all kinds of microcontrollers are Monk takes you under electrical products, being designed into the hood of Arduino from modern digital electronics throughout and reveals professional gadgets to analog the world and none is programming secrets. antiques, with help more popular than the Also shows you how from this updated eight-pin version. Now to use interrupts, book. The Second the home hobbyist can manage memory, Edition offers expert create projects with these little program for the insights, case studies, and step-by-step microcontrollers using a low cost Internet, maximize instruction from a lifelong electronics guru. development tool called the CHIPAXE system and the Basic software serial communications, Discover how to assemble your workbench, perform digital signal use the latest test equipment, zero in on and language.Chuck Hellebuyck introduces how to use this development setup to processing, and much more. All of the 75+ replace dead components, and handle example sketches featured in the book are $24.95 build useful projects with an eight-pin reassembly. PIC12F683 microcontroller. $14.95 available for download. $20.00 46 February 2018 NV Webstore - Feb 18_NV Webstore June 2016 working.qxd 1/2/2018 5:11 PM Page 47

Order online @ store.nutsvolts.com Or CALL 1-800-783-4624 today!

CD-ROM SPECIAL EDUCATIONAL

February 2018 47 NEAR SPACE ■ BY L. PAUL VERHAGE Total Solar Eclipse Near Space Flight Results — Part 2

lot of data was collected on my eclipse near space fl ight; unfortunately, not as much as I hoped (some experiments failed to record data at the Aappropriate time). Still, there was enough data for a second article and I’d like to share three of the results with you.

Cosmic Ray Results experiment seems to me to indicate that the total solar I launched two cosmic ray experiments on the eclipse had no effect on the cosmic ray counts observed eclipse mission and both returned data. The fi rst radiation during a fl ight. If there was an effect, it must be buried in experiment was with my standard Geiger counter (Aware the noise of the Geiger counter. Cosmic rays are random in Electronics RM-60). This Geiger counter is designed to nature, so there’s lots of variation in the data and that can produce a fi ve volt spike (the output actually goes low) at hide subtle effects. the detection of a particle of ionizing radiation. One note is appropriate at this point. The peak in The PICAXE measured the output of the Geiger cosmic ray fl ux that occurs at an altitude of 61,000 feet is counter and counted the number of pulses over a 10 called the Pfotzer Maximum and its discovery was made second interval in 30 second cycles. The command I used by German physicists Georg Pfotzer and Erich Regener in was COUNT B.1, 10000, B4. Since the 1930s. the balloon was fi lled to have As cosmic rays an ascent rate of 1,000 feet per enter the atmosphere, minute, the cosmic ray fl ux was they collide with measured at roughly 500 foot molecules and shatter intervals. them into secondary This Geiger counter cosmic rays. The Pfotzer Maximum marks the point at which primary cosmic rays (those that originate in space) are producing the greatest number of secondary cosmic rays (those that originate in the atmosphere). This always occurs at around 62,000 feet,

Using a Fuji FinePix S700 set to six power optical The RM-60 Geiger counter and the zoom, I was able to capture this image as the moon tracking module that housed it. The RM-60 plugs into an old- was just uncovering the sun. This is called the fashioned serial port and produces a voltage pulse at each diamond ring effect since it reminds viewers of the detection. So, it’s pretty easy to interface this Geiger counter sparkle of a diamond ring. to microcontrollers like the PICAXE.

48 February 2018

Verhage - Near Space - Feb 18.indd 48 1/2/2018 4:22:52 PM APPROACHING THE FINAL FRONTIER Post comments on this article and find any associated files and/or downloads at www.nutsvolts.com/magazine/issue/2018/02.

and the solar eclipse was no exception. Neutrons The second radiation experiment used a thermal neutron detector. This detector is about six inches tall and filled with a clear gel. The gel is on the verge of boiling at room temperature, and all it needs to boil is a tiny bit of energy. The chemical composition of the detector is such that the gel can absorb thermal or low energy neutrons. Those captured neutrons provide just the extra bit of energy that the gel needs to boil. This results in a bubble appearing every place that a neutron is absorbed. By the way, this is the I purchased two neutron detectors for the solar eclipse mission. same way the old hydrogen bubble chambers The one on the top was launched into near space where it worked (but the gel doesn’t operate at cryogenic recorded 40 neutrons during the 135 minute flight. The one at the temperatures). bottom remained on the ground and recorded no neutrons during By counting the number of bubbles inside the the same time. In fact, later experiments indicate that it takes over gel, one can determine the number of neutrons that a day to detect a single neutron on the ground on average. The were detected. Then, after a mission, the gel can be detector is manufactured by Bubble Technology Industries. “reset” and cleared of bubbles by applying a small amount of pressure to the gel. That pressure squeezes the supernova explosions, and perhaps massive black holes in bubbles closed so the gel can produce new ones at the the center of galaxies. absorption of new thermal neutrons. Any neutrons detected on the eclipse flight were the Now, neutrons are not a component of cosmic rays. result of cosmic rays colliding with molecules (oxygen and Cosmic rays are (for the most part) protons or the nuclei nitrogen) in the atmosphere. Since the Geiger counter of hydrogen atoms. They’re kicked into high energy states indicated that the maximum cosmic ray flux occurred at possibly by the powerful magnetic fields associated with 61,000 feet, I suspect the neutron flux was also greatest at this altitude. Air Temperature Different mechanisms warm the bottom two layers of the atmosphere. The lowest layer — the troposphere — is warmed by its contact with the ground. As we measure the temperature of the troposphere, we find that it decreases with altitude, or distance from the warm ground. The second layer — the stratosphere — is warmed by the ozone gas it contains. The energy of the ultraviolet radiation it blocks from reaching the surface becomes thermal energy. We find that as we measure the temperature of the stratosphere, its temperature increases with altitude or as we approach the ultraviolet-rich sun. In both cases, the sun is the ultimate This is a very typical looking chart of the cosmic ray flux as a function of source to warm the atmosphere. Therefore, altitude. The small drop-off between 43,000 and 45,000 feet looks a lot I was hoping to detect a decrease in like normal random variation in cosmic ray flux. It’s no different from what the temperature of either layer of the is seen in non-eclipse flights. atmosphere during the eclipse since it February 2018 49

Verhage - Near Space - Feb 18.indd 49 1/2/2018 4:23:11 PM APPROACHING THE FINAL FRONTIER

photometer. The LED colors were violet/ ultraviolet, blue, green, yellow, orange, red, infrared at 890 nm, and infrared at 940 nm. Blue and violet light are most strongly scattered by the atmosphere (hence, our blue sky) and red is the least scattered. Therefore, I was expecting to see the brightness of the sky change at different rates for the colors of the spectrum (red most affected and violet least affected). As some of the photometer charts show, the sky affected all the colors of the spectrum equally. I suspect the wider variation in violet- UV intensity below 20,000 feet and above 60,000 feet is due to the sensor getting saturated. Otherwise, the way the intensity of these three colors changed is basically identical. You can see as the balloon approached totality at 44,000 feet, the Totality occurred when the balloon was between an altitude of 43,000 sky’s intensity in every color went to zero and 45,000 feet. Unfortunately, there’s no sign of an unexpected — regardless of the photometer’s pointing temperature change between those altitudes. direction. would block the light from the sun. I connected an LM335 My Next Solar Eclipse Launch temperature sensor to a flight computer and then placed the sensor outside in the open air. The results can be seen The next total solar eclipse to cross the United States in the graph. occurs on April 8, 2024. The path of totality begins in The chart shows the changes in the air temperature Texas and travels northeast to Lake Erie and Lake Ontario. pausing between the troposphere and stratosphere (at This eclipse will take place on a Monday, which means it’s between 40,000 and 50,000 feet). The boundary between a school day. Therefore, I’m going to need to take some the troposphere and stratosphere is called the tropopause vacation days if I want to study this eclipse. because changes in the air temperature pause during this Because of my experience with last August’s eclipse, I transition. My balloon flights don’t always detect the pause, want to make the following changes for the next one. First, but the eclipse flight did. I’ll launch multiple balloons. It’s important to cover a range If there was an atmospheric temperature effect from of altitudes during the eclipse. That way, data can tease out the eclipse, then the tropopause is hiding it. Due to bad subtle effects the eclipse may have on Earth’s atmosphere. timing on my part, the balloon was in the wrong place at Besides, launching redundant payloads on balloons is the wrong time for this experiment. an insurance policy for the possible failure of any one experiment. Photometer Next, I’ll add a second Geiger counter to the balloon (or balloons). The random nature of cosmic radiation Another successful experiment on the eclipse flight makes it difficult to measure small variations in the number was conducted with my eight-channel LED photometer. of particles detected per minute. With multiple Geiger The photometer is based on the work of Forrest Mims counters, I can isolate variations that appear regardless of who discovered that LEDs produce a small current when their altitude. Even if the Geiger counters were on the same exposed to light close to the color they emit. This makes balloon, I would expect to have better luck measuring them color-selective and an inexpensive way to measure variations in the cosmic ray flux. the intensity of light in specific frequencies. Third, I’ll make a video recording of the neutron The BalloonSat carrying this experiment oriented the detector during the flight. By relating the time a bubble LEDs of the photometer straight up. However, rocking and appears with the time of the mission, I can determine the spinning of the BalloonSat resulted in the LEDs changing altitude that each detection takes place. According to their pointing direction throughout the flight. Bubble Tech, the bubbles appear rapidly, so their detection As I said, the photometer has eight channels. in the resulting video will be easy. Unfortunately, it will be a Those came from the eight different LEDs built into the boring process of watching over two hours of video of just 50 February 2018

Verhage - Near Space - Feb 18.indd 50 1/2/2018 4:23:28 PM a bubble detector. Lastly, I’ll add a sun sensor to the photometer. The data I have from last August was collected in random directions. With a sun detector, I can at least isolate the pointing direction of the photometer (relative to the sun) at each measurement. By charting only data recorded in the same direction, my chart will remove some of the wide swings seen in the sky’s measured intensity. Since the moon’s shadow on the ground will be 200 miles across, I expect it will be more difficult to see it any more clearly than I did in near infrared. However, the eclipse will last longer and that should give it a stronger effect on Earth and its atmosphere. So, I’m looking forward to studying the next eclipse from near space and would like to compare the results. If you’re in the Texas area, be sure to look around, you might see multiple near spacecraft overhead on April 8, 2024. Onwards and Upwards, Your near space guide NV violet-uv yellow ir940 February 2018 51

Verhage - Near Space - Feb 18.indd 51 1/2/2018 4:23:46 PM THE DESIGN CYCLE n BY FRED EADY Smartphone App Programming for Remote Control

here’s almost nothing you can’t do with a smartphone. However, if you want to cook up Tsomething special for yourself using your iPhone or Android device, it’s advantageous to have tools that help you get your arms around smartphone app programming. You don’t know it yet, but if you can think and code in the Basic and/or C language, you actually have a fi rm grasp on smartphone app programming. In this installment of Design Cycle, we’ll code an iOS app that can be run on an iPhone or iPad. Using the same coding paradigm, we’ll code the other side of our app to target an inexpensive WEMOS device based on the ESP8266.

Coding the Remote Device Private switch1 As Pin Private switch2 As Pin The WEMOS D1 Mini posing in Photo 1 is based Private switch0State As Boolean on the ESP8266. Since the ESP8266 is involved, that Private switch1State As Boolean implies communications between the remote Mini Private switch2State As Boolean and our iPhone will fl ow over Wi-Fi. The WEMOS Mini Private ser As B4RSerializator can be programmed in many ways. We’ll take the B4R End Sub programming path. B4R is a free programming platform that is geared towards the Arduino. B4R also has a special place in its heart for the ESP8266. Our goal is to code the D1 Mini as a remotely controlled Wi-Fi node. The code we’ll write will toggle the Mini’s output pins. Using the logic levels available at its I/O pins, you can drive relays, LEDs, etc. We won’t get deep into the inner workings of each line of B4R code as you can easily go to the B4R website and look up any mnemonics you don’t readily understand. You’ll fi nd that B4R source code is self-documenting and easy to follow. Let’s begin by laying out our Process Global assignments:

Sub Process_Globals Public Serial1 As Serial Private server As WiFiServerSocket Private wemosPins As D1Pins n PHOTO 1. This little module has replaced having Private espWifi As ESP8266WiFi to fabricate special printed circuit boards and write Private astream As AsyncStreams complicated TCP/IP code. Private switch0 As Pin 52 February 2018

Eady - Design Cycle - Feb 18.indd 52 1/2/2018 8:58:00 PM ADVANCED TECHNIQUES FOR DESIGN ENGINEERS Post comments on this article and find any associated files and/or downloads at www.nutsvolts.com/magazine/issue/2018/02.

The names to the left of As are our aliases. The listening for a new connection request. names on the right of As are members of libraries. So, Since we’re going to be keeping up with the Mini’s I/O we are setting up our WEMOS D1 Mini as a server using pin states, we initialize our logical I/O states in accordance AsyncStreams and B4RSerializator as our application to its I/O pin states. data pipe and application data protocol, respectively. At this point, the D1 Mini is connected to the LAN and Our Process Global statements also tell us that we have is listening on port 51042 for incoming data. Before any predefined definitions for the Mini’s I/O pins and that there incoming data can be processed, the client device (iPhone) are three I/O pins being used by our application. It also must connect to the WEMOS Mini server. looks like we’ll be keeping tabs on the states of the three When a connection is established, we must prepare switchx pins. an application path (data pipe) on which the data will flow. For the sake of our discussion, we are only coding This is where AsyncStreams comes into play: three of the available D1 Mini I/O pins. You can code them all if you wish, as the code for each additional pin Sub Server_NewConnection (NewSocket As can be copied from the code we have already written. WiFiSocket) Now that our aliases and libraries are defined, let’s astream.Initialize(NewSocket.Stream, write some crank-it-up code: “astream_NewData”, “astream_Error”) End Sub Private Sub AppStart Serial1.Initialize(115200) Incoming data will cause the subroutine astream_ Log(“AppStart”) NewData to be called. B4RSerializator is used at both ends If espWifi.Connect2(“YourSSID”,”YourPassword”) of the Wi-Fi link to allow the transmission of an array of Then objects with numbers, strings, and arrays of bytes. At the server.Initialize(51042, “server_ other end of the link, B4RSerializator returns an array of NewConnection”) bytes. server.Listen The remote client (iPhone) will always send two bytes Log(“Waiting for connection.”) in a command string. The sender will always convert an Log(“My ip: “, espWifi.LocalIp) array to bytes, and the receiver will always convert bytes to Else an array. So, the server side code looks like this: Log(“Crapped Out.”) End If Sub astream_NewData (Buffer() As Byte) switch0.Initialize(wemosPins.D0, switch0. Dim be(10) As Object ‘used as a storage MODE_OUTPUT) buffer. switch1.Initialize(wemosPins.D1, switch1. Dim objects() As Object = ser. MODE_OUTPUT) ConvertBytesToArray(Buffer, be) switch2.Initialize(wemosPins.D2, switch2. For Each o As Object In objects MODE_OUTPUT) Select o switch0.DigitalWrite(False) Case “S0” switch1.DigitalWrite(False) If switch0State = False Then switch2.DigitalWrite(False) switch0.DigitalWrite(True) switch0State = False switch0State = True switch1State = False Else switch2State = False switch0.DigitalWrite(False) End Sub switch0State = False End If The first order of business is to connect to our local astream.Write(ser. LAN’s router. Once that’s accomplished, we can initialize ConvertArrayToBytes(Array(“S0”,switch0State))) our D1 Mini server to listen on port 51042. The “Log” Case “S1” statements are simply informative and show up in the B4R If switch1State = False Then IDE (integrated development environment). switch1.DigitalWrite(True) If the LAN connection and server initialization are switch1State = True successful, we can then move to initialize the WEMOS Else Mini’s three I/O pins as outputs and write logical lows to switch1.DigitalWrite(False) all three. If the LAN connection fails, the server reverts to switch1State = False February 2018 53

Eady - Design Cycle - Feb 18.indd 53 1/2/2018 8:58:00 PM ADVANCED TECHNIQUES FOR DESIGN ENGINEERS

End If client informing it of the status of the addressed I/O pin. astream.Write(ser. ConvertArrayToBytes(Array(“S1”,switch1State))) Coding the Client iPhone Case “S2” If switch2State = False Then B4I will be used to bring our iPhone code to life. The switch2.DigitalWrite(True) code we generate with B4I will also run on an iPad. Coding switch2State = True with B4I is very similar to coding with Visual Basic. The Else B4I graphical user interface (GUI) is created using Visual switch2.DigitalWrite(False) Designer, which also generates the skeleton subroutine switch2State = False calls for the graphical widgets. End If Once we have defined all the application objects and astream.Write(ser. generated the widget subroutines, we can then start to ConvertArrayToBytes(Array(“S2”,switch2State))) flesh in our application code. Again, we won’t get into the End Select details of how to use B4I as you can get the full Monty Next from the B4I website. End Sub The Visual Designer view for your iPhone remote control application can be seen in Screenshot 1. As you As you can see, following the conversion of incoming can see, we have laid out three buttons, three status bytes to an array, the command string (which is now an indicators, a connect button, a connection status area, an array) is parsed. The code contained within the subroutine information label, and an IP address text box. The actual astream_NewData uses the Boolean state of the Mini I/O visual that is shown to the user is depicted in Phoneshot 1. pin to determine the state of the physical Mini I/O pin. Let’s get to work on the iPhone application code: We have programmed the trio of D1 Mini I/O pins to toggle on every reception of a valid command that Sub Process_Globals is directed towards that particular I/O pin. Once the ‘These global variables will be declared once addressed I/O pin has been toggled, we use AsyncStreams when the application starts. and B4RSerializator to encode a return message to the ‘Public variables can be accessed from all

n PHONESHOT 1. This is an iPhone screenshot of our application in a disconnected state. Note the broken n SCREENSHOT 1. Visual Designer lets us lay out the buttons and views just red chain at the far left of the IP as we want them to be seen on the iPhone screen. address text box.

54 February 2018

Eady - Design Cycle - Feb 18.indd 54 1/2/2018 8:58:00 PM ADVANCED TECHNIQUES FOR DESIGN ENGINEERS

modules. Public App As Application Public NavControl As NavigationController Private Page1 As Page Private astream As AsyncStreams Private ser As B4RSerializator Private socket As Socket Public connected As Boolean Private btnConnect As Button Private btnS0 As Button Private btnS1 As Button Private btnS2 As Button Private imgvLedD0 As ImageView Private imgvLedD1 As ImageView Private imgvLedD2 As ImageView Private txfIP As TextField Private lblIP As Label Private lblStatus As Label Dim data() As Object End Sub

If you’re thinking this looks a bunch like the B4R code, you’re right. The cool thing about B4R and B4I is that if you n SCREENSHOT 2. The B4R development platform learn to code in one, you can code in the other. As you automatically programs the WEMOS D1 Mini upon can see in our Process Globals assignments, we are coding successful compilation of the target source code. In this with AsyncStreams and B4RSerializator on the iPhone end case, we have instructed the Mini to cough up its server IP too. address in the log area of B4R. If you think about that, it is a must. We have to have an “other end” to our data pipe (AsyncStreams), and we touched. The Connect button is actually the blue RF must be able to encode and decode on both ends of the graphic to the right of the IP address text box. link with B4RSerializator. The IP address textfield is used to input the address The NavigationController is iPhone related and you of the WEMOS D1 Mini server. Once the IP address is can get the gist of what it does by its name. Since the D1 entered, the Connect button is used to kick off the code Mini is a Wi-Fi device and Wi-Fi flows over TCP/IP, sockets for the connection to the server. The status label will shift are involved. A socket is no more than an IP address that is its graphic payload between a broken red chain and green associated with a port address. linked chain, depending on the status of the connection to The trio of buttons (S0, S1, and S2) is shadowed by a the Mini server. The data object is an array that is used in trio of associated blue LED indicators called imgvLedDx. the B4RSerializator encoding and decoding processes. The LED indicators are image views that will contain We are ready to move into making things happen. either the ON or OFF version of the blue LED. The blue Let’s initialize the B4RSerializator and show our Visual LED graphics you see in Figure 1 were created using Designer artwork: Photoshop. There are Private Sub Application_Start (Nav As tutorials on the NavigationController) Internet that ser.Initialize describe how to NavControl = Nav create the LED Page1.Initialize(“Page1”) images. Each of Page1.RootPanel.LoadLayout(“nvRemoteControl”) these images NavControl.ShowPage(Page1) n FIGURE 1. These LED images will toggle End Sub were very easy to create. There are between ON plenty of tutorials on the Internet that and OFF when Before we touch the Connect button, we must enter describe in detail how to draw these the associated the IP address of the D1 Mini server. If you take a peek types of graphic images. button is back at the B4R code, the Mini’s IP address is displayed in February 2018 55

Eady - Design Cycle - Feb 18.indd 55 1/2/2018 8:58:00 PM ADVANCED TECHNIQUES FOR DESIGN ENGINEERS

Globals. A logical TRUE value in our connected variable n PHONESHOT 2. The WEMOS will allow our data pipe to be initialized and assign D1 Mini’s IP address has been “astream” as a prefix name for all of the subroutines entered and the Connect button associated with our new AsyncStreams data pipe: touched. We are now connected to the Mini server and all of the I/O pins we control are in the Private Sub Astream_Error OFF state. Log(“Disconnected”) connected = False StateChanged the log area of the B4R IDE. End Sub I’ve captured the B4R log entry in Screenshot 2. Private Sub Astream_Terminated The Mini is waiting for a Astream_Error connection, and listening at End Sub IP address 192.168.1.222 on port 51042. So, we simply The StateChanged subroutine is called to handle the enter 192.168.1.222 in the chain graphic, which is represented as text in the label we txfIP textfield and touch the call lblStatus: Connect pushbutton: Public Sub StateChanged Sub btnConnect_Click If connected Then Connect(txfIP.Text) lblStatus.TextColor = Colors.Green End Sub lblStatus.Text = “□” Else Public Sub Connect(ip As String) lblStatus.TextColor = Colors.Red If astream.IsInitialized Then lblStatus.Text = “□” astream.Close End If End If End Sub socket.Initialize(“socket”) socket.Connect(ip, 51042, 30000) The chain graphic is a text squiggle that can’t be read End Sub by a human. That’s why you see nothing recognizable between the quotes in the StateChanged subroutine. The btnConnect subroutine is called when the Connect It’s sufficient to say that the status of the chain is button is touched. When the Connect subroutine launches, dependent on the Boolean variable connected. If the a quick check is made to ensure that our AsyncStreams connected variable is TRUE, the chain is linked and green. data pipe is not already in use, our socket object is On the other hand, if the connected variable is FALSE, the initialized, and the connection request containing our chain is broken and red. Our link is up in Phoneshot 2. socket values (192.168.1.222 and 51042) is transmitted. To control the Mini’s output pins, we simply touch the We’ll give it 30,000 milliseconds to work. desired button (S0, S1, or S2): If all goes as designed (or not), the Socket_Connected subroutine is launched: Sub btnS0_Click astream.Write(ser. Private Sub Socket_Connected (Successful As ConvertArrayToBytes(Array(“S0”))) Boolean) End Sub If Successful Then Sub btnS1_Click connected = True astream.Write(ser. astream.Initialize(socket.InputStream, ConvertArrayToBytes(Array(“S1”))) socket.OutputStream, “astream”) End Sub StateChanged Sub btnS2_Click End If astream.Write(ser. End Sub ConvertArrayToBytes(Array(“S2”))) End Sub The status of our new connection attempt is stored in the Boolean connected variable we defined in the Process The button code is self-documenting. When a button 56 February 2018

Eady - Design Cycle - Feb 18.indd 56 1/2/2018 8:58:00 PM ADVANCED TECHNIQUES FOR DESIGN ENGINEERS

is touched, B4RSerializator converts a n PHONESHOT 3. The blue LED graphic tells us two-byte command array to bytes and that the D0 I/O pin of the WEMOS D1 Mini is sends it over the astream output data logically high, or ON in the OFF state. pipe (socket.OutputStream). Looking back at the B4R code, we see that the D1 Mini application is looking for commands S0, S1, and LED ON/OFF graphic that S2 in array form. is displayed is determined When the Mini server receives our button command by the state of data(1). The string, it toggles the associated I/O bit and returns a status graphics blueledon.png and message to the client iPhone. The iPhone application blueledoff.png were included processes the incoming status message using the Astream_ as graphic fi les available to NewData subroutine: our application in the Visual Designer. Private Sub Astream_NewData (Buff er() As Byte) data = ser.ConvertBytesToArray(Buff er) I Leave You Select data(0) Illuminated Case “S0” If data(1) = True Then I touched button S0 and imgvLedD0.Bitmap = (LoadBitmap(File. was presented the iPhone DirAssets, “blueledon.png”)) view you see in Phoneshot 3. I checked the voltage at pin Else D0 of the Mini and it was indeed at +3.3V. imgvLedD0.Bitmap = (LoadBitmap(File. B4R provides access to all of the WEMOS D1 Mini’s DirAssets, “blueledoff .png”)) tricks, while B4I puts the compute power of an iPhone and End If iPad into your Design Cycle. NV Case “S1” If data(1) = True Then imgvLedD1.Bitmap = (LoadBitmap(File. DirAssets, “blueledon.png”)) Else imgvLedD1.Bitmap = (LoadBitmap(File. DirAssets, “blueledoff .png”)) TS-4900 End If Computer on Module Case “S2” i.MX6 ARM CPU If data(1) = True Then imgvLedD2.Bitmap = (LoadBitmap(File. WiFi & Bluetooth DirAssets, “blueledon.png”)) Solo or Quad Core Else 2 GB DDR3 RAM imgvLedD2.Bitmap = (LoadBitmap(File. DirAssets, “blueledoff .png”)) End If End Select End Sub

The status message returned from the WEMOS Mini server consists of the button touched and the status of the associated Mini output pin. The button touched is decoded by B4RSerializator as data(0), and the status of the output pin is decoded by B4RSerializator as data(1). The blue

B4R B4I Anywhere Software Actual Size www.b4x.com www.embeddedARM.com

February 2018 57

Eady - Design Cycle - Feb 18.indd 57 1/2/2018 8:58:00 PM NV New Products - Feb 18_Mar15 -NV - NewProducts.qxd 1/2/2018 4:46 PM Page 58

■ NEW PRODUCTS Continued from page 13

1/4-28 UNF Slot The TBST-120/60/60/2 is a compact shielded tent, designed to The HP- suppress interference from ambient RTG-C high noise during EMC pre-compliance power terminal measurements. With an outer block complies dimension of 4’ x 2’ x 2’, it can with UL and accommodate pre-compliance test CSA Standards, equipment such as LISNs or TEM- as well as RoHS, cells or others, as well as the device and features: under test, yet easily fit on a test bench. • Rated: The TBST-120/60/60/2 shielded 600 volts, tent has been designed with two waveform capture rate 90 amps layers of conductive fabric, • Standard LAN and USBTMC- • Operating Temperature: -25°C suspended on rigid aluminum compliant USB device port to +150°C. supports; the double-layer design • Housing: PA 66 (UL94V-0) significantly improving the tent’s For more information, contact: • Terminals: Copper — Current shielding effectiveness. B&K Precision conducting plate. Stainless A filter panel mounted at the www.bkprecision.com Steel — Terminal frame side provides one 240V/10A AC • Withstanding Voltage: AC filter, two 240V/10A DC filters, and THREE-POLE HIGH 2,500V four coaxial feed through adapters with screw caps. The front opening POWER BLOCK For more information, contact: provides access to the test space and lockMaster Electronics, Inc., BlockMaster Electronics is closed using conductive hook-and- Bannounces a new extension to www.blockmaster.com loop tape in order to avoid its existing line of high output power compromising the shielding efficacy. modular feed-through terminal TENT ENCLOSURES When measuring the conducted blocks, designed specifically for DIN noise spectrum of a powered device rail or panel mounting. FOR BENCHTOP being tested in an unshielded setup, The new three-pole high power conducted noise to be measured is block is rated at 90 amps and 600 PRECOMPLIANCE often hidden below the ambient volts and is well-suited for high power TESTS noise level, making accurate distribution in electrical panels. This measurements impossible without high power block snaps onto a DIN aelig Company, Inc., announces eliminating the interference. rail or mounts onto a panel. Sthe TekBox TBST120/60/60/2 Most shielded environments have Applications include: Shielded Tent which provides an previously been prohibitively • Panels economical RF/EMI-attenuated expensive for many situations, but • CNC equipment environment for a variety of bench- the TekBox shielded solution is now • Standby generators top “EMI quiet” applications. available at under $2,000. • Switch gear • HVAC equipment • Water pumps • Other industrial and commercial applications

Multiple HP-RTG-C power blocks may be ganged together or used individually. Its termination accommodates 2 to 12 AWG wire and is configured as follows:

LINE SIDE: 1/4-28 UNF Slot LOAD SIDE: 58 February 2018 NV New Products - Feb 18_Mar15 -NV - NewProducts.qxd 1/2/2018 4:46 PM Page 59

Specifications temperature range is -55°C to • Outer dimensions: 47.25” x +180°C. The socket also features a 24” x 24” floating guide for precise ball-to-pin • Opening: 33.5” x 13.8” alignment. The specific configuration • Frame: 0.8” x 0.8”extruded of the package to be tested in the www.poscope.com aluminum supports CBT-BGA-6073 is a BGA, 20x15 mm, • Shielding: Two layers of 0.8 mm pitch, 252 position 23x17 conductive fabric ball array. • Seal: Conductive Velcro™ tape The socket is mounted using • Suspension: Velcro strips supplied hardware on the target PCB • Filter panel: 1 x 240V/10A AC with no soldering, and uses the filter; IEC socket smallest footprint for nearby passive • 2x 240V/10A DC filter; cables components. The socket uses a five with female banana couplers post stiffener plate to support the • 3x N-female feed-through back side of the PCB and allows connector with screw caps passive components to be placed in • 1x BNC-female feed-through between posts. connector This socket utilizes a clamshell lid • Attenuation: >58 dB in the with an integrated compression range DC to 1.5 GHz mechanism. The socket is • Weight: 23.75 lbs constructed with a cam actuated - USB #"  - Ethernet - Encoders lever lid with a central opening for - Web server - LCD Applications include things like direct thermal characterization of - Modbus #" " - CNC (Mach3/4) #""  wireless device testing, EMC pre- silicon. - IO compliance testing, secure To use, place the device inside communications, satellite the socket, close the clamshell lid by communications, medical equipment latching, and apply downward shielding, operator safety, etc., to pressure by turning the lever. This name a few. socket can be used for hand test and temperature characterization, as well For more information, contact: as debugging applications in Saelig Company development and MCP comparisons www.saelig.com between various manufacturers. - up to 256 - up to 32 Pricing for the CBT-BGA-6073 is microsteps microsteps - 50 V / 6 A - 30 V / 2.5 A EXTREME TEMP $972 (qty 1) with reduced pricing #"! "" available depending on the quantity - Isolated SOCKET required. ronwood Electronics recently  "" Iintroduced a new BGA socket For more information, contact:  "" addressing high performance Ironwood Electronics requirements for the Multi-Chip www.ironwoodelectronics.com Memory Package CBT-BGA- 6073. The contactor is a stamped spring pin with 31 gram actuation force per ball and cycle life of 125,000 insertions. The self-inductance of the contactor is 0.88 nH, insertion - up to 50MS/s loss < 1 dB at 15.7 GHz, and - resolution up to 12bit - Lowest power consumption contact resistance is <30 #" "" megohms. - 7 in 1: Oscilloscope, FFT, X/Y, Recorder, """   " " " """" The current capacity of " each contactor is four amps at 60°C temperature rise. Socket February 2018 59 READER - TO - READER TECHFORUM

>>> QUESTIONS Neutralizing Battery Corrosion not to exceed a 90 volt DC output What’s the best way to neutralize and most likely on the low end to Legacy Printer Port (LPT1) battery corrosion? I inherited an old, prevent the motor from stalling. I’m doing some work with legacy but expensive quartz watch from Steve Ghioto computer equipment and have my grandfather and found a heavily Atlantic Beach, FL written Basic software to control corroded coin battery inside the time and temperature in a high watch case. I need to neutralize the [#11175 - November 2017] temperature kiln. I’ve used an old corrosion without damaging the Troubleshooting Amp Problems Compaq laptop (LTE Elite 4/40CX). movement. I picked up a CrownDC150a I use the COM 1 port to control #2184 Clarence Dugan power amp at a garage sale. When temperature and the LPT1 port to Quitman, TX I tested it on my bench, one side is cycle the kiln on/off via an SCR. rather distorted but then clears up Everything works great. I’m once the amp warms up, making able to toggle the printer port pins it hard to trace. Is this a common via OUT commands. When trying >>> ANSWERS problem with these amps? Any other legacy computers, everything troubleshooting tips are appreciated. works except the printer ports don't [#11171 - November 2017] respond to the OUT commands and Variable DC Motor Control #1 One can often use a controlled remain in a high state. However, they I’d like to have continuous burst of freeze spray to hit individual DO operate the dot matrix printer variable control of the motor in my components once it has warmed up. indicating they are functional. My bench vibrator/polisher. It has a DC Hitting resistors or capacitors or even question is how do I gain control of (not AC!) motor that is rated at 90 solder connections may reveal the some of the data pins and be able to VDC with a power supply that delivers culprit. toggle them high and low? 10 amps. I prefer to build something George Kaczowka #2181 Jerry Sobel, R.Ph. myself. Anyone have some design tips, York, ME Las Vegas, NV or better yet, a schematic? #2 You mention the model is Amplifying Plant Signals #1 Here is the “wrong” answer to DC150A. Crown does not list that I’m trying to duplicate an ESP the problem: Harbor Freight sells a model but does have a D-150 and experiment described in the book router speed control for $20. Plug it D-150AII listed. “What A Plant Knows,“ by Chamovitz. in between the wall outlet and your Service info is here: https://www. Basically, I need an amplifier and tool. See if it does what you want. If crownaudio.com/en/products/d- sensor to read signals from stems and not, take it back and they will give series. roots. What frequency response does you your money back. The symptom you mention could the amp need? My guess is from DC Chip Veres be crossover distortion in the output to maybe 20 Hz? If this is the case, Miami, FL stage due to an out-of-spec bias then what sort of amp configuration voltage (very low or non-existent). As do I need? #2 What about using a variac with the amp warms up, the bias voltage #2182 Carlos Dixon a standard full wave rectifier and generator begins to function to some Flint, MI large filter capacitors? The schematic degree and the distortion becomes (Figure 1) lists several commercial less. The bias voltage is designed to Measuring Breathing Rate components. vary as the output stage temperature I’m building a lie detector based Several things to mention before changes, but should never fall to zero. on heart rate, breath rate, and any attempt at construction: Connect an audio generator (1 galvanic skin response. I have it all • Be aware that most variacs are kHz, variable 0 to about 2V RMS sine figured out except for breath rate. not fully isolated, meaning the neutral wave) to the amp's input and connect What sort of sensor should I use to on the mains supply is connected to a suitable sized dummy load (8 detect breath? the neutral on the output. ohm) resistor and oscilloscope to the #2183 Jeanne Villeneuve • Mechanical stops will need to be output terminals. Power-up the amp Vidalia, GA implemented on the control dial as and observe the output sine wave 60 February 2018

Tech Forum - Feb 18.indd 60 1/2/2018 8:01:46 PM >>>YOUR ELECTRONICS QUESTIONS ANSWERED HERE BY N&V READERS

Send all questions and answers by email to [email protected] or via the online form at www.nutsvolts.com/tech-forum

[#12172 - December 2017] AMP Clamp Could someone explain in simple terms how an AMP clamp works? Does it have a transformer in it or Hall- effect sensors or similar?

#1 AC amp clamps use a current transformer. The clamp is a laminated iron ring with a coil of wire wound n FIGURE 1. around it. The alternating current in a powered AC line induces a for distortion at the zero crossing. similar? magnetic flux in the clamp’s ring Also look for a symmetrical sine wave I want to create a four-node VAX which the attached coil picks up amplitude. An offset step at the zero cluster like the one I used to work on, via electromagnetic induction. crossing is likely a bias problem. and would love to see it sitting on my That induced signal is fed to an A non-symmetrical sine wave desk as a stack of Raspberry Pi boards. amplifier whose output is rectified could be a power supply problem and filtered; the resulting averaged or output transistor problem. If the #1 I did a search for VAX VMS (i.e., RMS) DC voltage is fed to the sine wave is clipped on the top (well emulator and found the following: meter’s measuring circuit. The typical before maximum output power is VAX/VMS on RaspberryPi at the conversion is 1A AC = 1V DC on the reached) but the zero crossing point RaspberryPi Forum - https://www. meter. seems okay, then the bias may not raspberrypi.org/forums/viewtopic. DC clamps use Hall-effect be the issue. Rather, the power php?t=7552&p=93217. sensors. As I understand them, the supply voltage could be too low or Lance Corey construction is similar to AC clamps, the distortion is being introduced at Santa Ana, CA except an exciter coil is attached to the input stage or possibly the VA the iron ring to pre-energize the ring (voltage amplifier) stage. #2 Consider looking at SimH. It has with a specific frequency/voltage, Erik a network-capable VAX simulator. It which the Hall-effect circuitry sees Escondido, CA is available in source code form (say, as a zero level. DC current flowing if you wanted to run it under Linux through the clamp creates a magnetic #3 Crowns are generally great on an SBC), and also as a Windows field which alters that excite signal, amps, very few issues. My guess is executable (you would not have to which, in turn, changes the signal the you have a cracked or weak solder use a virtual machine). Visit http:// Hall-effect sensor sees, which causes joint someplace — perhaps in the simh.trailing-edge.com/. the Hall-effect detector circuit to power stage — that makes better Jay Jaeger output a voltage (positive or negative) contact once things get hot and Madison, WI proportionate to the current flowing expand. It might also be a bad cap in the measured conductor. Like the somewhere, but that seems less likely #3 What you are looking for is AC clamp, that detected signal is to me. SimH: a free VAX emulator that will fed to an amplifier which outputs a Ralph Hipps run on the Raspberry Pi available at DC level which is fed to the meter’s CA http://simh.trailing-edge.com. You measuring circuit with a similar can get VMS licenses and software at conversion scale (i.e., 1A DC = 1V #12171 - December 2017] www.openvmshobbyist.com. Check DC on the meter). VAX VMS Emulation out this article: https://www.rs- As you’re aware, amp clamps Is there an emulator for a Digital online.com/designspark/a-raspberry- are an EXTREMELY SAFE method of Equipment Corporation’s VAX VMS pi-vax-cluster. I think you will find measuring high current (i.e., 10s and 4.7 machine, either running on an SBC everything you need. 100s of amps) in powered circuits (Single Board Computer), or possibly Ronald Schubot because you don’t have to break any an image that can run as a virtual Kalamazoo, MI wires for making the measurement. machine in VMWare or something HOWEVER, because their resolution February 2018 61

Tech Forum - Feb 18.indd 61 1/2/2018 8:02:21 PM >>>YOUR ELECTRONICS QUESTIONS ANSWERED HERE BY N&V READERS

is typically between 100 mA (0.1A) The clamp is rated for sinusoidal use a transformer to measure the and 1A (due to the limitations of the currents. Measurements of non- current. The “clamp” is the core for magnetic detection circuitry), amp sinusoidal current is best done with that transformer, and it is opened to clamp’s use is limited to measuring a true-RMS instrument connected to go around the AC wire as it becomes power lines connected to large the clamp secondary winding. the one-turn primary. There are simple devices (i.e., pump motors) that Currents small relative to the components to scale the multi-turn naturally consume large amounts of capability of the clamp can be secondary current down for the current in operation. measured by passing the conductor correct reading — either analog or Ken Simmons through the clamp multiple times and digital. The digital part uses its own Auburn, WA dividing the measured value by the circuit to convert the measurement to number of turns. its display. #2 An amp clamp is a transformer Peter A. Goodwin A DC current meter cannot use having a one-turn primary (the Rockport, MA the same transformer method, so it conductor carrying the current to be uses the Hall device that converts a measured) and a multi-turn secondary #3 You are on the right track. The magnetic fi eld to a resistance, and (to feed the measuring instrument). ones that measure AC use a pickup the internal components convert that Being a transformer, it can only coil, and the ones that measure DC resistance to a reading — analog or be used to measure alternating use a Hall-effect sensor. digital. current. Be aware of its measurement Chip Veres Raymond Ramirez rating, because too much current Miani, FL Bayamon, PR can saturate the clamp, resulting in inaccurate readings. #4 The common AC current meters #5 I'm no expert, but you are

62 February 2018

Tech Forum - Feb 18.indd 62 1/2/2018 8:02:40 PM correct in your assumptions. I found compared to the VGA display that each character. Keep in mind the this great article at Wikipedia on the there’s no way it can hold all the LCD display consists of four rows of subject: https://en.wikipedia.org/ information shown on VGA. 20 characters each. Each character wiki/Current_clamp. You would be FAR better off is formed by a 5 x 7 dot matrix, Fernando Cordero rigging up some kind of serial port and the characters are separated by Clermont, FL interface to the PC with the VGA approximately a pixel width and 0.2 output and selectively sending pixel height. So, you are going from [#12173 - December 2017] whatever data is of interest to the an aspect ratio of 4:3 to 25:7 or VGA To LCD LCD. 12.5:3.5 — a signifi cant difference. I would like to be able to drive Ralph Hipps In addition, the pixels in the a 4x20 line LCD with a VGA output CA VGA display can vary in color and from an old computer. Is there a brightness, where the LCD display simple interface to do this? #2 In all honesty, I believe this is only black and white, and are not would be a fruitless exercise. The individually adjustable in brightness. #1 The short answer is no. VGA interface would be far from simple, Finally, the electronic interfaces is an analog interface; LCDs use a and the resulting image on the 4x20 to drive each type of display are digital interface. You would need a LCD display would most likely not be signifi cantly different both in three-channel ADC to start with, but recognizable from the original VGA hardware and software, and would even that’s not enough. It would be image. require a very complex interface to very diffi cult to extract alphanumeric VGA has a resolution of 640 x even come close. characters for the LCD from that 480 and the LCD display would be Ira Wexler data. Plus, the 4x20 LCD is so small 100 x 28, assuming 5 x 7 matrix for Owings Mills, MD

WIRELESS SCOPE-IN-A-PROBE

• 200 MSa/s Sampling Rate

• 30 MHz Bandwidth Ultra Portable WiFi Oscilloscope Fits Perfectly in Your Hand. • 80 Vpp Input Range Works with PC, Mac, Tablet or Phone. • Fully Calibrated

• Intuitive Software for Windows, Linux, MacOS, Android & iOS

• 1 Week Battery Life (20 Measurements per Day)

• Ideal for Onsite Maintenance & Inspection, Isolated (Instant-on) Measurements, Manufacturing, Aerospace & Automotive $299.95 Free Shipping

February 2018 63

Tech Forum - Feb 18.indd 63 1/2/2018 8:03:01 PM ElectroNet - Classified Ads - Index - Feb 18_Mar15 -NV - NewProducts.qxd 1/2/2018 5:14 PM Page 64

For the ElectroNet online, go to www.nutsvolts.com ELECTRONET click Electro-Net

Add USB to your next project-- CLASSIFIEDS USB It's easier than you might think! USB-FIFO USB-UART USB/Microcontroller Boards RFID Readers Design/Manufacturing Services Available KITS HARDWARE Absolutely NO driver software development required! D.I.Y. LASER TAG WANTED www.dlpdesign.com www.LaserTagParts.com DEC and VME Equipment WANTED! PARTS | KITS | SCHEMATICS | FIRMWARE Digital Equipment Corp FORUM | STORE | HOBBY & COMMERCIAL and Motorola MVME Systems LIGHTING and Parts Buy - Sell - Trade CALL KEYWAYS 937-847-2300 or email [email protected] Wanna read even more about electronics? Check out our book selection at Subscribe today! store.nutsvolts.com ADvertiser INDEX

■ LOOK FOR ■ SEARCH FOR ■ FIND Find your favorite advertisers here! Accutrace ...... 67

AUDIO/VIDEO DEVELOPMENT CONTROL All Electronics Corp...... 35 Team Kingsley ...... 21 PLATFORMS/TOOLS Hitec Commercial Solutions ...... 2 Technologic Systems ...... 57 ServoCity ...... 66 ExpressPCB ...... 45 BATTERIES/CHARGERS Hitec Commercial Solutions ...... 2 EDUCATION ROBOTICS Hammond Manufacturing ...... 8 M.E. Labs ...... 21 Hitec Commercial Solutions ...... 2 BUYING ELECTRONIC PoLabs ...... 59 SDP/SI ...... 13 Hitec Commercial Solutions ....2 SURPLUS ServoCity ...... 66 All Electronics Corp...... 35 EMBEDDED SYSTEMS Lemos International ...... 13 Saelig Co. Inc...... 3, 63 TEST EQUIPMENT CIRCUIT BOARDS Technologic Systems ...... 57 PoLabs ...... 59 Measurement Computing .....BC Saelig Co., Inc...... 3, 63 Accutrace ...... 67 ExpressPCB ...... 45 ENCLOSURES M.E. Labs ...... 21 Saelig Co., Inc...... 3, 63 Hammond Manufacturing ...... 8 TOOLS PanaVise ...... 18 PanaVise ...... 18 COMPONENTS LCDs/DISPLAYS PoLabs ...... 59 All Electronics Corp...... 35 Saelig Co., Inc...... 3, 63 PoLabs ...... 59 Saelig Co., Inc...... 3, 63 TRANSFORMERS MICROCONTROLLERS / Hammond Manufacturing ...... 8 Saelig Co., Inc...... 3, 63 DATA LOGGING I/O BOARDS Measurement Computing ...... BC M.E. Labs ...... 21 WIRE, CABLE AND SDP/SI ...... 13 Technologic Systems ...... 57 CONNECTORS DESIGN/ENGINEERING/ All Electronics Corp...... 35 ServoCity ...... 66 REPAIR SERVICES MISC./SURPLUS Team Kingsley ...... 21 Accutrace ...... 67 All Electronics Corp...... 35 WIRELESS PRODUCTS ExpressPCB ...... 45 Lemos International ...... 13 MOTORS / MOTOR Technologic Systems ...... 57 Technologic Systems ...... 57 64 February 2018 SERVO MAGAZINE ... Paving the way for the next generation of Robotics Experimenters!

SERVO MAGAZINE SERVO MAGAZINE SERVO MAGAZINE SERVO MAGAZINE SERVO MAGAZINE SERVO MAGAZINE SERVO MAGAZINE SERVO MAGAZINE SERVO MAGAZINE SERVO MAGAZINE SERVO MAGAZINE SERVO MAGAZINE SERVO MAGAZINE SERVO MAGAZINE SERVO MAGAZINE SERVO MAGAZINE SERVO MAGAZINE SERVO MAGAZINE SERVO MAGAZINE SERVO MAGAZINE SERVO MAGAZINE SERVO MAGAZINE SERVO MAGAZINE SERVO MAGAZINE SERVO MAGAZINE SERVO MAGAZINE SERVO MAGAZINE SERVO MAGAZINE SERVO MAGAZINE SERVO MAGAZINE SERVO MAGAZINE SERVO MAGAZINE SERVO MAGAZINE SV Sub Ad.indd 65 12/4/2017 9:00:23 PM

PWM Meter Need to know what PWM signal your receiver, robot or servo controller is sending? No need to fuss with an oscilliscope, just plug in our new PWM Meter!

Low Voltage Cutoff Switch Draining your LiPo batteries below 3V per cell will cause permant damage. Protect againse over discharge with our new Low Voltage Cutoff Switch!

Visit ServoCity.com Today!

Full Page.indd 66 12/4/2017 9:12:04 PM ea ea ea

Our Full Service Capabilities:

(408)748-9600 ITAR I SO 9001:2008 UL Approved

Full Page.indd 67 9/5/2017 6:21:32 PM Looking to develop your Smart Data Logging Application? Measurement Computing makes it easy to integrate high quality measurements to your Raspberry Pi® or other Single-board Computer with open-source Linux® Drivers

Challenge: Develop a low-cost monitoring solution with high accuracy and reliability MCC enabled an engineering design and consulting fi rm to develop a low-cost instrument for monitoring power distribution components. The number of potential installations was in the thousands, so the instrument needed to be economical without sacrifi cing highly accurate measurements. To fulfi ll these needs, the MCC USB-201-OEM was integrated with a single-board computer for a cost-effective smart solution.

MCC was chosen for: • Measurement and manufacturing quality • Availability of stable, open-source Linux Drivers • Free pre-sales and post-sales technical support

Many Measurement Computing products – including most USB, Ethernet™, Bluetooth®, and PCI products – are supported under professional, open-source Linux drivers.

Source code and examples are available on GitHub. Visit www.mccdaq.com/Linux for more information!

1 YEAR

MCCDAQ.COM Contact us 1.800.234.4232

©2018 Measurement Computing Corporation, 10 Commerce Way, Norton, MA 02766 • [email protected]

N&V-BACK-COVER-February.inddFull Page.indd 68 1 1/2/201812/20/17 9:12:40 1:30 PM