Question: the code below are [ Placeholders ] . These placeholders indicate where the desired code should be to accomplish PI control.Do the following. Make your

the code below are [Placeholders]. These placeholders indicate where the desired code should be to accomplish PI control.Do the following.
Make your choice by completing the matching question below.
Once you have made your selection in the matching question you need to do the following as well.
Submit the code. You can add your code at the bottom of this test.,
Test your code by simulating it in SimulIDE and add a screenshot of the oscilloscope output and submit this as well at the bottom together with your code.
Code to be modified
const int analogInputPin = A0; // ADC input pin (A0)
const int pwmOutputPin =9; // PWM output pin (OC1A, pin 9 on most Arduinos)
const float setpointVoltage =1.0; // Desired setpoint in volts
const float Kp =1.042; // Proportional gain
unsigned long previousMillis =0;
const long interval =10; // Sampling interval in milliseconds (10ms)
void setup(){
pinMode(pwmOutputPin, OUTPUT); // Set pin 9 as output for PWM
// Configure Timer1 for 10-bit Fast PWM mode
TCCR1A =(1<< WGM11)|(1<< WGM10)|(1<< COM1A1);
TCCR1B =(1<< WGM12)|(1<< CS11); // Set prescaler to 8
}
void loop(){
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval){
previousMillis = currentMillis;
int adcValue = analogRead(analogInputPin); // Read the ADC value
float setpoint =(setpointVoltage *1023.0)/5.0;
float error = setpoint - adcValue; // Calculate the error signal
// Proportional control
float proportionalTerm = Kp * error;
//[Placeholder 1]
//[Placeholder 2]
//[Placeholder 3]
// Calculate control output
float controlOutput = proportionalTerm +[Placeholder 4];
// Constrain control output to valid 10-bit PWM range
controlOutput = constrain(controlOutput,0.0,1023.0);
OCR1A = static_cast(controlOutput); // Set PWM output on pin 9(OC1A)
}
}
Question 45
Prompt
1
[Placeholder 1]
Answer
Select match
Question 45
Prompt
2
[Placeholder 2]
Answer
Select match
Question 45
Prompt
3
[Placeholder 3]
Answer
Select match
Question 45
Prompt
4
[Placeholder 4]
Answer
Select match
Additional content

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 Programming Questions!