Microcontroller, FPGA, or CPLD for Precision Pulse Control?

In summary, Jason is considering microcontrollers, FPGAs, and CPLDs for his project. He doesn't know much about them,
  • #1
Jdo300
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
 
Engineering news on Phys.org
  • #2
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
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

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
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
chroot said:
(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
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
chroot said:
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
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
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
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
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
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
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
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
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

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

- Warren
 
Last edited by a moderator:
  • #17
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
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
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. I am 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
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
Jdo300 said:
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
Jdo300 said:
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
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

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

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

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
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
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
 
  • #26
Hi Warren,

Ok, here is what I ultimately want to do. The goal is to produce a PC programmable 3-channel function generator that can put out short pulses of variable width. The phase shift and frequency both have to be programmable from a program on a PC. The output pulses would be fed to line drivers like the mic4427 or a UCC27321P.

Also later on, I want to incorporate the ability to take voltage measurements (like a data logger) but I’m not too concerned with that right now since I could use an external programmable DMM to do that.

The microcontroller that I need would not really have to do any processing on its on. Its job would mainly be to communicate the frequency, phase shift, and amplitude settings from my PC program to the four channels of the AD9959 IC. I would simply come up with a basic command set that I can send the microcontroller from my PC using the serial port, which I will program using the MSCOMM control in Visual Basic.

I heard that there are a number of options for programming the micro; anywhere from assembly to C, to Basic. I don’t mind programming the thing directly in assembly but I figured that it may be easier to do it in C or basic since I’m only swapping data through registers and not doing any real processing.

As for some constraints, I would be doing all I can do with the AD9959, so I would get the 500MHz crystal to run the IC so I can generate output frequencies up to 100MHz. Since the output would drive a logic gate to make the pulses, I’m not too concerned about how pretty the sine wave output looks but I will have an option to have the IC output sine waves for lower frequencies where the sine waveform looks nicer (like 50MHz and below).

So the microcontroller would have to be able to handle the 32-bit frequency input for all four channels, as well as the 14-bit phase shift input and the 10-but amplitude input. Since the AD9959 supports serial input, I would most likely go serial so I won’t need to have a ton of I/O pins on the PIC.

That’s all I can think of for now. Thank you very much for your guidance on this :smile:.

- Jason O
 
Last edited:
  • #27
You might be able to just use your parallel port and an RS-232 reciever to control the digital inputs on your AD9959 directly; no need to program a microcontroller at all.

- Warren
 
  • #28
WOW that would be simple... I don't know much about serial communications (from the hardware end) so I'm trying to read up more on it. From what I can tell from reading the datasheet on the AD9959, the serial data can be input into the chip asynchronously which I guess is a good thing :smile:. Would I need any other special chips to do this? I remember seeing a lot of references to the MAX232 chip which is supposed to be an RS232 receiver.

- Jason O
 
  • #29
Sorry, I goofed up my previous post. I meant to say "your parallel port or a serial port and an RS-232 receiver".

The MAX232 is a perfectly fine RS-232 receiver, as far as I know. You might be able to wire the MAX232 directly to the AD9959, but I admittedly have not read the datasheets of either device.

Serial port communication is dirt simple on the PC, by the way. If you can go the serial port route, I would definitely use it.

- Warren
 
  • #30
HI Warren,

The more I read about this the more I like it. for the PC end, I will DEFINITELY be using the serial port to program out from. As for communications with the AD9959, apparently it uses an SPI interface to communicate through so I found this other nifty chip, MAX3110E, which is supposed to convert the RS232 signals into the SPI ones. Now I'm just trying to figure out how to set this all up so I can select which one of the four channels on the AD9959 to program and then out of those four channels, which of the three inputs to program (frequency, phase shift, and amplitude). It all seems simple enough and maybe I can implement it with some multiplexers and shift registers or something? I'm trying to read more on the SPI and RS232 interfaces to figure out how to even start setting this up. But whatever the ultimate solution, it will definitely be simpler then programming a microcontroller to do the job. Maybe I need to make up some kind of primitive command setup to tell the circuit how to route the bits??

- Jason O
 
  • #31
I'm studying the datasheet for the IC now. It looks like they actually implements some kind of serial command structure for this IC (Man it's practically a microcontroller on it's on). Here's a link to the datasheet. The I/O info starts on page 30:

http://www.ortodoxism.ro/datasheets2/2/049iw670xf1p0dyxsaoplk09ss3y.pdf

Man this just keeps getting better :smile: I'm glad I didn't add a microcontroller to control the microcontroller :redface:

- Jason O
 
Last edited:

FAQ: Microcontroller, FPGA, or CPLD for Precision Pulse Control?

What is the difference between a microcontroller, FPGA, and CPLD?

A microcontroller is a small computer on a single integrated circuit that is designed for specific tasks, such as controlling electronic devices. An FPGA (Field-Programmable Gate Array) is an integrated circuit that can be programmed after manufacturing to perform specific tasks, making it highly customizable. A CPLD (Complex Programmable Logic Device) is a type of programmable logic device that is smaller and less complex than an FPGA, but still offers some customization options.

What are the main applications of microcontrollers, FPGAs, and CPLDs?

Microcontrollers are commonly used in embedded systems, such as in consumer electronics, automotive systems, and industrial control systems. FPGAs are often used in digital signal processing, high-performance computing, and in prototyping and testing of electronic designs. CPLDs are typically used in simpler applications, such as in consumer electronics and industrial control systems.

How do I choose between a microcontroller, FPGA, or CPLD for my project?

The choice between a microcontroller, FPGA, or CPLD depends on the specific requirements of your project. If you need a low-cost, low-power solution for a simple task, a microcontroller may be the best option. If you need high performance and flexibility, an FPGA may be more suitable. A CPLD may be a good choice for simpler applications where cost and power consumption are important factors.

What are the advantages and disadvantages of using a microcontroller, FPGA, or CPLD?

Microcontrollers are cost-effective, low-power, and easy to use, but they have limited processing power and are not as customizable as FPGAs or CPLDs. FPGAs offer high performance and flexibility, but they are more expensive and consume more power than microcontrollers. CPLDs are smaller and less complex than FPGAs, but they have limited customization options compared to FPGAs.

How do I program a microcontroller, FPGA, or CPLD?

Microcontrollers are typically programmed using a programming language, such as C or assembly, and a compiler. FPGAs and CPLDs are programmed using a hardware description language (HDL), such as Verilog or VHDL, and a synthesis tool. Some FPGAs and CPLDs also have graphical programming interfaces available. In all cases, the programming process involves writing code or designing a circuit, compiling or synthesizing it, and then programming it onto the device using a programmer or development board.

Similar threads

Replies
10
Views
2K
Replies
3
Views
2K
Replies
2
Views
2K
Replies
17
Views
24K
Replies
11
Views
7K
Replies
7
Views
4K
Replies
3
Views
2K
Replies
5
Views
3K
Back
Top