Getting set up with PIC development - Page 1
Forum section: electronics / projects

author: dmlandrum
author_rank: Regular Contributor
timestamp: March 31, 2014, 11:11:36 pm
content: Hello! It's been a while since I posted here. I'm finally finding myself with some free time to pursue some projects, and I've always wanted to build myself some music synthesizers.I'm wanting to use PICs for this, since they're the only reasonably hobbyist-friendly MCU I can find that have 32-bit hardware timers available. Actually, 24 bits would be good enough for my application, but it seems my options are either 16 or 32 in this regard, so 32 it is. (Actually, about 20 bits would be good enough with the right clock speed, but now I'm just splitting hairs.)My question is, if I buy a picKIT 3, do I need to make sure I buy anything else? I'm talking about anything directly development related (other tools), rather than project parts. I've tried to find answers on their site, but I just end up closing the tab more confused than when I started.If anyone's curious about the application I have in mind, here's an article on DCOs:http://sequence15.blogspot.com/2008/02/analyzing-juno-106-dco-circuit.html-- Also includes an explanation on why 16-bits isn't quite enough, although I suppose I could use the same auto-ranging trick.Thanks for the help!EDIT: I tried to remove this post to repost to the Beginner's forum, but it won't let me.

author: dannyf
author_rank: Super Contributor
timestamp: March 31, 2014, 11:22:21 pm
content: A pickit2/3 will allow you to program the chip + cables / adapters if you so choose. You will need other software tools, like an IDE/compiler. But at a minimum, that's what you need.You don't need a 16/24/32-bit hardware timer: you can create that in software.

author: Pack34
author_rank: Frequent Contributor
timestamp: March 31, 2014, 11:33:30 pm
content: For PIC work, I have had good experience with MiktoElectronica's programmer and IDE.http://www.mikroe.com

author: dmlandrum
author_rank: Regular Contributor
timestamp: April 01, 2014, 12:19:17 am
content: Thanks for the replies.Sorry, I suppose I should've pointed out that I know I need a compiler. I've done chip development before, but not PICs, and I don't want to order a bunch of stuff only to find I missed an essential $2 part that I'll now have to pay $7.95 to have shipped.I actually just tried to make a single-voice DCO synth with my Arduino. It was a bit of a fool's errand. You really do need to have those precise hardware timers to make the idea work.The mikroC looks really good, but I can't afford $99 + $249 for the programmer plus IDE/compiler. Will the programmer work with any open source tool chains?Thanks again!

author: dannyf
author_rank: Super Contributor
timestamp: April 01, 2014, 12:22:42 am
content: QuoteYou certainly can make it work with AVR/Arduino which generally has better peripherals than the low-end PICs.

author: dmlandrum
author_rank: Regular Contributor
timestamp: April 01, 2014, 12:36:32 am
content: Oh, I'm looking at the much higher-end PICs for this. I found one with four 32-bit timers, plus four more 16-bit timers configurable for PWM. Perfect for what I have in mind, as well as some other projects.The Arduino has one 16-bit timer, so I could make a simple one-oscillator synth if I used the ranging trick mentioned in the article. I tried getting a little fancier than that and rolling my own timers, essentially, and quickly ran into timing precision problems. I could probably get it to work through trial and error, but I run out of patience too fast.I've been wanting an excuse to get into PICs anyway.

author: dannyf
author_rank: Super Contributor
timestamp: April 01, 2014, 12:39:59 am
content: QuoteA 8-bit timer is more than enough to do what you wanted to do.

