uvic-auvic / Firmware-Power_Board_1.0

1 stars 0 forks source link

Setup the 8 Sensor ADCs #4

Closed lymacasm closed 6 years ago

lymacasm commented 6 years ago

Goal The goal of this issue is to setup the 8 ADC pins to read from three of our sensors. 2 of these pins will be for reading battery current draw (1 for each battery), one will be for reading the water sensor, and the other for the external pressure sensor (measures the pressure of the water, outside of the housing).

Task The pins we're using are PA0, PA1, PA2, PA3, PA4, PA5, PA6, and PA7. PA1 is for the water sensor, PA2 is for the external pressure sensor, and PA3 and 4 are for the current sensors. Your job will be to configure all 4 of these GPIOs to work as ADCs to read from these sensors. (Has changed a bit, talked to @anijjar about it). You'll need to use DMA to read from each channel.

What is an ADC? ADC stands for Analog to Digital Converter. Essentially, what it does is convert an analog value (in our case, a voltage) to a digital value. So really, what we're doing, is reading the voltage seen on each of the 4 pins mentioned in this issue. You can almost think of them as voltmeters. Once converted to a digital value, we can then process that voltage on our microcontroller.

Testing To properly test your code, you should use a potentiometer wired to 3V3 (3.3 V). If you can find a 3-pin potentiometer, you can wire the middle pin to the GPIO, the top pin to 3V3, and the bottom pin to GND. You should make sure to test all 4 pins. When testing, you should be able to see the digitally converted value change as you adjust the potentiometer. You should be able to move between maximum voltage and minimum voltage in this configuration (approximately). (IMPORTANT:Before wiring as I've described, make sure to look at the datasheet for the potentiometer to ensure that I didn't tell you to do something stupid!)

lymacasm commented 6 years ago

Pull request has been merged.