Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 14:062850afdf38
- Parent:
- 13:1faffc2dc651
- Child:
- 15:83bbc18cccbc
diff -r 1faffc2dc651 -r 062850afdf38 main.cpp --- a/main.cpp Fri Mar 26 14:27:37 2021 +0000 +++ b/main.cpp Thu Apr 22 11:35:17 2021 +0000 @@ -11,19 +11,27 @@ main_init(); /*reset the FPGA!*/ /*control codes*/ - wait_ms(2000); /* keep FPGA in reset for 5s, to let motor stop*/ - enbale_fpga(); /* enable FPGA */ - wait_ms(3); - led4 = i2c.i2c_window_open(); /*send password 0xd0d0*/ - //wait_ms(1); - //led4 = i2c.i2c_window_open(); /*send password 0xd0d0*/ - wait_ms(3); -// i2c.i2c_clear_spd_ctrl(); -// wait_ms(1); + wait_ms(2000); /* keep FPGA in reset for 5s, to let motor stop*/ + enbale_fpga(); /* enable FPGA */ + wait_ms(10); + i2c.i2c_window_open(); /*send password 0xd0d0*/ + wait_ms(1); + i2c.i2c_clear_spd_ctrl(); + wait_ms(1); + i2c.i2c_set_input_mode(0x4); + wait_ms(1); + i2c.i2c_set_open_loop_duty(0xffff); + wait_ms(1); + i2c.i2c_set_comm_i_thres(15,1); + wait_ms(1); + i2c.i2c_set_comm_di_thres(0,1); + wait_ms(1); + i2c.i2c_set_fall_time_blank(4); + wait_ms(1); i2c.i2c_set_50k_pwm(1); - wait_ms(3); - i2c.i2c_set_position_pulse_width(3,3); /*unsigned int mantisaa_2b, unsigned int exponent_3b*/ - wait_ms(3); + wait_ms(1); + i2c.i2c_set_position_pulse_width(2,2); /*unsigned int mantisaa_2b, unsigned int exponent_3b*/ + wait_ms(1); // i2c.i2c_set_position_duty(3); // wait_ms(10); // i2c.i2c_set_position_anti_cog(0); @@ -31,33 +39,25 @@ // i2c.i2c_set_start_up_duty(3); // wait_ms(10); i2c.i2c_set_start_up_pulse_width(3,5); /*(unsigned int mantisaa_3b, unsigned int exponent_3b*/ - wait_ms(3); + wait_ms(1); // i2c.i2c_set_start_up_num_comm(3); // wait_ms(10); -// i2c.i2c_set_curve_type(3); -// wait_ms(10); -// i2c.i2c_set_loop_mode(0); -// wait_ms(10); // //led4 = i2c.i2c_set_soft_start_up(1, 1, 0, 1, 1); // wait_ms(10); // i2c.i2c_clear_spd_ctrl(); -// wait_ms(10); -// i2c.i2c_set_loop_mode(0); -// wait_ms(10); -// i2c.i2c_set_curve_type(3); -// wait_ms(3); -// i2c.i2c_set_dc_ini(2); -// wait_ms(3); -// i2c.i2c_set_dc_sr(2); - wait_ms(3); + wait_ms(1); + i2c.i2c_set_loop_mode(0); + wait_ms(1); + i2c.i2c_set_curve_type(3); + wait_ms(1); + i2c.i2c_set_dc_ini(2); + wait_ms(1); + i2c.i2c_set_dc_sr(0); + wait_ms(1); i2c.i2c_set_rough_gain(0); - wait_ms(3); - i2c.i2c_set_open_loop_duty(0xffff); -// wait_ms(10); -// i2c.i2c_set_comm_i_thres(15,1); - wait_ms(3); - i2c.i2c_set_comm_di_thres(0,1); - wait_ms(10); + wait_ms(1); + i2c.i2c_set_ehp_reg_gain(0); + wait_ms(1); led4 = i2c.i2c_motor_start(); /*send password 0xcafe*/ /*enter infinite loop, motor should be running*/