Silicon ChipThe Microbridge: universal PIC32 programmer plus! - May 2017 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Going off-grid could be a bad idea
  4. Feature: Technorama – a Community Radio Station Initiative by John Maizels
  5. Feature: Industrial Robots – coming to a workplace near you! by Dr David Maddison
  6. PartShop
  7. Project: Turn your 10MHz counter into a 6GHz+ counter by Nicholas Vinen
  8. Feature: Micromite Tutorial, Part 3: strings and arrays by Geoff Graham
  9. Product Showcase
  10. Feature: Check your tyre pressures from inside the car by Leo Simpson and Nicholas Vinen
  11. Project: The Microbridge: universal PIC32 programmer plus! by Geoff Graham
  12. Subscriptions
  13. Serviceman's Log: Getting sucked in by a vacuum cleaner by Dave Thompson
  14. Project: New Marine Ultrasonic Anti-Fouling Unit by John Clarke
  15. Project: Micromite BackPack V2 with touch-screen and USB by Geoff Graham
  16. Review: The latest digital hearing aids from BlameySaunders by Ross Tester
  17. Vintage Radio: HMV’s 64-52 Little Nipper by Charles Kosina
  18. PartShop
  19. Market Centre
  20. Advertising Index
  21. Outer Back Cover: Hare&Forbes MachineryHouse

This is only a preview of the May 2017 issue of Silicon Chip.

You can view 39 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 "Turn your 10MHz counter into a 6GHz+ counter":
  • 1000:1 6GHz+ Prescaler PCB [04112162] (AUD $7.50)
  • 1000:1 6GHz+ Prescaler PCB pattern (PDF download) [04112162] (Free)
  • 1000:1 6GHz+ Prescaler panel artwork (PDF download) (Free)
Articles in this series:
  • Getting Started with the Micromite (February 2017)
  • Getting Started with the Micromite (February 2017)
  • Getting Started with the Micromite, Part Two (March 2017)
  • Getting Started with the Micromite, Part Two (March 2017)
  • Micromite Tutorial, Part 3: strings and arrays (May 2017)
  • Micromite Tutorial, Part 3: strings and arrays (May 2017)
  • Getting Started with the Micromite, Part 4 (June 2017)
  • Getting Started with the Micromite, Part 4 (June 2017)
Items relevant to "The Microbridge: universal PIC32 programmer plus!":
  • Microbridge PCB [24104171] (AUD $2.50)
  • PIC16F1455-I/P programmed for the Microbridge [2410417A.HEX] (Programmed Microcontroller, AUD $10.00)
  • MCP1700 3.3V LDO (TO-92) (Component, AUD $2.00)
  • Microbridge complete kit (Component, AUD $20.00)
  • Software for the Microbridge (Free)
  • Microbridge PCB pattern (PDF download) [24104171] (Free)
Items relevant to "New Marine Ultrasonic Anti-Fouling Unit":
  • New Marine Ultrasonic Anti-Fouling Unit PCB [04104171] (AUD $15.00)
  • PIC16F88-I/P programmed for the New Marine Ultrasonic Anti-Fouling Unit [0410417A.HEX] (Programmed Microcontroller, AUD $15.00)
  • One 40kHz 50W ultrasonic transducer (Component, AUD $55.00)
  • ETD29 transformer components (AUD $15.00)
  • IPP80N06S4L-07 high-current N-channel Mosfet (TO-220) (Component, AUD $2.00)
  • New Marine Ultrasonic Anti-fouling unit lid panel artwork (PDF download) (Free)
Articles in this series:
  • New Marine Ultrasonic Anti-Fouling Unit (May 2017)
  • New Marine Ultrasonic Anti-Fouling Unit (May 2017)
  • New Marine Ultrasonic Anti-Fouling Unit, Part 2 (June 2017)
  • New Marine Ultrasonic Anti-Fouling Unit, Part 2 (June 2017)