author: dmlandrum
author_rank: Regular Contributor
timestamp: April 01, 2014, 12:50:03 am
content: How so? I did the numbers on this, and taking into account wanting to be able to slide pitches without any zipper noise, and wanting very precise tuning to be possible, running a much larger timer at a higher clock rate, while maybe a bit brute-force, does allow me to keep the system very straightforward.Any time you feed in number n, you get a cycle at a specific frequency. As stated in the article, a 16-bit timer at 1Mhz, the difference between n and n+1 was a pitch variation of .2 cents (a cent is 1/100th of a half-step on the piano) in the lowest ranges. In order to handle the higher ranges with similar accuracy, you need to change the timer frequency on the fly. What happens if you want to slide the note smoothly between ranges?The human ear is very sensitive to zipper noise (hearing discrete steps in a pitch that is sliding). 0.2 cents between n and n+1 is about the most that could be accepted.

author: PlainName
author_rank: Super Contributor
timestamp: April 01, 2014, 12:58:03 am
content: Whilst everyone else is trying to convince you to use something you don't want to...Which high end PIC did you have in mind? If it's a PIC32, Microchip do the MPLab IDE, which is free if you don't mind not having optimisation. PICKIT3 will be driven by that, so the total cost should be the programmer.

author: dannyf
author_rank: Super Contributor
timestamp: April 01, 2014, 01:02:12 am
content: Use the 8-bit timer to increment a counter. This allows you to construct a multi-byte counter out of an 8-bit counter.The minimum count would be around 20 ticks; the maximum count, assuming a 16-bit counter + 8-bit timer = 24 bits. You do the math.

author: dmlandrum
author_rank: Regular Contributor
timestamp: April 01, 2014, 01:08:11 am
content: Okay, this is my turn to facepalm, because I never bookmarked the chip I had found.I just remember those numbers. It was a PIC32, I do know that much. So I guess I get to go search for it again. It was capable of running at 50MHz, I think. That would be plenty fast to also implement a couple of LFO functions via DDS, even without the DSP extensions.I once implemented an audio rate (44.1kHz) DDS oscillator using a Freescale HCS12 dev board in C. It ran really well, and got me an A in the course and compliments from the professor and TA.@dannyf:Okay, I could do something like that and get one oscillator off of the Arduino. Indeed, I just might, since I'll need something to do before the PIC stuff gets delivered.Thanks, all!

author: dmlandrum
author_rank: Regular Contributor
timestamp: April 01, 2014, 01:27:59 am
content: @dunkemhigh:Okay, I might have misunderstood the spec sheet the first time. It looks like it's either/or on 16 vs 32 bit timers (they have to combine together). Still for my application, I only need two. I see some chips that support 16-bit PWM, but that would be for a different (also musically-related) project.The PIC32MX210F016B looks pretty good on cursory examination, but of course I'll look closer before deciding.

author: Pack34
author_rank: Frequent Contributor
timestamp: April 01, 2014, 01:33:54 am
content: Quote from: dmlandrum on April 01, 2014, 12:19:17 amYes, all you need is the hex file. Their programmer works for all PIC16/18, dsPIC, and PIC32 micros.

author: clickinggreen
author_rank: Newbie
timestamp: April 01, 2014, 02:01:00 am
content: Grab yourself a PIC24 (a bit cheaper - my preference) or a PIC32 device, a good development board (a google for "PIC24 develoment board" should do the trick) and then use Microchip's free development envioroment.- MPLAB X - their IDE (it's in java so works on Windows, Linux, Macs)- C24 compiler - PIC24 and dsPIC devices- C32 compiler - PIC32 devicesI presonally like the PIC24FJ64GB004 which has multiple 32-bit timers and comes with USB. Having said that there are heaps of good options out there!

author: PlainName
author_rank: Super Contributor
timestamp: April 01, 2014, 02:56:26 am
content: QuoteIt is not bad, but if that's your bag I think you would be better off going for the PIC32MX250F128B - same chip but more RAM and ROM. It's surprising how fast they can run out sometimes, and you can always bung a cheaper smaller version in once you've got your code running (if it will fit). The one-off cost isn't vastly different.

