Microcontroller, FPGA or CPLD?

  • Thread starter Jdo300
  • Start date
  • #1
554
5
Hello All,

I'm still working on the ultimate programmable precision pulse control circuit for my experiments. Most of the stuff I have made so far has used discrete components and analog parts to do the job but I'm ready to start looking into some of the more advanced approaches.

As the title shows, I'm looking at microcontrollers, FPGAs and CPLDs. I don't know much about them beyond the general differences but I'm not sure which one would be best to learn to program first. So I thought I would ask you all here to get some opinions on this. Which type do you all think would be easiest to get into?

To give you an idea of my background, I have taken an intro class to Assembly programming, and computer architecture as well as other languages such as C++, VB, and Java.

God Bless,
Jason O
 

Answers and Replies

  • #2
159
0
fpga more complex, more power, fast, cost more too. Easy to modify as well. Some companies have graphical layout to help in programming (haven't done FPGA but check xilinx out, development kit cost a lot $$)

cpld i believe has faster processing, easy to modify too. Cost maybe about the same or little more than microcontroller depending on I/O's. Uses VHDL language (eg: atmel that has really cheap development kit starting maybe $50)

microcontroller is less complex (once you have the base code made), cheap and less power (if you went with UART). If you go to like USB microcontroller it cost a bit but then has more capability. Can be program in C, C++, Assembly)

I guess it depends on your application. If you want something portable, cost less and doesn't need the processing complexity (like doing audio/video streaming, data transfer etc) an 8051 controller will work well just to toggle bits, DAC, A/D, I2C, SPI to control other device.
 
  • #3
berkeman
Mentor
60,384
10,679
Here is a brief intro to programmable logic (CPLDs and FPGAs):

http://www.handasarabia.org/mambo/index.php?option=com_docman&task=doc_download&gid=12&lang=Ar

You can download a copy of the Altera CPLD design software "Quartus II" from Altera's website:

https://www.altera.com/support/software/download/sof-download_center.html

You need to register first with Altera, I think, but I believe that the download is free.

You can download a copy of Xilinx's excellent FPGA design software suite "ISE WebPack" from Xilinx's website:

http://www.xilinx.com/products/design_resources/design_tool/index.htm [Broken]

And for your first uC programming experiments, I'd recommend getting or building a simple PIC evaluation board, and programming it in C or assembly.

Learning all of these tools is very important for EEs. Depending on what kind of work you do, you will probably use each of them on pretty much a daily basis in one way or another. BTW, Verilog is used in the Silicon Valley for writing CPLD and FPGA code, but I believe VHDL is mostly used elsewhere.
 
Last edited by a moderator:
  • #4
chroot
Staff Emeritus
Science Advisor
Gold Member
10,239
39
If you're already familiar with C programming, you'll find the microcontrollers to have the easiest learning curve. They will not be capable of any truly "precise" pulse generation, though. The best precision you'll be able to get is some multiple of their clock period.

