Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 4: (State Machines Implemented in C) You have been asked to write a program that controls a motor, which in turn positions a part

image text in transcribed

Question 4: (State Machines Implemented in C) You have been asked to write a program that controls a motor, which in turn positions a part of a medical device. The program should respond from input from three user buttons, an "Up" button, a "Down" button, and an "Off" button. Repeated requests of the same type (i.e., "Up" followed by "Up") are allowed. However, the device in question needs 400 milliseconds to calibrate itself in between "Up'" and "Down" positions, and for safety reasons, absolutely may not be moved during this calibration period. You have been given the following already-implemented functions: void resetTimer;/ resets a global msCounter variable to zero // msCounter is incremented automatically by Sys Tick int isPressedUp); I/returns 1 if Up button is pressed int isPressedDown); returns 1 if Down button is pressed void motorUp);I/instructs the motor to move the device up void motorDown); I/ instructs the motor to move the device down void motorOff);instructs the motor to turn off if it isn't already off Draw the finite state machine for this system Write a state table for this system, like we have done in class Write C code to implement this state machine, using a big switch loop with a case for each state State any (reasonable) assumptions you make about the behavior of the given functions or the system requirements Given the following struct: a. b. c. d. typedef struct statet source; state_t destination; event t event; ) stateTransitiont; Fill in the following typedef blocks, one to enumerate the states in the system above and one to enumerate the events in the system above typedef enum state t; typedef enum ) event t; Then, fill in the state transition table const stateTransition_t transitionTablel Finally, modify your main code from the first part, so that it uses the state transition table to update state (outside of the switch loop). State any (reasonable) assumptions you make about the behavior of the given functions or the system requirements Question 4: (State Machines Implemented in C) You have been asked to write a program that controls a motor, which in turn positions a part of a medical device. The program should respond from input from three user buttons, an "Up" button, a "Down" button, and an "Off" button. Repeated requests of the same type (i.e., "Up" followed by "Up") are allowed. However, the device in question needs 400 milliseconds to calibrate itself in between "Up'" and "Down" positions, and for safety reasons, absolutely may not be moved during this calibration period. You have been given the following already-implemented functions: void resetTimer;/ resets a global msCounter variable to zero // msCounter is incremented automatically by Sys Tick int isPressedUp); I/returns 1 if Up button is pressed int isPressedDown); returns 1 if Down button is pressed void motorUp);I/instructs the motor to move the device up void motorDown); I/ instructs the motor to move the device down void motorOff);instructs the motor to turn off if it isn't already off Draw the finite state machine for this system Write a state table for this system, like we have done in class Write C code to implement this state machine, using a big switch loop with a case for each state State any (reasonable) assumptions you make about the behavior of the given functions or the system requirements Given the following struct: a. b. c. d. typedef struct statet source; state_t destination; event t event; ) stateTransitiont; Fill in the following typedef blocks, one to enumerate the states in the system above and one to enumerate the events in the system above typedef enum state t; typedef enum ) event t; Then, fill in the state transition table const stateTransition_t transitionTablel Finally, modify your main code from the first part, so that it uses the state transition table to update state (outside of the switch loop). State any (reasonable) assumptions you make about the behavior of the given functions or the system requirements

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

3rd Edition

978-1119907466

More Books

Students also viewed these Databases questions

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago