Project Feasibility


privitmj

Recommended Posts

Hello,

 

    I am another newbie to the FPGA world. I stumbled across the Papilio Pro in Make magazine 36 as I was trying to determine which type of microcontroller I wanted to use for the project that I'm about to describe. I have been tasked to create a relay panel that will configure different rocket engine valves. Each engine has multiple valves with multiple valve coil configurations. For example, some need 4 coils in series or 2 sets of coils in series which are then paralleled etc. I have come up with a fairly accurate relay count of around 60. I'd like to also create a GUI for a windows based PC so that the operator can select a pre-programmed engine type or valve configuration and then in turn have the PC send the signal to the FPGA which in turn will be able to close which ever necessary relays that are required for that config. I have some microcontroller experience from college and I also own an Arduino, would I be better off using one of these? I like the idea of FPGAs and I always wanted to learn VHDL programming... In general, what are some advantages of using FPGAs over a microcontroller? And is it easy to interface with a FPGA through a GUI?

 

Thanks in advance for the help,

 

 

Mike

Link to comment
Share on other sites

Hi! Sounds like an impressive project

 

Although it is more common to use a PLC, FPGAs are sometimes used in this sort of environment - the security system in my company's data center is based around a Spartan 3E, to agrigate all the inputs and output. I assume it then interfaces back to a microcontroller / embedded PC of some sort.

 

It all depends on how much intelligence you need in the controller - do you want the PC to be in control of the timing, or do you want the equivilent of scripts running in the embedded platform?

 

One of the beauties of FPGA is that the hardware can be developed largely independantly of the PCB - you could take the Papilio One's schematic then lay it out however you like for your board then have it manufactured. While that is going on you could be testing your design on a breadboard with LEDs and buttons, while you wait for your PCB to come back.

 

One thing to be vary careful of is the pin states during powerup and programming - you want to have all your relays fail safe, have the FPGA control switching the PSU that supplies relay coil power on using a couple of pins that need to be in different states (e.g. external logic that computes "coil_power_on <= pin0 and not pin1").

 

It you don't do it this way then during FPGA configuraiton strange things can/willl happen, as pins can be pulled high or low during the configuration / reset process. 

Link to comment
Share on other sites

Thanks for the reply ham.

 

I'd like to use the PC simply to have the GUI capabilities. We typically use a lot of latching button/relay panels here and I was trying to think outside the box on this one i.e use a windows based GUI instead of the mechanical button panel option. The technician will select the proper configuration and hit a confirmation button which invokes the PC to send the proper code to the FPGA which will interpret said code and active/latch the proper relays. Does this make sense?

 

I guess I'm not sure what would be in control of timing for this... I would assume have the FPGA be in control of the timing? Does it matter? I'm an electronics guy, but my MCU/FPGA experience is quite limited (sad panda).

 

I've read a lot about FPGAs in the last couple of days and I see a lot about companies/people using them just for prototyping. Do these have a permanent use just as a MCU has - after programming it, you can install it into a circuit and its good to go for years and years....

 

I'm basically unsure if a FPGA will even work for my application, and I'm especially unsure if they are easily interfaced with a GUI....

Link to comment
Share on other sites

Hello privitmj,

 

I firmly believe in using the right tool for the job, while an FPGA is like a multi-tool that can be utilized in pretty much any task it is not always the best tool available. Let me try to think through the pro's and con's based on what you just told us.

 

Cost: In many cases cost is a major factor, quite often I run into a situation where the task is so simple and the stakes if the task fails are so low that its a no brainer to use a less expensive and less complicated microcontroller. I think in your situation cost is not a factor, it sounds like you need something that will be rock solid, I would probably eliminate the need for a low cost board from the consideration.

 

Complexity and difficulty vs flexibility: FPGA's are more complicated to deal with then a microcontroller like the Arduino is. We are trying very hard to make things as easy as an Arduino, but there is still a lot of work to be done towards those ends. The design process is going to be more difficult but the trade off is that you will pretty much guarantee that you will not be painted into a corner. With a microcontroller like the Arduino you can start the design process only to discover that it is just not up to the task or that you are one hardware resource shy of what you need. With an FPGA you have a LOT of flexibility to deal with any bottlenecks and can write custom hardware to address those bottlenecks. With a micro your option is to find a more powerful micro and port your work to that new board... If the design flexibility is important to you then an FPGA is a big plus. If you are pretty confident that an Arduino or SBC like the Raspberry Pi will get the job done then maybe that flexibility is not worth the complexity. Keep in mind that the Raspberry Pi comes with its own complexity, but it is complexity that is more commonplace since linux boxes are very well understood and documented on the Internet.

 