FPGAs and CPLDs are much, much more flexible. You can program both using schematics, but you might find it more useful to learn a hardware description language like Verilog. (Stay away from VHDL, it's a horrible language and virtually no one in industry uses it.) The learning curve can be pretty steep. FPGAs and CPLDs will both involve significantly higher start-up costs than microcontrollers. The benefit? They're so flexible that you can probably get virtually any timing you want out of them, particularly if you use FPGAs which have built-in digital PLLs. They're not going to have fabulous jitter performance, but you'll be able to get performance and flexibility close to that of an ASIC for many applications.

- Warren
 
  • #5
berkeman
Mentor
60,384
10,679
(Stay away from VHDL, it's a horrible language and virtually no one in industry uses it.) The learning curve can be pretty steep.

Hey chroot, Do you have any good learning resources you could recommend for Verilog? I've only used it a little, and I learned that from the digital hotshots that I work with. When I asked them for a good book recommendation, they just laughed and said that there aren't any. There are books, but none that are good to learn from. Do you have any suggestions, especially ones that include discussions of the RTL subset of Verilog? Thanks.
 
Last edited:
  • #6
chroot
Staff Emeritus
Science Advisor
Gold Member
10,239
39
The classic book is Palnitkar:

https://www.amazon.com/dp/0130449113/?tag=pfamazon01-20

It serves as a thorough reference, and has a reasonably good pedagogical approach.

The reason why your coworkers laugh is because Verilog, like C and many other "programming" languages, has some gotchas. Understanding the syntax is not enough to be able to write code that will synthesize to small, fast logic. There are often four or five ways to code any specific task, and there can be differences in speed or size of the resulting logic of almost orders of magnitude.

I recommend reading papers by Sutherland to get more of the "design sense" of how to properly use Verilog.

http://www.sutherland-hdl.com/on-line_ref_guide/vlog_ref_top.html

- Warren
 
Last edited by a moderator:
  • #7
berkeman
Mentor
60,384
10,679
The classic book is Palnitkar:

https://www.amazon.com/dp/0130449113/?tag=pfamazon01-20

It serves as a thorough reference, and has a reasonably good pedagogical approach.

The reason why your coworkers laugh is because Verilog, like C and many other "programming" languages, has some gotchas. Understanding the syntax is not enough to be able to write code that will synthesize to small, fast logic. There are often four or five ways to code any specific task, and there can be differences in speed or size of the resulting logic of almost orders of magnitude.

I recommend reading papers by Sutherland to get more of the "design sense" of how to properly use Verilog.

http://www.sutherland-hdl.com/on-line_ref_guide/vlog_ref_top.html

- Warren

Great stuff, chroot. Thanks for the links.
 
Last edited by a moderator:
  • #8
554
5
Hey Guys,

Thanks for all the great links and recomendations :-). It looks like the FPGA approach is where I might head. I don't have a startup kit but I will at least familiarize myself with some of the programming stuff so that I can use it when I finally do get a development kit. Thank you all!

- Jason O
 
  • #10
554
5
Hello Again,

Just a quick question. Does anyone know of any good FPGA development kits for a newbie like me? I heard of someone using a Spartan kit but does anyone here have any recommendations?

Thanks,
Jason O
 
  • #11
chroot
Staff Emeritus
Science Advisor
Gold Member
10,239
39
Hey Jdo300,

asic-world.com is a good site. It's more a reference than a tutorial though. You will learn the syntax and basic composition of the language there, but you won't learn the minutia of how to make your resulting design fast and small. To my knowledge, there really is no comprehensive book on writing tight Verilog.

- Warren
 
  • #12
6
0
Ultra precise can mean a lot of different things, first thing you need to specify is how precise. How long are the pulses you are trying to make? What type of precision do you need? Also it is nice to know what type of budget, how much time you have to do your project?
 
  • #13
554
5
Hi Odin42,

When I say high precision, I'm looking at the frequency resolution that I need. The primary range I'm working in is from 1 Hz to 1 MHz although it would be nice if I could go up to the 20 MHz range (I know that's asking a lot). The pulse width I'd like to have would be somewhere from 10 ns and up. In a perfect world, I would be nice to have a frequency resolution of at least 0.1 Hz. for most of the range. The FPGA has to have a fast enough clock to give me the ability to do phase shifting between the output pulses with 15 degree resolution between channels. (there would be three channels of pulse output).

Thanks,
Jason O
 
Last edited:
  • #14
chroot
Staff Emeritus
Science Advisor
Gold Member
10,239
39
You want to generate a square wave, over a range of frequencies from 1 Hz to 20 MHz, with a frequency resolution of something like 0.1 Hz? You're not going to be able to do this with anything but an FPGA. I would look into numerically controlled oscillators (NCOs), which are simple designs which can "play back" a pattern stored in memory at any speed you like. They also give you excellent phase resolution, and are trivially easy to change phases.

The only problem I see is that you're going to have quite a bit of jitter if use an NCO to generate a square wave. The normal procedure to use an NCO is to follow it with some kind of analog smoothing filter, but that won't be an option for a square wave.

Honestly, why on earth are you attempting to create something like this with digital components anyway? Now that we understand your needs better, I would really suggest that you just use an analog frequency synthesizer chip (ADI makes some). If you need to control it digitally, use a microcontroller or some digitally-controlled potentiometers.

- Warren
 
  • #15
554
5
Hi Warren,

Thanks for the tips. I've never even heard of an analog frequency synthesizer. What kind of frequency range can these things have? I would love to learn more about these. especially if they can by synchronized together and phase shifted with respect to each other. That is honestly all I need to do. The only reason I'm having so much trouble is to find a setup that will work well up into the higher frequencies. If you know of any chips that may be suitable for my purposes, I would be very happy too look into it.

Thanks,
Jason O
 
Last edited:
  • #16
chroot
Staff Emeritus
Science Advisor
Gold Member
10,239
39
Digital frequency synthesis didn't even exist until just recently!

Look into chips like this one:

http://www.analog.com/en/prod/0,2877,1073%255F850%255FADF4002,00.html [Broken]

$5 a piece at DigiKey. There are all kinds of ways you could connect two together.

- Warren
 
Last edited by a moderator:
  • #17
554
5
Thanks for the reference. I"m going to definitely look into this one. BTW, do you know of any of these chips that come in a through hole package?
 
  • #18
chroot
Staff Emeritus
Science Advisor
Gold Member
10,239
39
Sorry, I don't really keep track of packages of the products I help design, much less those sold by other companies! Besides, I'd say only 10% of the parts sold today come in packages that are easy to solder. I don't really know what to tell you to do with a tiny SMT package. :frown:

- Warren
 
  • #19
554
5
It's ok Warren Thanks for you help with this.

@Everyone,

I'm still going to see about learning to program an FPGA and I was wondering if anyone here knows of any physically small development boards for under $100. It doesn't need to be fancy; I just need the bare minimum, which would be the FPGA, programming port, memory to hold the program, and some IO pins. In a perfict world, I would like to get a development board that is around 3" x 3" to fit inside of the coil that I'll be experimenting with. Im playing around with high speed rotating magnetic fields so the board would need to sit in the middle of the field where the 'dead zone' is to avoid relativistic effects from running wires to the coil from the outside (yeah I know it sounds weird). Any suggestions?

Thanks,
Jason O
 
  • #20
554
5
Ok, have been doing some more reading to figure out how to actually make the FPGA generate the frequencies I need. Apparently, I have to implement some different fractional division techniques to even get decently frequency resolution out of it.

Now that I think about it, I'm beginning to sway back to the Analog frequency synthesis idea again. The other good thing is that I actually have two 68HC12 microcontrollers that I got from school (for free) that I could use to program the frequency chips. But I'm wondering if anyone here may know of any good resources out there to aid me in doing this. I have pretty much no experience in this area. I am now looking at some tutorials to see how to program the microcontroller, which as someone pointed out earlier, will be much less painful since I already have some experience programming in C and assembly. My only question at this point is figuring out how to sync up the three AFS chips.

Thanks,
Jason O
 
  • #21
berkeman
Mentor
60,384
10,679
BTW, do you know of any of these chips that come in a through hole package?

If it helps, you can buy little "Surf Boards" adapter boardlets to convert tiny SMT parts to through-hole parts. I don't know if there is one available for the SMT package that you are looking at, though. I use them often for fine-pitch TQFPs and such, if I'm just making a quick one-off prototype or fixture in the Lab.

Kind of like these: http://www.capitaladvanced.com/

I get them at a small hole-in-the-wall electronics shop in Sunnyvale, Anchor Electronics.
 
  • #22
chroot
Staff Emeritus
Science Advisor
Gold Member
10,239
39
Ok, have been doing some more reading to figure out how to actually make the FPGA generate the frequencies I need. Apparently, I have to implement some different fractional division techniques to even get decently frequency resolution out of it.

The proper design of an NCO doesn't use any kind of floating-point math, just integer math.

Let's imagine that you have a waveform stored in a memory as a thousand discrete samples. To play the waveform back, you step through the array in some kind of a loop.

If you simply keep track of an index into the memory, though, you'll only have a thousand choices. That means your phase resolution is only 1:1,000. This is not good enough for many applications.

Now, imagine subdiving each of your samples a thousand times more. Instead of a thousand indices, now you have a million. The first thousand indices all correspond to the first sample, while the second thousand indices all correspond to the second sample, etc. Your counter needs to run to a million now, instead of a thousand. To translate an index into a memory location, you just lop off the least significant bits.

At the expense of a few more flip-flops in your counter, you now have a phase resolution of 1:1,000,000. This is the basic concept of an NCO.

Now that I think about it, I'm beginning to sway back to the Analog frequency synthesis idea again.

Honestly -- and I mean no offense -- it would be stupid to do this in digital electronics, unless you're doing it for a learning experience. There is absolutely no reason why any practicing engineer would attempt to do this in digital, when it's a $5 solved problem in analog.

The other good thing is that I actually have two 68HC12 microcontrollers that I got from school (for free) that I could use to program the frequency chips. But I'm wondering if anyone here may know of any good resources out there to aid me in doing this. I have pretty much no experience in this area. I am now looking at some tutorials to see how to program the microcontroller, which as someone pointed out earlier, will be much less painful since I already have some experience programming in C and assembly. My only question at this point is figuring out how to sync up the three AFS chips.

You'll need the following things:

1) A C compiler, like gcc, which can cross-compile to the 68HC12.
2) A flash memory device (if your 68HC12 does not include flash -- I don't know and don't care to look it up).
3) A programmer capable of reprogramming your flash memory.

