Silicon ChipchipKIT’s new “Lenny” - February 2020 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: IoT is a security nightmare
  4. Feature: Underground mapping, leak detection & pipe inspection by Dr David Maddison
  5. Project: Remote monitoring station messages or emails by 4G! by Tim Blythman
  6. Review: chipKIT’s new “Lenny” by Tim Blythman
  7. Project: Indoor Air Quality Monitor based on a Micromite BackPack by Geoff Graham
  8. Serviceman's Log: When in doubt, swap it out by Dave Thompson
  9. Project: Low distortion, two-channel DDS audio signal generator by Phil Prosser
  10. Feature: El Cheapo modules: 8-channel USB Logic Analyser by Jim Rowe
  11. Product Showcase
  12. Project: Building the new “bookshelf” stereo speakers, Pt 2 by Phil Prosser
  13. Vintage Radio: 1946 Tecnico-Aristocrat Model 651 by Associate Professor Graham Parslow
  14. Subscriptions
  15. PartShop
  16. Market Centre
  17. Advertising Index
  18. Notes & Errata: Digital Lighting Controller, October-December 2010; DSP Active Crossover, May-July 2019; Super-9 FM Radio, November & December 2019
  19. Outer Back Cover

This is only a preview of the February 2020 issue of Silicon Chip.

You can view 38 of the 112 pages in the full issue, including the advertisments.

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

Items relevant to "Remote monitoring station messages or emails by 4G!":
  • 4G Remote Monitoring Station Power Control Shield PCB [27111191] (AUD $5.00)
  • Firmware (Arduino Sketch) for the 4G Remote Monitoring Station (Software, Free)
  • 4G Remote Monitoring Station Power Control Shield PCB pattern (PDF download) [27111191] (Free)
Items relevant to "Indoor Air Quality Monitor based on a Micromite BackPack":
  • PIC32MX170F256B-50I/SP programmed for the Indoor Air Quality Monitor [AirQuality.hex] (Programmed Microcontroller, AUD $15.00)
  • Micromite LCD BackPack V2 complete kit (Component, AUD $70.00)
  • Firmware (HEX) files and BASIC source code for the Indoor Air Quality Monitor [AirQuality.hex] (Software, Free)
Items relevant to "Low distortion, two-channel DDS audio signal generator":
  • DSP Crossover CPU PCB [01106193] (AUD $5.00)
  • DSP Crossover LCD Adaptor PCB [01106196] (AUD $2.50)
  • DSP Crossover front panel control PCB [01106195] (AUD $5.00)
  • Low-distortion DDS complete PCB set (5 boards) [01106192-6] (AUD $20.00)
  • DSP Crossover DAC PCB [01106192] (AUD $7.50)
  • DSP Crossover power supply PCB [01106194] (AUD $7.50)
  • PIC32MZ2048EFH064-250I/PT programmed for the Low-distortion DDS Signal Generator (Programmed Microcontroller, AUD $30.00)
  • Pulse-type rotary encoder with pushbutton and 18t spline shaft (Component, AUD $3.00)
  • 128x64 Blue LCD screen with KS0108-compatible controller (Component, AUD $30.00)
  • ST7920 driver for PIC32MZ projects (Software, Free)
  • Firmware and source code for the Low-distortion DDS Signal Generator (Software, Free)
  • DSP Active Crossover/DDS/Reflow Oven PCB patterns (PDF download) [01106191-6] (Free)
