Silicon ChipColour MaxiMite Microcomputer, Pt.2 - October 2012 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: The attractions of electric cars
  4. Feature: Electric Remotely Piloted Aircraft . . . With Wings by Bob Young
  5. Feature: HAARP: Researching The Ionosphere by Dr. David Maddison
  6. Project: LED Musicolour: Light Up Your Music, Pt.1 by Nicholas Vinen
  7. Project: Reverse Loop Controller For DCC Model Railways by Jeff Monegal
  8. Project: The Nick-Off Bad Cat Deterrent by Greg Swain and Nicholar Vinen
  9. Project: Colour MaxiMite Microcomputer, Pt.2 by Geoff Graham
  10. Project: Wireless Remote Control For The Barking Dog Blaster by Ross Tester
  11. Vintage Radio: The Philips twins: the Dutch BX462A & the Australian model 115 by Rodney Champness
  12. PartShop
  13. Order Form
  14. Book Store
  15. Market Centre
  16. Advertising Index
  17. Outer Back Cover

This is only a preview of the October 2012 issue of Silicon Chip.

You can view 21 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.

Articles in this series:
  • Radio Control (November 1996)
  • Radio Control (November 1996)
  • Radio Control (February 1997)
  • Radio Control (February 1997)
  • Radio Control (March 1997)
  • Radio Control (March 1997)
  • Radio Control (May 1997)
  • Radio Control (May 1997)
  • Radio Control (June 1997)
  • Radio Control (June 1997)
  • Radio Control (July 1997)
  • Radio Control (July 1997)
  • Radio Control (November 1997)
  • Radio Control (November 1997)
  • Radio Control (December 1997)
  • Radio Control (December 1997)
  • Autopilots For Radio-Controlled Model Aircraft (April 1999)
  • Autopilots For Radio-Controlled Model Aircraft (April 1999)
  • Model Plane Flies The Atlantic (May 1999)
  • Model Plane Flies The Atlantic (May 1999)
  • Tiny, Tiny Spy Planes (July 1999)
  • Tiny, Tiny Spy Planes (July 1999)
  • 2.4GHz DSS Radio Control Systems (February 2009)
  • 2.4GHz DSS Radio Control Systems (February 2009)
  • Unmanned Aerial Vehicles: An Australian Perspective (June 2010)
  • Unmanned Aerial Vehicles: An Australian Perspective (June 2010)
  • RPAs: Designing, Building & Using Them For Business (August 2012)
  • Flying The Parrot AR Drone 2 Quadcopter (August 2012)
  • Multi-Rotor Helicopters (August 2012)
  • Multi-Rotor Helicopters (August 2012)
  • Flying The Parrot AR Drone 2 Quadcopter (August 2012)
  • RPAs: Designing, Building & Using Them For Business (August 2012)
  • Electric Remotely Piloted Aircraft . . . With Wings (October 2012)
  • Electric Remotely Piloted Aircraft . . . With Wings (October 2012)
Items relevant to "LED Musicolour: Light Up Your Music, Pt.1":
  • LED Musicolour PCB [16110121] (AUD $25.00)
  • dsPIC33FJ128GP802-I/SP programmed for the LED Musicolour [1611012A.HEX] (Programmed Microcontroller, AUD $25.00)
  • LED Musicolour front & rear panels [16110122/16110123] (PCB, AUD $20.00)
  • LED Musicolour Firmware (HEX/C - zipped) [1611012A.HEX] (Software, Free)
  • LED Musicolour PCB pattern (PDF download) [16110121] (Free)
  • LED Musicolour front & rear panel artwork (PDF download) [16110122/16110123] (Free)
Articles in this series:
  • LED Musicolour: Light Up Your Music, Pt.1 (October 2012)
  • LED Musicolour: Light Up Your Music, Pt.1 (October 2012)
  • LED Musicolour: Light Up Your Music, Pt.2 (November 2012)
  • LED Musicolour: Light Up Your Music, Pt.2 (November 2012)