- Warren
 
  • #23
554
5
Hello All,

I think I found what I believe to be the Rolls-Royce of DDS iCs. The AD9959. This thing has four channels of DDS output and can use up to a 500MHz crystal. Here's some of the features from the datasheet:

FEATURES
  • 4 synchronized DDS channels @ 500 MSPS
  • Independent frequency/phase/amplitude control between channels
  • Matched latencies for frequency/phase/amplitude changes
  • Excellent channel-to-channel isolation (>65 dB)
  • Linear frequency/phase/amplitude sweeping capability
  • Up to 16 levels of frequency/phase/amplitude modulation (pin-selectable)
  • 4 integrated 10-bit D/A converters (DACs)
  • Individually programmable DAC full-scale currents
  • 32-bit frequency tuning resolution
  • 14-bit phase offset resolution
  • 10-bit output amplitude scaling resolution
  • Serial I/O Port (SPI) with enhanced data throughput
Here's the link to the datasheet:
http://www.analog.com/UploadedFiles/Data_Sheets/210775240AD9959_0.pdf [Broken]

The only problem with this is that the IC comes in a CP-56 package which would be incredibly horrible to solder! However! I have found a solution which will make it extremely easy to do it!

Check out this PDF file here:
http://www.schmartboard.com/schmartboard_dc_ez_instructions.pdf [Broken]