Articles in this series:
  • El Cheapo Modules From Asia - Part 1 (October 2016)
  • El Cheapo Modules From Asia - Part 2 (December 2016)
  • El Cheapo Modules From Asia - Part 3 (January 2017)
  • El Cheapo Modules from Asia - Part 4 (February 2017)
  • El Cheapo Modules, Part 5: LCD module with I²C (March 2017)
  • El Cheapo Modules, Part 6: Direct Digital Synthesiser (April 2017)
  • El Cheapo Modules, Part 7: LED Matrix displays (June 2017)
  • El Cheapo Modules: Li-ion & LiPo Chargers (August 2017)
  • El Cheapo modules Part 9: AD9850 DDS module (September 2017)
  • El Cheapo Modules Part 10: GPS receivers (October 2017)
  • El Cheapo Modules 11: Pressure/Temperature Sensors (December 2017)
  • El Cheapo Modules 12: 2.4GHz Wireless Data Modules (January 2018)
  • El Cheapo Modules 13: sensing motion and moisture (February 2018)
  • El Cheapo Modules 14: Logarithmic RF Detector (March 2018)
  • El Cheapo Modules 16: 35-4400MHz frequency generator (May 2018)
  • El Cheapo Modules 17: 4GHz digital attenuator (June 2018)
  • El Cheapo: 500MHz frequency counter and preamp (July 2018)
  • El Cheapo modules Part 19 – Arduino NFC Shield (September 2018)
  • El cheapo modules, part 20: two tiny compass modules (November 2018)
  • El cheapo modules, part 21: stamp-sized audio player (December 2018)
  • El Cheapo Modules 22: Stepper Motor Drivers (February 2019)
  • El Cheapo Modules 23: Galvanic Skin Response (March 2019)
  • El Cheapo Modules: Class D amplifier modules (May 2019)
  • El Cheapo Modules: Long Range (LoRa) Transceivers (June 2019)
  • El Cheapo Modules: AD584 Precision Voltage References (July 2019)
  • Three I-O Expanders to give you more control! (November 2019)
  • El Cheapo modules: “Intelligent” 8x8 RGB LED Matrix (January 2020)
  • El Cheapo modules: 8-channel USB Logic Analyser (February 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules (May 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules, Part 2 (June 2020)
  • El Cheapo Modules: Mini Digital Volt/Amp Panel Meters (December 2020)
  • El Cheapo Modules: Mini Digital AC Panel Meters (January 2021)
  • El Cheapo Modules: LCR-T4 Digital Multi-Tester (February 2021)
  • El Cheapo Modules: USB-PD chargers (July 2021)
  • El Cheapo Modules: USB-PD Triggers (August 2021)
  • El Cheapo Modules: 3.8GHz Digital Attenuator (October 2021)
  • El Cheapo Modules: 6GHz Digital Attenuator (November 2021)
  • El Cheapo Modules: 35MHz-4.4GHz Signal Generator (December 2021)
  • El Cheapo Modules: LTDZ Spectrum Analyser (January 2022)
  • Low-noise HF-UHF Amplifiers (February 2022)
  • A Gesture Recognition Module (March 2022)
  • Air Quality Sensors (May 2022)
  • MOS Air Quality Sensors (June 2022)
  • PAS CO2 Air Quality Sensor (July 2022)
  • Particulate Matter (PM) Sensors (November 2022)
  • Heart Rate Sensor Module (February 2023)
  • UVM-30A UV Light Sensor (May 2023)
  • VL6180X Rangefinding Module (July 2023)
  • pH Meter Module (September 2023)
  • 1.3in Monochrome OLED Display (October 2023)
  • 16-bit precision 4-input ADC (November 2023)
  • 1-24V USB Power Supply (October 2024)
  • 14-segment, 4-digit LED Display Modules (November 2024)
  • 0.91-inch OLED Screen (November 2024)
  • The Quason VL6180X laser rangefinder module (January 2025)
  • TCS230 Colour Sensor (January 2025)
  • Using Electronic Modules: 1-24V Adjustable USB Power Supply (February 2025)
Items relevant to "Building the new “bookshelf” stereo speakers, Pt 2":
  • Bookshelf Speaker Passive Crossover PCB [01101201] (AUD $10.00)
  • Bookshelf Speaker Subwoofer Active Crossover PCB [01101202] (AUD $7.50)
  • Bookshelf Speaker Passive and Active Crossover PCB patterns (PDF download) [01101201-2] (Free)
  • Bookshelf Speaker System timber and metal cutting diagrams (PDF download) (Panel Artwork, Free)
Articles in this series:
  • Easy-to-build Bookshelf Speaker System (January 2020)
  • Building the new “bookshelf” stereo speakers, Pt 2 (February 2020)
  • Building Subwoofers for our new “Bookshelf” Speakers (March 2020)
  • Stewart of Reading (October 2023)
  • Stewart of Reading (November 2023)
  • ETI BUNDLE (December 2023)
  • Active Subwoofer For Hi-Fi at Home (January 2024)
  • Active Subwoofer For Hi-Fi at Home (February 2024)

Purchase a printed copy of this issue for $10.00.

“Hands on” review by Tim Blythman Introducing the – a PIC-based Arduino Arduino started out using 8-bit Atmel AVR micros, but these days, there are Arduinos based on all sorts of chips. This one happens to use basically the same device that Geoff Graham used in his 28-pin Micromite series. As you would expect, it’s very capable, and it can take advantage of most of the vast range of Arduino software and hardware that’s available. T he battle between Microchip and Atmel has been going on for a long time now, with neither side giving any ground; that is, until Microchip ended the argument by purchasing Atmel! Despite that, to this day, we still see a clear line dividing the Atmel AVR-based Arduino boards and PIC-based boards such as the Micromite. Even though Microchip took over Atmel in 2016, the two families remain essentially distinct, although some features have flowed between the two and you can now use Microchip’s MPLABX IDE to program some Atmel microcontrollers. The chipKIT family blurs this line further, allowing a PIC32-based microcontroller to be programmed with the Arduino IDE. The Lenny is only one member of this family; there are numerous other chipKIT boards with PIC32 microcontrollers and varying features. They all sport a 32-bit PIC32 microcontroller, and with that comes all the advantages of a 32-bit microcontroller compared to the 8-bit AVRs. And like all PIC32 devices, they operate from a 3.3V supply, compared to the 5V that’s typical for AVRs (although AVRs can run from 3.3V too). To work with the Lenny, you’ll need a copy of the Arduino IDE (integrated development environment), which can be downloaded for free from: siliconchip.com.au/link/aatq chipKIT history The first chipKIT boards were introduced around nine years ago by a partnership between Microchip Technology 38 Silicon Chip and Digilent. The idea was to create a PIC32-based board that could use Arduino-compatible add-ons (such as shields and modules) and also provide a programming experience for those familiar with the Arduino IDE. The first boards were known as the chipKIT Uno32 and Max32, and were intended to be interchangeable with the Uno and Mega respectively. The Uno32 uses a PIC32MX320F128 while the Max32 sports a PIC32MX795F512, the same processor as the original Maximite (siliconchip. com.au/Series/30), also from around nine years ago. Several chipKIT boards have been developed, most using PIC32MX variants, although a few use the higher-specced PIC32MZ series. Hardware compatibility is achieved by using the standard Arduino header layout, although there is the proviso that any attached boards must support 3.3V logic levels and not just 5V. The PIC32 microcontrollers have a small edge here over some other 3.3V chips, in that many have some pins which are 5V tolerant, which simplifies interfacing to other 5V parts. Much of the magic is in the software; the compiler and libraries mean that (for the most part), the same Arduino sketch code can be used for an ATmega328-based Uno and a PIC32 based chipKIT board. The original IDE for working with chipKIT boards was called the MPIDE (multi-platform IDE) and was forked from the open-source Arduino IDE. Finally, with support for non-AVR boards being introduced into the Arduino IDE, Australia’s electronics magazine siliconchip.com.au Features: • • • • • • Arduino R3 footprint and layout 32-bit PIC microcontroller (PIC32MX270F256) Native USB interface 256kB flash memory (244kB usable) 64kB RAM 40MHz processor clock the chipKIT core for the Arduino was introduced. So now, chipKIT support can be added to the Arduino IDE using the Boards Manager, after which the chipKIT boards appear in the usual list. The chipKIT Lenny While many of the early chipKIT boards were produced by Digilent, the open-source nature of the hardware and software meant that variants inevitably followed. A company called Majenko Technologies designed the Lenny board; they specialise in open-source hardware designs. We could have reviewed any of the chipKIT variants, but we chose the Lenny because it’s one of the cheaper chipKIT boards available. It also appears to be well designed regarding Arduino compatibility. In particular, it follows the R3 layout. It has dedicated pins for I2C and SPI in the correct places, as well as secondary I2C and SPI connections where you would find them on the Uno. So it has the best chance of working with shields, even if they date back to the days when the Uno was the only option. It uses a PIC32MX270F256D micro. We used the DIP variant of this chip in our February 2019 USB Adaptor for Micros (siliconchip.com.au/Article/11414). Its immediate predecessor, the PIC32MX250F256B, was also used in the ASCII Video Terminal project from July 2014 (siliconchip. com.au/Article/7925). These chips have an onboard USB peripheral. In this case, it is used for direct communication with the host PC, similarly to the Arduino Leonardo. And it’s the Leonardo which is the inspiration for the Lenny design and name, in case you hadn’t guessed. The hardware Fig.1 shows the schematic of the Lenny. As it is opensiliconchip.com.au source hardware, all the design files (such as PCB files) are available online via siliconchip.com.au/link/aaxi The DC jack, CON1, supplies up to 12V to 5V LD1117S50T regulator REG1 via schottky diode D1. Alternatively, REG1 can be supplied directly from the VIN pin. The 5V rail powers 3.3V MCP1825S-3302 regulator REG2. The LD1117S50T regulator can handle up to 15V, but the Lenny manual notes an absolute maximum of 12V. Since 12V automotive systems can easily reach above 14V, this reduces the board’s apparent usefulness. IC2, an op amp configured as a comparator, controls Q1 to connect the 5V from the USB socket unless power is available from VIN. This part of the circuit is virtually identical to that used in the reference Uno R3 design. An 8MHz clock is provided by clock oscillator XO1 and fed into the OSC1 pin of the PIC32MX270F256D, IC1. The pins of IC1 are broken out to the various headers around the board, as well as to the micro-USB socket, CON3. There are two tactile push-buttons on the board. S1 is marked PROG and is used to activate the bootloader for uploading sketches, while S2 is used to reset the microcontroller. Near the USB socket is the ICSP header (CON9) with staggered pins to allow a header to be friction-fitted temporarily. The ICSP header is not needed during regular operation, but can be used to program the PIC32 microcontroller directly or to update the bootloader firmware. There are four LEDs onboard. Two indicate serial data activity (TX and RX), one is for power and one flashes during programming, and can be used for other tasks in your own code. The usual array of bypass capacitors surround the microcontroller. While the board is sparse, the simplicity lends itself to the possibility of being the basis of other PIC32based designs. Table 1 shows the capabilities of each pin that’s broken out to one of the usual Arduino headers. Software As mentioned above, to use the Lenny with the Arduino IDE, we need to install the chipKIT core. This contains several parts, but they are all installed as a single unit. It includes a series of board definitions, which ensure that the pins marked on the board are correctly associated with the physical pins on each specific microcontroller. It also includes a C++ compiler. Like the AVR Arduino core, it is based on the open-source gcc (GNU Compiler Collection). This turns the Arduino-flavoured C++ code into PIC32-specific machine code. There are also libraries which translate the common Arduino-specific functions into code which correctly interfaces with the peripherals on a PIC32 microcontroller. This includes such simple functions as digitalWrite() and analogRead(), as well as things like the SPI and I2C interfaces. There are also utilities to upload the sketch to the board; in the Lenny’s case, this is pic32prog, the same program that can be used to program some variants of the Micromite. We’re using version 1.8.5 of the Arduino IDE. To program the Lenny, you need an IDE new enough to include the Boards Manager, which was first included with version 1.6.7, but Australia’s electronics magazine February 2020  39 D1 CON1 A REG1 LD1117S50TR 3 2 VIN K VIN REG2 MCP1825S-3302 Vcc (+5V) VOUT 10 F 4 VOUT GND 10 F 1 OUT IN S 10k GND GND 2 4 1 F 4 +3.3V 5 G 1 IC2 3 PROG D2 IC2: MCP6001T A +3.3V 17 RESET 10 42 9 8 CON2 33 PROG 35 AVDD 5 1 3 15 34 4 RB8/SCL1 USB D–/RB11/PGEC2 +3.3V 100nF E 30 CLK MOSI2/RA9/TDI 13 32 A0 SCK2/RB15 RC3 RC5 MISO2/RA4/SOSCO RC7 CLKI/RA2 RC6 RA10/TMS RC4 RA7/TCK RB7 RA8/TDO RC9 RC8 20 A0 21 25 A2 27 A3 23 A4 24 A5 CON4 A A   K CHIPKIT LENNY K  LED1 K AREF 19 GND SCK1 14 MISO1 22 MOSI1 11 D10 D9 D8 38 31 D7 3 D6 41 D5 2 D4 37 D3 43 D2 5 D1 4 D0 AN1 /RA1 AN2 /RB0 AN6/RC0 AN8/RC2 AN4/RB2 VCAP AN5/RB3 VSS 6 VSS 29 VSS 39 7 10 F  LED2 K Fig.1: there isn’t much to the Lenny circuit. The main microcontroller handles the USB interface, so there is no need for an interface IC. The remainder of the circuit is mostly involved with power supply and voltage regulation. we haven’t tried it with a version that early; it may work. We’re using Windows 10, but the same process should work for macOS, Linux (x86 and x64) and even a Raspberry Pi. Board installation Firstly, open the Preferences window (File -> Preferences) and add the following URL to the Additional Boards Manager URL list: https://raw.githubusercontent.com/chipKIT32/chipKITcore/master/package_chipkit_index.json Silicon Chip SCL1 SDA1 1 A A LED0 CON5 CON6 AVSS 16 PWR LED 18 44 RB13/MOSI1 IC1 26 PIC32MX270PIC3 2 MX270RC1 F256D 36 4x 1k A1 40 RB14/SCK1 RB5 12 2 1 AREF OUT 3 GND CON9 SC AN0/RA0 RESET S2 100nF PROG/RB4/SOSCI RA3 8 MHz XO 1 6 2020 RB9 /SDA1 USB D+/RB10/PGED2 VDD RESET 3 5 MCLR RB1/MISO1 +3.3V VIN 40 VDD VUSB3V3 CON8 +5V GND 28 VDD VBUS +3.3V GND 100nF 6 2 4 +3.3V RESET LK1 FAST PROG L1 100nF +5V F1 500mA L2 S1 1M 4 10k 100nF K 2 1 2 3 X 4 2 1 F 10k Q1 D 1 Vdd (+3.3V) 3 +5V 10k CON3 1 Separate this from any existing entries with a comma. Now open the Boards Manager from Tools -> Board -> Boards Manager. It may take a few moments for the list to be populated, as each URL is checked. Unfortunately, you cannot remove URLs after the boards are installed, as this makes them unavailable from the IDE. We understand this behaviour may change in future versions of the Arduino IDE. The chipKIT option should appear, as shown in Screen1, so click the Install button. Installation may take a while as Australia’s electronics magazine siliconchip.com.au Pin Features D0.....................5V tolerant digital I/O, serial RX D1.....................5V tolerant digital I/O, serial TX D2.....................5V tolerant digital I/O, serial1 TX, interrupt D3.....................5V tolerant digital I/O, PWM, interrupt D4.....................5V tolerant digital I/O, serial1 RX, interrupt D5.....................5V tolerant digital I/O, PWM, interrupt D6.....................5V tolerant digital I/O, PWM, interrupt D7.....................3.3V digital I/O D8.....................5V tolerant digital I/O D9.....................PWM D10...................PWM D11...................SPI MOSI D12...................SPI MISO D13...................SPI SCK SDA...................5V tolerant digital I/O SCL...................5V tolerant digital I/O A0......................analog or 3.3V digital I/O A1......................analog or 3.3V digital I/O A2......................analog or 3.3V digital I/O A3......................analog or 3.3V digital I/O A4......................analog, 3.3V digital I/O or I2C SDA A5......................analog, 3.3V digital I/O or I2C SCL ICSP SCK..........3.3V digital I/O ICSP MOSI........5V tolerant I/O ICSP MISO........3.3V digital I/O Table 1 - Lenny pin capabilities there are the various board definitions and compilation and upload tools to be installed. The total size is around 1GB. Note that the Lenny board doesn’t appear in the list on this screen, but it is supported by version 2.1.0 of the chipKIT core, as shown in Screen2. Using it We found that there are a few quirks when using the Lenny compared to a typical AVR board like the Uno. These are apart from obvious differences such as the 3.3V I/O voltage. The first is the “PROG” button. The Lenny needs to be manually put into programming mode by pushing the PROG button, which isn’t necessary on the Uno. This is because the onboard USB interface is shared between the programming interface and user programs. If you don’t press this button before initiating a code upload, that upload will fail. The PROG button can be a little awkward to access if a shield is fitted to the top of the Lenny. We were just able to get a finger into the gap, but we imagine some people might struggle with this. Also, note that this means that the serial port number (COMx) changes between programming mode and run mode. This happens with the AVR-based Leonardo too, but the upload utility detects it, so it works seamlessly, and there is no need to change the serial port manually. The Lenny software does not do this, so to work with a program that uses the serial port (especially for debugging), the serial port has to be changed twice for each program upload. siliconchip.com.au The way we sidestepped this is to use another serial terminal program, specifically, TeraTerm. TeraTerm has the advantage that it can resume communication even if a serial port disconnects while the terminal is open, as is the case when the Lenny switches to programming mode. The TeraTerm window can simply stay open in the background. It operates a bit differently to the Arduino Serial Monitor, but it’s perfectly adequate for most purposes. Benchmarking We decided to run some benchmarks on the Lenny, to compare its performance to other Arduino boards – see Table 2. We used the same method as in our review of the new Arduino Nano boards in October 2019 (siliconchip. com.au/Article/12015). Since one of those boards, the Nano 33 IoT, also has a 32-bit chip (an Atmel SAMD21), this makes a good comparison for the Lenny. The benchmark tests show the Lenny to be by far the fastest overall. Note that the Lenny runs at 40MHz while the Nano 33 IoT runs at 48MHz. The Nano 33 IoT is ahead by a tiny margin when doing byte, integer and long multiplies, but otherwise, the Lenny comes out firmly on top. There are vague mentions of a 50MHz bootloader configuration for the Lenny, which we imagine would put it even further ahead. But the PIC on our Lenny is the 40MHz variant, so this upgrade is a bit dubious; it may work, but perhaps not reliably. Compatibility We don’t expect that the Lenny will be immediately compatible with all Arduino sketches, in particular, those which use direct port writes. When such techniques are used, those sketches will only work on the specific board they are written for, which is typically the Uno. To test this, we tried compiling a few different sketches written for different shields. The first one we tried was for the Jaycar XC4454 LCD Shield. This uses the common HD44780-type LCD controller and is supported by the ‘LiquidCrystal’ library, which is usually included with the Arduino IDE. Once we had the pins set correctly (the Jaycar shield uses a different pin configuration to the default), the sketch worked as expected. Since this shield uses one-way communication, it depends on the LCD controller accepting 3.3V logic levels, which it appears to do. The next test was one of our own shields, the 3.5in Touchscreen Arduino Adapter from May 2019 (siliconchip.com. au/Article/11629). We found that the display worked fine, even with the level converting resistors in place. The level-converting resistors are intended to allow 5V I/O signals to drive the 3.3V controller on the LCD, but in this case the 3.3V I/O is being divided down to 2.2V levels. So, it’s remarkable that it worked! The touch controller did not fare so well; we could not get it to work, even modifying the level-converting resistors to deliver 3.3V I/O signals (by removing the lower resistors from the dividers). We could not resolve this issue, but expect that there is some way to make it work. After all, the same display works perfectly well with the practically identical PIC32MX170F256 chip in the Micromite. We suspect that this has to do with the different ways that SPI interfaces are handled, particularly as the touch Australia’s electronics magazine February 2020  41 digitalRead digitalWrite pinMode byte * byte / byte + integer * integer / integer + long * long / long + float * float / float + itoa() ltoa() dtostrf() random() y|=(1<<x) bitSet() analogRead() analogWrite() Nano 5.032µs 4.532µs 4.470µs 0.632µs 5.412µs 0.443µs 1.386µs 14.277µs 0.883µs 6.102µs 38.662µs 1.763µs 7.932µs 80.162µs 10.107µs 12.957µs 125.987µs 78.637µs 91.412µs 0.569µs 0.569µs 111.987µs 7.167µs Nano    EveryNano33 IoT chipKIT Lenny 6.679µs 0.948µs 0.804µs 6.459µs 1.913µs 1.066µs 3.244µs 1.931µs 1.644µs 0.570µs 0.197µs 0.199µs 5.297µs 0.636µs 0.451µs 0.381µs 0.197µs 0.149µs 1.263µs 0.171µs 0.174µs 14.052µs 0.591µs 0.396µs 0.759µs 0.171µs 0.124µs 5.547µs 0.168µs 0.174µs 38.362µs 0.596µs 0.396µs 1.514µs 0.169µs 0.124µs 7.314µs 3.016µs 1.329µs 78.337µs 11.721µs 4.296µs 9.692µs 2.806µs 1.276µs 12.792µs 3.041µs 0.876µs 125.487µs 16.196µs 2.696µs 76.687µs  46.896µs 90.512µs 9.546µs 2.121µs 0.444µs   0.099µs 0.444µs 0.123µs 0.099µs 112.887µs 422.946µs 21.046µs 6.932µs 6.801µs 1.401µs Table 2 - chipKIT Lenny benchmark (lower controller IC on the 3.5in panels works at a much lower maximum bus speed than the LCD. We also tried our updated Seismograph shield from April 2019 (siliconchip.com.au/Article/11532). Amongst the other hardware, the main shield used has an SD card interface that uses the SPI peripheral and a real-time clock (RTC) module that uses the I2C peripheral. This project did not compile immediately, as we used a specific format of an I2C command that had not been implemented in the chipKIT core. This format (where a third argument is presented in the requestFrom() function call) is documented in the official Arduino reference. Further investigation shows that this issue has been identified but not fixed in the chipKIT core (see https://github.com/ chipKIT32/chipKIT-core/issues/240). The specific SD card file system library we used in this project was not able to read the SD card either. We also tried an example SD card sketch (CardInfo) from the Arduino IDE, and this was able to correctly identify the card and list its contents. So it appears there are some minor differences between the AVR and chipKIT libraries. six; pin D11 is the one that is missing this feature. Fortunately, the extra speed of the PIC32 microcontroller means that software-based PWM is available and can perform this task instead. The ‘SoftPWMServo’ library uses the core timer to generate PWM signals (and servo signals) on pins that do not have hardware PWM support. The library notes that it may be subject to approximately 50ns of jitter in the output. This equates to around 1% of the pulse width resolution, so is unlikely to be noticeable for most applications. Special features While browsing through the list of included examples, we noticed a folder called “USB_MSD”. Inside, there are two example sketches which program the Lenny board to behave as though it is a USB Mass Storage Device. At first, we could not get either of the examples to compile, but by adding two lines (and commenting a third out), we got the sketch “AnalogToFile” to compile and upload. These changes are shown in Screen3. is better) Once uploaded, the Lenny was visible to the attached computer as a USB Mass Storage Device. After formatting it, we were able to copy files to it. There was only 26kB of space available, as the contents are held in a 48kB RAM buffer. The “AnalogToFile” sketch also creates a file in this file system, which can be read by the USB host computer. Being able to program a board to emulate a USB stick that can modify its own contents is very interesting. Previously, to copy log files from an Arduino project, you needed an SD card or a clunky custom interface, such as copying data from a serial terminal. Now, using the Lenny, you can simply get the board to PWM support You might have also noticed from Ta- Screen1: once the chipKIT URL has been added to the preferences page, the ble 1 that the Lenny only has five hard- chipKIT core can be selected from the Boards Manager. Though the Lenny is ware PWM pins, compared to the Uno’s not in this list, its profile is installed. 42 Silicon Chip Australia’s electronics magazine siliconchip.com.au to set aside some time to work through the minor niggles which pop up. The chipKIT core files are common to all chipKIT boards; thus, it would be a similar process to get such shields working with any chipKIT board. But unfortunately, some libraries depend on AVR-specific features, so they cannot be made to work easily. The Lenny verdict Screen2: the full list of available chipKIT boards can be seen after the chipKIT core is installed. While they have diverse names, all are based around PIC32 microcontrollers. generate its log file to the internal RAM image and then it can be easily copied and pasted via a file browser program. We haven’t looked into this too deeply, but there is probably a way to attach to an SD card and just use the Lenny as a card reader that can also write to itself. While it is a limited and simple interface, we think there are many potential uses for it. We’re impressed with the speed of the Lenny board, as shown in the benchmarks. The 32-bit processor is much faster at mathematically-intensive programs than an 8-bit processor, and generally quicker than other 32-bit boards such as the Nano 33 IoT. The extra speed also means that software PWM on all pins is possible. While not as accurate as hardware PWM, it is certainly adequate for most purposes. The writers of the chipKIT core have worked hard to make it compatible with other Arduinos, but there are still some gaps present in important libraries. So it is not always a trivial process to port existing projects from 8-bit AVR-based boards to the Lenny. The ability of the Lenny to behave as a USB Mass Storage Device is really powerful, since it is such an intuitive way to move files around. Overall, the Lenny is a great board, but perhaps not capable of being a drop-in substitute for AVR-based boards. We expect that it will be best used in applications where its specific features would be a benefit over other boards, rather than as an upgrade in existing applications. In particular, we expect to see projects spring up around USB Mass Storage Device examples. SC Other USB features Some other USB-equipped boards like the Leonardo can emulate a keyboard or mouse. We used such a board (called a ‘Beetle’) in our project from August 2018 to interface an IR remote control to a computer by emulating a keyboard (siliconchip.com.au/Article/11195). We tried the keyboard and mouse examples that are available for the Lenny, and they performed as expected, although we could not get an infrared interface working, as the IR library uses AVR-specific interrupt code to receive the signal. Screen3: the “USB_MSD” examples show off what we think is one of the Lenny’s The overall impression here is that most interesting feature, being able to act as a USB Mass Storage Device. We needed most things will work, but you need to make some minor changes to the code to get it to compile, which are shown here. siliconchip.com.au Australia’s electronics magazine February 2020  43