Items relevant to "Micromite BackPack V2 with touch-screen and USB":
  • Micromite LCD BackPack V2 PCB [07104171] (AUD $7.50)
  • PIC16F1455-I/P programmed for the Microbridge [2410417A.HEX] (Programmed Microcontroller, AUD $10.00)
  • PIC32MX170F256B-50I/SP programmed for the Micromite Mk2 plus capacitor (Programmed Microcontroller, AUD $15.00)
  • 2.8-inch TFT Touchscreen LCD module with SD card socket (Component, AUD $25.00)
  • MCP1700 3.3V LDO (TO-92) (Component, AUD $2.00)
  • Micromite LCD BackPack V2 complete kit (Component, AUD $70.00)
  • Matte/Gloss Black UB3 Lid for 2.8-inch Micromite LCD BackPack (PCB, AUD $5.00)
  • Clear UB3 Lid for 2.8-inch Micromite LCD BackPack (PCB, AUD $5.00)
  • Gloss Black UB3 Lid for 2.8-inch Micromite LCD BackPack (PCB, AUD $4.00)
  • Software for the Microbridge (Free)
  • Firmware (HEX) file and documents for the Micromite Mk.2 and Micromite Plus (Software, Free)
  • Micromite LCD BackPack V2 PCB pattern (PDF download) [07104171] (Free)

Purchase a printed copy of this issue for $10.00.