Items relevant to "Reverse Loop Controller For DCC Model Railways":
  • DCC Reverse Loop Controller PCB [09110121] (AUD $10.00)
  • PIC12F675-I/P programmed for the DCC Automatic Reverse Loop Controller [0911012A.HEX] (Programmed Microcontroller, AUD $10.00)
  • PIC12F675-I/P programmed for the DCC Block Switch [0911012B.HEX] (Programmed Microcontroller, AUD $10.00)
  • Pair of ZXCT1009 Current Shunt Monitor ICs for DCC Reverse Loop Controller project (Component, AUD $10.00)
  • Firmware (HEX) files for the DCC Automatic Reverse Loop Controller [0911012A and 0911012B] (Software, Free)
  • DCC Reverse Loop Controller PCB pattern (PDF download) [09110121] (Free)
Items relevant to "The Nick-Off Bad Cat Deterrent":
  • Nick-Off! Proximity Alarm PCB [03110121] (AUD $5.00)
  • Nick-Off! Proximity Alarm PCB pattern (PDF download) [03110121] (Free)
  • Nick-Off! Proximity Alarm front panel artwork (PDF download) [03110122] (Free)
Items relevant to "Colour MaxiMite Microcomputer, Pt.2":
  • Colour Maximite PCB [07109121] (AUD $17.50)
  • Colour MaxiMite Firmware, Documentation and Demo software (Free)
Articles in this series:
  • Colour MaxiMite Microcomputer, Pt.1 (September 2012)
  • Colour MaxiMite Microcomputer, Pt.1 (September 2012)
  • Colour MaxiMite Microcomputer, Pt.2 (October 2012)
  • Colour MaxiMite Microcomputer, Pt.2 (October 2012)
Items relevant to "Wireless Remote Control For The Barking Dog Blaster":
  • ETD29 transformer components (AUD $15.00)
  • Barking Dog Blaster panel artwork (PDF download) (Free)
Articles in this series:
  • Barking Dog Blaster: Shut That Annoying Mutt Up! (September 2012)
  • Barking Dog Blaster: Shut That Annoying Mutt Up! (September 2012)
  • Wireless Remote Control For The Barking Dog Blaster (October 2012)
  • Wireless Remote Control For The Barking Dog Blaster (October 2012)

Purchase a printed copy of this issue for $10.00.

