VGA Sensor Display

VGA Sensor Display:

We decided that for presentation purposes it would be better to have a visual representation of the status of our sensors (using the VGA output).  An existing project from ECE287 was modified to show the status of each room's sensors.  By taking the output of each sensor directly into an Altera UP2 board, the VGA displays a mock-up of the test rooms and the status of each of their sensors.  Activated sensors turn green,  and a room will turn pink if music is playing.  Note that the output of the PIRs and microphones were below the threshold for a "high" signal for the UP2, so this display is not completely functional due to lack of a proper signal.  Some demo photos are depicted below.  The Verilog HDL source code is also provided.


VGA Sample Output:

 

 

Verilog HDL Source Code:

module dector(MUSIC1,MUSIC2,PIR1_IN, PIR2_IN, IRBeam1_IN, IRBeam2_IN, IRBeam3_IN, IRBeam4_IN, Mic1_IN, Mic2_IN, rst, clk, vga_h_sync, vga_v_sync, vga_R, vga_G, vga_B);
input clk, rst;
input PIR1_IN, PIR2_IN, IRBeam1_IN, IRBeam2_IN, IRBeam3_IN, IRBeam4_IN, Mic1_IN, Mic2_IN, MUSIC1, MUSIC2;
output vga_h_sync, vga_v_sync, vga_R, vga_G, vga_B;
wire inDisplayArea;
wire [9:0] CounterX;
wire [8:0] CounterY;

hvsync_generator syncgen(.clk(clk), .vga_h_sync(vga_h_sync), .vga_v_sync(vga_v_sync),
  .inDisplayArea(inDisplayArea), .CounterX(CounterX), .CounterY(CounterY));

wire wall = (((CounterX[9:5]==0 && (CounterY[8:5]>=0) && (CounterY[8:5]<8)))||
            ((CounterY[8:5]==0) && (CounterX[9:5]>=0) && (CounterX[9:5]<10))||
            ((CounterX[9:5]==9) && (CounterY[8:5]>=0) && (CounterY[8:5]<7))||
            ((CounterY[8:5]==8) && (CounterX[9:5]>=0) && (CounterX[9:5]<10))||
            ((CounterY[8:5]==6) && (CounterX[9:5]>=9) && (CounterX[9:5]<=19))||
            ((CounterX[9:5]==19 && (CounterY[8:5]>=6) && (CounterY[8:5]<=14)))||
            ((CounterY[8:5]==14) && (CounterX[9:5]>=9) && (CounterX[9:5]<19))||
            ((CounterX[9:5]==9 && (CounterY[8:5]>=8) && (CounterY[8:5]<=14)))
            );

wire irBeam1=  (CounterX[9:5]==8) && (CounterY[8:5]==2);
wire irBeam2= (CounterX[9:5]==8) && (CounterY[8:5]==7);
wire irBeam3= (CounterX[9:5]==10) && (CounterY[8:5]==7);
wire irBeam4= (CounterX[9:5]==10) && (CounterY[8:5]==12);
wire pir1= (CounterX[9:5]==1) && (CounterY[8:5]==4);
wire pir2= (CounterX[9:5]==18) && (CounterY[8:5]==10);
wire mic1= (CounterX[9:5]==7) && (CounterY[8:5]==4);
wire mic2= (CounterX[9:5]==11) && (CounterY[8:5]==10);
wire room1= (((CounterY[8:5]==1) && (CounterX[9:5]>=1) && (CounterX[9:5]<=8))||
            ((CounterY[8:5]==2) && (CounterX[9:5]>=1) && (CounterX[9:5]<=7))||
            ((CounterY[8:5]==3) && (CounterX[9:5]>=1) && (CounterX[9:5]<=8))||    
            ((CounterY[8:5]==4) && (CounterX[9:5]>=2) && (CounterX[9:5]<=6))||
            ((CounterY[8:5]==4) && (CounterX[9:5]==8))||
            ((CounterY[8:5]==5) && (CounterX[9:5]>=1) && (CounterX[9:5]<=8))||
            ((CounterY[8:5]==6) && (CounterX[9:5]>=1) && (CounterX[9:5]<=8))||
            ((CounterY[8:5]==7) && (CounterX[9:5]>=1) && (CounterX[9:5]<=7))
                );
wire room2= (((CounterY[8:5]==7) && (CounterX[9:5]>=11) && (CounterX[9:5]<=18))||
            ((CounterY[8:5]==8) && (CounterX[9:5]>=10) && (CounterX[9:5]<=18))||
            ((CounterY[8:5]==9) && (CounterX[9:5]>=10) && (CounterX[9:5]<=18))||    
            ((CounterY[8:5]==10) && (CounterX[9:5]==10))||
            ((CounterY[8:5]==10) && (CounterX[9:5]>=12) && (CounterX[9:5]<=17))||
            ((CounterY[8:5]==11) && (CounterX[9:5]>=10) && (CounterX[9:5]<=18))||
            ((CounterY[8:5]==12) && (CounterX[9:5]>=11) && (CounterX[9:5]<=18))||
            ((CounterY[8:5]==13) && (CounterX[9:5]>=10) && (CounterX[9:5]<=18))
                );


