Review: Programming PIC microcontrollers on the Mac using Parallels
Editors Note: This review was prepared by Mariano I. Lizarraga for MacResearch.org.
PIC microcontrollers are widely used on industry and academia. According to Microchip, the manufacturer of the PIC microcontroller, it took them nine years to ship their four billionth unit, but only one year to ship a million more. This gives a good idea of how widespread the use of this microcontroller is and how popular it has become.
In Mexico alone, more than 90% of the microcontroller-oriented classes in colleges and universities use the PIC microcontroller as teaching platform. The ease of use, very low pricing and extensive programming platforms, that go from free (in assembly language) to reasonably priced (in C, Pascal and Basic) have made the PIC a popular chip.
Nevertheless, most of the programming devices (called programmers in PIC jargon) as well as the programing environments, only work in Windows, leaving us Mac users out-played by or Windows colleagues. Even though there exist several compiler options (gputils, CCS) and at least one IDE (PICC lite) for Mac OS X. The availability of programmers (device programmers) that are out-of-the-box compatible with Mac OS X is inexistent. Needless to say that overall solutions that include the IDE for a high level language (C, Pascal or Basic) with the programmer are also absent in Mac OS X.
With the introduction of Mac OS X on Intel based processors and the release of Parallels a new hope was given to us who for some reason or other prefer the PIC among many other microcontrollers in the market. Unfortunately, as you will find out by reading the rest of this article, the situation has not improved to a point that one can finally get rid of that old Windows machine.
Parallels and the PIC
Installing Parallels and have a Windows virtual machine running is a breeze and it is as easy as installing it on any PC. Parallels’ website offer step by step guides on how to install and be up and running in no time.
Serial Port on the Virtual Machine
Once the Windows virtual machine was installed then the first thing to verify with the task at hand was wether one would be able to read the output of a serial device such as a GPS or Inertial Measurement Units (IMUs). For that, a USB to RS232 converter was used. This devices are very popular among hobbyists and professionals who need to access an RS232 device using modern laptops or PCs that do not have serial ports. They can be bought at Fry’s, Digikey, TigerDirect and the like.
As soon as the USB connector was plugged to the Mac it appeared on the USB devices available to Parallels. Selecting it from the list immediately made it available to the Windows virtual machine and from there on installing it was identical to the installation in a regular Windows machine. When the installation was done, The Device Manager in Windows showed the serial port without any apparent problems.
The next step was to get the serial message from a Tokimec IMU to the Mac. For that, Hyperterminal, the serial terminal program included in Windows XP was used. Unfortunately Hyperterminal was not able to use the available serial port. Nevertheless not all was lost, trying several serial terminal programs the one that made the job was USART Terminal by MikroElektronika.
So once that the serial communication was working the next step was to try out the programming environments. Three different programming environments were installed without any significant problem: Microchip’s MPLAB IDE and C30 programming language, MikroPascal and MikroPascal for dsPICs.
Up to now everything seemed to go reasonably well so now it was time to get the Programmers to work.
PIC Device Programmers
Device programmers in the PIC environment are as diverse as PIC models themselves. There are probably about 30 to 40 different programmers out there, from very simple do-it-yourself type to the very professional industry-quality programmers. For this review four programmers were tested: the JDM programmer which is a very simple but powerful serial programmer, the GTP USB which used to be a free USB programming device (now the author sells the firmware for a reasonable price), the PICkit 2 entry-level programmer manufactured by Microchip and finally the EasydsPIC which is a full-blown development board for dsPICs which are powerful cousins of the traditional PICs. It is important to note that all of these programmers where successfully tested and extensively used in a Windows machine previous to this test drive.
JDM Programmer
As previously mentioned, the JDM programmer is a very powerful serial programmer and it is very popular, specially among hobbyists, due to the fact that it uses easy to find parts and is capable of programming a wide variety of PICs. For this test a PIC16F84A microcontroller was used for the test. On the software side WinPIC800, which is a freeware, was the tool used. After configuring the device,
WinPIC800 was unable to recognize the JDM programmer trough Parallels.
GTP USB Programmer
This programmer is possibly one of the most powerful entry-level programmers out there. It programs a very wide variety of PICs, dsPICs, EEPROMs and ATMEL AVR microcontrollers. It’s USB powered, ICSP compatible and matches very nice with the WinPIC800 software. It is probably not as popular as it should be because it is a harder than the JDM to assemble and needs a preprogrammed PIC18F2550 to handle the USB communication and programming. The programmer’s firmware used to be free but about mid 2006 the owner of the firmware decided to start selling it and its successive updates.
As soon as the USB cable was connected to the Mac, Parallels made it available to the Windows Virtual Machine. Once the drivers were installed it appeared in the Windows Device Manager without a problem. Once again WinPIC800 was used as software for flash programming but it also failed to recognize the hardware.
Microchip PICkit 2
Next on the test list was the PICkit 2 which is manufactured by Microchip, the maker of the PIC microcontrollers. The PICkit 2 is USB powered, ICSP compatible, and comes with a low-pin demo board that includes a PIC16F690 microcontroller.
In the same manner as the previous programmers it was available to the Windows virtual machine, but, at every attempt to connect the device a “Busy” message was obtained rendering it thus unusable via Parallels.
But, this was not the end of it. Jeffery L. Post has developed and maintains a free command line tool for Linux and Mac OS X called PK2 which after installing an additional USB library, was configured and worked seamlessly. It identified the correct device, read, programmed and erased the chip without a single complain.
The current version of PK2 only supports PICkit 2 with firmware update 1.21 or lower but a new version, that according to the author, will be available this spring, will be able to support PICkit 2 firmware updates 2.x and and with this a larger list of supported PICs.
Mikroelectronika Easy dsPIC 3
The Easy dsPIC 3 is a fabulous development kit for Microchip’s dsPIC30F family. The dsPIC chips are more powerful PICs with a feature set oriented towards Digital Signal Processing. One way to view it is that PICs are to Microprocessors what dsPICs are to DSPs.
As all the previous devices, as soon as the USB cable was connected to the Mac it was available in parallels to be connected to the Windows virtual machine. Once it was connected, the Flash Programmer software included with the development board recognized it and began reading the chip.
After several tries it was noticed that on average 1 out of 5 reads, and 2 out of 5 writes failed (behavior that of course was not seen on the PC). But it was a minor failure compared to previous programers that did not work at all using parallels. Also reading and writing was about an order of magnitude slower than when doing it on PC.
Conclusions
If you are into any serious PIC programming, as sad as it sounds, you should probably still avoid trowing over the window your Beige Box. The lack of any formal support for device programmers and the limited existence of programming IDEs makes it really tough to survive on Macs alone. Nevertheless if you are in for a try or a small-sized project I think the best path to follow is use your preferred IDE in the Windows virtual machine to generate you HEX file and then use PK2 to program a chip using PICkit 2 via the command line in Mac OS X.
If you find any better work around make sure you post it at http://www.macresearch.org to let those interested know.
















