Silicon ChipMax’s Cool Beans - September 2022 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Subscriptions: PE Subscription
  4. Subscriptions
  5. Back Issues: Hare & Forbes Machineryhouse
  6. Publisher's Letter
  7. Feature: What’s in a name? by Mark Nelson
  8. Feature: The Fox Report by Barry Fox
  9. Feature: Net Work by Alan Winstanley
  10. Project: TOUCHSCREEN AND REMOTE DIGITAL PREAMP WITH TONE CONTROLS by NICHOLAS VINEN AND TIM BLYTHMAN
  11. Project: MICROMITE TO SMARTPHONE CONNECTOR VIA BLUETOOTH by TOM HARTLEY
  12. Project: 20A DC Motor Speed Controller by JOHN CLARKE
  13. Project: USB-PD Triggers, Decoys and Testers by Jim Rowe
  14. Feature: Circuit Surgery by Ian Bell
  15. Feature: Make it with Micromite by Phil Boyce
  16. Feature: Max’s Cool Beans by Max the Magnificent
  17. Feature: AUDIO OUT by Jake Rothman
  18. PCB Order Form
  19. Advertising Index

This is only a preview of the September 2022 issue of Practical Electronics.

You can view 0 of the 72 pages in the full issue.

Articles in this series:
  • (November 2020)
  • Techno Talk (December 2020)
  • Techno Talk (January 2021)
  • Techno Talk (February 2021)
  • Techno Talk (March 2021)
  • Techno Talk (April 2021)
  • Techno Talk (May 2021)
  • Techno Talk (June 2021)
  • Techno Talk (July 2021)
  • Techno Talk (August 2021)
  • Techno Talk (September 2021)
  • Techno Talk (October 2021)
  • Techno Talk (November 2021)
  • Techno Talk (December 2021)
  • Communing with nature (January 2022)
  • Should we be worried? (February 2022)
  • How resilient is your lifeline? (March 2022)
  • Go eco, get ethical! (April 2022)
  • From nano to bio (May 2022)
  • Positivity follows the gloom (June 2022)
  • Mixed menu (July 2022)
  • Time for a total rethink? (August 2022)
  • What’s in a name? (September 2022)
  • Forget leaves on the line! (October 2022)
  • Giant Boost for Batteries (December 2022)
  • Raudive Voices Revisited (January 2023)
  • A thousand words (February 2023)
  • It’s handover time (March 2023)
  • AI, Robots, Horticulture and Agriculture (April 2023)
  • Prophecy can be perplexing (May 2023)
  • Technology comes in different shapes and sizes (June 2023)
  • AI and robots – what could possibly go wrong? (July 2023)
  • How long until we’re all out of work? (August 2023)
  • We both have truths, are mine the same as yours? (September 2023)
  • Holy Spheres, Batman! (October 2023)
  • Where’s my pneumatic car? (November 2023)
  • Good grief! (December 2023)
  • Cheeky chiplets (January 2024)
  • Cheeky chiplets (February 2024)
  • The Wibbly-Wobbly World of Quantum (March 2024)
  • Techno Talk - Wait! What? Really? (April 2024)
  • Techno Talk - One step closer to a dystopian abyss? (May 2024)
  • Techno Talk - Program that! (June 2024)
  • Techno Talk (July 2024)
  • Techno Talk - That makes so much sense! (August 2024)
  • Techno Talk - I don’t want to be a Norbert... (September 2024)
  • Techno Talk - Sticking the landing (October 2024)
  • Techno Talk (November 2024)
  • Techno Talk (December 2024)
  • Techno Talk (January 2025)
  • Techno Talk (February 2025)
  • Techno Talk (March 2025)
  • Techno Talk (April 2025)
  • Techno Talk (May 2025)
  • Techno Talk (June 2025)