Handling multiple tasks in parallel: This is where FPGA's really, really shine. You can create hardware based relay controllers and have them all controlled by a Soft Processor like the ZPUino. Say you need to do something like monitor a temperature sensor and turn off a relay very quickly if the temperature goes too high. That's no problem for a micro if you have a couple sensors and relay's, but what if you have a bunch? Since the micro will read the temperature sensor in a sequential program it may take a while before it reads the high temperature and turns the relay off. With an FPGA you can use VHDL to write a hardware controller that would be able to act independently of the processor. You would then connect as many of those hardware relay controllers, in parallel, to a soft processor like the ZPUino. You could then write C code that would communicate over the USB port and execute on the ZPUino to control when to turn on or off relays. The hardware modules would run independently of the C code and have the ability to react instantly if a temperature sensor was too high.

 

As far as the GUI goes, we currently have a VGA core and library for the ZPUino that you can use to make a low res GUI. I'm not sure it would be up to the task of what you want... The other option is to connect the Papilio to the USB port of a computer and have a GUI on a computer send the required commands over the virtual serial port. Alvie even has a library that can be used to do RPC calls to functions running on the ZPUino. It does error checking and all kinds of extra's that might be useful...

 

As far as making a final circuit board to be permanently deployed, that is one of the main reasons the Papilio is Open Source. You can take the Papilio design and use it as the basis for your own custom design. There is a non-commercial clause on the Papilio design at the moment, but the only reason it is there is because I don't want people to manufacture the Papilio design as it is and sell them in direct competition with me. As far as someone using the Papilio design in derivatives, commercial or otherwise, I'm happy to see it happen. I would never say anything other then encouragement for anyone who does so. If there are legal concerns I'm happy to give an individual license out without the commercial clause so companies don't have to worry from a legal stand point.

 

Ok, having said all that, it does come back to the right tool for the job. With the information that you gave us I wonder if something like the Beagle Bone Black might be best suited for your task? It is probably fast enough to handle all the relays you need, not sure on that though, and it has the most I/O of any SBC out there. You would be able to create a GUI using any GUI toolkit out there since it is Linux. I would probably explore the Beagle Bone Black first and then have an FPGA as my second place consideration, as more about the project is discovered it could very easily become the case that the Beagle Bone Black is not suitable.

 

Keep in mind that this is assuming that you care going to make some kind of daughterboard that handles safely interfacing with the relays. The Papilio or Beagle Bone black would just be the heart of the system.

 

Jack.

Link to comment
Share on other sites

I would look at it this way.

 

1. Decide how you will talk to the design (I assume RS232 over USB) 

2, Think of a protocol to run over the link. It might be

   From host to FPGA

          H - heartbeat - must be seen every 0.1 second

          Onnnn - Open close   nnnn

          Cnnnn - Close output nnnn

          R - Reset all to to defaults

   From FPGA to host

          R - Reset has occured

          Onnnnnnnnnnn  status of outputs (in octal perhaps? 0-7)

          Innnnnnnnnnnn  status of inputs (in octal perhaps? 0-7)

          X - Error has occured

 

So then all the GUI has to do is open the serial ports and send:

    R H H H O0000 O0001 O0003

and from the device it might see

   R O0000 I0000 O0000 I0000 O0013 I0000.....

Showing that at some time outputs 0,1, and 3 have been switched on. 

 

FPGAs are used mainly in commercial products where MCUs don't work (either for processing, latency or I/O requirements) and where volumes are too low for custom chips, or where the ability to make design revisions through firmware updates are required.

 

Some of the PIC MCUs chips can drive a display and relays all in one package  - I've been looking at the Maximite kit for approx US$80 - http://en.wikipedia.org/wiki/Maximite. You can even get RetroBSD running on them!

Link to comment
Share on other sites

Jack,

 

    Thanks very much for the response. I'd like to stay away from the BBB because of its Linux nature. I'm handcuffed to Windows based applications only. Not sure if there would be any way around this.

 

Speed in this application is not of utmost importance. I'm thinking of using mechanically latching relays that get pulsed open, and once open they will stay in that configuration for hours at a time. If it takes 5 minutes (over exaggeration) to get all of the relays open, then that is fine so long as they can all be opened. The FPGA will theoretically put a voltage on certain I/O pins that will switch in a higher voltage (probably transistor switch, haven't gotten that far yet) to active the relay.

 

Can I program a FPGA to take input from a serial/usb port and in turn put voltages and certain I/Os?

 

 

Ham - Do you know of a good protocol tutorial? Your last post makes as much sense to me as my girlfriend's logic :o)

Link to comment
Share on other sites

I'm on a roll today with not making a lot of sense, I was up late last night working on a new release of the Papilio Schematic Library. I think it is starting to catch up to me. :)

 

Yes, you can definitely program an FPGA to take input from a serial/usb port that will turn any of the I/O pins to on or off (3.3V or 0V). You could do so with straight VHDL and using existing serial port examples, there is a tutorial I wrote a while back here. Or you could use a soft processor such as the AVR8 or the ZPUino which would let you control the I/O ports using the same C code and serial port libraries that the Arduino uses.

 

It is going to be easier to use the soft processor to get up and running quickly, you just need to download our ZAP IDE and study the Arduino digital pin examples.

 

Jack.

Link to comment
Share on other sites

Hmm, Alex that is interesting. I've been looking for something similar. Let me do a little more research :)

 

 

 

