Embedded/Firmware Bootcamp - Archived S21

Welcome to the Embedded Software Bootcamp!

This bootcamp is becoming depreciated, the new bootcamp can be found at Embedded Flight Software Bootcamp. Good luck and we hope to hear from you soon!

 

 

WARG members often find that joining this team requires more knowledge and has a larger learning curve than other student teams. Once members have acquired this knowledge they gain a lot of confidence and are able to make large contributions to the team. Therefore, this Bootcamp is designed as a first task to be completed to both help you through the learning curve, while giving you a project that is fully your own. The hope is that once you complete this Bootcamp you will feel confident and hopefully have acquired enough skills such that you are ready to take on tasks with our aircraft! Just a quick disclaimer: this Bootcamp will help accelerate and minimize the learning curve, but it will not teach you everything there is to know about. The remaining knowledge will be acquired through completing other tasks with the team.

Responsible Team Lead

Dhruv Rawat (“@Elias [Dhruv R]” on Discord)

Bootcamp Objectives

  • Learn C, and become familiar with some of the concepts in embedded programming.

  • Learn the underlying Hardware Abstraction Layer (HAL) libraries.

  • Learn how to track code revisions and perform code reviews using GitHub.

Bootcamp Outline

This Bootcamp has two options, both of which require a team lead's approval of completion in order to move onto working on other tasks. The estimated time of completion for this Bootcamp is a 2-4 hours.

NoteThis will vary depending on your expirience level in programming. This is a rough estimate and don't get discouraged if it takes you longer!

1. Implement a Servo Tester

Background

One of the biggest things that makes embedded programming interesting is working at the barrier between hardware and software. There are several low-level peripherals on-board the microcontrollers for interfacing with various devices. The two low-level libraries you will be working with for this bootcamp are the analog to digital converters (ADC) and the timers (TIM).

Analog to digital converters (ADCs) take an analog value and convert it to digital numbers. This peripheral is useful to interface with sensors, battery voltages, and potentiometers. For this bootcamp, you will be using the analog voltage of the potentiometer and converting it to a digital PWM signal to drive a servo.

Timer modules are a hardware feature of embedded microcontrollers. They allow the program to delay without blocking other code from running. Timers are useful to implement PWM, since PWM has very specific timing requirements for when the IO pin gets turned on and off.

Task

Your task is to input a potentiometer value from 0 to 3.3V and convert it to a PWM signal to drive a servo. The potentiometer should be able to control the servo to its full throw. Servo testers are useful for determining servo range, prototype testing, and centering servos.

You are tasked with implementing this on the Safety Controller.

Hints

  • For PWM, you will need to use timer 16 to create a PWM signal. The signal should be at 50Hz, with an on-time ranging from 1ms - 2ms. To achieve this frequency, you will need to change the prescaler and period in tim.c. Note that the input clock frequency is 48 MHz. To change the duty cycle, you will need to set the compare register using the HAL library APIs.

  • Look at the HAL_ADC_, HAL_TIM_, and __HAL_TIM_ functions to access the timers and ADCs. The HAL User Manual will be particularly useful here.

  • At the top of the main.h file is the IO pin mappings. Use those defines when configuring your ADC and PWM ports. If you want to learn more about the pinout and IO configuration, you can download STM32Cube and open the bootcamp.ioc file. (Not necessary due to COVID-19)

Git

The code for the embedded bootcamp is hosted on GitHub. You will have to fork the repository to make your changes. If you don't know what Git or GitHub is, or how to use it, please read our git tutorial linked below.

Submission

Because of resource constraints, you will likely not have the ability to actually test the code. Just make sure it compiles. To do this, enter the root directory of your project (~/embedded-bootcamp) and type make into your terminal. Afterwards, a message will be displayed on your terminal letting you know if your code built successfully. Please include a screenshot of this message when you submit your code.

To submit your work, create a pull request of your fork against the UWARG/embedded-bootcamp repository. Name your pull request Bootcamp: YOURNAME. Tell the responsible team lead that you've completed the bootcamp and they will review your submission. You may be asked to revise some things.

NoteIf you would like to test out the code, come to one of the work days and we'll show you how to program the board and actually test it out (Not possible due to COVID-19)

Additional Resources

2. Previous Experience

If you feel that you've obtained significant enough experience elsewhere to be exempt from option 1, you can contact the responsible team lead to explain, and preferably show what you've done. It will be up to the Team Lead’s discretion whether you qualify to be exempt from the Bootcamp. If the Team Lead feels that you should still complete option 1 it is because they think you can learn and gain skills from the completion of the Bootcamp.

Completion of Bootcamp

Upon the approved completion of the Bootcamp by a Team Lead you are now eligible to work on other tasks related to the ZeroPilot! If you have any feedback you would like to give to make this Bootcamp better please let a team lead know as we want this to be the best and most informative introduction to the team as possible.