Max’s Cool Beans By Max the Magnificent Flashing LEDs and drooling engineers – Part 31 A s is usually the case, I’m currently bouncing off the walls with excitement. Sometime last year, I may have mentioned that I’ve been invited to give the keynote presentation at the FPGA Forum 2022 in Norway (www.fpga-forum.no). This auspicious affair is attended by all of the movers and shakers in Norwegian programmable space (where no one can hear you scream), including designers, project managers, technical managers, researchers, final-year students and FPGA vendors. Norway Ho! This year’s Forum was originally intended to take place in February but... COVID... so it was rescheduled for September. The reason this is particularly poignant for me because I previously gave the keynote presentation at this exceptional event deep in the mists of time we used to call 2012. On the one hand, that’s only 10 short years ago, which would be but a trifling hop in my time machine if I could ever get the little scamp working (you simply can’t get the parts where I live in Huntsville, Alabama). On the other hand, technology has been racing along, as is its wont, and much has changed. For example, some FPGA companies that were with us in 2012 (eg, TierLogic and Tabula) have given up the ghost, bitten the dust, and shuffled off this mortal coil (I never metaphor I didn’t like). Contrariwise, some feisty newcomers (eg, Efinix and Renesas) have decided to scamper over to the bar and join the party. Oh yes, and there’s also the fact that we are now up to our metaphorical armpits in artificial intelligence (AI), machine learning (ML) and deep learning (DL). Plus, we are being inundated with new flavours of reality (I’m a sucker for strawberry myself), including augmented reality (AR), diminished reality (DR), virtual reality (VR) and augmented virtuality (AV) to name but a few. Phew! Suffice it to say that I have little doubt I’ll manage to scrape together something to talk about (much like my dear old mother, the real trick is to get us to stop talking). Oftentimes, in addition to the Norwegian contingent, attendees to the Forum come 52 from nearby nations, including Sweden and Finland. I’m also hoping to see representatives from a company called Testonica (testonica.com), which is headquartered in the Baltic country of Estonia. These guys and gals have a tasty technology called Quick Instruments. If you are designing a circuit board featuring an FPGA, all you have to do is provide a high-level view of the system – including the types of other devices on the board and their pin maps and register maps – and Quick Instruments automatically generates and compiles a corresponding firmware test suite, thereby allowing the FPGA to perform a sophisticated board-level self-test. On the eve of a new era The FPGA Forum has traditionally been held in the city of Trondheim, which is the third-most populous municipality in Norway. Among many other things, Trondheim is home to the Norwegian University of Science and Technology (NTNU). There are two reasons I mention this here. First, the day before my keynote, I’ll be giving a guest lecture to a gaggle of MSc electrical and electronic engineering students at NTNU (www.ntnu.edu). Second, the company Halodi Robotics (www.halodi. com), which I introduced in my previous column (PE, August 2022), is headquartered in Norway and their EVE humanoid robots (Fig.1) can be found in most Norwegian universities. I’m hoping an EVE will deign to attend my lecture, in which case you can bet your cotton socks I’ll be taking photographs and reporting further in a future column. EVE is human-sized and has 23 degrees of freedom. Boasting two-arm manipulation, EVE can handle an 8kg payload with each arm. EVE can also squat down to pick things up off the floor or out of cupboards and reach up to place objects on shelves. The amazing thing for me is that EVEs are already deployed and working around the world in applications ranging from retail to security. In the case of retail, for example, EVEs can perform tasks like roaming a supermarket’s aisles, spotting out-of-place items, and returning them to their rightful locations, restocking shelves, gathering items for remote shoppers to pick up later, identifying potential hazards like spills and reporting them, and... the list goes on. Similarly, when it comes to security applications, EVEs can autonomously roam around buildings looking for unauthorised intruders with unrecognised faces, checking doors are locked and lights are turned off… and so on and so forth. In fact, earlier this year, the American security company ADT signed the world’s largest order to date for humanoid robots by ordering 140 EVEs from Halodi. It all starts with a single servo As amazing as EVE is, such creations all start with a single actuator like a servo, which is the point you and I currently find ourselves in our discussions. As discussed last month, we started with a 9g hobby micro servo, where the ‘9g’ refers to the approximate weight of the servo, not the amount of torque it can provide. Originally, I was planning on taking one of these bodacious beauties apart to show you what’s inside, so I ordered a set Fig.1. EVE the humanoid robot. (Image: Halodi Robotics) Practical Electronics | September | 2022 Fig.2. Knob Circuit in the theoretical world. (Image: Arduino) of five SG90 micro servos from Amazon (I’ll explain why my plans changed in a moment). There are myriad suppliers for this sort of thing, including many generic offerings (https://amzn.to/3O32sC4), but ‘you get what you pay for,’ so be careful what you order. The cheap-and-cheerful servos I opted for offer 180° of rotational motion. As we previously discussed, the way these servos work is that our controller – an Arduino Uno is this case – periodically sends a positive-going pulse to the servo. The period between pulses isn’t particularly important – it’s the width of the pulses that counts – but it’s common to use a ‘refresh’ frequency of 20ms (milliseconds), which means we send new pulses to the servo 50 times each second (50Hz). When it comes to the width of the pulses, a value of 1.5ms instructs the servo to move to its default (centre) position. In the case of the servos I ordered, the accompanying data sheet says that a pulse of 1.0ms corresponds to a rotation of −90° (anticlockwise all the way to the ‘left’) while a pulse of 2.0ms corresponds to a rotation of +90° (clockwise all the way to the ‘right’). Although a 1.5ms pulse will always direct this sort of servo to its centre position, different servos may vary with respect to their end-point values. According to Motors for Makers (https://amzn. to/3IovsD0), for example, some servos will accept pulses from 0.7ms (full rotation left/anticlockwise) to 2.3ms (full rotation right/clockwise) (by ‘full’ we mean the maximum rotation supported by that particular servo). The main thing is that we don’t want to make our pulses too narrow or two wide such that they exceed the servo’s range because this may result in our stripping the gears, which is not considered to be a good thing to happen. It’s also important to remember that these servos are intended for hobby applications, so their specifications and tolerances can Practical Electronics | September | 2022 be more than a little wibbly-wobbly compared to industrial-grade devices. What I’m trying to say is that, even in a batch of supposedly ‘identical’ servos, there is the potential for a lot of variation, so it’s a good idea to characterise each device before using it. Speaking of which... Turn the knob on your side Older readers may remember a British radio comedy called The Goon Show featuring Spike Milligan, Harry Secombe, Peter Sellers and Michael Bentine. This zany program, which was a favourite of Prince Charles, was originally broadcast from 1951 to 1960 with occasional repeats. I recall an episode during which one of the characters said, ‘Turn the knob on your side.’ Another character responded, ‘I haven’t got a knob on my side.’ And the first character retorted, ‘Of the door, you idiot!’ (You had to be there and hear their voices. I’m still chuckling inside.) In my previous column, we noted that the Arduino comes equipped with a servo library (https://bit.ly/3O3rIZu). We also created a ‘Sweep’ circuit and program that caused our servo to sweep back and forth. Now we’re going to implement what the folks at Arduino call their ‘Knob’ circuit. It’s pleasing how pristine things are in the theoretical world (Fig.2). It’s also remarkable how much ‘rattier’ they appear when viewed in the real world (Fig.3). In this case, as opposed to the breadboardmounted potentiometer (pot) shown in the theoretical circuit, I’m using a rather chunky free-standing pot as shown in the upper right-hand corner of the image. Now let’s consider the program we’re going to use to characterise our servo (Fig.4). Our first step on Line 1 is to include the servo library. On Line 3, we create a servo object. In this case, we’ve called it MyServo, but any legitimate (non-keyword) name will do. On Line 5 we declare an integer (int) variable called PotPin that we assign to the Arduino’s A0 analog input, and then on Line 6 we declare another integer variable called PotVal that we will use to store the values we read from our pot. On Line 10, we use the attach() method to attach our servo variable to a pin. In this example we employ three arguments: 9, 1000 and 2000. The first argument, which is mandatory, specifies the pin we wish to use to drive our servo. This must be one of the pins that support pulse-width modulation (PWM), which are pins 3, 5, 6, 9, 10 and 11 in the case of an Arduino Uno (we are using pin 9 in this example). The second and third arguments, which are in units of microseconds, are optional. The second argument specifies the pulse width corresponding to the minimum (0°) angle on the servo, while the third argument specifies the pulse width corresponding to the maximum (180°) angle on the servo. We are using values of 1,000µs and 2,000µs (1ms and 2ms), respectively. Interestingly, the default values used for these parameters if we don’t specify them are 544 and 2400, respectively, which are well outside the range values we have been led to regard as being valid. Fig.3. Knob Circuit in the real world (the blue servo appears on the left). 53 F orce ( F ) R adius ( r) Fig.5. Visualising torque. Fig.4. Example Knob Circuit program. When we come to the main loop, we start on Line 15 by reading the value from the pot into our PotVal variable. Since the Arduino Uno has a 10-bit ADC (analogue-to-digital converter), this will result in values between 0 and 1023. The write() method provided by the Arduino’s servo library requires values in the range 0 to 180, corresponding to 0° to 180°, respectively. Thus, on Line 16, we use the Arduino’s map() function to convert the 0 to 1023 values read from the pot into their 0 to 180 equivalents. On Line 17, we write this new value to the servo, and on Line 18 we insert a 15ms delay to give the servo time to respond. A puzzling poser In Fig.3 you’ll see a small circle of card marked out in 45° angles in the lower left of the image. This is just something I threw together for the purposes of these discussions. If I had been doing this in earnest, I would have created a more accurate tool divided into 5° segments. When I placed this card under the rotating arm on top of the servo and ran the program above, turning the pot from one extreme to the other caused the servo arm to move only 90°. I changed the attach() method’s min and max arguments to be 700 and 2300, respectively. This resulted in an approximately 135° swing of the servo arm. Finally, I tried the servo library’s default values of 544 and 2400, which resulted in something close to a 180° swing, although I did detect little ‘graunching’ sounds at the extremities of the movement. This left me perplexed and puzzled. I can accept a little variance, but why would the data sheet specify min and max values of 1000 and 2000 when the servo actually requires values of 544 and 2500? (If you have any thoughts on this, I’d love to hear them.) Not so simple I fear this is the point in this article where we may expect some gnashing of teeth and rending of garb because our illustrious publisher, Matt Pulzer, keeps on telling me to ‘stick to the electronics’ and I keep on saying to myself, ‘But this other stuff is soooo interesting!’ For example... the term ‘simple machine’ refers to a mechanical device that can be used to change the direction or magnitude of a force. The six classical simple, as defined by Renaissance thinkers, are the lever, wheel and axle, pully, inclined plane, wedge and screw. I could waffle on about these little beauties for ages, but we have other fish to fry. Of particular interest to us here is the fact that gears may be considered simple machines that consist of two or more wheels equipped with interlocking teeth such that when one gear is rotated any other interlocked gears rotate in the opposite direction. It’s probably worth noting that some people – especially in the UK – informally refer to gears (aka gearwheels or cogwheels) as cogs, but the term ‘cog’ officially denotes an individual tooth on the gear. Although they may appear simple, there’s much more to gears than meets the eye. We could spend weeks delving into their intricacies, but we won’t because I can feel Matt’s all-seeing eye starting to swing in my direction. You can torque! Fig.6. Classic servomotor with arm attached to the output of the gear train. I’m afraid this is the point where we are going to have to introduce some semitechnical topics. Let’s start with torque, symbol T, which is the rotational equivalent of linear force and which we might think of as a ‘twisting force.’ The easiest way to visualise this is as an arm-wrestling competition (Fig.5). If we assume both contenders are equally matched, then the amount of force they are applying will cancel each other out, but that’s not the point we’re trying to make. If we consider only the nearside character, the amount of torque equals the force multiplied by the radius: T = r × F. There are two ways to look at this. First, let’s suppose you are trying to open a heavy hinged door by pushing on it. In this case, 54 Practical Electronics | September | 2022 Fig.7. Two gears with 9 and 18 teeth. (Image: Steve Manley) the maximum amount of force you can apply (ie, how hard you can push) is fixed. The radius is the distance from the hinges to the point at which you are pushing. If you push close to the hinges, the radius is small, so the torque you are generating will be small, which means opening the door will be difficult. By comparison, if you push on the door as far away from the hinges as you can, then the radius is larger, which means that – with the same amount of force as before – you can generate more torque, thereby (a) making opening the door a breeze and (b) letting a breeze pass through the door. The second way to look at things might be from the point of a servo with an arm on its output (Fig.6). In this case, the amount of torque that can be generated by the motor is fixed, so the amount of force the servo can exert is given by F = T/r. This tells us that the greater the radius of the arm (at the point we connect our linkage to it), the less force it can exert. Another concept is that of angular speed, symbol ω, which describes the angle an object moves through in a given amount of time. In the case of electric motors, angles are measured in degrees (symbol °), and angular speed is measured in revolutions per minute (RPM). When two gears are interlocked, the gear with fewer teeth must rotate more times than the gear with more teeth. Consider two gears where one has 9 teeth and the other has 18 teeth (Fig.7). In this case, the smaller gear will rotate two times for every rotation of the larger gear. What happens next depends on which of the gears is the driving gear (the input) and which of the gears is being driven (the output). If the larger gear is the input, then – in the case of our 9- and 18-tooth example – the smaller output gear will rotate at twice the speed but with only half the torque (twisting force). By comparison, if the smaller gear is the input – which is the more common case (and which is the way things work in our servo) – then the larger output gear will rotate at only half the speed but with twice the torque. The term ‘gear ratio’ refers to the relative torque between two gearwheels and is typically expressed as X:1, where X is Practical Electronics | September | 2022 the proportional increase in torque. In the case of our example system, the gear ratio would be 2:1. If our larger gear had 27 teeth then the gear ratio would be 3:1, and so on. When two or more gears are connected, we call the result a ‘gear train.’ If a 2:1 gear train is connected to a 3:1 gear train, which is – in-turn – connected to a 4:1 gear train, for example, then the resulting gear ratio for the entire gear train will be (2 × 3 × 4):1 = 24:1. Gears are typically very efficient, with power losses due to friction accounting for only a few percent. To make our lives simple for the purposes of these discussions, we will assume 100% efficiency. Just to round out this part of our discussions, in the context of gears, power (P) equates to torque multiplied by rotational speed: P = T × ω. For our 9-pin input and 18-pin output gears, PI = TI × ωI and PO = TO × ωO, respectively. Assuming 100% efficiency, PO = PI, which means TO × ωO = TI × ωI. In turn, this means TO/TI = ωI/ωO. Furthermore, if we use N to denote the number of teeth on a gear wheel, then the relationship between angular speed and the number of teeth can be expressed as ωI/ ωO = NO/NI. Tying all of this together, we can say our gear ratio of 2:1 = TO/TI = ωI/ ωO = NO/NI. (Note the similarity to a transformer’s turns ratio, voltages and currents.) Feast your orbs As I mentioned earlier, I originally planned on dismantling one of my cheap-and-cheerful servos and taking pictures to show you what was inside. However, my friend Steve Manley said that he could do a much better job using his Fusion 360 computer-aided design (CAD) software. Steve started by purchasing a couple of AZ-Delivery MG90S micro servos from Amazon (https://amzn.to/3ywy4Kk). He then dismantled one, measured everything with his micrometer, and used his microscope to painstakingly count the teeth on each of the gears forming the gear train. The result was a set of images that brought tears of joy to my eyes (Fig.8). One thing Steve noted is that he was led to believe that all of the gears in this servo were metal. However, it turned out that only the output gear was metal while the rest were plastic. Looking at the comments on Amazon, several other people were disgruntled by this deception. (As always, caveat emptor is the order of the day.) The term ‘compound gear’ refers to two or more gears that are fixed together and therefore rotate at the same speed. The green, blue, and red gears in Fig.7 are compound gears because they are each composed of two gears. In the case of this servo, we have three shafts: the motor shaft, an intermediate shaft, and the output shaft. It’s important to note that the green and blue compound gears are not physically attached to the Fig.8. Servo in case (top) and with case removed (bottom). (Image: Steve Manley) intermediate shaft; they just rotate around it. Similarly, the red compound gear is not physically attached to the output shaft. The only gears that are physically attached to their associated shafts are the brass-coloured input gear that’s attached to the motor shaft and the gold-coloured output gear that’s attached to the output shaft. Observe the black arm on the top of the servo. This may also be referred to as the ‘horn.’ These horns come in a variety of shapes and sizes. Also observe that the diameters of the shafts increase from input to output (motor shaft = 1mm, intermediate shaft = 1.16mm, output shaft = 1.36mm). Similarly, the size of the teeth and the thickness of the gears increases as we progress 55 Shaf t G ear # Teeth Input Input 9 1A 47 1B 10 2A 38 Intermediate O utput Intermediate O utput 2B 8 3A 32 3B 7 O utput 23 R atio 5. 2222 3. 8000 4. 0000 3. 2857 Next time Fig.9. Summary of servo gear train. through the gear train. All of these changes are required to accommodate the increasing torque from input to output. The green element located below the red compound gear contains a potentiometer that’s attached to the motor shaft. This pot is used to measure the current angular position of the shaft (various other techniques may be employed by different servos). The small printed circuit board (PCB) carrying the control electronics is mounted at the bottom of the servo under the motor. In addition to a voltage regulator and some discrete components, this board features a KC9702A control chip that interprets the PWM signal coming from the outside world, uses the value from the potentiometer to determine the difference between the desired and actual positions of the output shaft, and drives the DC motor accordingly. Further, let’s assume we wish to keep our original motor with its 9-tooth gear, and we also want to maintain our gear ratio of 260:1. This means our output gear will need 9 × 260 = 2,340 teeth. In turn, this means the diameter of the output gear will be 468mm (Fig.10.). I think we can all agree that having a gear close to half a meter in diameter would not be well-suited to small RC model applications. I don’t know about you, but I find it amazing to think that, by means of a handful of modestly sized gears, we can reduce a half-meter monster down to a package of around eight cubic centimetres. from input to output will be 26,000 RPM / 260 = 100 RPM, which matches the data sheet. Meanwhile, our torque increase will be 0.0072 kg-cm × 260, which results in 1.87 kg-cm torque at the servo’s horn. Now, if we ignore any ‘knobbly’ bits sticking out of the top and sides, using this gear train allows our servo to fit in a teeny-tiny package only around 23mm wide by 29mm tall by 12 mm deep. Suppose we were to return to the 2-gear scenario with which we started out in Fig.7. I’m afraid the time has come for me convey this column to head office and face ‘The wrath of Matt’ (I’ve just dispatched the butler to retrieve my ‘quaking in fear’ trousers). In my next column, in addition to being able to show Steve’s animation demonstrating the internal workings of the servo in awesome detail, we will move on to using joysticks to control multiple servos at the same time. Until that propitious day, as always, I welcome your captivating comments, insightful questions, and sagacious suggestions. What? You’re joking! A summary of the gears and gear ratios forming this servo’s gear train is presented in Fig.9. If we multiply all of the gear ratios together (5.2222 × 3.8000 × 4.0000 × 3.2857, we end up with a total input to output drive train ratio of ~260:1. This may not, at first glance, leave you quivering in excitement. After just a little contemplation, however, I think you’ll agree the results are more than impressive. Let’s start with the fact that the torque of the motor itself is miniscule. For example, Steve notes that he can easily stall the motor by pinching its rotating shaft between his thumb and forefinger. Steve is in the process of creating a video featuring an animation of this servo in action. I’m not sure from whence he obtained these numbers but, in his script, he starts by assuming that the motor’s speed is 26,000 RPM and its torque is 0.0072 kg-cm. Also, the rotational speed (ω) of the horn, as specified in in the data sheet is 60°/0.1s. So, ω = 60°/0.1s = 360°/0.6s = 1 rotation / 0.6s = 100 rotations / 60s = 100 RPM. Assuming our gear ratio is 260:1 as determined above, then our speed reduction 56 Fig.10. Without gear trains, hobby models would be bigger than the real thing. Cool bean Max Maxfield (Hawaiian shirt, on the right) is emperor of all he surveys at CliveMaxfield.com – the go-to site for the latest and greatest in technological geekdom. Comments or questions? Email Max at: max<at>CliveMaxfield.com Practical Electronics | September | 2022