Comments
The same?
Would the same happen if you booted into Windows instead (through BootCamp)? I've understood it so that when booted into Windows the Mac will be a genuine Intel-based x86 PC, and hence would act and support like Windows would on a "normal" PC. Isn't this true?
Re: The same?
Yes, your understanding is correct. A Mac running Windows via Bootcamp is in fact Windows machine by any other name. There would be no difference between that machine (logically) relative to any Windows based PC that you would by. Of course I'd argue that it'd be superior in design and integration to most other solutions one could buy, but that's just my opinion.
Dave
Re: The same?
I don't dissgree at all. ;-) That's why I want a MacBook for school, but I need to know for sure that apps like WinPic800, MPLAB, MultiSim and other science apps like that will work. I'll get a chance to test it this weekend (borrowing a MacBook). I'll let you know how it works out.
Re: The same?
When Windows was installed there was no problem with WinPic800 or my USB Pic Burner. MPLAB, MikroC and other science apps were ok too. :-)
PICKIT 2 Problem fixed
The problem with the PICKIT 2 appears to have been fixed, at least with the configuration:
Windows XP Pro SP 2
Parallels Build 3188
OS X 10.4.9
PICKIT 2 V2.20
MPLAB IDE v7.52
Both MPLAB IDE and PICKIT 2 V2.20 talk to the device -- no "busy" problem.
Note: I set the "Connect USB device automatically" option in the USB tab of the Parallels virtual machine configuration and plug in the PICKIT *after* Windows has started up.
So PIC development is good to go under OS X. No reason not to buy that Mac now.