[GuySoft] sent in this project. He doesn’t normally mess with electronics, but decided to give it a try. He chose a fairly complicated project to be his first, but seems extremely comfortable with it. This project was to control his R/C car with a pic16f84. That chip was chosen simply because it was the only one available at local stores. Though we’ve seen much more complicated projects in the past, he does a great job of showing exactly what has been done. He shares his thoughts and source code with us as well. He has express a little frustration about the closed source compiler he was using, so if anyone has any suggestions for him, he would probably appreciate it. The funny part is that he mentions that people would just tell him to “get an AVR”. We think the readers here will probably be happy with how he pulled it off.
27 thoughts on “Controlling An R/C Car With A Pic16F84”
Definitely get an avr. I use a parallel port programmer that cost me nothing to make and use WinAVR and PonyProg for development. The only cost is the avr itself!
Very nice beginner project/hack!
That “get an AVR” attitude that’s appearing now is really weird – it’s like school, with all the ‘cool kids’ ganging up to put peer pressure on everyone else to conform. Get over it! Who cares if someone is using a technology other than the one you like? If it works for them, it’s fine.
I only took a brief look – but I saw that his one complaint with the open source compiler was that a delay_ms() function did not work for his chip.
I recall using some sort of plugin for piklab that was a sort of “Delay Calculator” which would generate the assembly for a desired delay. Dropping that inline with the C code could be one solution (although, busy loops are certainly not very elegant).
When I plan on needing some rough ms delays, I tend to set up a timer interrupt to occur once every ms, and increment a counter variable (or a couple if I’m on an 8-bit system — I never tend to have anything on long enough to overflow 32-bits).
I agree that the get an AVR campaign is strange. The only reason I use PICs are that I started on them so I have experience with them. Really, I think it’s good to foster a community that has diverse talents. At least the microchip C compiler is free for academic use (they don’t verify). I really want to start trying to use the NXP arm processors… embedded linux, woo!
I think I was misunderstood. I’m suggesting AVR’s for the difference in price. If PICs are cheaper for you, or you just like them better, more power to you.
Hey all, well, I am getting a bumble-b as said in the post. So I will update when that works.
Andrew, I am actually looking now for an IDE for Linux, that will be good as Piklab, for AVRs.
Eclipse is too heavy, and vim is too basic. I found something called konroller, but can’t test it yet. Also, why use an LPT, when I can use USB?
Man, you guys and all of your AVR’s and PIC’s…be a real man and get an FPGA.
If you want to kill a fly, a flyswatter is a good choice, a propene torch meaby is a little too much.
I’m surprised nobody has mentioned using an Arduino yet…
That’s certainly true, but I bet the propane torch is a lot more fun. Then you get a new project: fixing your house after it burns down :)
Who the heck even uses that chip anymore? Seriously, it has no peripheral features. A tiny2313 is cheaper and has a better tool chain.
If you must use an el cheapo programmer this is a link to and AVR version:
But… For $20 I got a usb programmer over at ladyada’s store called the USBtinyISP.
I will disagree that programmers for AVR any cheaper, actually from what I see they not those official from Atmel that can in circuit debug and support wide range of chips are much more expensive. For example there is nothing so universal and cheap as PICkit 2 for price of arduino (and even half of it if you student). So I dont really understand from where such argument started? Same goes for chips price, yes old ones as 16f84 are overpriced but Atmel discontinue their old chips at all instead rising their price. So arguments king of way outdated?
Aphous an arduino is an AVR nubtard.
one interesting thing is that the a pic10f can be bought for less than 50 cents…you can get three of them for the price of an attiny13.
I have a PIC dev kit (from http://www.mikroe.com) and I’m really happy with it, although the compiler and libraries source is closed, it’s Windows only and doesn’t run on Linux using WINE, which means I’m adding the cost of another Windows PC devoted only to MCU programming to the toolkit price.
For this and other reasons I’m considering to move someday in the future to the more open AVR platform when my dev kit and its supported processors will become obsolete, provided that the platform I’ll choose can be programmed and debugged without using Java. Don’t ask why, I just don’t want to mess with it.
AVRs are probably expected to replace PICs in the future, still, in some projects PICs seem to be a better choice than AVRs. Correct me if I’m wrong, but due to their internal difference you can build a 50 MHz frequency counter using a PIC and no external prescaler (http://www.sprut.de/electronic/pic/projekte/frequenz/freq.htm and a ton of other projects like that one) but apparently you can’t do the same with an AVR. Please don’t make a flame war out of this post, I’m genuinely interested in knowing if this can or cannot be done with AVRs, and why.
yeah this is a real comlicated project
I don’t know why people always use the PIC16F84.. as therian says it is way overpriced and can’t do anything.
I own a PICkit 2 and it is worth it’s $40 price tag. You can in circuit debug your code on most modern PIC’s and that’s a really useful feature. Programming speed is also very high, comparable to a bootloader. (on the 16-bit PIC’s there is in fact a programming executive installed, with which you get about 12kB/s programming speed)
And if you need a cheaper programmer there are of course many different parallel/serial port programmers on the net.
I personally hate the 10F, 12F and 16F series because of their instruction set, the fact that many of them have a banked SFR map and they have just one indirect addressing register is really limiting the power of these MCU’s when it comes to more complex applications. (and there is no reasonable free C-compiler available for them)
I mainly use the dsPIC33F series from microchip because they have a lot of power (40MIPS, DMA, DSP) for less than $10!
For simpler applications i recommend the 18F series because microchip offers a free C-compiler.
As for the compiler I just use the microchip C-compilers which are free for academic use and generally produce very optimized code. (the C-compilers for the 16-bit PIC’s are derived from gcc; although full optimatisation is only available in PRO-version, but for most applications the limited optimatisation (-O1) is sufficient and when I need more optimized code I just write it in assembler..)
I think the biggest problem of PIC’s is that microchip only supports Windows. As far as I know there is no comparable IDE to MPLAB (with integrated ICD and Emulator) for UNIX.
The command line compilers should work through wine though.
I’m assuming you’ve tried piklab. I haven’t used it in a while, and would be curious to hear where you think its shortcomings are. (i.e. why it’s not comparable to MPLAB)
I’d recommend the Microchip Pickit 2/3 or a clone, you can program, debug, use as USB UART, logic analizer, and can drive small circuits.
In the software part, you have different compilers to choose, for ASM you have the GNU tools, and for C you can use SDCC or PIC-GCC. There is also an arduino like enviroment called pinguino.
But I would recommend to take a look at JalV2+Jallib and use CodeBlocks as IDE, it’s AWESOME! (And very active community).
Please see my SDCC problem on the blog post! Note I also gave code in the comments.
Also, will CodeBlocks work with AVRs? Since piklab I use for PICs. I am looking for an AVR IDE.
As I said, that chip was the cheapest option here ($2), I guess because there is an old stack of it. I hope to update once I get the bumble-b. That’s the cheapest usb AVR+programmer I found.
“I don’t know why people always use the PIC16F84.. as therian says it is way overpriced and can’t do anything.”
The reason I fell into 16F84s first was that there are a couple of very cheap parallel-port programmers for them: The no-ppp (no-parts pic programmer) and one similar that came free (cct bd only) with the book “Programming and Customizing PICmicro Microcontrollers”.
This was before PicAxe and before Arduino – it was the easiest way I could find to get to programming ANY microcontroller without spending $200 plus on a programmer.
Unfortunate that the programmer could only program a tiny subset of the PIC microcontrollers, but it was better than nuthin’.
Also the series of Square 1 books like Easy PIC’n is written around them.
So there is a whole bunch of people who may not yet have moved on and up to the Arduino. :-D
If it works, it’s good.
Quit yer bitchin’
Most people use the PIC16F84 because up to about three or four years ago it was the most widely known low end PIC in the world, which translates into being cheap, easy available and covered on nearly all electronics magazines/sites. It is certainly obsolete now and overpriced to dicourage its use and probably also cash on those who buy it because they absolutely need it. A cheap substitute is the PIC16F628, which will need only minor code adjustment.
I didn’t know that it even supports ICD but I must admit that I haven’t tried it a lot because MPLAB gives me everything I need – and I have no problem using windows for developing.
that’s why i like hack a day.. thank you for the info. I’ll have a look at those tools.
I started with microcontrollers 4 years ago and with exactly the PIC16F628!
At that time it was the cheapest option I could find in getting started with microcontrolers in Switzerland.. well probably there were cheaper options but I was young and new to everything related with computers; I actually started programming in assembler for PIC MCU’s xD
Your delay routine might not work,because
you didnt put 2 4pico capacitors on the crystal, its stated in mictochips datasheet. Without the pic is very unstable. try it out
Please be kind and respectful to help make the comments section excellent. (Comment Policy)