Compare commits

..

4 Commits

Author SHA1 Message Date
bmy
610bff5e47 pref: 适当增加速度 2024-07-09 02:13:32 +08:00
bmy
c286c90928 pref: 上电复位到指定位置 2024-06-10 17:47:09 +08:00
bmy
7523e7096e Merge branch 'master' of http://git.brisky.space/btl143/BC3D-firmware 2024-06-10 17:43:28 +08:00
bmy
52ac4c1956 pref: 上电复位到指定位置 2024-06-10 17:42:53 +08:00
3 changed files with 19 additions and 11 deletions

View File

@@ -18,7 +18,6 @@
<ParametersSub name="RSAW" value="CAN_RSAW_1TQ"/> <ParametersSub name="RSAW" value="CAN_RSAW_1TQ"/>
<ParametersSub name="Filter_0_Mode" value="CAN_FILTER_MODE_ID_LIST"/> <ParametersSub name="Filter_0_Mode" value="CAN_FILTER_MODE_ID_LIST"/>
<ParametersSub name="Filter_0_ID1" value="006"/> <ParametersSub name="Filter_0_ID1" value="006"/>
<ParametersSub name="Filter_0_ID2" value="000"/>
<ParametersSub name="Filter_0_ID3" value="007"/> <ParametersSub name="Filter_0_ID3" value="007"/>
</Parameters> </Parameters>
</CAN1> </CAN1>

View File

@@ -30,7 +30,7 @@
"titleBar.activeBackground": "#3B3485", "titleBar.activeBackground": "#3B3485",
"titleBar.activeForeground": "#FCFCFE" "titleBar.activeForeground": "#FCFCFE"
}, },
"EIDE.OpenOCD.ExePath": "C:/toolchains/openocd-arterytek/bin/openocd.exe", "EIDE.OpenOCD.ExePath": "D:/Program Files (x86)/at32_OpenOCD_V2.0.2/bin/openocd.exe",
"cortex-debug.variableUseNaturalFormat": true "cortex-debug.variableUseNaturalFormat": true
} }
} }

View File

@@ -76,6 +76,10 @@ void by_stepper_set_position_millimeter(float distance)
return; return;
} }
if (distance > 170) {
distance = 170;
}
gpio_bits_write(GPIOA, GPIO_PINS_9, FALSE); // EN gpio_bits_write(GPIOA, GPIO_PINS_9, FALSE); // EN
position_aim = (int64_t)(distance * ENCODER_PULSE_PER_MILLIMETER); position_aim = (int64_t)(distance * ENCODER_PULSE_PER_MILLIMETER);
position_offset = position_aim - position; position_offset = position_aim - position;
@@ -88,6 +92,9 @@ void by_stepper_add_position_millimeter(float distance)
if (!running_flag) { if (!running_flag) {
gpio_bits_write(GPIOA, GPIO_PINS_9, FALSE); // EN gpio_bits_write(GPIOA, GPIO_PINS_9, FALSE); // EN
position_aim = position + (int64_t)(distance * ENCODER_PULSE_PER_MILLIMETER); position_aim = position + (int64_t)(distance * ENCODER_PULSE_PER_MILLIMETER);
if (position_aim > 170 * ENCODER_PULSE_PER_MILLIMETER) {
position_aim = 170 * ENCODER_PULSE_PER_MILLIMETER;
}
position_offset = position_aim - position; position_offset = position_aim - position;
running_flag = 1; running_flag = 1;
} }
@@ -108,20 +115,20 @@ void by_stepper_init(void)
gpio_bits_write(GPIOB, GPIO_PINS_15, FALSE); // CLK gpio_bits_write(GPIOB, GPIO_PINS_15, FALSE); // CLK
by_stepper_set_dir(0); by_stepper_set_dir(0);
by_stepper_set_speed(STEPPER_SPEED_DIV2); // by_stepper_set_speed(STEPPER_SPEED_DIV2);
while (gpio_input_data_bit_read(GPIOB, GPIO_PINS_10) == SET && slow_start_cnt--) { // while (gpio_input_data_bit_read(GPIOB, GPIO_PINS_10) == SET && slow_start_cnt--) {
gpio_bits_write(GPIOA, GPIO_PINS_8, by_stepper.dir ? TRUE : FALSE); // DIR // gpio_bits_write(GPIOA, GPIO_PINS_8, by_stepper.dir ? TRUE : FALSE); // DIR
gpio_bits_write(GPIOB, GPIO_PINS_15, !gpio_output_data_bit_read(GPIOB, GPIO_PINS_15)); // CLK // gpio_bits_write(GPIOB, GPIO_PINS_15, !gpio_output_data_bit_read(GPIOB, GPIO_PINS_15)); // CLK
DWT_Delay(40U * (uint16_t)by_stepper.speed); // DWT_Delay(40U * (uint16_t)by_stepper.speed);
} // }
by_stepper_set_speed(STEPPER_SPEED_DIV4); by_stepper_set_speed(STEPPER_SPEED_DIV1);
while (gpio_input_data_bit_read(GPIOB, GPIO_PINS_10) == SET) { while (gpio_input_data_bit_read(GPIOB, GPIO_PINS_10) == SET) {
gpio_bits_write(GPIOA, GPIO_PINS_8, by_stepper.dir ? TRUE : FALSE); // DIR gpio_bits_write(GPIOA, GPIO_PINS_8, by_stepper.dir ? TRUE : FALSE); // DIR
gpio_bits_write(GPIOB, GPIO_PINS_15, !gpio_output_data_bit_read(GPIOB, GPIO_PINS_15)); // CLK gpio_bits_write(GPIOB, GPIO_PINS_15, !gpio_output_data_bit_read(GPIOB, GPIO_PINS_15)); // CLK
DWT_Delay(40U * (uint16_t)by_stepper.speed); DWT_Delay(30U * (uint16_t)by_stepper.speed);
} }
position = 0; // 位置归零 position = 0; // 位置归零
@@ -130,6 +137,8 @@ void by_stepper_init(void)
tmr_counter_value_set(TMR3, 0); tmr_counter_value_set(TMR3, 0);
LOGD("by_stepper init ok"); LOGD("by_stepper init ok");
by_stepper_set_position_millimeter(160.0f);
} }
void by_stepper_loop(void) void by_stepper_loop(void)