Silicon ChipThe Micromite Mk.2 - January 2015 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Petrol power tools are anathema
  4. Feature: Interfacing To The Brain by Dr David Maddison
  5. Feature: The Micromite Mk.2 by Geoff Graham
  6. Project: Isolating High Voltage Probe for Oscilloscopes by Jim Rowe & Nicholas Vinen
  7. Project: High-Energy Multi-Spark CDI For Performance Cars, Pt.2 by John Clarke
  8. Product Showcase
  9. Project: The Currawong 2 x 10W Stereo Valve Amplifier, Pt.3 by Nicholas Vinen
  10. Beginner's Project: the PicoMiniCube by Design by Philip Tallents, article by Ross Tester
  11. Subscriptions
  12. Review: Tektronix RSA306 Real Time Spectrum Analyser by Jim Rowe
  13. Order Form
  14. Salvage It by Ken Kranz
  15. Vintage Radio: The Stromberg-Carlson 5A26 radio by Associate Professor Graham Parslow
  16. Market Centre
  17. Advertising Index
  18. Outer Back Cover

This is only a preview of the January 2015 issue of Silicon Chip.

You can view 36 of the 104 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 "The Micromite Mk.2":
  • 44-pin Micromite PCB [24108141] (AUD $5.00)
  • PIC32MX170F256B-50I/SP programmed for the Micromite Mk2 plus capacitor (Programmed Microcontroller, AUD $15.00)
  • PIC32MX170F256D-50I/PT programmed for the Micromite Mk2 (44-pin) (Programmed Microcontroller, AUD $15.00)
  • CP2102-based USB/TTL serial converter with 5-pin header and 30cm jumper cable (Component, AUD $5.00)
  • Firmware (HEX) file and documents for the Micromite Mk.2 and Micromite Plus (Software, Free)
Items relevant to "Isolating High Voltage Probe for Oscilloscopes":
  • Isolated High-Voltage Probe PCB [04108141] (AUD $10.00)
  • Blue 3mm LED with diffused lens (Component, AUD $0.20)
  • Hard-to-get parts for the Isolated High-Voltage Probe (Component, AUD $37.50)
  • Isolated High-Voltage Probe PCB pattern (PDF download) [04108141] (Free)
  • Isolated High-Voltage Probe panel artwork (PDF download) (Free)
  • Isolated High-Voltage Probe drilling guide diagram (PDF download) (Panel Artwork, Free)
Items relevant to "High-Energy Multi-Spark CDI For Performance Cars, Pt.2":
  • Multispark CDI PCB [05112141] (AUD $10.00)
  • ETD29 transformer components (AUD $15.00)
  • Hard-to-get parts for the Multispark CDI (Component, AUD $45.00)
  • Multispark CDI PCB pattern (PDF download) [05112141] (Free)
  • Multispark CDI panel artwork (PDF download) (Free)
Articles in this series:
  • High-Energy Multi-Spark CDI For Performance Cars (December 2014)
  • High-Energy Multi-Spark CDI For Performance Cars (December 2014)
  • High-Energy Multi-Spark CDI For Performance Cars, Pt.2 (January 2015)
  • High-Energy Multi-Spark CDI For Performance Cars, Pt.2 (January 2015)
Items relevant to "The Currawong 2 x 10W Stereo Valve Amplifier, Pt.3":
  • Currawong 2 x 10W Stereo Valve Amplifier main PCB [01111141] (AUD $55.00)
  • Currawong Remote Control PCB [01111144] (AUD $5.00)
  • PIC16F88-I/P programmed for the Currawong Remote Volume Control [0111114A.HEX] (Programmed Microcontroller, AUD $15.00)
  • Front & rear panels for the Currawong 2 x 10W Stereo Valve Amplifier [01111142/3] (PCB, AUD $30.00)
  • Currawong 2 x 10W Stereo Valve Amplifier acrylic top cover (PCB, AUD $30.00)
  • Currawong 2 x 10W Stereo Valve Amplifier top cover cutting diagram (Software, Free)
  • Firmware and source code for the Currawong Remote Volume Control [0111114A.HEX] (Software, Free)
  • Currawong 2 x 10W Stereo Valve Amplifier main PCB pattern [01111141] (Free)
  • Currawong 2 x 10W Stereo Valve Amplifier panel artwork (PDF download) (Free)
