Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Suppose you have an inexpensive noisy mechanical switch that you wish to monitor using your STM32. Normally you would use a simple Digital Input

Suppose you have an inexpensive noisy mechanical switch that you wish to monitor using your STM32. Normally

Suppose you have an inexpensive noisy mechanical switch that you wish to monitor using your STM32. Normally you would use a simple Digital Input for this. However in this case, you chose to use both a digital input and an analog input so that you can observe the noisy behavior of the switch. Assume it is a simple2 terminal switch where one terminal is grounded (so grounded when closed) and you are measuring the other terminal. The objective of this question is to poll the switch every 1ms and see how the values of the digital read relate to the values read by the analog read. 1. Setup a new project in PlatformIO, using MBED and your STM32F429 board. 2. Using the MBED framework, set up 3 GPIOS (don't forget any required configurations): a. One analog IN (to read the switch) b. On digital IN (to read the switch) c. One digital OUT (connected to either an on-board LED or an external LED) 3. Using the Timer HAL provided by MBED (timer, ticker, timeout etc.) set up a recurring function call that runs every 1ms that will read the switch state on both analog and digital inputs 4. Write a short algorithm that you will use to determine if the switch is open or closed, by reading the analog input only. 5. Compare the output of the algorithm in 4. with the value read from the digital input. If the values match, leave the LED (digital OUT) OFF. 6. If the values from 4. and that read from the digital IN differ, then light up the LED. 7. Essentially, when you run the code, the LED will only light up if the two values differ meaning that the switch value is unreliable. 8. Submit your main code file.

Step by Step Solution

3.43 Rating (153 Votes )

There are 3 Steps involved in it

Step: 1

Here is a possible solution for your task 1 To set up a new project in PlatformIO you can follow the steps in this guide1 You need to select the MBED framework and the STM32F429 board from the options ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microeconomics An Intuitive Approach with Calculus

Authors: Thomas Nechyba

1st edition

538453257, 978-0538453257

More Books

Students also viewed these Accounting questions

Question

Eliminate street slang.

Answered: 1 week ago

Question

Write each fraction as a percent. 7 50

Answered: 1 week ago