author: dmlandrum
author_rank: Regular Contributor
timestamp: April 01, 2014, 06:41:02 am
content: @clickinggreen:I completely spaced that I still need two PWM outputs over and above the 32bit timers. The integrating capacitor needs a varying voltage across it based on the frequency it's being discharged so the output waveform maintains a consistent amplitude throughout the frequency range.I just peeked at the PIC24 offerings and there are a few there that will work better.Although to be honest, I'm kinda reconsidering this project. Sure, I'd end up with a good synth, but it would still be one that sounds like everyone is used to. But whatever I come up with, I'm sure it will involve a PIC.

author: dannyf
author_rank: Super Contributor
timestamp: April 01, 2014, 10:48:42 am
content: QuoteThe PIC24 family tend to have better peripherals. Some in that family has 9 PWM modules with its own timerbase so you can use the timers for something else. Extremely handy.I would also suggest that you take a look at the STM32F or even the STM8 discovery boards. They come with programmer and a hardware debugger, multiple timers and at a substantially lower cost points than the PICs: PICKIT3 is $50 each, + chips vs. ~$10 for the STM discovery boards.

author: dmlandrum
author_rank: Regular Contributor
timestamp: April 01, 2014, 12:13:36 pm
content: You know, I ordered the Tiva some time ago because I wanted to play around with ARM and the DSP extensions. TI, however, made setting up a toolchain such a pain in the rear that I eventually gave up on it. If ST makes it easier to set up a toolchain, I'd certainly not mind trying to jump back into those waters.

author: dannyf
author_rank: Super Contributor
timestamp: April 01, 2014, 01:00:01 pm
content: The learning curve on the STM32 would be roughly the same as the learning curve on Tiva. So if you had troubles with Tiva, STM32 may not be for you.

author: dmlandrum
author_rank: Regular Contributor
timestamp: April 01, 2014, 02:42:16 pm
content: Oh, it's not learning to program the controller itself that's the problem. It's setting up the toolchain (editor, compiler, debugger) that I had trouble with, and it was all licensing trouble rather than installation.

author: dannyf
author_rank: Super Contributor
timestamp: April 01, 2014, 03:00:56 pm
content: I cannot speak for your experience. In my case, CCS was fairly simple to download, install and set-up. Marginally more involved if you decide to go with Keil / Iar + jtag - a few more clicks away.Fairly foolproof and tough to mess it up.If you lay out your specific issues, people can probably better help you. The TiVa chips have some of the richest peripherals among mcus. Definitely a better choice than the PICs.

author: dmlandrum
author_rank: Regular Contributor
timestamp: April 01, 2014, 03:18:18 pm
content: It's been a while since I revisited this. Let me get home (in a few hours) and I'll fire it all up and see where I'm at.Thanks for the help.

author: dmlandrum
author_rank: Regular Contributor
timestamp: April 01, 2014, 08:03:00 pm
content: Well, I got home and pulled up CCS again, and it's in the same state as before: it asks for a license file, asks if I want a 90-day extension, but appears to be happy to run anyway if I tell it no. It also doesn't recognize my Tiva, but itdoesrecognize my MSP430. Clearly I screwed something up in the install, even though I've followed that PDF at least three times, installing and uninstalling, trying to get this to work. I'm almost to the point where I need to nuke and pave my laptop.

author: dannyf
author_rank: Super Contributor
timestamp: April 01, 2014, 10:25:21 pm
content: Maybe uninstall it and re-download and reinstall it?

author: senso
author_rank: Frequent Contributor
timestamp: April 01, 2014, 10:55:35 pm
content: There is probably a lot of crap left over in the windows register after the first install.

author: dannyf
author_rank: Super Contributor
timestamp: April 01, 2014, 10:59:15 pm
content: Or maybe he downloaded a MSP430 only CCS.

author: dmlandrum
author_rank: Regular Contributor
timestamp: April 02, 2014, 11:27:04 am
content: The download I grabbed did say Tiva, but I suppose anything's possible.I've been thinking about doing a reload of my laptop anyway...