微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 经典款嵌入式智能小车的设计技巧,提供硬件选型

经典款嵌入式智能小车的设计技巧,提供硬件选型

时间:06-03 来源:互联网 点击:

用硬件描述语言描述驱动的过程。

process(Bus2IP_Clk,slv_reg1,the_end)

begin

if slv_reg1=x00000000 then

counter=x00000000;

chao_out = 0;

div_clk=0;

elsif rising_edge(Bus2IP_Clk) then

if the_end = 1 then

chao_out = 1;

counter=counter+1;

if(counter=x1F4) then

counter=x00000000;

chao_out = 0;

div_clk=1;

end if;

end if;

end if;

end process;

-- implement slave model software accessible register(s) read mux

SLAVE_REG_READ_PROC : process( Bus2IP_Resetn,slv_reg_read_sel, slv_reg0, slv_reg1,Bus2IP_Clk,div_clk ) is

begin

case slv_reg_read_sel is

when 10 =>

if Bus2IP_Resetn = 0 then

timer_count = x00000000;

the_end = 0;

elsif div_clk=1 then

if slv_chao_in=1 then

the_end = 0;

timer_count = timer_count + 1;

else

slv_ip2bus_data = timer_count; --slv_reg0;

the_end = 1;

timer_count = x00000000;

end if;

else

slv_ip2bus_data = slv_reg0;

end if;

when 01 => slv_ip2bus_data = slv_reg1;

when others => slv_ip2bus_data = (others => 0);

end case;

end process SLAVE_REG_READ_PROC;

5.3 PWM模块的调试

由于需要两路的PWM来分别操作舵机和直流电机,所有PWM的调试时至关重要的。

代码如下:

int main()

{

unsigned long i,j;

//close PWM

PWM_IP_mWriteSlaveReg1(XPAR_PWM_IP_0_BASEADDR,0,0x00); //PWM0

PWM_IP_mWriteSlaveReg1(XPAR_PWM_IP_1_BASEADDR,0,0x00); //PWM1

for(i=0;i=99999;i++);

PWM_deal(0x2E);

while(1)

{

PWM_deal(0x2E);

delay(60);

PWM_deal(0x38);

delay(60);

PWM_deal(0x2E);

delay(60);

PWM_deal(0x24);

delay(60);

}

return 0;

}

void PWM_deal(unsigned char reg0)

{

//PWM0 舵机

//PWM 频率

PWM_IP_mWriteSlaveReg1(XPAR_PWM_IP_0_BASEADDR,0,0x1F4);

//PWM 占空比

PWM_IP_mWriteSlaveReg0(XPAR_PWM_IP_0_BASEADDR,0,reg0);

//PWM1 直流电机

PWM_IP_mWriteSlaveReg1(XPAR_PWM_IP_1_BASEADDR,0,0x1F4); //

PWM_IP_mWriteSlaveReg0(XPAR_PWM_IP_1_BASEADDR,0,reg0); //slv_reg0

}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top