Here is the board I can order which will fit the IC:
http://www.schmartboard.com/index.asp?page=products_qfp&id=70 [Broken]

Problem solved!

(By thw way, could you take a look at the AD9969 and let me know what you think :smile:)

Thanks,
Jason O
 
Last edited by a moderator:
  • #24
554
5
Hello Again,

I'm now reading up more on how to program my HC12 board and along the way, I came across lots of tutorials that dealt wth programming small PIC IC's. They appear to be MUCH simpler than the complicated HC12 that I am looking into. Considering that all I want to do is program the AD9959, I'm beginning to think that the HC12 might be waay overkill for what I want to do. What do you all think? Are there any PICs out there that are optimized for IO operations? I see that there are many different ones out there.

Thanks,
Jason O
 
  • #25
chroot
Staff Emeritus
Science Advisor
Gold Member
10,239
39
PICs are indeed much easier to program. Are you trying to program the device through your computer, or what? You're really not giving us enough information to be able to help you. I don't really understand what you're trying to do, or what obstacles you are facing.

- Warren
 

Related Threads on Microcontroller, FPGA or CPLD?

  • Last Post
Replies
17
Views
2K
  • Last Post
Replies
16
Views
7K
  • Last Post
Replies
13
Views
4K
  • Last Post
Replies
10
Views
3K
  • Last Post
Replies
5
Views
3K
  • Last Post
Replies
11
Views
10K
  • Last Post
Replies
1
Views
5K
  • Last Post
Replies
3
Views
888
R
Replies
5
Views
2K
  • Last Post
Replies
5
Views
1K
Top