Now with & 100-pin micro r ecto Arduino conn The COLOUR Pt.2: By GEOFF GRAHAM MAXIMITE Building the unit and using its new sound & colour features Last month, we introduced the Colour Maximite, an inexpensive computer with colour VGA output, keyboard input and an SD card for storage. We now take you through construction and provide a brief run-down on how to use its new features. I N DESIGNING THE Colour Maximite, we have been careful to specify parts that can be easily sourced. So if you want to “go it alone” without a kit, that option is always open to you. The two custom parts, the PCB and a programmed PIC32 chip, can be purchased directly from the SILICON CHIP Partshop. Alternatively, if you want to source the PIC32 chip yourself, you must also have access to a suitable programmer. In that case, the PIC32 chip can be purchased direct from Microchip, Element14 or some other supplier. You must be careful to choose the correct part number as there are two 100-pin packages, one measuring 12 x 12mm and the other 14 x 14mm. We designed the PCB to suit the latter, to make it 74  Silicon Chip easier to solder, so be sure to purchase the 14 x 14mm package (with the /PF suffix), as specified in the parts list. The SD card connector is a little more difficult. Every manufacturer seems to have their own footprint for this connector. We designed the PCB so that it could accommodate a number of different footprints but we have only tested the Hirose DM1A connector which is reasonably popular and available from Element14 and others. The high-density VGA connector is also available in a number of different footprints so we have selected the most popular. This version has an overall depth of 22mm from front to back. The 10µF SMD capacitor connected to pin 85 of the PIC32 must be a ceramic type. Don’t try to substitute a tantalum or (heaven forbid) an electrolytic here, as this component is critical to ensure that the PIC32’s CPU starts and runs correctly. As mentioned last month, regulator REG2 (TC1262) was selected for its low drop-out voltage and accuracy. You can substitute another device with the same pin-out but you should ensure that it has a drop-out voltage of 0.8V or less, otherwise the Colour Maximite could intermittently crash. Construction Take a look now at Fig.4 for the PCB assembly details. It’s quite straightforward and should only take a couple of hours to build. It’s best to start with the microcontroller (IC1) which is a surface-mount siliconchip.com.au CON1 CON4 PS/2 KEYBOARD SDA A4 D3 5819 Sound (PWM) CON3 DC D1 100nF 22pF 26 51 100nF IC1 PIC32MX795 POWER SWITCH J1 CON5 IC4 DS1307 device. This might sound daunting but it is relatively easy to solder. Even better, if you’ve bought a kit, the PCB may come with the chip already soldered in place, so you don’t have to do that job. We have described how to solder SMD chips many times in the past and we won’t repeat that in any great detail here. The important factor is that, in addition to a temperature-controlled soldering iron, you also need a good liquid flux designed for SMD work, a pair of fine-tipped tweezers and a magnifying glass (or magnifying lamp). If you are new to soldering SMD devices you can watch an excellent tutorial on this subject at: http://store. REG2 (OR LINK) 10 F 10 F TC1262 47 100nF LITHIUM 3V 7805T geoffg.net/maximite.html D8 D9 D10 D11 D12 D13 GND D0 D1 D2 D3 D4 D5 D6 D7 47 32768Hz D6 D2 X2 A 4148 5819 10k 1k 120 + 10k D5 1 10 F 47nF 4. 7k D4 4148 + 1k 4148 120 Colour Maximite 100nF 47nF 120 REG1 C 2012 Geoff Graham 100nF 76 22pF 1k VGA 4004 100nF 8MHz 4. 7k POWER LED1 K 9V 330nF 1k X1 1k J2 1 Fig.4: follow this PCB parts layout diagram to build the Colour Maximite. The PCB is screen-printed so you can also follow that to help place the components. Note that this diagram also includes the parts placement for the optional battery-backed clock. Begin the assembly by installing the PIC32 micro and make sure that all polarised parts are correctly orientated. 2.2 FIRMWARE CON9 PWM1 PWM2 GND ICSP J3 10k S1 LOAD GPI/O CON6 A5 10 2 SCL A5 A4 A3 A2 A1 A0 1 1 100nF 3 100nF 4 VIN GND GND 5V 3V3 RES CON2 USB TYPE B SD CARD SOCKET CR2032 CELL K curiousinventor.com/guides/Surface_ Mount_Soldering/101 You can also refer to pages 80-82 of the June 2012 issue of SILICON CHIP for a detailed description on soldering in SMDs ICs. In any case, the basic technique is as follows. First, carefully place IC1 on its pads, with its bevelled corner (adjacent to pin 1) at bottom right. That done, apply plenty of flux and solder one corner pin. Then, after checking the chip’s alignment, solder the opposite pin. It’s now just a matter of steadily moving around the chip and soldering the remaining pins, applying additional flux as you go. Use only a tiny ACTIVITY A LED2 amount of solder when soldering each pin, to avoid solder bridges. If you do get a bridge, ignore it and carry on, as you can come back later and remove it using solder wick. The important factor is the flux. Use plenty of it before you apply the sol- Table Tab le 2: Capacitor Codes Value 330nF 100nF 47nF 22pF µF Value IEC Code EIA Code 0.33µF 330n 334 0.1µF 100n 104 0.047µF   47n 473 NA   22p   22 Table 1: Resistor Colour Codes o o o o o o o o siliconchip.com.au No.   3   2   5   3   2   1   1 Value 10kΩ 4.7kΩ 1kΩ 120Ω 47Ω 10Ω 2.2Ω 4-Band Code (1%) brown black orange brown yellow violet red brown brown black red brown brown red brown brown yellow violet black brown brown black black brown red red gold brown 5-Band Code (1%) brown black black red brown yellow violet black brown brown brown black black brown brown brown red black black brown yellow violet black gold brown brown black black gold brown red red black silver brown October 2012  75 This view shows the fully-assembled PCB for the Colour Maximite, with the battery back-up parts also in place to ensure the unit keeps the time when the power is turned off. Note that this is a prototype board. The final board is slightly different in the bottom righthand corner. dering iron to each pin and the solder will flow quickly and easily. For this job, flux is your friend and too much solder is the enemy. Finally, use a magnifying glass and a good light to carefully inspect the chip, to ensure that all the pins have been correctly soldered and that there are no bridges remaining. Once the PIC32 chip is in place, the remaining parts can be installed according to Fig.4 and the screen-printed labelling on the PCB. Start with the low-profile components (resistors and diodes) and work up to the taller items like the voltage regulators, the pin headers and the sockets. Be sure to install the diodes, regulators and electrolytic capacitors with the correct orientation. The SD-card socket specified is a surface-mount part. It has two small posts on the underside and these go into two matching holes in the PCB to ensure that the socket is correctly positioned. Once it’s in place, it’s a matter of locating and soldering all the tabs; there are 15 in total, including some for the body of the connector. In particular, two tiny tabs on the left hand side of the socket (viewed 76  Silicon Chip from the front) are not very obvious. They are used to detect when a card is inserted or is write-protected, so do not miss them. It’s best to leave the two LEDs until last. LED1 (green) is installed at front left, while LED2 (orange) goes to the right. To fit them, first bend each LED’s leads down through 90° immediately adjacent to its body, with its long lead (anode) on the right when looking at the lens from the front. That done, trim their leads to about 14mm long, then temporarily mount the PCB and front panel in the case. The two LEDs can now be fitted in position, so that they poke through their holes in the front panel. Their leads are then tack-soldered to the top pads on the PCB, after which you can remove the PCB and complete the soldering on the underside. Optional power switch Pin header J1 (marked on the board as POWER SWITCH) is for an optional power switch. Normally, you would simply fit a jumper to this header to short it out (or install a wire link). However, we provided this facility in case you wanted to wire in a front- panel switch, so that you can turn the Colour Maximite on and off just like a big computer. Basically, a power switch is up to you. The Colour Maximite uses so little power (approximately 160mA) that even if you left it turned on 24 hours a day, it would only consume an additional $2 worth on electricity in a year (less than the cost of a switch). The 5V regulator (REG1) should be fitted with a small heatsink (type 6073) to dissipate the heat when the power supply exceeds 12V. The 3.3V regulator (REG2) dissipates much less heat and doesn’t need a heatsink. Once the PCB has been completed, it can be installed in the case and secured using four No.4 x 9mm self-tapping screws. These go into integral spacers on the base of the case. That done, you can connect the stereo audio (or PWM output) from polarised header connector CON9 to a 3.5mm panelmount phono socket on the rear panel. The photographs and Fig.5 show the details for the connecting cable. Programming the PIC32 If you either purchased a kit or purchased the PIC32 chip from SILICON siliconchip.com.au The PCB is secured inside the case using four self-tapping screws that go into integral pillars in the base. Helping to put you in Control Control Equipment 50cm Flat Linear LED Cabinet Lights Replace your bulky fluorescent lights. Simply clip to a wall. 12VDC and 24VDC powered. Also available in 30 and 100 cm lengths which can be extended. CSL-1220 $34.95+GST Universal Indicator Display readings from thermocouples/RTD, 4-20mA and 0-10V signals. 24VDC out to power sensors and RS485 Modbus connection. IPI-132 $159.00+GST Screw Fixed Temperature Sensors Measure the temperature of surfaces using these RTD and K thermocouple sensors. Range 0 to 200degC CMS-006 $52.95+GST CHIP, you can skip this section as the micro will already be programmed. If not, you will need to solder a 6-pin polarised header connector in the ICSP (CON7) position on the PCB, as shown on Fig.4. After that, it’s just a matter of connecting your programmer to this header and programming the chip with the firmware (available from the SILICON CHIP website). You need the ColourMM_plus_ bootloader_V4.0.hex file, where 4.0 is the firmware version number. This version of the firmware includes a bootloader which is a small section of code that allows you to later update the firmware over the USB interface. With software of this complexity, it’s virtually impossible to avoid bugs and when these are found and fixed, the author will create an updated version of the firmware which will be available at http://geoffg.net/ maximite.html#Downloads The update will contain all the necessary software and instructions Testing Testing the Maximite is as simple as plugging it into a 9V DC power supply siliconchip.com.au (normally a plugpack) and switching on. Note that the power provided by PCs on their USB ports can be unreliable, so the initial testing should be done using a plugpack. On power up, the firmware will run a self-test and after this has successfully completed it will turn on the green power LED on the front panel. An illuminated LED is therefore an indication that all is OK, while no light means that you have a problem. If the LED doesn’t come on, you should first check the power supply voltages. The supply voltage should be 7-16V, while REG1’s output should be 5V and REG2’s output should be at 3.3V. If these voltages are correct, you should then check all the capacitors for correct placement, value and polarity. Every one is critical and a misplaced capacitor could prevent the processor from starting up. Check also that the power LED is correctly orientated and that its associated 47Ω resistor is correct. The LED will not light if it is installed the wrong way around or a high-value resistor has been installed. The final check is to examine IC1 for shorts or defects in soldering. This will DIN Rail Cutter. This easy to use Din Rail Cutter is ideal for cutting 35x7.5mm steel din rail (Top Hat style). HET-070 $109.95+GST Thermostats Dead simple DIN-rail mount thermostats. Use them to switch a heater or fan on -off in a cabinet. Contacts are rated at 10A 250VAC HEC-005 $29.95+GST Synapse-Wireless Same form as an XBee but heaps more power and functionality. With mesh networking download python programs to do remote control and monitoring. SFC-101 $34.95+GST Big Easy Driver Based on the popular Easy Driver the new version can drive bipolar stepper motors with coil currents up to 2A/phase. Features Microstepping of 2,4,8 and 16. SFC-074 $24.95+GST Contact Ocean Controls Ph: 03 9782 5882 www.oceancontrols.com.au October 2012  77 This close-up view shows the wiring between CON9 and the audio socket. GROUND LEFT RIGHT 3.5mm STEREO PHONO SOCKET 3-PIN HEADER (TO CON9) Fig.5: here’s how to wire up the 3-pin polarised header and the 3.5mm stereo phono socket that’s mounted on the rear panel (ie, for the stereo sound output). require a high-powered magnifying glass and you should carefully check each pin. With the firmware running, you can check the video output by attaching a VGA monitor – you should see the MMBasic prompt in full colour. Finally, plug in a PS/2 keyboard and try typing something in. With the firmware running correctly, any faults in these interfaces can only be related to components specific to those interfaces. As such, they should be easy to diagnose – it’s basically a matter of checking the parts and/or the PCB tracks between the relevant connector and the micro. Note that when displaying white characters on a black background, the text may not appear to be as sharp as with the monochrome Maximite (it is still very good though). This effect depends on the VGA monitor and (if it occurs) is caused by slight timing variations between the three colours as the video is clocked out of the SPI channels. Back-up clock assembly Installing the additional parts for the battery-backed clock is straightforward. Fig.4 shows the details. There are two options here: you can either use a cell holder and a 3V LiMn coin cell (see photos), or you can use a cell with solder tabs. The PCB layout accommodates both options. When you first power up the Colour Maximite, the firmware will recognise that the clock is installed and will display a message under the Maximite logo saying that the clock is not set. To set it, you use the standard commands in MMBasic for setting the time: TIME$ = “hh:mm” DATE$ = “dd/mm/yy” where hh is the hours (in 24-hour notation) and mm is the minutes when setting the time. Similarly, dd is the day, mm is the month and yy is the year when setting the date. That should then be the last time for a long period that you have to use these commands. From then on, MMBasic will automatically retrieve the current time and date on power-up and display it under the Maximite logo – just to let you know that your battery-backed clock is working correctly. Using the Arduino connector This is the startup screen that you can expect to see when you power up your Colour Maximite. You can see just under the logo where MMBasic has found the optional battery-backed clock and retrieved the current time. 78  Silicon Chip The designations for the Arduino pins are screen-printed on the PCB and follow the standard layout. These pins include both +5V and +3.3V supply rails which you can use for your circuit up to 150mA in total (ie, combined). Other pins give you access to the input power supply voltage and allow you to reset the PIC32 processor. Many Arduino systems make the I2C signals available on connector pins A4 and A5. We have therefore provided two jumpers (J2 and J3) so that you can select between the normal I/O function for these pins (A4 and A5) or the I2C signals (SDA and SCL). Note that these two I2C signals are shared with external I/O pins 12 & 13 on the rear panel (see Fig.9) and so are siliconchip.com.au also connected to the Arduino header when selected by jumpers J2 & J3. Other than that, the Arduino connector works as usual. The I/O pins can be controlled from within MMBasic using the designations D0-D13 and A0-A5, as marked on the PCB. These input/outputs are independent of the I/Os on the back panel. For example, to get the input voltage on A3, the MMBasic command would be: Volts = PIN(A3) The analog pins (A0-A5) have an input range of 0-3.3V, while the digital pins will accept input voltages up to 5V. The output from all pins is 0V at logic 0 and 3.3V at logic 1. Serial port COM2 is available on D0 and D1, as is common with Arduino boards. Again note that the output is 3.3V while the inputs can be up to 5V. USB Interface The USB interface allows you to connect the Colour Maximite to your desktop or laptop computer so that you can enter text without having to connect a VGA monitor and keyboard to the Maximite itself. Anything you send over the USB will be interpreted as keystrokes by MMBasic and any output from MMBasic will be sent back via the USB. Before using the USB interface, you need to install the SILICON CHIP USB Serial Port Driver on your computer (available from the SILICON CHIP website). This will work with all modern versions of Windows and full instructions are included with the driver. The standard CDC protocol is used and drivers are included as standard in the Mac and Linux operating systems. The Colour Maximite will be listed in the Device Manager on your Windows PC under Ports (COM and LPT). It will appear as “Communications Port – SILICON CHIP USB Serial Port”, with a specific COM port number. When you configure the serial emulation software on your computer, you will need to specify this number to establish communications with the Maximite. If the software also needs to know the communications parameters, you should specify 9600 baud, one stop bit and no parity. For Windows, we recommend that you use the free, open source Tera Term (http://logmett.com) for the serial emulation software. This emulator works with the XMODEM command in MMBasic for transferring files and also siliconchip.com.au VGA CONNECTOR 6 1 7 2 8 3 COMP 9 DETECT 4 10 GND 5 RED VIDEO 11 12 680 HSYNC 13 RCA CONNECTOR 14 15 3 2 1 4 5 VGA CONNECTOR VIEWED LOOKING AT BACK PANEL 6 7 8 Fig.6: you can also get a composite video output if you need it (monochrome only). This is accessed via the VGA connector by making up this adapter cable. When this cable is plugged in, MMBasic will detect that pin 9 is connected to ground (on power-up) and will switch to composite output at 50Hz with 512 lines. If you need NTSC timing, you can reconfigure MMBasic to that standard using the CONFIG VIDEO NTSC command. 9 10 11 12 13 14 15 with the full-screen editor in MMBasic. You can also copy and paste text from Windows into Tera Term and then transfer it to the Maximite. For this to work, you need to configure Tera Term for a delay of 50ms per line (Settings –> Serial Port). Working with Colour The Colour Maximite produces eight colours, including black and white. Previous versions of MM­Basic already had the facility to select the colour (which could be black or white) when drawing graphics. The major difference is that you can now also specify the colour as red, yellow, green and so on. The colour is specified as a keyword or number. So, for example, to draw A great feature of the Colour Maximite is that it will accept Arduino “shields” that plug into matching connectors on the Maximite’s PCB. The above photo shows an example of an Arduino compatible breadboard. Prototyping boards like this make it easy to add some special circuitry to the Colour Maximite. October 2012  79 13 15 108.5 21 A A 4 87.5 28 (FRONT PANEL) 48 13 ALL DIMENSIONS IN MILLIMETRES 15 59 17 17 C B D 7 7 12 11 21 10 23 43 21 11 (BACK PANEL) HOLES A: 3.5mm DIAMETER; HOLE B: 6mm DIAMETER; HOLE C: 11mm DIAMETER; HOLE D: 14mm DIAMETER Fig.7: these diagrams show the front and rear panel cutouts for the Colour Maximite. The position of most cutouts is critical, as the associated components are soldered to the PCB. Before starting on the cutouts, check their position and size against the actual components that you are using, as their footprints (and size) can vary between manufacturers. Fig.8: the front panel artwork can be copied onto adhesive paper and then covered with a thin adhesive plastic sheet or sealed with a heat laminator. It’s available in PDF format from the SILICON CHIP website. GND GND +5.0V +3.3V 20 1 19 2 18 3 17 4 16 5 15 6 14 7 13 8 12 9 11 GND 10 GND INPUT/OUTPUT PIN CONNECTIONS Fig.9: this diagram shows the pin designations of the external I/O connector as viewed from outside the case. The pin numbers are used in MMBasic when you want to configure and use the I/O pins. The 5V and 3.3V outputs are for powering other circuits (150mA total current drain). 80  Silicon Chip a red circle you would use the command: CIRCLE (x, y), RED where x and y are the coordinates of the circle’s centre. You could also use the number “4” instead of the keyword RED but the keyword makes the program easier to read. There are eight colour keywords: BLACK, BLUE, GREEN, CYAN, RED, PURPLE, YELLOW and WHITE, cor- responding to the numbers 0-7. As another example, the following will set a pixel to yellow: PIXEL(x, y) = YELLOW Many commands allow you to use a default colour, primarily the PRINT command which always uses the default output colour. You can specify this default with the COLOUR command. For example: COLOUR GREEN Following this, all graphics that do not specify a colour will be outputted in green. The COLOUR command also allows you to specify the background colour. For example: COLOUR PURPLE, YELLOW will print text in purple with a yellow background (ughh!). Note that, to cater for our American readers, you can also use the command COLOR. Embedding colour commands To make text more colourful, MM­ Basic allows you to embed colour commands into text strings using the CLR$() function. When you embed this function in a string, it will instruct the PRINT command to select a specific colour for the following text. For example, this will print the word “cat” in blue: PRINT “My fluffy “ CLR$(BLUE) “cat” The full syntax for the function is: CLR$(foreground, background). As you can see, you can set the background colour with the optional second argument. For example, this siliconchip.com.au These two screen grabs show two colour patterns generated by the Colour Maximite. The colours are vivid and look stunning (the CMYK reproductions shown here don’t do them justice). The program used to generate this output is available from the SILICON CHIP website and when you run it, you will also appreciate that the output is animated. This screen grab shows the Julia set generated by the Colour Maximite. The Julia set is mathematically similar to the more famous Mandelbrot set and the program to create this image was written by Rob (loki) on the Back Shed forum. It’s included in the software files available on the SILICON CHIP website. will print yellow letters on a red background: PRINT CLR$(YELLOW, RED) “ALARM” The colours are reset to the defaults (set by the COLOUR command) when the print command terminates. Colour modes As explained Pt.1, generating eight colours uses up some of the CPU’s capacity and memory. By reducing the number of colours, you can increase the speed and the amount of free memory available. To allow you to make this tradeoff, we created the MODE command in MMBasic. This command controls how the Colour Maximite generates colours and it can be used to select one of four different colour modes ranging from 1-4. MODE 1 is the monochrome mode. siliconchip.com.au In this mode, the Colour Maximite operates the same as the monochrome Maximite, with the same performance and the same amount of free memory. A second argument can be used to select the colour of the monochrome output. For example, the following will set the monochrome output to green: MODE 1, GREEN MODE 2 is the 4-colour mode. In this mode, four colours (including black) are available. The four colours available are selected by a number from 1-6 in the second argument of the MODE command (the palette). This mode is half-way between monochrome and the full 8-colour mode in its use of the CPU and memory. MODE 3 is the 8-colour mode and is the default at power up. This uses the most memory but there’s still plenty left for programs and data. Finally, MODE 4 is provided for games and the like that need all eight colours but also require better performance than is available when using MODE 3. In MODE 4, the display is switched to 240 x 216 pixels and because there are less pixels to draw, screen writes are much faster. This lower resolution also requires less memory, so the programmer has the maximum amount of free memory for loading fonts, playing music and so on. You can switch between all four colour modes while your program is running and the switch is instantaneous. This allows you to tune the display and performance to your requirements at any time. Stereo audio A new feature of the Colour Maximite is that it will play synthesised music and sound effects – and in full stereo too. This implementation was created by Pascal Piazzalunga, a Maximite fan who lives in France. You start the music playing with the command: PLAYMOD filename, playtime The first argument is the name of a music or sound effects file, while the second is the length of time that the file will be played. If the latter is not specified, the file will play continuously until specifically told to stop or the program ends. Once started, the synthesised audio will play in the background. This means that your program will continue running and executing commands without interrupting the music. For performance reasons the file October 2012  81 tracks that you can easily find on the Internet. One of the largest libraries is at: http://modarchive.org You can also create your own music using a program called a “tracker”. This is a music sequencer that allows the user to arrange notes on a timeline across several channels. An example of a tracker can be found at http://www. modplug.com Tone output This view (without the rear panel) shows how the two LEDs and the SD-card socket are fitted to the PCB. Note that this version simply uses a link in place of the power switch and doesn’t include the optional battery back-up components or the audio cable which runs from CON9 to the off-board stereo phono socket. must reside on the internal flash drive created by MMBasic (drive A:). The music must also be in the MOD format. This format originated from the Amiga systems of the late 1980s. It is not a recording of the music (like an MP3 file) but instead contains instructions for synthesising the music. On the original Amiga, the task of decoding the instructions contained in the file and synthesising the music was performed by dedicated hardware. It is a tribute to the power of the PIC32 chip and the software written by Pascal Piazzalunga that it can perform the same synthesis in software while simultaneously generating colour VGA, running a BASIC program, communicating via USB and performing many other tasks. There is an entire subculture based around this format (and similar formats) that is part of what is called the “demoscene”. But you do not have to worry about joining that scene because there are many thousands of music Repeated from Pt.1, this rear view shows (from left to right) the VGA socket, the DC power socket, the multi-way I/O connector, the keyboard socket and the audio and USB sockets. The unit is powered from either a 9V plugpack (or battery) or from a USB port on a PC. 82  Silicon Chip If you need to just create a simple sound, you can use the TONE command, which is also new in version 4.0 of MMBasic. This will generate a single-frequency tone that is a pure sinewave. You can specify different frequencies for each stereo channel in the range of 1Hz to 20kHz, with a resolution of 1Hz. Each frequency is locked to the PIC32’s crystal oscillator, so it will be very accurate. As with the music created by the PLAYMOD command, the sinewave is synthesised in software. Normally, this feature would be used to make a simple beep sound but with the two channels joined together using a simple resistive mixer, you could, for example, generate DTMF tones. Another use is as an accurate audio signal generator for testing amplifiers and loudspeakers. Other features The Colour Maximite has many other features that we have not covered here (the magazine does not have enough pages!). These include multiple communications protocols, loadable fonts, full-screen editor, an internal flash file system, advanced programming features, a sprite engine and more. The MMBasic User Manual, available for download from the SILICON CHIP website, now runs to 55 pages. So if you want to get the most from your Colour Maximite you have some serious reading ahead of you. If you have the original Maximite, you can get many of the features described above by upgrading your firmware to version 4.0. Your Maximite will not be able to generate colour but you can play music and sound effects (in mono), generate tones and more using this version. For updates and construction hints for all Maximites go to http://geoffg. SC net/maximite.html siliconchip.com.au