reg curr_R;
reg curr_G;
reg curr_B;
always @(posedge clk)
begin
    curr_R = wall;
    curr_G = wall;
    curr_B = wall;

    if(MUSIC1==1'b1)
    begin
            curr_R = curr_R | room1;
            curr_G = curr_G;
            curr_B = curr_B | room1;
        end
    else
        begin
            curr_R = curr_R;
            curr_G = curr_G;
            curr_B = curr_B;
    end
    
    if(MUSIC2==1'b1)
    begin
            curr_R = curr_R | room2;
            curr_G = curr_G;
            curr_B = curr_B | room2;
        end
    else
        begin
            curr_R = curr_R;
            curr_G = curr_G;
            curr_B = curr_B;
    end

    if(PIR1_IN==1'b1)
       
        begin
            curr_R = curr_R;
            curr_G = curr_G | pir1;
            curr_B = curr_B;
        end
    else
        begin
            curr_R = curr_R | pir1;
            curr_G = curr_G | pir1;
            curr_B = curr_B;
        end
       
    if(PIR2_IN==1'b1)
       
        begin
            curr_R = curr_R;
            curr_G = curr_G | pir2;
            curr_B = curr_B;
        end
    else
        begin
            curr_R = curr_R | pir2;
            curr_G = curr_G | pir2;
            curr_B = curr_B;
        end
       
    if(IRBeam1_IN==1'b1)
       
        begin
            curr_R = curr_R;
            curr_G = curr_G | irBeam1;
            curr_B = curr_B;
        end
    else
        begin
            curr_R = curr_R | irBeam1;
            curr_G = curr_G;
            curr_B = curr_B;
        end
       
    if(IRBeam2_IN==1'b1)
       
        begin
            curr_R = curr_R;
            curr_G = curr_G | irBeam2;
            curr_B = curr_B;
        end
    else
        begin
            curr_R = curr_R | irBeam2;
            curr_G = curr_G;
            curr_B = curr_B;
        end
       
    if(IRBeam3_IN==1'b1)
       
        begin
            curr_R = curr_R;
            curr_G = curr_G | irBeam3;
            curr_B = curr_B;
        end
    else
        begin
            curr_R = curr_R | irBeam3;
            curr_G = curr_G;
            curr_B = curr_B;
        end   
       
    if(IRBeam4_IN==1'b1)
       
        begin
            curr_R = curr_R;
            curr_G = curr_G | irBeam4;
            curr_B = curr_B;
        end
    else
        begin
            curr_R = curr_R | irBeam4;
            curr_G = curr_G;
            curr_B = curr_B;
        end   
       
    if(Mic1_IN==1'b1)
       
        begin
            curr_R = curr_R;
            curr_G = curr_G | mic1;
            curr_B = curr_B;
        end
    else
        begin
            curr_R = curr_R;
            curr_G = curr_G;
            curr_B = curr_B | mic1;
        end   
       
    if(Mic2_IN==1'b1)
       
        begin
            curr_R = curr_R;
            curr_G = curr_G | mic2;
            curr_B = curr_B;
        end
    else
        begin
            curr_R = curr_R;
            curr_G = curr_G;
            curr_B = curr_B | mic2;
        end           
end
reg vga_R, vga_G, vga_B;
always @(posedge clk)
begin
    vga_R <= curr_R & inDisplayArea;
    vga_G <= curr_G & inDisplayArea;
    vga_B <= curr_B & inDisplayArea;
   
end

endmodule



//////////////////////////////////////////////////////////////////////////////////////////////

module hvsync_generator(clk, vga_h_sync, vga_v_sync, inDisplayArea, CounterX, CounterY);
input clk;
output vga_h_sync, vga_v_sync;
output inDisplayArea;
output [9:0] CounterX;
output [8:0] CounterY;

//////////////////////////////////////////////////
reg [9:0] CounterX;
reg [8:0] CounterY;
wire CounterXmaxed = (CounterX==10'h2FF);

always @(posedge clk)
if(CounterXmaxed)
    CounterX <= 0;
else
    CounterX <= CounterX + 1;

always @(posedge clk)
if(CounterXmaxed) CounterY <= CounterY + 1;

reg    vga_HS, vga_VS;
always @(posedge clk)
begin
    vga_HS <= (CounterX[9:4]==6'h2D); // change this value to move the display horizontally
    vga_VS <= (CounterY==500); // change this value to move the display vertically
end

reg inDisplayArea;
always @(posedge clk)
if(inDisplayArea==0)
    inDisplayArea <= (CounterXmaxed) && (CounterY<480);
else
    inDisplayArea <= !(CounterX==639);
   
assign vga_h_sync = ~vga_HS;
assign vga_v_sync = ~vga_VS;

endmodule

 

Project Links:

Home

Project Proposal

Detection Method

MATLAB Image Processing

Sensor Design and Construction

Test Room

Control Logic

Costs

Conclusions and Future Work