*****Update******

 

So, I checked it out and the latest drivers are for Vista. The website doesn't look too professional so I doubt my company will approve them as a vendor :( I don't think creating one would be too hard though... Do you have any other suggestions? I was looking at  www.controlanything.com for those boards, but again, I feel like I should be able to build one for cheaper than $900. Plus all of this valuable FPGA experience I'd get :)

Link to comment
Share on other sites

If I were trying to do this, I would use a microcontroller with a bank of shift registers to control the relays. I'm an AVR guy, but a PIC or other device would work just as well. Use the UART to interface to the computer via serial port and then have the microcontroller clock out the data to the shift registers. I've used the 74HC595 in a number of projects and it's easy to use, readily available, and inexpensive. You'll need something to amplify the signal to power the relay coil too. This can be as simple as a transistor such as the ubiquitous 2N2222 for each relay, or you can get fancy and go with multi-channel chips like the ULN2003.

 

One of the really slick things about this approach is that you can daisy chain additional registers to add as many channels as you need. If you loop the output from the last register back to the microcontroller you can even implement automatic determining of the length of the chain on the fly. Once you know how many bits to shift out (one per output pin), you just clock them out in a row and then pulse the latch line and the values are simultaneously loaded into the output registers.

 

FPGAs are amazing but IMHO not really the right tool for this task. Also integrating expensive development/prototyping boards into finished products is an expensive and amateur-ish way to go. Using the microcontroller/74HC595 approach you can get dozens of channels for a few dollars in parts. The 8 output 74HC595 is about 50 cents each.

Link to comment
Share on other sites

There are relay driver chips with SPI interface that can be daisy-chained and they are very easy to use with any microcontroller.

 

Here is one that I have used in a project.  It has 8 outputs and can sink 240 mA:

http://www.digikey.com/product-detail/en/TLE7232G/TLE7232GCT-ND/2231239

 

Edit: Oops, I didn't notice it's now obsolete.  But I think there are other similar relay driver chips available.

 

Like this one:

http://www.digikey.com/product-detail/en/TLE7230G/TLE7230GTR-ND/1016106

Link to comment
Share on other sites

Those would work well too, and it's tidier than having two separate chips per group of channels. It's more than 4x the cost of a 74HC595 + ULN2003 though, at least in small quantities. Functionally both solutions are about the same. Shift registers are a great way to get large amounts of digital IO from small pin count microcontrollers. I've used them in my Nixie tube clocks where I wanted to control dozens of cathodes from a few pins on an AVR.

Link to comment
Share on other sites

I did purchase a FPGA board for the heck of it, but I think that I might go the AVR route for this particular project as speed and multitasking are not an issue.

 

James - Is it possible to configure a shift register with a mixture of low and high signals i.e. I don't want all of the relays on at one time. For example I might want relays 1,2,4,8,25,42,43,50 on and the rest off.... Also, do you have any development suggestions for the AVR chips? I was looking at the Atmel development boards... is that overkill? Or should I just download the IDE, buy a programmer and be done with it?

Thanks again!

 

Mike

Link to comment
Share on other sites

That's precisely what shift registers do. Think of them as a serial to parallel converter where you clock in a row of bits that are any combination of 0's and 1's and then load those bits simultaneously into the output latches. You can get parallel to serial shift registers too but that's the opposite of what you want. Here's a reasonable explanation of how they work.

 

 

There are many other tutorials and animations out there if you look around a bit.

 

I have a STK-500 development board I got many years ago but it's overkill for what you want. If you look on ebay, you can get basic development boards with something like an ATMEGA8 for around 10 bucks, that's more than enough processing power. My suggestion would be to get something like that, an in-circuit programmer which is another 5-10 bucks, and then download AVR Studio.

 

Another thing you might look into is Bascom AVR, it's free for hobby use or around $100 for a commercial supported version. The syntax is similar to Qbasic and it has fairly good documentation and was fairly easy for me to pick up.

 

If you already know C, GCC is available for the AVR. If you run Windows, WinAVR is a nice tidy package incorporating GCC.

 

 

I would encourage you to play with the FPGA board too, it's not the best choice for this project IMO but it's a lot of fun to play with. You *could* synthesize the AVR and shift registers all within the FPGA but that's taking the scenic route and is not economical in a finished product.

Link to comment
Share on other sites

Oh yes, I will definitely be playing with my FPGA :) I just have to decide on what I want to do with it first! Probably just start with the basic tutorials. Maybe sometime in the future I'll try to recreate the project with a FPGA!

 

I also just purchased the STK-500. Looks like I'll be plenty of busy in the next few months "working" with this stuff.

Link to comment
Share on other sites

Well it sounds like you're pretty well set. Just about any AVR will work fine for development but for what you're doing, you can probably get away with one of the 8 pin ATTINY series. All you need is a UART and at least three additional pins to control the shift register. The code will probably fit in a few hundred bytes of program flash.

Link to comment
Share on other sites

  • 1 month later...

Archived

This topic is now archived and is closed to further replies.