Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

View file
nameGit-Cheat-Sheet.pdf

Launchpad

Launchpad is our effort to help new members get acclimated with some of the skills they may use on our team. It is absolutely not going to teach everything, but its meant to be a small project to pick up as your first ticket on the team that will incorporate the general kind of coding that you may become familiar with.

Full disclosure: the boards + environment used here are ESP32s - we do not actually use them in NER (instead, currently all of our boards are STM32s). The tooling here is quite simple, but don't be surprised if its a bit different than what you use after completing this. Similarly, ESPs are known for their Bluetooth capabilities - and while our car doesn't use Bluetooth, I thought it would be really cool to take advantage of it here. Again, this is just supposed to be a fun intro into embedded development that is a little bit more advanced than what you may see in cornerstone- nothing more. Have fun and please ask questions as they come up! We will have dedicated time in the first several meetings of the semester to talk about this, but please slack us anytime throughout the week as needed!

1. Setting Up

Hopefully you’ve done the full setup described throughout this doc. If you have, the launchpad subsystem is embedded into your venv already! in your terminal, simply run

Code Block
launchpad

You should be greeted with a message - and this sets up the ESP32 specific tooling.

Youll need to then clone the launchpad repo - place it in the same NER folder described in the setup.

You also should have one of the esp dev kits and a magnet from us.

That’s all for now!

2. Create the app

Your goal is to create a simple application that utilizes a few of the tools embedded into the ESP chip:

  • Bluetooth (duh)

  • Hall Effect Sensor (magnetic field strength)

This application, running freeRTOS, should:

  1. continuously read magnetic field data and both blink an LED based on the strength (stronger field == faster blinking)

  2. Broadcast the raw data over Bluetooth

  3. Utilize an interrupt (ISR) to precisely time the blinking of an LED

The repository contains some starter/outline code for you. When finished, you can also take a look at my completed example.

Thats all! You are not expected to necessarily know anything about freeRTOS, interrupts, or any of these skills; Just because I haven’t in detail explained these things in this doc does not mean you are expected to understand it. Ask questions, do some individual investigation, or use whatever tools you want to help. freeRTOS and interrupts are used extensively in our vehicle apps, so getting some experience with them here will help out.

3. Testing

You’ll need a micro-USB cable to connect your laptop to the device. If you don’t have one around, stop by the Richards Makerspace and test it with one of ours down there.

Once your code is ready to build, and assuming you’ve run “launchpad” in the venv, you can do so with the following command:

Code Block
pio build

To upload the build code, run

Code Block
pio run --target upload

To view the bluetooth data, download the NRF connect app on your phone. In the scanner, you should see an ESP device. Connect to that

4. Tips/keep in mind

  • The value returned from the sensor is a raw ADC value. This means it is a unit less value, understood as a strength “percentage”. To understand this value, the resolution of the ADC needs to be known. You'll notice the starter code defines this. This value is simply the number of bits used to depict this percentage - the more bits, the higher the precision you are able to achieve.

Ex. for a ADC with 16 bit resolution:

The highest number that can be expressed with 16 bits is 2^16 = 65536. A raw ADC value of 32768, for instance, means 50% “strength”. Really, its just looking at this value as a percentage of the resolution.

  • The hall sensor normally would need to be calibrated to account for the ambient magnetic field in your environment. Doing so is out of scope of this task, so don’t worry about it too much, just try to set it up so that the light does not blink much at the reading level it gets without the magnet nearby. Depending on your environment, this might be at different reading values. All apps have the same ADC resolution, but you may read stronger or weaker fields, which is okay. Regardless, the strength should increase as the magnet gets closer.