哈喽,大家好~
这里分享一下将之前的计算出来的SVPWM通过IO发送出来。
先用锯齿载波测试一下,实现方式如下:
always @(posedge clk) begin
if (!reset) begin
counter_18k <= 32'd0;
end
else if (counter_18k >= count_value_18k) begin
svpwm1_reg <= svpwm1;
svpwm2_reg <= svpwm2;
svpwm3_reg <= svpwm3;
counter_18k <= 32'd0;
end
else begin
counter_18k <= counter_18k + 1'b1;
end
end
always @(posedge clk) begin
if ( counter_18k >= svpwm1_reg ) begin
pwm_out_reg[0] = 1'd1;
end
else begin
pwm_out_reg[0] = 1'd0;
end
end
always @(posedge clk) begin
if ( counter_18k >= svpwm2_reg ) begin
pwm_out_reg[1] = 1'd1;
end
else begin
pwm_out_reg[1] = 1'd0;
end
end
always @(posedge clk) begin
if ( counter_18k >= svpwm3_reg ) begin
pwm_out_reg[2] = 1'd1;
end
else begin
pwm_out_reg[2] = 1'd0;
end
end
然后将pwm_out_reg信号用IO输出看一下效果:
用示波器看一下发波情况:
从上面可以看出发波符合预期结果。
然后将锯齿载波修改成三角载波即可。
欢迎留言交流。