Building a DC power supply using FPGA voltage control? - Page 1
Forum section: electronics / projects

author: Sypher
author_rank: Contributor
timestamp: October 06, 2012, 03:46:47 pm
content: I was wondering how difficult it would be to create a DC power supply like in Dave's 5 part series, except using an FPGA for the voltage control. This would serve as 2 different projects (my EE and VHDL/FPGA class), hence I would like to combined them.Can anyone offer any advice? How difficult would it be vs using a micro controller? I have no experience with FPGA's yet, but I'm enrolled in a VHDL class. Any thoughts would be appreciated.Go for it or bail?

author: TerminalJack505
author_rank: Super Contributor
timestamp: October 06, 2012, 11:26:21 pm
content: Personally, I'd say that would be a fairly challenging VHDL project. You'll be able to find a lot of reference code out there for driving the LCD, SPI, I2C, etc., though, so it might be something you can do in a semester. You can always use a soft core as well, although that really just turns your FPGA project into a microcontroller project. (Unless you're the one that writes the soft core.)

author: joelby
author_rank: Frequent Contributor
timestamp: October 07, 2012, 12:56:46 am
content: None of the bits alone would be too difficult, but it might take you 20 times longer to finish than it would have taken with a microcontroller unless you are already experienced with FPGAs.As an example, to write to an SPI device using a microcontroller involves just a couple of lines of C code to set the controller's parameters and then start reading and writing data. You could use a freely available SPI IP core, but some classes might not let you use any code that you didn't write yourself, and often the free code is terrible, undocumented, or has limitations that take you a while to understand and work around.A soft core would make things a lot easier, though even these suffer from insufficient documentation (open source) or complicated toolchains (FPGA vendor supplied), and they are often quite bare-bones and don't have the sorts of built-in peripherals that microcontrollers bundle these days.

author: hans
author_rank: Super Contributor
timestamp: October 07, 2012, 12:49:17 pm
content: The beautiful thing of FPGA's is that they can process things in parallel very good. For e.g. you could make a 'power regulator' module (that maybe controls D/A and A/D to control CV and CC modes - for example, but I recommend having the control loop in analog design). You could reuse this module very easy like 4 times, given that you have the required external components and design hierarchy right.But, interfacing with IC's or doing things like menu's is not very easy. I've never handled strings in FPGA's. I've done sequential actions using a series of state machines, which is probably your friend in VHDL. Like if you want to control a multi channel DAC via I2C, you probably need (well this is how I did it):1) I2C layer - these are around on opencores and other IP cores site. Easy, right.. Well, some of them are kinda buggy, so prepare for a lot of slow debugging. (my project took 18minutes of compile time - so 1 little code line change, adding a on-chip debugger, makes for a long waiting game..)2) DAC Register layer - Something that thinks what data needs to be written to execute a command. Like you need the address, register ID and then data (maybe 2 data bytes?)3) DAC Control layer - the layer that actually determines which registers are need to be written.4) Something that 'starts' layer 3. (Menu controller, processor, etc.)In the end you can turn a FPGA into a 'microcontroller' with custom peripherals (like you could also just write the VHDL so an external DAC is treated like an 'integrated' DAC for your C program). I've done this with NIOS processor before, using Avalon busses etc. Problem is; the processor is not free. The trail version stops working if you disconnect the debugger I believe (I was using a licensed one at graduation company).Ofcourse there are alternatives, but I have no experience with them.If you get the basics down with writing VHDL code, designing some simple systems , then it mustn't be hard to go further with this. Given that you have a good overview on to split your design into building blocks.

author: nctnico
author_rank: Super Contributor
timestamp: October 07, 2012, 01:08:00 pm
content: Quote from: joelby on October 07, 2012, 12:56:46 amXilinx has a small softcore called Picoblaze (aka KCPSM) which is very simple to program (assembly) and easy to use. I have used it for several signal processing projects. The beauty of an FPGA is that you can have several of these running in parallel at a high frequency so it would allow for fast control loops.With these kind of projects it is a good idea to calculate safe limits for PWM and/or DAC settings. So when the software computes a wrong value you can limit the output value so a safe value.

author: ptricks
author_rank: Frequent Contributor
timestamp: October 07, 2012, 03:10:05 pm
content: One other issue with FPGA is the voltage levels. FPGA require different supply voltages, often it is multiple supplies, so you would have to add 1.8V and 3.3V , sometimes 2.5V , supplies just for the FPGA to run. The other issue is the interface pins cannot tolerate anything above 3.3V, anything more and you ruined your FPGA, that means having to use level converters for any chips connected to it that doesn't have 3.3V logic. You also will need to add an eeprom for the FPGA to load the program information from on startup. Then there is the cost, for the cost a FPGA amd support circuitry you could buy all the parts in the original design and have change to spare.

author: Baliszoft
author_rank: Frequent Contributor
timestamp: October 07, 2012, 03:57:22 pm
content: Microchip has some pics dedicated to smps applications (with adc up to 2msps), maybe one of these could be used to regulate a bench psu.

author: Sypher
author_rank: Contributor
timestamp: October 08, 2012, 03:10:00 pm
content: Thanks for all the replies, any advice on where to start or how to go about the FPGA implementation?

author: gxti
author_rank: Frequent Contributor
timestamp: October 08, 2012, 03:32:15 pm
content: There's lots of good advice in the thread already. If you still don't even know what direction you're headed in, time to consider a simpler project.

author: mrflibble
author_rank: Super Contributor
timestamp: October 11, 2012, 03:28:22 pm
content: An fpga is not the most obvious match for this sort of project. Your typical mcu however has i2c, spi, dac and adc conveniently built in. Not top mention that writing a bit of C is a lot less work than getting the same functionality in vhdl/verilog. And yes yes softcores. Softcores are nice, but if this is the first fpga exposure ever ... you can bet that getting used to the toolchain + added to that how-the-hell-does-this-microblazed-nios2-thingy-work is going to take up some time.So if you haven't already started I'd say go the mcu route for this project.And if you did already start, ditch it now and restart with an mcu. ;-) Because given the non-match of tool vs project I suspect that progress is sloooow. Unless you are superdoubleplus awesome of course, in which case by all means continue and I wish you the best with your superdoubleplus awesomeness. (also, where do I get me some of that, because for me on fpga it would definitely take a lot more effort than on mcu).