This commit is contained in:
janik
2026-02-27 17:31:42 +07:00
parent 87bd6ef982
commit eddce0bc68
13 changed files with 15687 additions and 14973 deletions

View File

@@ -80,9 +80,18 @@ static inline pid_motor_cmd_t pid_update_motor(pid_i32_t *pid,
{
pid_motor_cmd_t cmd;
// Basic PID (no overflow protection, as requested)
int32_t error = setpoint - position;
// Deadband: if within ±3 counts, hold position and reset integrator
if (error >= -3 && error <= 3) {
pid->integrator = 0;
pid->prev_error = 0;
pid->last_output = 0;
cmd.pwm = 0;
cmd.dir = 1;
return cmd;
}
int32_t p = pid->kp * error;
int32_t i = pid->integrator + pid->ki * error;

View File

@@ -145,12 +145,12 @@ uint8_t DMA_buffer[64];
uint8_t my_address = 0xFF;
int32_t total_count = 0;
int32_t target_count = 0;
int32_t kp = 4;
int32_t kp = 6;
int32_t ki = 1;
int32_t kd = 0;
int32_t i_min = -500;
int32_t i_max = 500;
int32_t pid_max_step = 10;
int32_t kd = 3;
int32_t i_min = -800;
int32_t i_max = 800;
int32_t pid_max_step = 25;
pid_i32_t motor_pid;
pid_motor_cmd_t motor_cmd;
uint8_t vendor_options[VENDOR_SPECIFIC_OPTIONS_LENGTH];
@@ -178,6 +178,12 @@ uint8_t beefy_tape = 0; // thick tape detected
// Version string
const char VERSION_STRING[] = "2.0.0-dev";
// Peel motor ramp state
#define PEEL_RAMP_TIME_MS 100
int16_t peel_target_pwm = 0; // Target: positive=fwd, negative=rev, 0=stop
int16_t peel_current_pwm = 0; // Current ramped value
uint32_t peel_last_ramp_time = 0;
// Button/driving state
uint8_t drive_mode = 0; // 0 = tape drive, 1 = film peel
uint8_t driving = 0; // currently in continuous drive mode
@@ -229,6 +235,7 @@ void set_Feeder_PWM(uint16_t PWM, uint8_t direction);
void update_Feeder_Target(int32_t difference);
void peel_motor(uint8_t forward);
void peel_brake(void);
void peel_ramp_update(void);
void drive_continuous(uint8_t forward);
void halt_all(void);
void identify_feeder(void);
@@ -327,8 +334,10 @@ int main(void)
HAL_TIM_Encoder_Start(&htim3, TIM_CHANNEL_ALL);
// Start PWM timer (TIM1) for motor control
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1);
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_2);
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1); // Feed motor
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_2); // Feed motor
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_3); // Peel motor
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_4); // Peel motor
// Start PID control timer (TIM14) with interrupt
HAL_TIM_Base_Start_IT(&htim14);
@@ -373,24 +382,76 @@ int main(void)
{
if ((driving_direction && sw2_state) || (!driving_direction && sw1_state))
{
// Button released, stop driving
halt_all();
driving = 0;
HAL_TIM_Base_Stop(&htim16);
HAL_TIM_Base_Stop(&htim17);
sw1_pressed = 0;
sw2_pressed = 0;
sw1_long_handled = 0;
sw2_long_handled = 0;
set_LED(0, 0, 0);
}
else if (!drive_mode)
{
// Tape mode: keep target ahead of current position
if (driving_direction)
target_count = total_count + 10000;
else
target_count = total_count - 10000;
}
else // Not currently driving, check for button presses
}
else if (both_pressed_handled)
{
// Check for both buttons pressed (long hold)
if (sw1_pressed && sw2_pressed && !sw1_state && !sw2_state)
// Both-press mode: wait for release, handle long-hold actions
if (sw1_state && sw2_state)
{
uint16_t time1 = htim16.Instance->CNT;
uint16_t time2 = htim17.Instance->CNT;
uint16_t min_time = (time1 < time2) ? time1 : time2;
// Both released - show mode color briefly then clear
both_pressed_handled = 0;
HAL_TIM_Base_Stop(&htim16);
HAL_TIM_Base_Stop(&htim17);
sw1_pressed = 0;
sw2_pressed = 0;
sw1_long_handled = 0;
sw2_long_handled = 0;
HAL_Delay(400);
set_LED(0, 0, 0);
}
else
{
// Still holding - check for long-hold actions
uint32_t hold_time = HAL_GetTick() - both_pressed_start;
if (hold_time > 2000 && hold_time < 2100)
{
show_version();
}
else if (hold_time > 4000 && hold_time < 6000)
{
set_LED((hold_time / 100) % 2, 0, !((hold_time / 100) % 2));
}
else if (hold_time >= 6000)
{
set_LED(1, 0, 1);
HAL_Delay(100);
NVIC_SystemReset();
}
}
}
else if (sw1_pressed || sw2_pressed)
{
// At least one button pressed - use decision window
uint16_t time1 = sw1_pressed ? htim16.Instance->CNT : 0;
uint16_t time2 = sw2_pressed ? htim17.Instance->CNT : 0;
uint16_t max_time = (time1 > time2) ? time1 : time2;
if (min_time > 500 && !both_pressed_handled)
// Wait 100ms decision window before acting (unless already past it)
if (max_time < 100)
{
// Both long press - toggle drive mode
// Still in decision window - do nothing yet
}
else if (sw1_pressed && sw2_pressed && !sw1_state && !sw2_state)
{
// Both pressed - toggle mode
both_pressed_handled = 1;
both_pressed_start = HAL_GetTick();
if (drive_mode)
@@ -404,116 +465,84 @@ int main(void)
set_LED(1, 1, 0); // Yellow = peel mode
}
}
else if (both_pressed_handled)
else if (sw1_pressed && !sw2_pressed)
{
uint32_t hold_time = HAL_GetTick() - both_pressed_start;
if (hold_time > 2000 && hold_time < 2100)
// Single SW1 handling
if (!sw1_state && time1 > 2000 && !sw1_long_handled)
{
// Show version after 2 seconds
show_version();
}
else if (hold_time > 4000 && hold_time < 6000)
{
// Flash warning for bootloader
set_LED((hold_time / 100) % 2, 0, !((hold_time / 100) % 2));
}
else if (hold_time >= 6000)
{
// Reboot into bootloader
set_LED(1, 0, 1); // Magenta
HAL_Delay(100);
NVIC_SystemReset();
}
}
}
// SW1 (bottom button) handling
else if (sw1_pressed)
{
uint16_t time_pressed = htim16.Instance->CNT;
if (!sw1_state && time_pressed > 500 && !sw1_long_handled) // button still pressed, long press
{
// Long press SW1 - continuous backward
sw1_long_handled = 1;
set_LED(1, 1, 1); // White while driving
set_LED(1, 1, 1);
if (drive_mode)
{
peel_motor(0); // peel backward
}
peel_motor(0);
else
{
drive_continuous(0); // drive backward
}
drive_continuous(0);
driving = 1;
driving_direction = 0;
}
else if (sw1_state && time_pressed <= 500 && time_pressed > 50) // released, short press
else if (sw1_state && time1 <= 2000 && time1 > 100)
{
// Short press SW1 - feed backward 2mm
set_LED(1, 1, 1);
start_feed(20, 0); // 20 tenths = 2mm backward
start_feed(20, 0);
HAL_TIM_Base_Stop(&htim16);
sw1_pressed = 0;
sw1_long_handled = 0;
}
else if (sw1_state) // released
else if (sw1_state)
{
HAL_TIM_Base_Stop(&htim16);
sw1_pressed = 0;
sw1_long_handled = 0;
if (!driving) set_LED(0, 0, 0);
}
}
// SW2 (top button) handling
else if (sw2_pressed)
else if (sw2_pressed && !sw1_pressed)
{
uint16_t time_pressed = htim17.Instance->CNT;
if (!sw2_state && time_pressed > 500 && !sw2_long_handled) // button still pressed, long press
// Single SW2 handling
if (!sw2_state && time2 > 2000 && !sw2_long_handled)
{
// Long press SW2 - continuous forward
sw2_long_handled = 1;
set_LED(1, 1, 1); // White while driving
set_LED(1, 1, 1);
if (drive_mode)
{
peel_motor(1); // peel forward
}
peel_motor(1);
else
{
drive_continuous(1); // drive forward
}
drive_continuous(1);
driving = 1;
driving_direction = 1;
}
else if (sw2_state && time_pressed <= 500 && time_pressed > 50) // released, short press
else if (sw2_state && time2 <= 2000 && time2 > 100)
{
// Short press SW2 - feed forward 2mm
set_LED(1, 1, 1);
start_feed(20, 1); // 20 tenths = 2mm forward
start_feed(20, 1);
HAL_TIM_Base_Stop(&htim17);
sw2_pressed = 0;
sw2_long_handled = 0;
}
else if (sw2_state) // released
else if (sw2_state)
{
HAL_TIM_Base_Stop(&htim17);
sw2_pressed = 0;
sw2_long_handled = 0;
if (!driving) set_LED(0, 0, 0);
}
}
// Reset both_pressed_handled when buttons released
if ((sw1_state || !sw1_pressed) && (sw2_state || !sw2_pressed))
else if (sw1_state && sw2_state)
{
if (both_pressed_handled)
{
both_pressed_handled = 0;
HAL_Delay(50); // debounce
set_LED(0, 0, 0);
}
// Both released without triggering both-press (one was released too fast)
HAL_TIM_Base_Stop(&htim16);
HAL_TIM_Base_Stop(&htim17);
sw1_pressed = 0;
sw2_pressed = 0;
sw1_long_handled = 0;
sw2_long_handled = 0;
}
}
// Update feed state machine
feed_state_machine_update();
// Ramp peel motor PWM
peel_ramp_update();
// Debug output via USART1
debug_output();
@@ -1002,15 +1031,7 @@ static void MX_GPIO_Init(void)
HAL_NVIC_EnableIRQ(EXTI4_15_IRQn);
/* USER CODE BEGIN MX_GPIO_Init_2 */
/*Configure GPIO pins : PEEL1_Pin PEEL2_Pin */
HAL_GPIO_WritePin(GPIOA, PEEL1_Pin|PEEL2_Pin, GPIO_PIN_RESET);
GPIO_InitStruct.Pin = PEEL1_Pin|PEEL2_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
// PEEL1/PEEL2 (PA2/PA3) are TIM1_CH3/CH4 - configured by MX_TIM1_Init
/* USER CODE END MX_GPIO_Init_2 */
}
@@ -1092,12 +1113,13 @@ void HAL_TIM_PeriodElapsedCallback (TIM_HandleTypeDef * htim)
}
}
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
void HAL_GPIO_EXTI_Falling_Callback(uint16_t GPIO_Pin)
{
if(GPIO_Pin == SW1_Pin) // SW1 (lower button)
{
if (!sw1_pressed)
{
htim16.Instance->CNT = 0;
HAL_TIM_Base_Start_IT(&htim16);
sw1_pressed = 1;
// now the main loop has to sample sw1_pressed and act. It can check how long its been pressed by reading TIM->CNT
@@ -1108,6 +1130,7 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
if (!sw2_pressed)
{
htim17.Instance->CNT = 0;
HAL_TIM_Base_Start_IT(&htim17);
sw2_pressed = 1;
}
@@ -1482,8 +1505,12 @@ void update_Feeder_Target(int32_t difference)
#define FEED_PWM_MIN_THRESHOLD 840 // 35% of 2400 - below this, don't drive
void set_Feeder_PWM(uint16_t PWM, uint8_t direction)
{
if (PWM > 0 && PWM < FEED_PWM_MIN_THRESHOLD) PWM = 0;
if (direction)
{
htim1.Instance->CCR1 = PWM;
@@ -1498,37 +1525,69 @@ void set_Feeder_PWM(uint16_t PWM, uint8_t direction)
void peel_motor(uint8_t forward)
{
if (forward)
{
HAL_GPIO_WritePin(PEEL1_GPIO_Port, PEEL1_Pin, GPIO_PIN_SET);
HAL_GPIO_WritePin(PEEL2_GPIO_Port, PEEL2_Pin, GPIO_PIN_RESET);
}
else
{
HAL_GPIO_WritePin(PEEL1_GPIO_Port, PEEL1_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(PEEL2_GPIO_Port, PEEL2_Pin, GPIO_PIN_SET);
}
peel_target_pwm = forward ? PWM_MAX : -PWM_MAX;
}
void peel_brake(void)
{
// Both high = brake (or both low depending on driver)
HAL_GPIO_WritePin(PEEL1_GPIO_Port, PEEL1_Pin, GPIO_PIN_SET);
HAL_GPIO_WritePin(PEEL2_GPIO_Port, PEEL2_Pin, GPIO_PIN_SET);
peel_target_pwm = 0;
}
void peel_ramp_update(void)
{
uint32_t now = HAL_GetTick();
uint32_t dt = now - peel_last_ramp_time;
if (dt == 0) return;
peel_last_ramp_time = now;
if (peel_current_pwm == peel_target_pwm) return;
// Step size: full range (PWM_MAX) in PEEL_RAMP_TIME_MS
int16_t step = (int16_t)((int32_t)PWM_MAX * dt / PEEL_RAMP_TIME_MS);
if (step < 1) step = 1;
if (peel_target_pwm > peel_current_pwm)
{
peel_current_pwm += step;
if (peel_current_pwm > peel_target_pwm)
peel_current_pwm = peel_target_pwm;
}
else
{
peel_current_pwm -= step;
if (peel_current_pwm < peel_target_pwm)
peel_current_pwm = peel_target_pwm;
}
// Apply to TIM1 CH3/CH4
if (peel_current_pwm > 0)
{
htim1.Instance->CCR3 = peel_current_pwm;
htim1.Instance->CCR4 = 0;
}
else if (peel_current_pwm < 0)
{
htim1.Instance->CCR3 = 0;
htim1.Instance->CCR4 = -peel_current_pwm;
}
else
{
htim1.Instance->CCR3 = 0;
htim1.Instance->CCR4 = 0;
}
}
void drive_continuous(uint8_t forward)
{
// Set full PWM for continuous drive
// Bypass PID - set target far away in the desired direction so PID drives at max
pid_reset(&motor_pid);
if (forward)
{
htim1.Instance->CCR1 = 0;
htim1.Instance->CCR2 = PWM_MAX;
target_count = total_count + 10000;
}
else
{
htim1.Instance->CCR1 = PWM_MAX;
htim1.Instance->CCR2 = 0;
target_count = total_count - 10000;
}
}
@@ -1538,8 +1597,11 @@ void halt_all(void)
htim1.Instance->CCR1 = PWM_MAX;
htim1.Instance->CCR2 = PWM_MAX;
// Stop peel motor
peel_brake();
// Stop peel motor immediately
peel_target_pwm = 0;
peel_current_pwm = 0;
htim1.Instance->CCR3 = 0;
htim1.Instance->CCR4 = 0;
// Reset PID state to prevent sudden movement
pid_reset(&motor_pid);
@@ -1628,11 +1690,15 @@ void start_feed(int16_t distance_tenths, uint8_t forward)
if (forward)
{
// Forward feed: start with peeling
// Forward feed: drive both motors simultaneously
feed_state = FEED_STATE_PEEL_FORWARD;
feed_state_start_time = HAL_GetTick();
feed_state_duration = distance_tenths * PEEL_TIME_PER_TENTH_MM;
peel_motor(1); // Peel forward
// Start feed motor at the same time
feed_timeout_time = HAL_GetTick() + (distance_tenths * TIMEOUT_TIME_PER_TENTH_MM) + 500;
feed_target_position = total_count + tenths_to_counts(distance_tenths);
target_count = feed_target_position;
}
else
{
@@ -1658,27 +1724,13 @@ void feed_state_machine_update(void)
switch (feed_state)
{
case FEED_STATE_PEEL_FORWARD:
// Peeling film before forward drive
// Peeling film while feed motor drives simultaneously
if (elapsed >= feed_state_duration)
{
peel_motor(0); // Brief reverse peel
feed_state = FEED_STATE_PEEL_BACKOFF;
feed_state_start_time = now;
feed_state_duration = PEEL_BACKOFF_TIME;
}
break;
case FEED_STATE_PEEL_BACKOFF:
// Brief reverse peel to reduce tension
if (elapsed >= feed_state_duration)
{
peel_brake();
// Start driving
peel_brake(); // Peel done, feed motor continues via PID
feed_state = FEED_STATE_DRIVING;
feed_state_start_time = now;
feed_timeout_time = now + (feed_distance_tenths * TIMEOUT_TIME_PER_TENTH_MM) + 500;
feed_target_position = total_count + tenths_to_counts(feed_distance_tenths);
target_count = feed_target_position;
// feed_target_position and feed_timeout_time already set in start_feed
}
break;
@@ -2307,9 +2359,17 @@ void debug_output(void)
*p++ = '0' + sw1_pressed;
*p++ = '0' + sw2_pressed;
// Raw GPIO pin state: 1=high(released), 0=low(pressed)
*p++ = ','; *p++ = 'G'; *p++ = ':';
*p++ = '0' + (uint8_t)HAL_GPIO_ReadPin(SW1_GPIO_Port, SW1_Pin);
*p++ = '0' + (uint8_t)HAL_GPIO_ReadPin(SW2_GPIO_Port, SW2_Pin);
*p++ = ','; *p++ = 'D'; *p++ = ':';
p += debug_itoa(current_drive_value, p);
*p++ = ','; *p++ = 'M'; *p++ = ':';
*p++ = '0' + drive_mode;
*p++ = '*'; *p++ = '\r'; *p++ = '\n';
HAL_UART_Transmit(&huart1, (uint8_t*)debug_tx_buffer, p - debug_tx_buffer, 10);

View File

@@ -2,57 +2,58 @@
../Core/Inc/pid.h:39:23:clamp_i32 3
../Core/Inc/pid.h:46:20:pid_init 1
../Core/Inc/pid.h:70:20:pid_reset 1
../Core/Inc/pid.h:77:31:pid_update_motor 8
../Core/Inc/pid.h:77:31:pid_update_motor 10
../Core/Inc/crc.h:18:20:CRC8_107_init 1
../Core/Src/main.c:284:5:main 52
../Core/Src/main.c:569:6:SystemClock_Config 3
../Core/Src/main.c:608:13:MX_TIM1_Init 10
../Core/Src/main.c:702:13:MX_TIM3_Init 3
../Core/Src/main.c:751:13:MX_TIM14_Init 2
../Core/Src/main.c:782:13:MX_TIM16_Init 2
../Core/Src/main.c:814:13:MX_TIM17_Init 2
../Core/Src/main.c:846:13:MX_USART1_UART_Init 5
../Core/Src/main.c:894:13:MX_USART2_UART_Init 5
../Core/Src/main.c:940:13:MX_DMA_Init 1
../Core/Src/main.c:961:13:MX_GPIO_Init 1
../Core/Src/main.c:1019:6:HAL_TIM_PeriodElapsedCallback 15
../Core/Src/main.c:1095:6:HAL_GPIO_EXTI_Callback 5
../Core/Src/main.c:1117:6:HAL_UARTEx_RxEventCallback 4
../Core/Src/main.c:1139:6:set_LED 4
../Core/Src/main.c:1149:6:comp_crc_header 1
../Core/Src/main.c:1157:6:handleRS485Message 41
../Core/Src/main.c:1458:6:update_Feeder_Target 8
../Core/Src/main.c:1485:6:set_Feeder_PWM 2
../Core/Src/main.c:1499:6:peel_motor 2
../Core/Src/main.c:1513:6:peel_brake 1
../Core/Src/main.c:1520:6:drive_continuous 2
../Core/Src/main.c:1535:6:halt_all 1
../Core/Src/main.c:1550:6:identify_feeder 2
../Core/Src/main.c:1562:6:show_version 1
../Core/Src/main.c:1572:9:tenths_to_counts 1
../Core/Src/main.c:1580:10:calculate_expected_feed_time 3
../Core/Src/main.c:1608:6:start_feed 4
../Core/Src/main.c:1648:6:feed_state_machine_update 31
../Core/Src/main.c:1849:6:check_tape_loaded 5
../Core/Src/main.c:1896:6:handle_vendor_options 7
../Core/Src/main.c:1953:6:stall_detection_init 3
../Core/Src/main.c:1965:6:stall_detection_update 3
../Core/Src/main.c:1980:9:check_stall 4
../Core/Src/main.c:2001:6:onewire_delay_us 2
../Core/Src/main.c:2008:6:onewire_set_output 1
../Core/Src/main.c:2018:6:onewire_set_input 1
../Core/Src/main.c:2027:6:onewire_write_low 1
../Core/Src/main.c:2032:6:onewire_write_high 1
../Core/Src/main.c:2037:9:onewire_read_bit 1
../Core/Src/main.c:2043:9:onewire_reset 1
../Core/Src/main.c:2061:6:onewire_write_bit 2
../Core/Src/main.c:2083:9:onewire_read_bit_slot 1
../Core/Src/main.c:2101:6:onewire_write_byte 2
../Core/Src/main.c:2110:9:onewire_read_byte 3
../Core/Src/main.c:2125:9:read_floor_address 2
../Core/Src/main.c:2155:9:write_floor_address 7
../Core/Src/main.c:2250:9:debug_itoa 6
../Core/Src/main.c:2266:9:debug_hex8 1
../Core/Src/main.c:2274:6:debug_output 3
../Core/Src/main.c:2322:6:reset_position_if_needed 3
../Core/Src/main.c:2355:6:Error_Handler 1
../Core/Src/main.c:291:5:main 58
../Core/Src/main.c:598:6:SystemClock_Config 3
../Core/Src/main.c:637:13:MX_TIM1_Init 10
../Core/Src/main.c:731:13:MX_TIM3_Init 3
../Core/Src/main.c:780:13:MX_TIM14_Init 2
../Core/Src/main.c:811:13:MX_TIM16_Init 2
../Core/Src/main.c:843:13:MX_TIM17_Init 2
../Core/Src/main.c:875:13:MX_USART1_UART_Init 5
../Core/Src/main.c:923:13:MX_USART2_UART_Init 5
../Core/Src/main.c:969:13:MX_DMA_Init 1
../Core/Src/main.c:990:13:MX_GPIO_Init 1
../Core/Src/main.c:1040:6:HAL_TIM_PeriodElapsedCallback 15
../Core/Src/main.c:1116:6:HAL_GPIO_EXTI_Falling_Callback 5
../Core/Src/main.c:1140:6:HAL_UARTEx_RxEventCallback 4
../Core/Src/main.c:1162:6:set_LED 4
../Core/Src/main.c:1172:6:comp_crc_header 1
../Core/Src/main.c:1180:6:handleRS485Message 41
../Core/Src/main.c:1481:6:update_Feeder_Target 8
../Core/Src/main.c:1510:6:set_Feeder_PWM 4
../Core/Src/main.c:1526:6:peel_motor 2
../Core/Src/main.c:1531:6:peel_brake 1
../Core/Src/main.c:1536:6:peel_ramp_update 9
../Core/Src/main.c:1580:6:drive_continuous 2
../Core/Src/main.c:1594:6:halt_all 1
../Core/Src/main.c:1612:6:identify_feeder 2
../Core/Src/main.c:1624:6:show_version 1
../Core/Src/main.c:1634:9:tenths_to_counts 1
../Core/Src/main.c:1642:10:calculate_expected_feed_time 3
../Core/Src/main.c:1670:6:start_feed 4
../Core/Src/main.c:1714:6:feed_state_machine_update 29
../Core/Src/main.c:1901:6:check_tape_loaded 5
../Core/Src/main.c:1948:6:handle_vendor_options 7
../Core/Src/main.c:2005:6:stall_detection_init 3
../Core/Src/main.c:2017:6:stall_detection_update 3
../Core/Src/main.c:2032:9:check_stall 4
../Core/Src/main.c:2053:6:onewire_delay_us 2
../Core/Src/main.c:2060:6:onewire_set_output 1
../Core/Src/main.c:2070:6:onewire_set_input 1
../Core/Src/main.c:2079:6:onewire_write_low 1
../Core/Src/main.c:2084:6:onewire_write_high 1
../Core/Src/main.c:2089:9:onewire_read_bit 1
../Core/Src/main.c:2095:9:onewire_reset 1
../Core/Src/main.c:2113:6:onewire_write_bit 2
../Core/Src/main.c:2135:9:onewire_read_bit_slot 1
../Core/Src/main.c:2153:6:onewire_write_byte 2
../Core/Src/main.c:2162:9:onewire_read_byte 3
../Core/Src/main.c:2177:9:read_floor_address 2
../Core/Src/main.c:2207:9:write_floor_address 7
../Core/Src/main.c:2302:9:debug_itoa 6
../Core/Src/main.c:2318:9:debug_hex8 1
../Core/Src/main.c:2326:6:debug_output 3
../Core/Src/main.c:2382:6:reset_position_if_needed 3
../Core/Src/main.c:2415:6:Error_Handler 1

Binary file not shown.

View File

@@ -4,55 +4,56 @@
../Core/Inc/pid.h:70:20:pid_reset 16 static
../Core/Inc/pid.h:77:31:pid_update_motor 72 static
../Core/Inc/crc.h:18:20:CRC8_107_init 16 static
../Core/Src/main.c:284:5:main 64 static
../Core/Src/main.c:569:6:SystemClock_Config 64 static
../Core/Src/main.c:608:13:MX_TIM1_Init 120 static
../Core/Src/main.c:702:13:MX_TIM3_Init 64 static
../Core/Src/main.c:751:13:MX_TIM14_Init 8 static
../Core/Src/main.c:782:13:MX_TIM16_Init 8 static
../Core/Src/main.c:814:13:MX_TIM17_Init 8 static
../Core/Src/main.c:846:13:MX_USART1_UART_Init 8 static
../Core/Src/main.c:894:13:MX_USART2_UART_Init 8 static
../Core/Src/main.c:940:13:MX_DMA_Init 16 static
../Core/Src/main.c:961:13:MX_GPIO_Init 56 static
../Core/Src/main.c:1019:6:HAL_TIM_PeriodElapsedCallback 40 static
../Core/Src/main.c:1095:6:HAL_GPIO_EXTI_Callback 16 static
../Core/Src/main.c:1117:6:HAL_UARTEx_RxEventCallback 16 static
../Core/Src/main.c:1139:6:set_LED 24 static
../Core/Src/main.c:1149:6:comp_crc_header 16 static
../Core/Src/main.c:1157:6:handleRS485Message 144 static
../Core/Src/main.c:1458:6:update_Feeder_Target 24 static
../Core/Src/main.c:1485:6:set_Feeder_PWM 16 static
../Core/Src/main.c:1499:6:peel_motor 16 static
../Core/Src/main.c:1513:6:peel_brake 8 static
../Core/Src/main.c:1520:6:drive_continuous 16 static
../Core/Src/main.c:1535:6:halt_all 8 static
../Core/Src/main.c:1550:6:identify_feeder 16 static
../Core/Src/main.c:1562:6:show_version 8 static
../Core/Src/main.c:1572:9:tenths_to_counts 32 static
../Core/Src/main.c:1580:10:calculate_expected_feed_time 24 static
../Core/Src/main.c:1608:6:start_feed 16 static
../Core/Src/main.c:1648:6:feed_state_machine_update 40 static
../Core/Src/main.c:1849:6:check_tape_loaded 24 static
../Core/Src/main.c:1896:6:handle_vendor_options 56 static
../Core/Src/main.c:1953:6:stall_detection_init 16 static
../Core/Src/main.c:1965:6:stall_detection_update 24 static
../Core/Src/main.c:1980:9:check_stall 32 static
../Core/Src/main.c:2001:6:onewire_delay_us 24 static,ignoring_inline_asm
../Core/Src/main.c:2008:6:onewire_set_output 32 static
../Core/Src/main.c:2018:6:onewire_set_input 32 static
../Core/Src/main.c:2027:6:onewire_write_low 8 static
../Core/Src/main.c:2032:6:onewire_write_high 8 static
../Core/Src/main.c:2037:9:onewire_read_bit 8 static
../Core/Src/main.c:2043:9:onewire_reset 16 static
../Core/Src/main.c:2061:6:onewire_write_bit 16 static
../Core/Src/main.c:2083:9:onewire_read_bit_slot 24 static
../Core/Src/main.c:2101:6:onewire_write_byte 24 static
../Core/Src/main.c:2110:9:onewire_read_byte 16 static
../Core/Src/main.c:2125:9:read_floor_address 24 static,ignoring_inline_asm
../Core/Src/main.c:2155:9:write_floor_address 40 static,ignoring_inline_asm
../Core/Src/main.c:2250:9:debug_itoa 32 static
../Core/Src/main.c:2266:9:debug_hex8 48 static
../Core/Src/main.c:2274:6:debug_output 16 static
../Core/Src/main.c:2322:6:reset_position_if_needed 16 static,ignoring_inline_asm
../Core/Src/main.c:2355:6:Error_Handler 8 static,ignoring_inline_asm
../Core/Src/main.c:291:5:main 64 static
../Core/Src/main.c:598:6:SystemClock_Config 64 static
../Core/Src/main.c:637:13:MX_TIM1_Init 120 static
../Core/Src/main.c:731:13:MX_TIM3_Init 64 static
../Core/Src/main.c:780:13:MX_TIM14_Init 8 static
../Core/Src/main.c:811:13:MX_TIM16_Init 8 static
../Core/Src/main.c:843:13:MX_TIM17_Init 8 static
../Core/Src/main.c:875:13:MX_USART1_UART_Init 8 static
../Core/Src/main.c:923:13:MX_USART2_UART_Init 8 static
../Core/Src/main.c:969:13:MX_DMA_Init 16 static
../Core/Src/main.c:990:13:MX_GPIO_Init 56 static
../Core/Src/main.c:1040:6:HAL_TIM_PeriodElapsedCallback 40 static
../Core/Src/main.c:1116:6:HAL_GPIO_EXTI_Falling_Callback 16 static
../Core/Src/main.c:1140:6:HAL_UARTEx_RxEventCallback 16 static
../Core/Src/main.c:1162:6:set_LED 24 static
../Core/Src/main.c:1172:6:comp_crc_header 16 static
../Core/Src/main.c:1180:6:handleRS485Message 144 static
../Core/Src/main.c:1481:6:update_Feeder_Target 24 static
../Core/Src/main.c:1510:6:set_Feeder_PWM 16 static
../Core/Src/main.c:1526:6:peel_motor 16 static
../Core/Src/main.c:1531:6:peel_brake 8 static
../Core/Src/main.c:1536:6:peel_ramp_update 24 static
../Core/Src/main.c:1580:6:drive_continuous 16 static
../Core/Src/main.c:1594:6:halt_all 8 static
../Core/Src/main.c:1612:6:identify_feeder 16 static
../Core/Src/main.c:1624:6:show_version 8 static
../Core/Src/main.c:1634:9:tenths_to_counts 32 static
../Core/Src/main.c:1642:10:calculate_expected_feed_time 24 static
../Core/Src/main.c:1670:6:start_feed 16 static
../Core/Src/main.c:1714:6:feed_state_machine_update 40 static
../Core/Src/main.c:1901:6:check_tape_loaded 24 static
../Core/Src/main.c:1948:6:handle_vendor_options 56 static
../Core/Src/main.c:2005:6:stall_detection_init 16 static
../Core/Src/main.c:2017:6:stall_detection_update 24 static
../Core/Src/main.c:2032:9:check_stall 32 static
../Core/Src/main.c:2053:6:onewire_delay_us 24 static,ignoring_inline_asm
../Core/Src/main.c:2060:6:onewire_set_output 32 static
../Core/Src/main.c:2070:6:onewire_set_input 32 static
../Core/Src/main.c:2079:6:onewire_write_low 8 static
../Core/Src/main.c:2084:6:onewire_write_high 8 static
../Core/Src/main.c:2089:9:onewire_read_bit 8 static
../Core/Src/main.c:2095:9:onewire_reset 16 static
../Core/Src/main.c:2113:6:onewire_write_bit 16 static
../Core/Src/main.c:2135:9:onewire_read_bit_slot 24 static
../Core/Src/main.c:2153:6:onewire_write_byte 24 static
../Core/Src/main.c:2162:9:onewire_read_byte 16 static
../Core/Src/main.c:2177:9:read_floor_address 24 static,ignoring_inline_asm
../Core/Src/main.c:2207:9:write_floor_address 40 static,ignoring_inline_asm
../Core/Src/main.c:2302:9:debug_itoa 32 static
../Core/Src/main.c:2318:9:debug_hex8 48 static
../Core/Src/main.c:2326:6:debug_output 16 static
../Core/Src/main.c:2382:6:reset_position_if_needed 16 static,ignoring_inline_asm
../Core/Src/main.c:2415:6:Error_Handler 8 static,ignoring_inline_asm

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

89
code/feeder_mk2.launch Normal file
View File

@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="com.st.stm32cube.ide.mcu.debug.launch.launchConfigurationType">
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.access_port_id" value="0"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.cubeprog_external_loaders" value="[]"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.debug_auth__pwd_enable" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.debug_auth_certif_path" value=""/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.debug_auth_check_enable" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.debug_auth_key_path" value=""/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.debug_auth_permission" value=""/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.debug_auth_pwd_file" value=""/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.enable_live_expr" value="true"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.enable_swv" value="false"/>
<intAttribute key="com.st.stm32cube.ide.mcu.debug.launch.formatVersion" value="2"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.incremental_flashing" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.ip_address_local" value="localhost"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.limit_swo_clock.enabled" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.limit_swo_clock.value" value=""/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.loadList" value="{&quot;fItems&quot;:[{&quot;fIsFromMainTab&quot;:true,&quot;fPath&quot;:&quot;Debug/feeder_mk2.elf&quot;,&quot;fProjectName&quot;:&quot;feeder_mk2&quot;,&quot;fPerformBuild&quot;:true,&quot;fDownload&quot;:true,&quot;fLoadSymbols&quot;:true}]}"/>
<intAttribute key="com.st.stm32cube.ide.mcu.debug.launch.mode" value="0"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.override_start_address_mode" value="default"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.port" value=""/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.remoteCommand" value="target remote"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.semihosting" value="Disabled"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startServer" value="true"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startuptab.exception.divby0" value="true"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startuptab.exception.unaligned" value="false"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startuptab.haltonexception" value="true"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swd_mode" value="true"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swv_port" value="61235"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swv_trace_hclk" value="48000000"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.useRemoteTarget" value="true"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.vector_table" value=""/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.verify_flash_download" value="true"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.cti_allow_halt" value="false"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.cti_signal_halt" value="false"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.enable_logging" value="false"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.enable_max_halt_delay" value="false"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.enable_shared_stlink" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.frequency" value="140"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.halt_all_on_reset" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.log_file" value="C:\Users\janik\feeder_mk2\code\Debug\st-link_gdbserver_log.txt"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.low_power_debug" value="enable"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.max_halt_delay" value="2"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.reset_strategy" value="connect_under_reset"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.stlink_check_serial_number" value="true"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.stlink_txt_serial_number" value="005300393133510B33313735"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.watchdog_config" value="none"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkenable_rtos" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkrestart_configurations" value="{&quot;fVersion&quot;:1,&quot;fItems&quot;:[{&quot;fDisplayName&quot;:&quot;Reset&quot;,&quot;fIsSuppressible&quot;:false,&quot;fResetAttribute&quot;:&quot;Software system reset&quot;,&quot;fResetStrategies&quot;:[{&quot;fDisplayName&quot;:&quot;Software system reset&quot;,&quot;fLaunchAttribute&quot;:&quot;system_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset\r\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Hardware reset&quot;,&quot;fLaunchAttribute&quot;:&quot;hardware_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset hardware\r\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Core reset&quot;,&quot;fLaunchAttribute&quot;:&quot;core_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset core\r\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;None&quot;,&quot;fLaunchAttribute&quot;:&quot;no_reset&quot;,&quot;fGdbCommands&quot;:[],&quot;fCmdOptions&quot;:[&quot;-g&quot;]}],&quot;fGdbCommandGroup&quot;:{&quot;name&quot;:&quot;Additional commands&quot;,&quot;commands&quot;:[]},&quot;fStartApplication&quot;:true}]}"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.enableRtosProxy" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyCustomProperties" value=""/>
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriver" value="threadx"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriverAuto" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriverPort" value="cortex_m0"/>
<intAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyPort" value="60000"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doHalt" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doReset" value="false"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.initCommands" value=""/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDeviceId" value="com.st.stm32cube.ide.mcu.debug.stlink"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="61234"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.runCommands" value=""/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/>
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="arm-none-eabi-gdb"/>
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.NON_STOP" value="false"/>
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.UPDATE_THREADLIST_ON_SUSPEND" value="false"/>
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_START_MODE" value="remote"/>
<booleanAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN" value="true"/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN_SYMBOL" value="main"/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="Debug/feeder_mk2.elf"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="feeder_mk2"/>
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="true"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value=""/>
<booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/feeder_mk2"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;memoryBlockExpressionList context=&quot;reserved-for-future-use&quot;/&gt;"/>
<stringAttribute key="process_factory_id" value="com.st.stm32cube.ide.mcu.debug.launch.HardwareDebugProcessFactory"/>
</launchConfiguration>

View File

@@ -78,6 +78,7 @@ class FeederMonitor:
self.sw1_pressed = False
self.sw2_pressed = False
self.drive_value = 0
self.drive_mode = 0
# Statistics
self.packet_count = 0
@@ -170,6 +171,9 @@ class FeederMonitor:
elif part.startswith('D:'):
self.drive_value = int(part[2:])
elif part.startswith('M:'):
self.drive_mode = int(part[2:])
self.packet_count += 1
self.last_packet_time = time.time()
return True
@@ -304,7 +308,8 @@ class FeederMonitor:
feed_icon = f"{Colors.YELLOW}{Colors.RESET}" if self.feed_in_progress else f"{Colors.DIM}{Colors.RESET}"
beefy_icon = f"{Colors.MAGENTA}{Colors.RESET}" if self.beefy_tape else f"{Colors.DIM}{Colors.RESET}"
print(f"{Colors.CYAN}{Colors.RESET} {init_icon} Initialized {feed_icon} Feeding {beefy_icon} Beefy Tape {Colors.CYAN}{Colors.RESET}")
mode_str = f"{Colors.YELLOW}PEEL{Colors.RESET}" if self.drive_mode else f"{Colors.BLUE}TAPE{Colors.RESET}"
print(f"{Colors.CYAN}{Colors.RESET} {init_icon} Initialized {feed_icon} Feeding {beefy_icon} Beefy Tape Mode: {mode_str} {Colors.CYAN}{Colors.RESET}")
# Address and buttons
addr_str = f"0x{self.address:02X}" if self.address != 0xFF else "UNSET"

File diff suppressed because one or more lines are too long

View File

@@ -6770,6 +6770,16 @@
)
(uuid "167da701-8bda-4d70-bf9f-94ec72cae84b")
)
(text "RC0402FR-071K4L mismatch"
(exclude_from_sim no)
(at 204.724 -27.686 0)
(effects
(font
(size 7.62 7.62)
)
)
(uuid "18c1a8e1-04b3-4699-ae05-5f45c0b31efd")
)
(text "TODO: R22 footprint mismatch"
(exclude_from_sim no)
(at 119.634 -10.668 0)

View File

@@ -0,0 +1 @@
{"hostname":"SUPERDUPER","username":"janik"}