FPGA, SoC, And CPLD Boards And Kits
FPGA Evaluation and Development Kits
5925 Discussions

Changing the degrees the BeInMotion kit rotate

Altera_Forum
Honored Contributor II
888 Views

So far I'm new in programming FPGAs and using the Quartus , Qsys and Nios. I tried to change all the values in the void turn_left() but returned empty handed. So far I'm grasping the basics but i'm pretty it is in that function. I want it to rotate from 90 degrees to around 45 deg. so that it will be smoother. Here's the code 

 

int turn_left() 

int dc_m1_pwm_duty = dc_m1_pwm_freq/4; 

int dc_m2_pwm_duty = dc_m2_pwm_freq/4; 

 

dc1_cmp = 1; 

dc2_cmp = 1; 

 

IOWR(IR_RX2_BASE,0x00,0); 

IOWR(IR_RX1_BASE,0x00,0); 

IOWR(DC2_PWM2_BASE+0x08,0,0); 

IOWR(DC1_PWM1_BASE+0x08,0,0); 

 

IOWR(DC2_PWM1_BASE,0,dc_m2_pwm_freq); 

IOWR(DC2_PWM1_BASE+0x04,0,dc_m2_pwm_duty); 

IOWR(DC1_PWM2_BASE,0,dc_m1_pwm_freq); 

IOWR(DC1_PWM2_BASE+0x04,0,dc_m1_pwm_duty); 

 

IOWR(IR_RX2_BASE,1,722); 

IOWR(IR_RX1_BASE,1,722); 

IOWR(IR_RX2_BASE,0x00,1); 

IOWR(IR_RX1_BASE,0x00,1); 

 

IOWR(DC1_PWM2_BASE+0x08,0,1); 

IOWR(DC2_PWM1_BASE+0x08,0,1); 

 

while(1) 

if(( dc1_cmp ==0 ) && (dc2_cmp ==0 )) 

return 0; 

else 

usleep(90000); 

dc_m1 = IORD(IR_RX1_BASE,1); 

dc_m2 = IORD(IR_RX2_BASE,1); 

i = dc_m1-dc_m2; 

j = dc_m2-dc_m1; 

if(i > 5) { 

if(dc_m2_pwm_duty >= 100) 

dc_m2_pwm_duty-=50; 

if(dc_m1_pwm_duty < 850) 

dc_m1_pwm_duty+=50; 

IOWR(DC2_PWM1_BASE+0x04,0,dc_m2_pwm_duty); 

IOWR(DC1_PWM2_BASE+0x04,0,dc_m1_pwm_duty); 

else 

if(j > 5) { 

if(dc_m1_pwm_duty >= 50); 

dc_m1_pwm_duty-=50; 

if(dc_m2_pwm_duty < 1700) 

dc_m2_pwm_duty+=50; 

IOWR(DC2_PWM1_BASE+0x04,0,dc_m2_pwm_duty); 

IOWR(DC1_PWM2_BASE+0x04,0,dc_m1_pwm_duty); 

 

Hope someone and I'll appreciate it. Thank you in advance.
0 Kudos
0 Replies
Reply