Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootcamp: Ameen #135

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Bootcamp: Ameen #135

wants to merge 1 commit into from

Conversation

AmeenDurani
Copy link

Changes made:

-configured pinout diagram to generate code

  • used hal spi transmit, recieve, transmitrecieve functions to send and fetch packets from adc

Copy link

@HardyYu HardyYu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good Work! I left some comments here. Please ask any question if the feedback / the BootCamp is confusing to you.

2021-Firmware-Bootcamp/Core/Src/tim.c Show resolved Hide resolved
2021-Firmware-Bootcamp/Core/Src/main.c Show resolved Hide resolved
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot to pull down the Chip Select line before calling the SPI function.

2021-Firmware-Bootcamp/Core/Src/main.c Show resolved Hide resolved
rx_buffer_split[0] = rx_buffer_split[0] & 0b00000011; //isolating B9 and B8
uint16_t rx_buffer = (rx_buffer_split[0] << 8) + rx_buffer_split[1];
if(rx_buffer > 65535 || rx_buffer < 0) continue;
HAL_TIM_PWM_ConfigChannel(&htim1, rx_buffer, TIM_CHANNEL_1);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this function is the correct function to manipulate the PWM duty cycle here. You are also missing a piece of math to convert the ADC data to PWM timer counts.
ADC generates a number that vary from 0 to (2^10-1) since the resolution of this ADC is 10 bits.
Your PWM timer has 65535 counts in one period. When 5% of 65535 is on high level, 95% of counts on low level, you have a 5% duty cycle and that maps to 0 from the ADC data.
If the PWM has a 10% duty cycle, meaning 10% of 65535 counts on high, 90% on low. That maps to the max number from ADC.
Your math is supposed to handle this mapping from ADC value to PWM counts, and find the correct HAL function to change the Timer from high to low.

@DerekTang04 DerekTang04 changed the title Changes made to bootcamp Ameen Onboarding Sep 13, 2024
@DerekTang04 DerekTang04 changed the title Ameen Onboarding Bootcamp: Ameen Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants