This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Simple lighting problem using FPGA

I'm working on a masters project at University, where I'm investigating different photometric stereo techniques. This requires me to write a piece of code, which when run, it triggers four lights to flash, one after the other. I appreciate this is probably (hopefully) a really simple problem but my coding experience is quite limited and I'm not sure how to link the code to the flash lights, whether this be through the use of an FPGA or some other micro controller.

I'm thinking of using a counter, after 1 count light 1 will turn on, after another count light 2 will turn on and so on...

Ideally I'd like to use C or use Matlab. What is the best way to write this code and what is the best method of linking this code to the flash lights?

Thank

  • Alastair,

    Different FPGA boards and microcontrollers will be a little different on how the actual code will be written to get it to do this.
    For the most part it will simply connecting each of the four LED's to a separate GPIO (General purpose input output) pin on your FPGA. Then you will need a resistor going from the other end of the LED to ground.

    The code that you would write as I said will be a little different for each board that you are using but in it's most basic form it would say (this is in C, if you need to use Matlab this will not work the same way) :

    //------------------------------------------------------------
    //
    //Initialize the GPIO peripheral of your board
    //
    //------------------------------------------------------------
    GPIO1=0;//initialize all LED's to off when begin
    GPIO2=0;
    GPIO3=0;
    GPIO4=0;
    while(1){
    GPIO4=0;//Turn off Fourth LED
    GPIO1=1; //Turn on First LED
    Delay(1000);//Delay 1second (change this based on how long you want them to stay on)(also change this to whatever delay function your board uses)
    GPIO1=0;//Turn off First LED
    GPIO2=1//Turn on Second LED
    Delay(1000);//wait
    GPIO2=0;//Turn off Second LED
    GPIO3=1;//Turn on Third LED
    Delay(1000);//wait
    GPIO3=0;//Turn off Third LED
    GPIO4=1;//Turn on Fourth LED
    Delay(1000);//wait

    }

    Again this will change based on what board you are using. Also there is a shorter way to do this but this is the most basic way if that is all you need. Hope this helps.
    If you let me know which board you are using I might be able to give you better code.

    Respectfully,
    Cameron Phillips