Page 412 - 2
P. 412

[ 그림 5] LED   회로도                           [ 그림 6]  초음파센서 회로도

             [ 그림 5]  은 초음파센서로 일정거리이상 멀어지면 LED                  가 켜지는 회로도이다.
             [ 그림 6]  는 거리를 재는 초음파센서를 이용한 회로도이다.



            8.  소프트웨어 작성하기
              가. FPGA  에서 데이터 처리를 위한 프로그램 소스


            module step(clk, reset, step_phase1, step_phase2, step_phase3, sw1, sw2, sw3);



            input clk, reset, sw1, sw2, sw3;


            output [3:0] step_phase1, step_phase2, step_phase3;



            reg [3:0] sw1_b, sw2_b, sw3_b;                                  // 스위치 버퍼
            reg [3:0] step_phase1, step_phase2, step_phase3; //      모터 상
            reg [31:0] tcnt, tcnt1, tcnt2, tcnt3, tcnt4, tcnt5;





            integer temp = 0, temp1 = 0, temp2 = 0, temp3 = 0, temp4 = 0, temp5 = 0, step = 0,
            step1 = 0, step2 = 0, step3 = 0, step4 = 0, step5 = 0, flag = 0, flag1 = 0, flag2 = 0;
            parameter speed = 100000;


            always @(posedge clk)           // 스위치 버퍼

            begin
                    sw1_b <= {sw1_b[3:0], sw1};
                    sw2_b <= {sw2_b[3:0], sw2};
                    sw3_b <= {sw3_b[3:0], sw3};

            end


                                                         - 412 -
   407   408   409   410   411   412   413   414   415   416   417