I had used Hitec PICC in the past to write programs for my projects that used the 16F series microcontrollers, but I had not tried the 18F series because I had nothing to compile C code with for it. I had received a few of these from Microchip as engineering samples back in my community college days and they were still sitting in the anti static box that they had arrived in from ten years earlier, driving me nuts because they were just there, not been used and seemingly abandoned. I suppose it is like anyone who gets excited when a new version of a computer game is released. It was such a shame that these were there and although I had the best of intentions I was always too busy with something else. Sometimes some of the better things in life are free. But I just needed a free compiler for the 18 series. Enter the XC8 compiler from Microchip. MPLAB had always been free from what I understand but back in community college all we had was assembly language and I did not like that. I could use it but why make something harder than it needed to be? Once I found out that there was a free version I could finally put those 18F PICs to use.
Years ago I had built a programmer for the mid range 16F series and started to install bootloaders to make it easier to work with. A bootloader is a small program that is initially written into a microcontrollers flash memory where your application program is stored and is the first bit of code to execute upon power up. What this program does is wait a few milliseconds to see if you are uploading a new program and if so, write it all to memory and if not then launch into the pre existing program. The nice thing about using a bootloader is when you make changes to your program and need to upload it to the chip, you simply upload the program through a serial connection with the microcontroller in circuit instead of having to remove the chip and put it into a dedicated programmer.
There is a process I had to go through to get a bootloader installed which meant having to program the chip the traditional way to initially install the bootloader. You have to pick the clock speed that you will be using, compile the bootloader and then install it. After that it is quite simple to make code changes. Quite possibly the bootloader was a big reason why the Arduino became so popular recently.
I have not done much work with MPLAB and XC8 but it seemed to work very well together. There was a small project I wanted to develop that used bluetooth to control a remote relay board for my workshop server and equipment. I wanted the capability of being able to remotely reset the Linux computer, remove power if needed and cycle the router that is out there. It’s a redundant circuit because that old Linux computer is rock solid reliable, is up and running for months and only ever is rebooted for whatever reason. I also wanted to learn from a coding perspective how to become interactive, as in there is two way communication happening within the application and me the user. I should be able to press an assigned key on the keyboard and the microcontroller should select whichever corresponding relay to act on and then display the resulting status on screen, then wait for the next user input. In the past all my projects had sent data to me to be displayed on the screen but I had not learned how to send to or how the microcontroller would process my input. I prototyped a circuit together on strip board and ordered a four channel relay card. When I was researching the components it was cheaper to buy a card with four relays prebuilt than it was to buy the individual parts and make one myself. To cut a long story short the project worked. I could connect via bluetooth wireless with my smartphone to the bt card on the serial port of the microcontroller and could switch whichever relay on or off as planned. What happened after this was summer came along and what spare time I had left was spent with the bike.