Articles in this series:
  • Currawong Stereo Valve Amplifier: A Preview (October 2014)
  • Currawong Stereo Valve Amplifier: A Preview (October 2014)
  • Currawong 2 x 10W Stereo Valve Amplifier, Pt.1 (November 2014)
  • Currawong 2 x 10W Stereo Valve Amplifier, Pt.1 (November 2014)
  • Currawong 2 x 10W Stereo Valve Amplifier, Pt.2 (December 2014)
  • Currawong 2 x 10W Stereo Valve Amplifier, Pt.2 (December 2014)
  • The Currawong 2 x 10W Stereo Valve Amplifier, Pt.3 (January 2015)
  • The Currawong 2 x 10W Stereo Valve Amplifier, Pt.3 (January 2015)
  • Modifying the Currawong Amplifier: Is It Worthwhile? (March 2015)
  • Modifying the Currawong Amplifier: Is It Worthwhile? (March 2015)
  • A New Transformer For The Currawong Valve Amplifier (October 2016)
  • A New Transformer For The Currawong Valve Amplifier (October 2016)
Items relevant to "Salvage It":
  • SPICE simulations for Common Mode Chokes (Software, Free)
The Micromite Mk.2 More memory, more functions & much faster than before! Introduced in the May 2014 issue of SILICON CHIP, the Micromite is a small 28-pin chip running a powerful BASIC interpreter. Now we introduce the Micromite Mk.2 with more memory, higher speed and a host of other improvements. It’s all due to the relentless march of semiconductor technology. By Geoff Graham T HE SEMICONDUCTOR industry does move fast. Just after the introduction of the Micromite back in May 2014, the manufacturer of the PIC32MX150F128 microcontroller used in the device surprised us with a new version of the chip. Designated the PIC32MX170F256, it has the same capabilities as the original but has double the amount of RAM and flash memory. Even better, it only costs 40 cents more. We had gone to a lot of effort to squeeze the MMBasic interpreter into the original chip. However, as soon as we saw the new chip, we started thinking of implementing some of the features that were missed out in the original version. The result is the Micromite Mk2. It does everything the original Micromite did but it does it much faster, with a lot more memory and a lot more features. The original Micromite is still fine for everyday jobs; it’s just that it now has a newer and faster cousin. The Micromite Just in case you missed the May 2014 issue, the Micromite is a PIC32MX150F128 microcontroller programmed with our BASIC interpreter called MMBasic. This microcontroller comes in two package styles: (1) a 28pin plastic dual-in-line (DIL) package which can be plugged into a breadboard or IC socket; and (2) a 44-pin surface mount (SMD) package. The 28-pin Micromite has 19 I/O pins which can be configured by the The Micromite Mk.2 is just a Microchip PIC32MX170F256 microcontroller programmed with Version 4.6 of our MMBasic interpreter. You can buy the microcontroller in both 28-pin and 44-pin versions and once programmed it turns into an easy to use controller that you can employ for a host of tasks, eg, servo control, infrared remote control, distance sensors, temperature sensors and much more. 20  Silicon Chip BASIC program to be digital inputs or outputs, analog inputs, frequency measurement inputs and more. The 44-pin chip has 33 I/O pins with the same characteristics. The BASIC interpreter running on the Micromite is a high-level implementation of the language. It supports floating point and strings, long variable names, arrays with multiple dimensions, user defined subroutines/ functions and a host of other advanced programming features. Programs are stored in the chip’s internal flash memory and can be edited on the chip using the inbuilt full-screen editor and a serial link. A program can be configured to run immediately on power-up so that the Micromite acts as a pre-programmed custom chip and the user need not know anything about what’s running inside. Perhaps the most powerful feature of the Micromite is the range of communications protocols that it supports. These include I2C, asynchronous ser­ ial, RS232, IEEE 485, SPI and 1-Wire. Using these, your program can communicate with other chips and sensors and can send data to test equipment. The new chip As stated, the Micromite Mk.2 uses the new PIC32MX170F256 series. For people who struggle to decode these siliconchip.com.au part numbers, “PIC32” refers to the 32-bit family of Microchip processors, “MX170” is the chip’s part number and “F256” refers to the amount of flash memory in the chip (256K bytes in this case). The MX170 comes in a number of variations with different packages, pin numbers and maximum speeds. Table 1 lists the versions suitable for the Micromite Mk.2 and their characteristics. The recommended part number is the PIC32MX170F256B-50I/SP. This has a top speed of 50MHz and is in a plastic DIL package with 28 pins. If you purchase one of these from Microchip, it will cost you around $US4 (plus freight). You then need a programmer such as a PICKit3 to load the MMBasic firmware and turn it into a Micromite Mk2. Alternatively, if you only need a few chips, a more convenient option is to purchase the chip fully-programmed from the SILICON CHIP OnlineShop for $15.00 plus postage. More memory & much faster One of the great features of the Micromite Mk2 is that the free space for your BASIC programs has been increased to 58KB and the amount of free RAM is now 52KB. This is a huge increase on the original Micromite which had just 20KB and 22KB respectively. Previously, you could run quite large programs. Now you can run truly enormous programs with plenty of comments and other components that consume the program space. In addition, the extra RAM allows your programs to build large arrays for manipulating numbers and large buffers for moving data around. Another feature of the Micromite Mk2 is that it is much faster than the previous version. The chip used in the original Micromite had a limited amount of flash memory, so when we squeezed the MMBasic interpreter into this chip, we had to optimise it to conserve space. And that slowed down the interpreter. With double the amount of flash memory in the Micromite Mk2, we have the luxury of optimising the interpreter for speed. So now programs on the Micromite Mk2 will run about 40% faster than on the previous Micromite running at the same clock speed. In fact, the Micromite Mk2 has more memory and runs faster than the siliconchip.com.au Fig.1: the DHT-22 is a combined +3-5V DC temperature & humidity sensor that is supported by MMBasic in the Micromite Mk2. Using ANY MICROMITE just one command you can I/O PIN get both the temperature and humidity with no complicated programming required. Note that the DHT-22 is also known as the RHT03 or AM2302. popular Maximite and Colour Maximite computers described in the March 2011 and September 2012 issues of SILICON CHIP. Big numbers The original Micromite used floating point numbers (often abbreviated to “float”) for all arithmetic. Floating point is good because it allows you to have numbers with a decimal point such as “12.4”. However, the problem with floating point numbers is that they only store an approximation of the number when the number has more than six or seven significant digits. Despite this issue, floating point is still the best for general purpose computing. It is rare that you need more than six digits of accuracy in everyday life and operations like division always do what you expect 4.7k when you are using floating point. On the other hand, when you are working in an embedded controller environment, you often need more precision than floating point numbers can provide. Because of this, we have given the Micromite Mk.2 the ability to store and manipulate numbers as 64-bit signed integers. These can be used to accurately count and manipulate numbers up to nine million million million (or ±9,223,372,036,854,775,807 to be precise), which is a very large number indeed. The downside of an integer is that it cannot store fractions (ie, numbers after the decimal point). Any calculation that produces a fractional result will be rounded up or down to the nearest whole number when assigned to an integer. New Features In The Micromite Mk.2 •  The same hex file works with both 28-pin and 44-pin chips. •  The amount of free memory for programs is increased by 300%. •  Programs will run about 40% faster at the same CPU speed. •  64-bit integers can be used to store and manipulate numbers as large as 19 digits. •  64-bit integer arithmetic is about 25% faster than floating point. •  A full SELECT...CASE decision structure has been implemented. •  Compiled C or assembler programs can be embedded in the BASIC program. •  The temperature and humidity can be read from a DHT22 sensor. •  The frequency of the internal clock can be trimmed for better timekeeping. •  The >> and << operators can shift bits in a number to the right or left. •  The processor can be put to sleep for a specified number of seconds. •  The gate time used when making frequency measurements can be specified. •  Internal pull-up or pull-down resistor can be enabled for any input pin. •  Voltage measurements can be corrected for variations in the supply voltage. •  The console can be used with RS232 signals without a converter. •  The TIMER function will now count up for over 200 million years. •  The SPI function can now send/receive data in 32-bit blocks (in addition to eight and 16 bits). •  Additional features to prevent common programming errors. •  The manual has been updated and it includes a full bookmark listing. January 2015  21 (%) as a suffix to a variable name. For example: +3.3V (FROM PICkit3) PICkit3 ICSP CON. Count% = Count% + 1 10k 1 1 MCLR 27 2 Vcc Because this expression uses 64-bit integers, it will be able to count up to a number with 19 digits with perfect accuracy. Even doing nothing else, a Micromite Mk2 running at full speed would take millions of years of counting to reach this limit. 28 3 GND PGD PCC 4 4 5 5 6 (NC) 28-PIN MICROMITE 8 20 47 µF 6V 19 13 CERAMIC OR TANTALUM LOADING FIRMWARE Fig.2: here’s how to connect a blank 28-pin chip to a PICkit3 programmer to load the MMBasic firmware for the Micromite Mk2. Once connected, you use MPLAB IPE (free from Microchip) to program the device. Note that the 47µF capacitor is critical and must be a tantalum or multilayer ceramic type. +3.3V (FROM PICkit3) 17 28 40 10k PICkit3 ICSP CON. MCLR Vcc GND PGD PCC NC 1 18 2 44–PIN MICROMITE 3 4 21 5 22 7 6 47 µF TANTALUM OR 10 µF CERAMIC 6 16 29 39 LOADING FIRMWARE Fig.3: the 44-pin version of the chip is programmed using a PICkit3 programmer as shown here. An illustration of where 64-bit integers come in handy is when you are dealing with latitude and longitude. For example, you might be planning a project which needs to capture these two numbers from a GPS module and use them to calculate the distance between two points. The problem comes about because latitude and longitude need to be stored with more than six digits of accuracy. For instance, the longitude of Sydney is 151.2094° and a floating point variable will only store that number as an approximation. This is a significant issue because even a slight variance in the stored number could represent an error amounting to several kilometres. However, you could store the latitude and longitude in hundredths of a 22  Silicon Chip second and use 64-bit integers to handle the number (Sydney’s latitude in hundredths of a second is 54,435,384). Because integers retain the full precision of the number, the location will be accurate to better than one metre. There are many other cases where large and precise numbers are required; eg, when working with frequency synthesisers. Calculations involving integers are also faster than floating point calculations (by about 25%) and there is nothing stopping you from using them exclusively in your programs if you need a bit more speed. The only drawback is that integers cannot store fractions, only whole numbers. For many programs though, that is not an issue. In MMBasic, 64-bit integers are specified by adding the percent symbol Mixed arithmetic With the introduction of two types of numbers (floating point and integers), you might be wondering how MMBasic handles the two when they are mixed in a calculation. Well, in general, this is done automatically and is transparent to the programmer. For example, if you assign a floating point to an integer, MMBasic will automatically convert it to an integer, including rounding the fractional component to the nearest integer. The opposite action will convert an integer to a float. Because floating point numbers can handle a wider range of numbers, the interpreter will automatically promote an integer to a float when the two are mixed in an expression. For example, in the following program fragment, the value of B% will be automatically converted to floating point with the result that 123.45 will be stored in Nbr: A = 23.34 B% = 100 Nbr = A + B% If all numbers in an expression are integers, then they will be left as integers and an integer will be returned. The only exception to this is division using the normal divide operator (/). In this case, both sides of the expression will be promoted to a floating point number and a floating point number will be returned. For integer division, you should use the integer divide operator (\). It will leave both sides of the expression as integers (or convert them if they are floats) and return an integer while truncating any fractional part. If you use constant numbers (eg, 23.45, 100, etc) in an expression, they will be treated as a floating point number if they contain a decimal point and an integer if they do not. Functions in MMBasic return integers or floating point depending on their characteristics. For example, the function to get the length of a string (LEN) will return an integer while siliconchip.com.au TAN() will return a floating point. As another example, PIN() will return a float if it is measuring voltage but an integer if it is counting the pulses in an input signal. BASIC CONNECTIONS 1 28 27 CFunctions Another new feature in the Micromite Mk2 is the ability to define program modules written in C or MIPS assembler. These modules can be easily called by your BASIC program and can be used to implement functions that cannot be implemented in BASIC. Typically, you use CFunctions to access special features of the PIC32 chip or where speed of execution is required. As an example, the firmware zip file for the Micromite Mk2 (available on the SILICON CHIP website) includes a CFunction that will add up to eight additional serial I/O ports. This isn’t something that you could do in BASIC alone, as the interpreter is not fast enough for this type of bit manipulation operation. However, by adding the code for the CFunction to your BASIC program, you can have the best of both worlds – the easy-to-program BASIC language and the high-speed ability of a function written in C. A few caveats are in order here. Writing in the C language is nowhere near as easy as writing in BASIC and the environment of the CFunction is limited. For example, you cannot interact with MMBasic (except in limited ways) or call standard library functions. However, CFunctions are handy for small functions that cannot be accomplished using BASIC. Example CFunctions The zip file containing the Micromite Mk.2 firmware includes a number of example CFunctions. These include sending serial data, receiving serial data, discovering the chip type that the program is running on (28-pin or 44-pin) and discovering the current clock speed. By using pre-compiled functions like these, you will be able to add functionality to your programs without having to know anything about the internals of the CFunction. Hopefully, other people will write more CFunctions and expand the library in the future. If you do want to delve into writing CFunctions yourself, the Micromite Mk.2 zip file includes a link to a 74siliconchip.com.au +2.3 TO +3.6V (25mA) (CAN BE 2 x AA CELLS OR A NOMINAL 3.3V POWER SUPPLY) SERIAL CONSOLE: VT100 TERMINAL OR USB TO TTL CONVERTER (38,400 BAUD, 8 BITS, NO PARITY, 1 STOP BIT, TTL VOLTAGE LEVELS) 8 MICROMITE 20 47 µF 6V Rx SERIAL TERMINAL Tx DATA FROM MICROMITE DATA TO MICROMITE GND 11 12 13 19 CERAMIC OR TANTALUM Fig.4: to use the Micromite Mk.2, you need to connect it to a VT100 emulator such as the ASCII Video Terminal described in SILICON CHIP in July 2014. Alternatively, you can connect it to a PC via a USB-Serial bridge. You can then use programs such as Tera Term or MMEdit to create programs and download them to the Micromite (see text). As before, the 47µF capacitor is critical and must be a tantalum or multilayer ceramic type. page tutorial which goes into all the details. Select...Case One often requested feature in MMBasic is the SELECT...CASE statement. Given the expanded flash memory capacity of the new chip, we have now been able to add this. This is generally used as a replacement for the IF...THEN...ELSEIF construct. The SELECT...CASE statement is much easier to use and makes the intentions of the program much more obvious to the casual reader (which might be you in a few years time). The structure is: SELECT CASE value   CASE testexp [[, testexp] ...]   <statements>   <statements>   CASE ELSE   <statements>   <statements> END SELECT The “value” is the value to be tested against each following CASE statement, while “testexp” can be a wide range of test expressions. For example, you can say 5 to 8 which will match the numbers 5, 6, 7 and 8. You can say >5 which will match any value greater than 5. There are many more tests that you can make and they are detailed in the user manual. Reduced programming errors While the BASIC programming lan- Fig.5: the terminal emulator that you use to connect to the Micromite Module (via USB) should be set to 38,400 baud, eight bits data, no parity and one stop bit. This screen grab shows what the set-up dialog in Tera Term should look like with the correct values entered. Note that your port number will almost certainly be different to that shown because it will change with the physical USB port. guage has the reputation for being easy to learn it also has a darker reputation for creating some difficult to debug programs. The new Micromite Mk2 has a number of additional features to help eliminate many of the more common programming errors and make it easier to debug the final program. For some time, MMBasic has had structured programming elements like multi-line IF...THEN constructs and subroutines/functions. These have mostly eliminated the need to use the GOTO command which has the January 2015  23 Fig.6: MMEDIT was written by Jim Hiley and can be installed on a Windows or Linux PC. It allows you to edit your program on the PC and then, with a single mouse click, transfer it to the Micromite for testing. potential to create truly impossibleto-understand programs. New in the Micromite Mk2 is the OPTION EXPLICIT command. This instructs the interpreter to not automatically create a variable when it is encountered in the program. Previously, when MMBasic found an expression like nbr = 1234, it would automatically create the variable nbr and then assign the number 1234 to it. This is fine for quick and dirty programs but in a larger program, disaster can strike if the variable was misspelt. For example, if the programmer accidentally misspelt the above variable as nmbr, the interpreter would automatically (and silently) create it with the value of zero. The programmer, who expected it to contain 1234, might miss this subtle change in testing, with the result that the program contained a potentially serious flaw. Now the programmer can specify OPTION EXPLICIT which will throw an error when the new variable is encountered without being explicitly declared beforehand. The way you do this is with the DIM command. For example, at the beginning of the program you can state: DIM AS INTEGER nbr This tells the interpreter that nbr is a Where To Get The Micromite Mk2 A pre-programmed Micromite Mk2 chip (28-pin version) is available for $15 plus p&p from the SILICON CHIP Online Shop (includes the 47μF capacitor). MMBasic and a User Manual are also available on the SILICON CHIP website (free of charge). 24  Silicon Chip valid variable (and is an integer). Then, if the program used a reference to nmbr, an error message will be shown (variable not declared). Another common class of bugs can occur when the type suffix is left off a variable. The type suffix indicates the type of variable – for example “$” indicates a string and so data$ would be a string. If the suffix was accidentally left off during program entry, the type of variable would then be a number, which is significantly different from that which the programmer had intended. To prevent this type of error, the programmer can specify OPTION DEFAULT NONE which tells MMBasic that variables must have a type suffix or the type must be explicitly specified in the DIM command. In fact, placing both OPTION EXPLICIT and OPTION DEFAULT NONE at the start of your program is good programming practice and will draw attention to a wide range of common programming errors. The OPTION DEFAULT command also allows you to specify the default type for a variable without a suffix. This can be convenient for a short program where you are only using integers (for example); you can then specify OPTION DEFAULT INTEGER and gain the speed benefit of integers with the shortcut of not having to specify a suffix. It does fly in the face of what we were talking about above but it is acceptable for short programs that only use the one type of variable. Constants Another source of bugs is the use of literal numbers as constants in a program. Let’s say that you are building a single-cell battery charger using the Micromite and you need to detect when the cut-off voltage has been reached. Your program might use something like this: IF PIN(15) > 1.8 THEN ... But what does pin 15 connect to and what does 1.8 represent? In a year or two when you need to modify the program, you will have probably forgotten. You could always use a variable called “MaxV” and set it to the threshold voltage but that runs the danger of being accidentally changed somewhere else in the program. A much better option is to use the new CONST command. For example: CONST BattV = 15, MaxV = 1.8 Then the above program line would read: IF PIN(BattV) > MaxV THEN . . . which is much more understandable to the casual reader. Another benefit of constants defined by the CONST command is that you can use them through your program and if you need to change the value of one particular constant you can do it easily in the one place. DHT22 sensor The DHT22 sensor is a module that will measure temperature and humidity and can be purchased for less than $5 on eBay. Support for the DHT22 has been added to the Micromite Mk2 and it provides a convenient method of measuring these two key weather parameters. Connecting the DHT22 is straightforward (see Fig.1) and getting the temperature and humidity into your BASIC program is just as easy. The command is: DHT22 pin, tVar, hVar where pin is the I/O pin used to connect to the DHT22 and tVar and hVar are floating point variables. After this command has been run, tVar and hVar will be updated with the measured temperature and humidity, with a resolution of one decimal place. Another useful addition to the Micromite Mk2 is the ability to specify an internal pull-up or pull-down resistor on any input. Using a pull-up, for instance, allows you to connect a switch directly to an input pin. When the switch is open, the pull-up resistor will keep the input high but when the switch is closed, the input will be pulled low. Overall, there have been almost 50 siliconchip.com.au new features and enhancements in the Micromite Mk2 and a summary of these is listed in the panel at the start of this article. For the full list, download the updated firmware from the SILICON CHIP website and refer to the detailed change log which is included in the zip file. The zip file also includes the Micromite Mk2 User Manual which goes into far more detail than we can provide here. It runs to almost 80 pages and includes a detailed description of each command and function. About half the manual is devoted to tutorials and explanations so it also provides an easy learning path for beginners to the Micromite and programming using BASIC. Programming the chip As we said earlier, the easy way to get going with the Micromite Mk2 is to purchase the chip fully programmed with the MMBasic language from the SILICON CHIP website – www. siliconchip.com.au There are also some web based companies such as micromite.org and www.circuitgizmos.com who also supply the chip fully programmed. As previously stated, another option is to purchase a blank chip directly from Microchip (www.microchipdirect.com) or their distributors (element14, RS Components, etc) and program it yourself. To program the chip you need the Micromite Mk2 firmware (download it from the SILICON CHIP website) and a PIC32 programmer such as the PICkit3 from Microchip. There are also many PICkit3 clones available on eBay and other sites for as cheap as US$30 and they seem to do the job just as well as the genuine product. In order to use the PICkit3, you need to download and install MPLAB X from Microchip. This includes a full development environment for Microchip products but the part of interest is the programmer called MPLAB X IPE (IPE stands for Integrated Programming Environment). This is usually installed as an icon on your desktop (in Windows) and double-clicking on it will put you into the programmer. Figs.2 & 3 show how the PICkit3 You can use a USB-to-serial bridge like the one shown here to connect the Micromite Mk.2 to a USB port on a PC. Once connected, you can use Tera Term or MMEdit to write programs for the Micromite and download them via this device. Table 1: Micromite Mk2 Microcontrollers CPU Package & Speed PIC32MX170F256B-50I/SP 28-pin DIL package. Guaranteed to run at 48MHz PIC32MX170F256B-50I/SO 28-pin SOIC package. Guaranteed to run at 48MHz PIC32MX170F256D-50I/PT 44-pin surface mount package. Guaranteed to run at 48MHz PIC32MX170F256B-I/SP 28-pin DIL package. Guaranteed to run at 40MHz PIC32MX170F256B-I/SO 28-pin SOIC package. Guaranteed to run at 40MHz PIC32MX170F256D-I/PT 44-pin surface mount package. Guaranteed to run at 40MHz This table lists the PIC microcontrollers that are suitable for use as a Micromite Mk.2. From our testing, the chips rated at 40MHz also ran at 48MHz (at room temperatures), so they are a viable choice if you cannot find the higher speed versions. is connected to the chip. The 47µF capacitor is critical and should be a tantalum or multilayer ceramic type with an ESR (Equivalent Series Resistance) of less than 1Ω. Do not use an electrolytic as the microcontroller may intermittently restart without warning. Using the Micromite Mk2 To write and test your BASIC programs on the Micromite Mk2, you first need to connect a VT100 terminal emulator to the console pins as shown in Fig.4. The emulator should have a TTL serial interface set at 38,400 baud (Fig.5). You have two choices here: you can build the ASCII Video Terminal described in SILICON CHIP, July 2014 or you could use a USB-serial bridge as shown in the accompanying photo. A USB-serial bridge will convert the USB interface on a PC to a TTL level serial interface which can directly connect to the Micromite Mk2. Note that the 47µF capacitor in Fig.4 is again critical (see the comments above related to this component). Issues Getting Dog-Eared? If you are using a USB-serial bridge, you then need to run a terminal emulator on your PC and we recommend Tera Term for Windows. Another excellent choice is MMEdit written by SILICON CHIP reader Jim Healy and this can be downloaded from www.c-com. com.au/MMedit.htm MMEdit contains a terminal emulator but it is also a powerful editor for MMBasic programs with features such as automatic formatting and colourcoded key words. Using either Tera Term or MMEdit, you can develop and test your program and when you are finished, set the program to automatically run when the chip is powered up. As a closing thought, consider that this little $4 chip has double the memory of the first personal computers which were programmed in BASIC (the Tandy TRS-80, Apple II, etc) and runs more than 50 times faster. That really is amazing. Finally, for firmware updates and handy hints, check the author’s website at geoffg.net/micromite.html SC Keep your copies safe with our handy binders Order online from www.siliconchip.com.au or fill in and mail the handy order form in this issue or ring (02) 9939 3295 and quote your credit card number. siliconchip.com.au January 2015  25