Documente Academic
Documente Profesional
Documente Cultură
Contents
1. Problem Statement ……………………………………………………. 3
8. Report ……………………………………………………............... 11
HDL Synthesis Report …………………………………………. 11
Timing Report …………………………………………………. 12
Mapping Report ………………………………………………... 12
Place and Route Report ………………………………………… 13
2
DSA 2010 To control the speed of stepper motor using light intensity on LDR.
Problem Statement
To control the speed of stepper motor using light intensity on LDR.
To interface LDR as an analog input to FPGA kit and display the output from LDR on
the 7 segment LED. It will also responsible for the speed of revolution of stepper motor
depending on the light intensity of the LDR.
Functional Specification
Introduction
The speed of stepper motor will be regulated by the light intensity on LDR. The ADC
chip 7891 will take output of analog sensor (LDR) as an input. Depending upon the
output of ADC the stepper motor will vary in speed. The components that are to be used:
LDR, Stepper Motor, ADC, and FPGA chip Spartan3.
Components used:
Stepper Motor – The stepper motor is an electrical motor, which converts digital
electrical input into a rotator motion. Stepper motor is the one that revolves through a
3
DSA 2010 To control the speed of stepper motor using light intensity on LDR.
fixed angle for each pulse applied to the logic sequence. By controlling the pulse rate
the speed of stepper motor can be controlled. Stepper motor is also called as a Single
Stack Variable Reluctance Motor. If the switching is carried out in a sequence, the
rotor will rotate with stepped motion.
The pulse rate given to stepper motor will depend on the ADC output, or indirectly on
Light Intensity.
Objective:
To regulate/change the speed of stepper motor depending upon the light intensity
at LDR. Also, to display the corresponding light intensity at 7 segment LED.
Approach:
We were required to change the speed of motor by light intensity of LDR. So, our first
task was to get digital output from LDR using ADC chip 7891 available on the board.
After making sure that the ADC interfacing is working properly, we shifted ourselves to
the next task at hand. We run the stepper motor as a separate module. After that we
integrated the modules to run the stepper motor depending upon the light intensity.
Block Diagram
4
DSA 2010 To control the speed of stepper motor using light intensity on LDR.
RTL Model
5
DSA 2010 To control the speed of stepper motor using light intensity on LDR.
ADC
6
DSA 2010 To control the speed of stepper motor using light intensity on LDR.
Stepper motor
7
DSA 2010 To control the speed of stepper motor using light intensity on LDR.
8
DSA 2010 To control the speed of stepper motor using light intensity on LDR.
Technology Schematic
9
DSA 2010 To control the speed of stepper motor using light intensity on LDR.
Floor Plan
Functional Simulation
10
DSA 2010 To control the speed of stepper motor using light intensity on LDR.
Reports
==========================================================
HDL Synthesis Report
Macro Statistics
# Adders/Sub tractors :4
32-bit adder :4
# Counters :5
19-bit up counter :1
32-bit up counter :4
# Registers :9
1-bit register :6
12-bit register :1
2-bit register :1
5-bit register :1
# Comparators : 14
12-bit comparator greatequal :4
12-bit comparator greater :3
12-bit comparator less :4
12-bit comparator lessequal :3
# Tristates :6
1-bit tristate buffer :6
=============================================================
11
DSA 2010 To control the speed of stepper motor using light intensity on LDR.
Timing Report
(a)Clock Information:
=============================================================
Mapping Report
Design Summary
Number of errors: 0
Number of warnings: 0
Logic Utilization:
Number of Slice Flip Flops: 101 out of 7,168 1%
Number of 4 input LUTs: 108 out of 7,168 1%
Logic Distribution:
Number of occupied Slices: 144 out of 3,584 4%
Number of Slices containing only related logic: 144 out of 144 100%
12
DSA 2010 To control the speed of stepper motor using light intensity on LDR.
=============================================================
Experiment
Kit Arrangement
13
DSA 2010 To control the speed of stepper motor using light intensity on LDR.
14
DSA 2010 To control the speed of stepper motor using light intensity on LDR.
The Light Intensity is normal and signal applied is 5 Vpp Sine wave of freq. 100 KHz
15
DSA 2010 To control the speed of stepper motor using light intensity on LDR.
Code
-----------------------------(1) Connector.v--------------------------------------
module
connector(clk,reset,ff,ch_adc,db,cs_ad7891,convst_ad7891,wr_ad7891,rd_ad7891,mode_
ad7891,start,direction, sequence,adc_data_out,y,seg_cs);
input clk,reset;
input ff;
input[2:0] ch_adc;
inout [11:0] db;
input start,direction;
output [3:0] sequence;
output [11:0] adc_data_out;
output cs_ad7891,convst_ad7891,wr_ad7891,rd_ad7891,mode_ad7891;
output [6:0] y;
output seg_cs;
always@(posedge clk)
clk_prescalar=clk_prescalar+1;
adc_controller
a1(smpclk,cs_ad7891,convst_ad7891,wr_ad7891,rd_ad7891,mode_ad7891,reset,clk,ch_a
dc,db,adc_data_out,y,seg_cs);
endmodule
//-----------------------------(2) adc_controller.v------------------------------------------------
module
adc_controller(smpclk,cs_ad7891,convst_ad7891,wr_ad7891,rd_ad7891,mode_ad7891,
reset,clk,ch_adc,db_7891,adc_data_out,y,seg_cs);
output smpclk,cs_ad7891,convst_ad7891,wr_ad7891,rd_ad7891,mode_ad7891;
output [11:0] adc_data_out;
16
DSA 2010 To control the speed of stepper motor using light intensity on LDR.
reg cs_ad7891,convst_ad7891,wr_ad7891,rd_ad7891,mode_ad7891,convst_ad7891_s;
wire sampling_clk,wr_s,rd_s;
always @ (ps_1)
begin
case (ps_1)
`reset_1 : ns_1 = `write_cwr;
`write_cwr : begin
17
DSA 2010 To control the speed of stepper motor using light intensity on LDR.
cs_ad7891 = 1'b0;
ns_1 = `start_conv; end
`read_data : begin
cs_ad7891 = 1'b0;
ns_1 = `reset_1; end
endcase
end
always @ (convst_ad7891_s)
convst_ad7891 = convst_ad7891_s;
always @ (db_7891_s)
adcin = db_7891_s;
always
mode_ad7891 = 1'b1;
18
DSA 2010 To control the speed of stepper motor using light intensity on LDR.
end
always @ (adcin) begin // 7 segment display
case (adcin[11:4])
8'b10111000 : y=7'b1110111;
8'b10111001 : y=7'b1111111;
8'b10111010 : y=7'b0111001;
8'b10111011 : y=7'b1011110;
8'b10111100 : y=7'b1111001;
8'b10111101 : y=7'b1110001;
8'b10111110 : y=7'b1111101;
8'b10111111 : y=7'b1110110;
8'b11000000 : y=7'b0000110;
8'b11000010 : y=7'b0001111;
8'b11000011 : y=7'b1110000;
8'b11000101 : y=7'b0111000;
8'b11000110 : y=7'b1011011;
8'b11001000 : y=7'b1001011;
8'b11001001 : y=7'b0111111;
8'b11001101 : y=7'b1110011;
8'b11001110 : y=7'b1100111;
8'b11010000 : y=7'b0111110;
8'b11010010 : y=7'b1100100;
8'b11010100 : y=7'b1101101;
default
y = 7'b0111111;
endcase
end
/* --- DAC code
always @ (dac_sel)
begin
case (dac_sel)
2'b00 : en = 4'b1000;
2'b01 : en = 4'b0100;
2'b10 : en = 4'b0010;
2'b11 : en = 4'b0001;
default : en = 4'b0000;
endcase
end
lowpass u1(.clk(div_adc[4]),.gateway_in(adcin),.gateway_out(dacout));
assign dac_out_s = bit_trunc[0] ? dacout[21:10] :
(bit_trunc[1] ? dacout[20:9] :
(bit_trunc[2] ? dacout[19:8] :
19
DSA 2010 To control the speed of stepper motor using light intensity on LDR.
(bit_trunc[3] ? dacout[18:7] :
(bit_trunc[4] ? dacout[17:6] :
(bit_trunc[5] ? dacout[16:5] :
(bit_trunc[6] ? dacout[15:4] :
(bit_trunc[7] ? dacout[14:3]:
dacout[13:2])))))));
assign conc1 = {dac_out_s[11],~dac_out_s[10:0]};
assign dac_out = (dac_out_s[11] == 0) ? (conc1 + 1) : conc1;
*/
endmodule
//------------------------------------(3) Stepper_motor.v----------------------------------------------
module stepper_motor_controller(clk,ff,start,direction,adc_data_out,sequence);
endmodule
always@(posedge clk)
begin
20
DSA 2010 To control the speed of stepper motor using light intensity on LDR.
if((adc_data_out>=12'b100010000001)&&( adc_data_out<=12'b101000000000) )
begin // between 257 and 1024
flg2=2'b10;
i2 = i2 + 1;
if(i2== 15000) // less speed than first 266.67 rps
begin
clk2 = ~clk2;
i2 = 0;
end
end
if((adc_data_out>=12'b100000000011)&&( adc_data_out<=12'b100010000000) )
begin // between 3 and 256
flg2=2'b01;
if(!ff)
begin
i3 = i3 + 1;
if(i3== 150000) // slow speed if ff is not pressed 26.67 rps
begin
clk3 = ~clk3;
i3 = 0;
end
end
else
begin
i3 = i3 + 1;
if(i3== 5000) // ff speed 800 rps
begin
clk3 = ~clk3;
i3 = 0;
end
end
end
21
DSA 2010 To control the speed of stepper motor using light intensity on LDR.
//clk4
if((adc_data_out>=12'b100000000001)&&( adc_data_out<=12'b100000000010) )
begin //between 1 and 2
i4 = i4 + 1;
flg2=2'b00;
if(i4== 155000) // slowest speed 25.6 rps
begin
clk4 = ~clk4;
i4 = 0;
end
end
end // always block
endmodule
//--------------------------(3b) speed_decider.v-------------------------------------
input clk,flg,f1,f2,f3,f4;
output reg speed;
// reg [1:0] flg2;
//assign flg2=flg;
always@(posedge clk)
begin
case (flg)
2'b00 : begin //slowest
speed =f4;
end
2'b01 : begin
speed =f3;
end
2'b10 : begin
speed =f2;
end
2'b11 : begin //fastest
speed =f1;
end
endcase
end
endmodule
22
DSA 2010 To control the speed of stepper motor using light intensity on LDR.
state1: begin
sequence = 5'b11100;
if(d)
current = state4;
else
current = state2;
end
state2: begin
sequence = 5'b10110;
if(d)
current = state1;
else
current = state3;
end
state3: begin
sequence = 5'b10011;
if(d)
current = state2;
else
current = state4;
end
state4: begin
sequence = 5'b11001;
if(d)
current = state3;
else
current = state1;
end
23
DSA 2010 To control the speed of stepper motor using light intensity on LDR.
endcase
end
end
endmodule
//--------------------------connector.ucf-----------------------------------
#PACE: Start of Constraints generated by PACE
24
DSA 2010 To control the speed of stepper motor using light intensity on LDR.
References
1. Datasheet of ADC 7891.
2. Operational and User manual of Mechatronics Kit.
25