Build the Microbridge a cheap universal PIC32 programmer combined with a USB/serial converter The Microbridge is primarily intended for use with the Micromite and includes the necessary USB/serial converter. You can manipulate the PIC32 from your PC, program any PIC32 microcontroller and the USB/serial converter can be used with many other processors including those on Arduino or Raspberry Pi. By Geoff Graham T he Micromite microcontroller, which has featured many times on our pages, requires a USB/serial converter to load, edit and run the program (unless you purchased a preprogrammed chip). We previously recommended devices based on the CP2102 for this job. They are cheap and convenient yet you still needed a PIC32 programmer so that you could update the Micromite firmware. Firmware updates for the Micromite are released regularly and usually Microbridge credits The Microbridge is the result of an international collaboration. • Peter Mather in the UK wrote the firmware for the PIC16F1455 and wrote the BASIC program for programming a PIC16F1455 using a Micromite (see panel on programming). • Serge Vakulenko in the USA wrote pic32prog. • Robert Rozee in New Zealand wrote the ASCII ICSP interface for pic32prog. • MicroBlocks (a company in Thailand) developed the original concept of using the PIC16F1455 as both a USB/serial converter and programmer but did not publish their code for copyright reasons. siliconchip.com.au provide worthwhile new features and bug fixes so it is definitely an advantage having access to a PIC32 programmer. But now you don't need the separate PIC32 programmer. Instead, the Microbridge combines the USB/ serial interface and PIC32 programming features in a single package. It is easy to build and uses a low-cost 14-pin chip. In fact, the Microbridge is so economical and convenient that it makes sense to permanently attach it to your REG 1 MCP1700-3302E +5V GND 10 F +3.3V OUT IN 10 F POWER AND SERIAL CON2 100nF +3.3V MINI USB TYPE B CON1 1 2 3 X 4 +5V +3.3V RX TX 1 +V 5V 12 13 4 8 9 1k 10 MODE S1 D–/RA1 11 IN CIRCUIT SERIAL PROGRAMMER (ICSP) CON3 5 RC5/RX IC1 PIC16F PIC 1 6F1 14 4 55 6 D+/RA0 MCLR/RA3 RC4/TX RC2/SDO/AN6 AN7/RC3 RC1/SDA PWM2/RA5 RC0/SCL/AN4 A LED1 VUSB3V3 GND  AN3/RA4 7 1 MCLR 2 VDD 3 GND PGD 0V PGC 14 K MC P1700 LED1 SC  20 1 7 MICROBRIDGE K A IN OUT GND Fig.1: the Microbridge consists of a Microchip PIC16F1455 microcontroller, a voltage regulator and a few passive components. The PIC16F1455 is ideally suited to this task because it requires few external components and can automatically tune its internal clock to the host's USB signal timing. May 2017  61 1 13 28 21 CON2 PC OR LAPTOP, ETC. 16 22 17 2 18 3.3V 15 5V RX TX MICROBRIDGE DATA FROM MICROMITE DATA TO MICROMITE GND CON3 MCLR USB CON1 VDD GND PGD PGC 25 4 5 3 23 28-PIN MICROMITE 24 6 7 9 26 10 20 11 14 12 Fig.2: how to connect the Microbridge to a 28-pin Micromite which is also powered by the Microbridge. The Microbridge works as a USB-to-serial converter by emulating a standard serial port over the USB connection to a desktop or laptop computer. Micromite. With that in mind, we have designed a new version of the Micromite LCD Backpack with the Microbridge integrated which is featured on page 84 of this issue. The development of the Microbridge and the associated software was a truly international effort with contributions from New Zealand to the USA (see the side box for the details). Circuit details Referring to Fig.1, you can see that the Microbridge consists of just a Microchip PIC16F1455 microcontroller, a voltage regulator and a few passive components. The PIC16F1455 is ideally suited to this task because it requires few external components, since it includes the USB transceiver and it does not require a crystal oscillator. Many devices with a USB interface require a crystal oscillator to ensure that the timing of the USB signals meets the strict timing requirements of the USB standard. However, the PIC16F1455 has a feature that Microchip calls Active Clock Tuning. This allows the PIC16F1455 to use the host's USB signals (which presumably are derived from a crystal oscillator) to automatically tune its internal R/C oscillator to the precision required by the standard. As a result, a crystal is not required and this helps keep the circuit simple and the cost down. The PIC16F1455 can run on a supply voltage of 2.3-5.5V and also 62  Silicon Chip includes its own 3.3V regulator for powering its USB transceiver (USB uses 3.3V signal levels). This means that we could directly power the PIC16F1455 from the USB 5V supply but then we would need level converters for the signal lines that go to the PIC32 processor (which runs from 3.3V). For that reason, we've included a lowcost 3.3V regulator (REG1, MCP1700) for powering the PIC16F1455 and we are ignoring its internal regulator. A side benefit of this approach is that this 3.3V supply has spare current capacity so it can also be used to power an attached Micromite chip. The serial interface is made available on CON2 and includes the 5V USB power and the 3.3V from our onboard regulator. By default, the serial interface runs at 38400 baud which is also the default used by the Micromite's console interface. The programming interface is on CON3 and this provides the six standard I/O pins used for In-Circuit Serial Programming (ICSP) on Microchip products. These are: Pin 1: MCLR/Vpp – this is the reset pin for the PIC32 chip and is driven low by the Microbridge. It is also used to force the PIC32 into programming mode. On other PICs, this pin is also used as a programming voltage source of around 15V but the PIC32 generates this internally. Pin 2: Vdd – normally, this is used to detect the power supply voltage 47 F 16V TANT 8 19 27 for the PIC32 but on the Microbridge it is not used. Pin 3: GND – the ground connection which must go to Vss (ground) on the PIC32. Pin 4: PGD – the programming data pin which is bidirectional so that data can be sent to the PIC32 then read back by the Microbridge's firmware to verify that programming has been successful and no errors have been introduced. Pin 5: PGC – the programming clock signal, generated by the Microbridge to synchronise the transfer of data on the PGD line. Pin 6: NC – not connected in most ICSP devices. The Microbridge is switched into programming mode by using pushbutton switch S1 and LED1 flashes to indicate serial traffic or it lights up continuously when in programming mode. USB/serial mode USB/serial mode is the default when power is applied. In this mode, the Microbridge works as a USB to serial converter in that it emulates a standard serial port over USB and converts the signal to a standard TTL level serial interface for the Micromite or another processor. From an operating system viewpoint, the Microbridge imitates the Microchip MCP2200 USB/serial converter. Windows 10 is delivered with the correct driver for this device already installed but for other operating systems, you may need to load a driver siliconchip.com.au 13 10k 28 16 1 CON2 PC OR LAPTOP, ETC. 3.3V +3.3V 21 17 22 18 2 15 5V RX 25 TX MICROBRIDGE GND CON3 MCLR USB CON1 VDD GND PGD PGC 4 3 28-PIN MICROMITE 23 5 24 6 7 9 26 10 20 11 14 12 Fig.3: how to program a 28-pin PIC32 chip using a direct connection from the Microbridge. In this example, the PIC32's 3.3V power supply is supplied separately but this power can also be provided by the Microbridge (from CON2). and these can be found on the Microchip website at www.microchip.com/ wwwproducts/en/MCP2200 With the correct driver loaded, the Microbridge appears as a standard serial port on your computer. For example, in Windows it will appear as COMxx where xx is some number allocated by Windows. To discover this number you can use Device Manager and look under "Ports (COM & LPT)" for the Microbridge which will be labelled "USB Serial Port (COMxx)", where xx is the serial port number (eg, COM6). You can then start your terminal emulator (eg, Tera Term) and specify this COM number in the setup menus. By default, the Microbridge operates at 38400 baud with 8-bit data, one stop bit and no parity, which are the standard settings used by the Micromite's console. However, you can change the baud rate to any standard speed from 300 to 230400 (ie, 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 76800, 115200 or 230400 baud) in the terminal emulator. Fig.2 shows how to connect the Microbridge to a 28-pin Micromite which is also powered by the Microbridge. When a character is sent or received by the Microbridge, LED1 flashes briefly. This is a handy visual clue that the device is working correctly. One point to note: TX (transmit) from the Microbridge must go to the RX (receive) on the Micromite and similarly the TX on the Micromite must connect to the RX on the siliconchip.com.au Microbridge. This is logical when you think about it as signals transmitted by one device must be received by the other. If you connect pin 1 of CON3 (the programming connector) to the MCLR (reset) pin of the Micromite, you can also use the Microbridge to remotely reset the Micromite. This is done by sending a serial break signal to the Microbridge. In Tera Term this is accomplished by pressing ALT-B or via the Tera Term menu. Another way of generating a reset is to press and hold the mode switch on the Microbridge for two or more sec- 47 F 16V TANT 8 19 27 onds. LED1 will flash and the MCLR line will be briefly driven low to effect the reset. Programming mode CON3 on the Microbridge (the ICSP socket) is compatible with the connector used on the Microchip PICkit 3 programmer so the Microbridge can plug into any programming connector intended for the PICkit 3. For example, the Microbridge can plug directly onto the programming connector on the original Micromite LCD Backpack (see the accompanying photograph on the next spread). Fig.4: This screenshot shows the complete operation of pic32prog. It uploads the hex file to the Microbridge, which programs it into the PIC32 and subsequently reads back the programmed data to verify that the programming operation completed correctly. May 2017  63 1 1 100nF 10 F Fig.5: PCB component overlay diagram for the Microbridge. The USB socket is the only SMD component. IC1 may be mounted in a socket. We prefer SMD ceramic capacitors to Tantalum due to their longer life however you can use through-hole (tag) Tantalum capacitors. REG1 Mode CON3 ICSP 1 CON2 24104171 A 10 F USB 1k IC1 PIC16F1455-I/P LED1 3V3 5V RX TX GND CON1 S1 1 Microbridge Alternatively, if you wish to program a 28-pin PIC32 chip using direct connections, Fig.3 shows how to do this. The PIC32's 3.3V power supply can be supplied separately or this power can be provided by the Microbridge via CON3. To enter programming mode, momentarily press and release mode switch S1 and LED1 will illuminate to indicate that programming mode is active. If you accidently pressed this switch and did not want to enter programming mode, cycle the power on the Microbridge or press and hold down S1 for two seconds; either way, this will return you to the default USB/ serial mode. To program a PIC32 via the Microbridge, use a program called pic32prog written by Serge Vakulenko in California. This is a Windows program and it can be downloaded from the Silicon Chip website or from GitHub (https://github.com/sergev/pic32prog). pic32prog must be run from the command prompt in Windows and the command line that you need to use is: pic32prog -d ascii:comxx yyyy.hex Where xx is the COM port number created by Windows for the Microbridge and yyyy.hex is the file containing the firmware that you want to program into the PIC32. For example, if your Microbridge was allocated the virtual serial port of COM12 and the file that you wanted to program was "firm.hex", the command line that you should use would be: pic32prog -d ascii:com12 firm.hex When you press enter, pic32prog will automatically upload the hex file to the Microbridge, program it into the PIC32 then read back the programmed data to verify that the programming operation was executed correctly. Fig.4 shows the output of this operation. At the completion of the programming operation, LED1 switches off and the Microbridge will revert to operating as a USB/serial converter. You can then start up your terminal emulator, connect to the Microbridge and run your program. A common cause of programming errors is that pic32prog cannot access the serial port on your computer because you have not closed the terminal emulator that you were previously using to access the Microbridge. So, make sure that you close your terminal emulator before you run pic32prog. Construction The Microbridge uses fewer than a dozen components and all except the USB socket are through-hole types so construction should take less than half an hour. The component overlay diagram is shown in Fig.5. Start with the USB socket as this is the only surface-mount component. On the underside of the socket, there should be two small plastic pegs which match corresponding holes on the PCB and these will correctly locate the socket. Once it is in place, solder the connector's mounting lugs first using plenty of solder for strength then, using a fine point soldering iron tip, solder the signal pins. Carefully check the pin soldering under a good light and with magnification and clean up any solder bridges using solder wick with a little added flux paste to make it easier. The remaining components are easy to fit and should be soldered starting with the low-profile items such as resistors and ending with the high profile components such as the connectors. Two of the capacitors and the LED are polarised so pay attention to their mounting orientation. We did not use an IC socket for IC1 because we had programmed and tested it beforehand but a socket is recommended and is handy if you suspect a fault and want to swap out the IC for testing. For CON2 (the serial I/O and power) connector, we mounted a five pin header on the underside of the board so that it could easily plug into a solderless breadboard for prototyping with the Micromite but you could use a different arrangement, for example, flying leads. The right-angle six pin socket used for the ICSP programmer output (CON3) can be difficult to find so you can do what we did and purchase a straight six pin socket intended for Arduino boards and bend the pins to Are Your S ILICON C HIP Issues Getting Dog-Eared? REAL VALUE AT $16.95 * PLUS P & P Keep them safe, secure & always available with these handy binders Order now from www.siliconchip.com.au/Shop/4 or call (02) 9939 3295 and quote your credit card number. *See website for overseas prices. 64  Silicon Chip siliconchip.com.au 90° so that the socket can mount flush to the PCB. See the parts list for suitable components. Testing There is not much to go wrong with the Microbridge, so if it does not work the first time you should first re-check the driver installation on your PC. Do you have the right driver, is it installed correctly and do you have the right COM port number? In normal USB/serial mode, the Microbridge will draw about 8mA and any reading substantially different from this indicates an assembly error. A handy test feature is that when you press a key in your terminal emulator, LED1 on the Microbridge should flash. Another test that you can make is to short the TX and RX pins on CON2 and as you type characters into the terminal emulator, you should see them echoed back to the terminal emulator. Parts List 1 double-sided PCB coded 24104171, 50mm x 22.5mm 1 Mini Type-B USB socket, horizontal SMD USB 2.0 (Altronics P1308) 1 PCB-mount SPST momentary tactile switch with 4.3mm actuator (S1) 1 14-pin DIL IC socket (for IC1) 1 6-pin 90° female socket, 2.54mm pitch OR 1 6-pin female socket, 2.54mm pitch, with pins bent through 90° (Altronics P5380, Jaycar HM3208) 1 5-pin vertical header, 2.54mm pitch Semiconductors 1 PIC16F1455-I/P* microcontroller programmed with 2410417A.HEX (IC1) 1 MCP1700-3302E/TO 3.3V linear regulator (REG1) 1 3mm red LED (LED1) Resistors (5%, ¼W) 1 1kW Capacitors 2 10µF 16V tantalum or X5R SMD ceramic (3216/1206 size) 1 100nF 50V multi-layer ceramic * PIC16LF1455-I/P or PIC16(L)F1454-I/P are also suitable CON3 on the Microbridge (the ICSP socket) is compatible with the connector used on the Microchip PICkit 3 programmer so the Microbridge can plug into any programming connector intended for the PICkit 3. For example, the Microbridge can plug directly onto the programming connector on the Micromite Plus LCD BackPack, as shown above. The Micromite Plus LCD BackPack plugged into the PICkit 3 for comparison is shown at right. siliconchip.com.au May 2017  65 Programming the PIC16F1455 The Microbridge uses a PIC16F1455 which acts as a PIC32 programmer to load the firmware into your blank PIC32 microcontroller, for example, to make it into a Micromite. This sounds great because now you do not need a PIC programmer. Or do you? The problem now is getting the Microbridge’s firmware into the PIC16F1455. One option is to purchase a pre-programmed PIC16F1455 from the Silicon Chip Online Shop. But if you already have at least one Micromite, you can program the PIC16F1455 yourself using just the Micromite and a standard 9V battery. It is easy to do and will only take 30 seconds. Then, once you have the PIC16F1455 programmed, you can use it to program as many other Micromites as you want! To get started, wire up the PIC16F1455, the Micromite and the 9V battery as shown in Fig.6. The best way to do this is on a solderless breadboard or a strip of perforated prototyping board. The battery can be a standard PP3 9V battery and this is used to provide the programming voltage for the PIC16F1455. Only a few milliamps will be drawn from it and as long as its terminal voltage is 8V or greater it will do the job. The switch used to connect the battery can be as simple as a lead with an alligator clip that can be clipped onto the battery’s positive terminal. +3.3V 1 +V 12 13 S1 4 5 9V BATTERY 6 10k 7 11 RESET VUSB3V3 D–/RA1 RC1/SDA D+/RA0 RC0/SCL 9 10 PIC16F PIC 1 6F1 14 4 55 RC2/SDO/AN6 RC4/TX PWM2/RA5 RC3/AN7 AN3/RA4 4 5 9 MCLR/RA3 RC5/RX 3 8 MICROMITE RUNNING MMBASIC V5.0 OR LATER 10 2 3 0V 14 Fig.6: if you already have a Micromite, you can program the PIC16F1455 for the Microbridge yourself using it along with a standard 9V battery. Connect them to the PIC16F1455 as shown in this circuit. The program running on the Micromite will prompt you when to connect and disconnect the battery. Fig.7: this screenshot shows the complete programming operation for a PIC16F1455 using a Micromite and a standard 9V battery. The program running on the Micromite is “MicrobridgeProg.bas”. 66  Silicon Chip The Micromite used for the programming operation can be any version of the Micromite family (ie, a 28-pin Micromite to a 100-pin Micromite Plus) so long as it is running version 5.0 or later of MMBasic. Pins 4 and 5 on the Micromite are used to load the firmware into the PIC16F1455 and all versions have these two pins free. If for some reason your one does not, you can edit the BASIC program to change the pin assignments (they are defined at the very start of the program). With everything connected, load the BASIC program MicrobridgeProg.bas into the Micromite. This program can be downloaded for free from the Silicon Chip website or the author’s website (geoffg.net/ microbridge.html). It will work with all chips that are supported by the Microbridge firmware (16F1455, 16F1454, 16LF1454 or 16LF1455). This program was written by Peter Mather of the UK who also developed the Microbridge’s firmware. Make sure that the 9V battery is disconnected and run the BASIC program on the Micromite. From there, it is just a case of following the program’s on-screen instructions which will tell you when to connect and disconnect the battery. The programming time is under 30 seconds and the software will report its progress as it goes. Fig.7 shows a typical programming session. When the programming operation has finished, you can disconnect the battery, remove the PIC16F1455 and install it in your Microbridge board. Then, you can use the Microbridge to program further PIC32 chips. The firmware loaded into the PIC16F1455 will be version 1.18 and this contains a bootloader which allows another Micromite to update it via the serial console interface. This updating is even easier than the initial programming described above and can be done with the Microbridge permanently connected to the Micromite. There will likely be no need to update the Microbridge’s firmware but, if there is, the current firmware can do it. SC siliconchip.com.au