Question: 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

 Question 4: (State Machines Implemented in C) You have been asked

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 SysTick int isPressedUp);/returns 1 if Up button is pressed int isPressedDown;/returns 1 if Down button is pressed void motorUpnstructs the motor to move the device up void motorDown; I instructs the motor to move the device down void motorOff);Iinstructs 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 state_t source, state t destination; event t event; l stateTransition_t; 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 transitionTableD 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 SysTick int isPressedUp);/returns 1 if Up button is pressed int isPressedDown;/returns 1 if Down button is pressed void motorUpnstructs the motor to move the device up void motorDown; I instructs the motor to move the device down void motorOff);Iinstructs 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 state_t source, state t destination; event t event; l stateTransition_t; 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 transitionTableD 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!