lab7_note

pdf

School

University of California, Berkeley *

*We aren’t endorsed by this school

Course

16B

Subject

Mechanical Engineering

Date

Oct 30, 2023

Type

pdf

Pages

8

Uploaded by DeanKangaroo5110

Report
EECS 16B Designing Information Devices and Systems II Fall 2023 UC Berkeley Lab Note 7 Lab Note 7: Controls Previously, we have built S1XT33N’s motor control circuitry and developed a linear model for the velocity of each wheel. We are one step away from our goal: to have S1XT33N drive in a straight line! As you probably noticed, simply applying the same PWM input to both wheels as we did during data collection in the last lab is not sufficient; S1XT33N ends up driving in a circle if we do this because of the differences between the two wheels. In this lab, we will see how to use the model we developed in System ID to control S1XT33N’s trajectory to be a straight line. Part 1: Open-Loop Control Introduction Before we implement our closed-loop controller, we need to understand how open-loop control works. An open- loop controller is one in which the input is predetermined using your system model, and not adjusted at all during operation. To design an open-loop controller for your car, you would set the PWM duty-cycle value of your left and right wheels (your inputs u L [ i ] and u R [ i ] ) such that the velocity of both wheels is your target wheel velocity ( v L = v R = v ). You can calculate these inputs from the target velocity v , θ L , R , and β L , R values (all 3 of which are constants) from System ID and hard-code these input values, as they won’t change at all as your car runs in open-loop control. As a reminder, here are the equations for our model that we defined in the last lab: v L [ i ] = d L [ i + 1 ] d L [ i ] = θ L u L [ i ] β L v R [ i ] = d R [ i + 1 ] d R [ i ] = θ R u R [ i ] β R (1) This works well if your model is perfect ( θ L , R and β L , R exactly match the real system), and your car is never bumped or otherwise disturbed. In other words, with no mismatch between the idealized behavior we model in System ID and no noise or disturbances from the environment, your car will drive straight. Model mismatch inevitably arises because every model is ultimately an approximation (recall how you used least-squares to derive your model coefficients θ L , R and β L , R : were your v [ i ] vs. u [ i ] plots perfectly linear?). As a result, open-loop control does not work very well in practice since the car has no way of adjusting to perturbations and model mismatch present in the real world. Jolt Calculation Since we are starting our cars from rest, in order for the cars to move, we must first overcome static friction. However, simply feeding it the open-loop inputs may not be sufficient to allow it to do so. Thus, before our Arduino tries to control our car, we need to provide each of S1XT33N’s motors with a large PWM signal for a brief time; we will call this the jolt. As you (should have!) observed in the System ID lab, the individual motors respond differently to changes in the PWM duty cycles (i.e. they have different sensitivities to the PWM input, θ L , R ), as well as different velocity offsets ( β L , R ). By extension, this means that from rest, the two motors require different PWM duty cycle inputs and thus different jolt values in order to overcome static friction and start moving. If the motors need different duty cycles to start moving, it is evidence of one or more of the following: Difference in motor parameters. The motors contain a component called the armature, which generates torque to turn the wheel from the current flowing through it. Your motors might have different armature resistances, which in turn limits the amount of armature current flowing through the motor for a given voltage. If the resistance is higher, the motor will need a higher voltage to force enough current through the internal motor circuit for the motor to turn. Difference in motor efficiencies. This could be interpreted as a subsection of the previous item, but the dis- tinction between the two is that we will interpret the first as primarily a consequence of differences in electrical characteristics, and this one as a consequence of differences in mechanical characteristics. The friction within the motor may be higher for one motor than the other, or perhaps a gear is slightly misaligned in one motor, etc. Mass imbalance in the car. If the mass of the car isn’t distributed evenly between the wheels (e.g. your breadboard is off-center and puts more weight on one side), the torque required for the wheels to begin turning will differ. Most of the cases outlined above are expected, and we are able to correct for them by modifying the jolts we apply to start each wheel when the car starts up. 1 Lab Note 7 — Controls (v5.1)
EECS 16B Designing Information Devices and Systems II Fall 2023 UC Berkeley Lab Note 7 Part 2: Closed-Loop Control of S1XT33N Introduction To correct for the imperfections of open-loop control, we will build a closed-loop controller that uses feedback to ensure that both wheels still drive at the same velocity. How do we choose the correct input value for our closed-loop controller? First, we need to identify a control variable (and a value for it) which corresponds to our desired system behavior. Once we do that, we need to determine the relationship between the input and this variable. We will define our control variable , δ , to be the difference in the distance traveled between the left and right wheels at a given timestep. δ [ i ] = d L [ i ] d R [ i ] (2) Our goal is for the car to drive straight. This means the velocities , not necessarily the positions, of the wheels need to be the same. Sanity check: If we want v L [ i ] v R [ i ] to be zero, what condition does this impose on δ ? We introduced δ [ i ] = d L [ i ] d R [ i ] as the difference in positions between the two wheels. If both wheels of the car are going at the same velocity, then this difference δ should remain constant, i.e. δ [ i + 1 ] δ [ i ] = 0, since no wheel will advance by more ticks than the other. Note: this does not mean that δ needs to be 0! We approximate this constant δ [ i ] i = δ ss by using the final value of δ your car exhibits at the end of a run. Sanity check: What does it mean for the car’s trajectory for when δ is a constant 0? What about a constant nonzero value? Deriving the closed-loop model In System ID, you linearized the car system around your operating point (the value of v you selected). We will now be deriving the equations which govern the behavior of our system. These equations determine the dynamics of the system that we want to control. We will implement a state-space controller by selecting two dimensionless positive coefficients, f L > 0 and f R > 0 , such that the system’s eigenvalue λ is placed in a stable position . (Recall that for discrete-time systems, eigenvalues must be within the unit circle on the complex plane for the system to be stable; i.e. the magnitude of the eigenvalue must be less than 1). | λ | < 1 (3) We begin with our open-loop equations from last week: v L [ i ] = d L [ i + 1 ] d L [ i ] = θ L u L [ i ] β L v R [ i ] = d R [ i + 1 ] d R [ i ] = θ R u R [ i ] β R (4) We want to adjust v L [ i ] and v R [ i ] at each timestep by an amount that’s proportional to δ [ i ] . Let’s say we want to drive δ [ i ] towards zero. If δ [ i ] is positive, the left wheel has traveled more distance than the right wheel, so relatively speaking, we can slow down the left wheel and speed up the right wheel to cancel this difference (i.e. drive it zero) in the next few timesteps. Therefore, instead of v (our target velocity), our desired velocities are now v f L δ [ i ] and v + f R δ [ i ] . As v L and v R tends to v , δ [ i ] tends to zero. v L [ i ] = d L [ i + 1 ] d L [ i ] = v f L δ [ i ] v R [ i ] = d R [ i + 1 ] d R [ i ] = v + f R δ [ i ] (5) In order to bring d L [ i + 1 ] and d R [ i + 1 ] closer to each other, at timestep i we set v L [ i ] and v R [ i ] to the desired values v f L δ [ i ] and v + f R δ [ i ] , respectively. Setting the open-loop equation 4 for v [ i ] equal to our desired equation 5 for v [ i ] , we solve for the inputs u L and u R : u L [ i ] = 1 θ L ( v f L δ [ i ]+ β L ) u R [ i ] = 1 θ R ( v + f R δ [ i ]+ β R ) (6) 2 Lab Note 7 — Controls (v5.1)
EECS 16B Designing Information Devices and Systems II Fall 2023 UC Berkeley Lab Note 7 These are the inputs required to equalize d L [ i + 1 ] and d R [ i + 1 ] ! But how do we know what to set the feedback gain values f L and f R to? To figure this out, we will need to find the eigenvalue(s) of the system so we can better understand its behavior in closed-loop feedback. Let’s begin by reviewing some terms related to state-space control. • System variable: Any variable dependent on/responding to the input or initial conditions of a system. • State variables: The smallest set of linearly independent system variables such that the values of the members of this set, together with the initial conditions, inputs, and known functions that model the system behavior, completely determine the value of all system variables for all t t 0 . For example, voltages across capacitors and currents through inductors are state variables in circuits. • State space: The n -dimensional space whose axes are the state variables ( n is the number of state variables) that represents all possible configurations of the state variables and thus the system. To study the dynamics, we will first define our state variables. If the goal is to have the car go straight, then our goal should be to maintain equal velocity for the left and right wheels. However, we are measuring the distance travelled by the left and right wheels, so we will implement a controller that drives the difference δ [ i ] down to zero. Let’s pick δ as our state variable. Does the definition of state variables apply to δ [ i ] ? In other words, is the following statement true: Knowing δ [ i ] at each time step as well as the initial conditions and inputs, we can uniquely determine the value of all other system variables. Let’s now find δ [ i + 1 ] in terms of δ [ i ] . We can do so by subtracting the two sides of the system of equations from equation 5 from each other. δ [ i + 1 ] = d L [ i + 1 ] d R [ i + 1 ] = v L [ i ]+ d L [ i ] ( v R [ i ]+ d R [ i ]) = v f L δ [ i ]+ d L [ i ] ( v + f R δ [ i ]+ d R [ i ]) = v f L δ [ i ]+ d L [ i ] v f R δ [ i ] d R [ i ] = f L δ [ i ] f R δ [ i ]+( d L [ i ] d R [ i ]) = f L δ [ i ] f R δ [ i ]+ δ [ i ] = δ [ i ]( 1 f L f R ) (7) Key points: • Since we are trying to drive δ to zero, δ is our state variable. All other system variables, such as v L , v R , d L , and d R , can be obtained from δ , the initial conditions, and the inputs at each timestep i . • Since we have only one state variable, our state space is one-dimensional. • Since δ [ i + 1 ] = δ [ i ]( 1 f L f R ) , the coefficient 1 f L f R fully describes the evolution of our state variable in time. So, 1 f L f R is our system eigenvalue! Feedback Gain ( f -Value) Tuning We can get different system dynamic behaviors over time for different values of 1 f L f R . Below are some example plots of system behavior (assuming no model mismatch) with various f -values. The rapid ramp-up at the beginning of each plot from t = 0 to t 0 . 1 is from the jolts, which are set to be unequal so that the controller has something to correct in these ideal simulations. Note that in the following plots, the distance travelled by one of the wheels can decrease, but since our car cannot go backwards, this is not possible with our cars. The purpose of the plots is simply to demonstrate the system’s behavior for various values of the system eigenvalue. 3 Lab Note 7 — Controls (v5.1)
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
EECS 16B Designing Information Devices and Systems II Fall 2023 UC Berkeley Lab Note 7 Examples of System Behavior with Various f -Values Figure 1: f L = 0 . 1 , f R = 0 . 1 With f L = f R = 0 . 1, our system eigenvalue is 0.8, so, since our system is one-dimensional, δ is multiplied by 0.8 at each timestep, slowly driving δ to zero. Since our f-values are equal, the d l and d r lines approach each other at equal rates. Figure 2: f L = 0 . 5 , f R = 0 . 5 With f L = f R = 0 . 5, our system eigenvalue is zero, and since our system is one-dimensional, this means it takes one timestep to send δ to zero. Figure 3: f L = 0 . 9 , f R = 0 . 9 With f L = f R = 0 . 9, our system eigenvalue is -0.8, and since our system is one-dimensional, δ is multiplied by -0.8 at each timestep. Since the sign of δ changes at each timestep, you see oscillatory behavior. 4 Lab Note 7 — Controls (v5.1)
EECS 16B Designing Information Devices and Systems II Fall 2023 UC Berkeley Lab Note 7 Figure 4: f L = 1 , f R = 1 With f L = f R = 1, our system eigenvalue is -1. This is the marginally-stable case: δ ’s magnitude does not in- crease or decrease, but its sign changes at every timestep. Picture this behavior in a car: if δ switches sign at every timestep, the car is veering from side to side in a sinu- soidal pattern while going forward. Figure 5: f L = 2 , f R = 2 With f L = f R = 2, our system eigenvalue is -3. This case is oscillatory, like the previous case, but this case is unstable, since δ is multiplied by -3 at each timestep and so it grows without bound. Figure 6: f L = 1 . 5 , f R = 0 . 1 With f L = 1 . 5 , f R = 0 . 1, our system eigenvalue is - 0.6, so while the behavior is oscillatory, δ is still driven to zero and the system is stable. However, one of the wheel controllers (the left one, in this case) is working much harder than the other (i.e. the left wheel’s velocity changes significantly while the right wheel’s velocity re- mains the same). This means that the left wheel will need to be able to attain a larger range of velocities than the right wheel. Sanity check question: Now that you know how the system responds to various eigenvalues, you can choose your feedback gains such that 1 f L f R is the eigenvalue that you want. Do you want them to be balanced (roughly the same magnitude) or unbalanced? 5 Lab Note 7 — Controls (v5.1)
EECS 16B Designing Information Devices and Systems II Fall 2023 UC Berkeley Lab Note 7 Steady-State Error Correction Ideally, our system should be able to drive δ to 0 over an infinite timespan. However, due to mismatch between the physical system and the model, some steady-state error will be present. We will approximate this value δ [ i ] i = δ ss by using the value of δ your car converges to at the end of a run after your controller has been implemented. Sanity check question: What would the path of a controlled car with nonzero steady-state error look like? How is this different from the path of a controlled car with zero steady-state error? Let’s assume there is only a mismatch between β in our model and reality; i.e. β is the real model and we mistakenly are using β . v L [ i ] = d L [ i + 1 ] d L [ i ] = θ L u L [ i ] β L v R [ i ] = d R [ i + 1 ] d R [ i ] = θ R u R [ i ] β R (8) where u L [ i ] and u R [ i ] (Equation 5 ) are the inputs we calculate from our closed-loop model. v L [ i ] = d L [ i + 1 ] d L [ i ] = θ L [ 1 θ L ( v f L δ [ i ]+ β L )] β L v R [ i ] = d R [ i + 1 ] d R [ i ] = θ R [ 1 θ R ( v + f R δ [ i ]+ β R )] β R (9) Solving for δ [ i + 1 ] in terms of δ [ i ] in the same way as before, we get: δ [ i + 1 ] = ( 1 f L f R ) δ [ i ] [ β L ( β L β L 1 ) β R ( β R β R 1 )] (10) Just to get a sense of the magnitude of the second term ( [ β L ( β L β L 1 ) β R ( β R β R 1 )] ) in the previous equation, let’s say there is a 10 percent mismatch (i.e. β β β = 0 . 1) between our model and reality, and that β L = β R + 10. The second term will become -1. The magnitude of the error is not that large, but let’s see how it will translate to the steady-state error. First, let’s simplify the model by letting λ = 1 f L f R and ε = [ β L ( β L β L 1 ) β R ( β R β R 1 )] : δ [ i + 1 ] = λδ [ i ]+ ε (11) You can show that δ ss = ε 1 λ if | λ | < 1. You can reach this conclusion if you iteratively expand δ [ i + 1 ] , and write δ [ i ] in terms of δ [ 0 ] . Let’s say in our designed system, λ = 0 . 9. We can see that in this case, the small ε can be amplified by a factor of 10 in steady state. This conclusion was derived based on the assumption that only β has a mismatch. As practice, derive δ [ i + 1 ] in terms of δ [ i ] , when there is a mismatch in the θ values instead. 6 Lab Note 7 — Controls (v5.1)
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
EECS 16B Designing Information Devices and Systems II Fall 2023 UC Berkeley Lab Note 7 Part 3: Turning Closed-Loop Control We can get a clue about turning by considering how we implemented closed-loop control. We perform feedback control to minimize the difference between the two wheels ( δ [ i ] = d L [ i ] d R [ i ] ). When perturbations cause one wheel to get ahead of the other, the result is a non-zero δ , causing feedback control to turn the car to correct the error. Our feedback control policy is: u L [ i ] = u OL L f L ω L δ [ i ] u R [ i ] = u OL R f R ω R δ [ i ] (12) Let’s say the right wheel has moved further than the left ( d R [ i ] > d L [ i ] ), resulting in a negative δ [ i ] . A negative δ [ i ] results in a reduction of u R [ i ] , and an increase of u L [ i ] . But what does this mean physically? If the right wheel is getting ahead of the left one, the left wheel will need to move a little faster and the right wheel a little slower for the wheels to even back out. Thus, feedback control corrects errors by turning to compensate for them. Thus, δ ̸ = 0 can be used to turn the car. What if we artificially modified our δ [ i ] values to make the car think it was turning? Turning via Reference Tracking To turn, we will manually add some δ re f to our δ value at each step of the control scheme. By doing so, we are tricking our control scheme into thinking that our car has turned by some amount to generate that extra δ re f of error, causing it to turn in the opposite direction to compensate. When making a turn, the magnitude of δ grows because otherwise, the car is driving straighter. Therefore, we need to update δ re f at each timestep to ensure that the car continues to turn. Without loss of generality, we’ll analyze a right turn, corresponding to adding a negative δ re f value (the car thinks it’s turned left, so it tries to turn right). Our goal is to generate this δ re f . We would like the car to turn with a specified radius r and linear velocity v . The controller’s unit for distance is encoder ticks, but each tick is approximately 1 cm of wheel circumference. Additionally, we want our car to turn gradually (rather than making a pivot turn), so δ re f will be a function of the controller’s time-step. We define the following variables: i [time] - timestep r [cm] - turn radius of the center of the car; 1 cm 1 encoder tick d [tick] - distance traveled by the center of the car l [cm] - distance between the centers of the wheels; 1 cm 1 encoder tick ω [rad/time] - angular velocity θ [rad] - angle turned Inspect the following diagram. Based on this geometry, we will derive an expression for δ re f [ i ] in terms of r , v , l , i in the pre-lab/lab notebook. 7 Lab Note 7 — Controls (v5.1)
EECS 16B Designing Information Devices and Systems II Fall 2023 UC Berkeley Lab Note 7 Notes written by Mia Mirkovic, Meera Lester (2019) Edited by Kourosh Hakhamaneshi (2020). Version 2.0, 2020 Edited by Steven Lu, Yi-Hsuan Shih (2021). Version 3.0, 2021. Edited by Steven Lu, Megan Zeng (2022). Version 4.0, 2022. Edited by Megan Zeng (2023). Version 5.0, 2023. Edited by Junha Kim, Ryan Ma (2023). Version 5.1, 2023. 8 Lab Note 7 — Controls (v5.1)

Browse Popular Homework Q&A

Q: In a 2015 study entitled How Undergraduate Students Use Credit Cards, it was reported that…
Q: 5. A 20 resistor is connected to an AC circuit. The RMS current through the resistor is found to be…
Q: A new screening program was instituted in a certain country. The program used a screening test that…
Q: Consider the function in the graph to the right. The function has a Select an answer v of at x = 10…
Q: Project3 The goal of this activity is to create a program that identifies the largest number among…
Q: Provide the abbreviation of the following nucleotide. O-P-O- N Koy H OH H OH NH NH₂
Q: How will I draw the graph based on the data and result? Thanks.
Q: Find the domain of the function. (a) f(x) =(2x+1)/(x^2+x-2)            (b) g(x)= (cube root of x…
Q: A geologist uses a simple pendulum that has a length of 37.10 cm and a frequency of 0.8190 Hz  at a…
Q: #Original immigrant data x = c(61159,…
Q: The count in a bacteria culture was 900 after 15 minutes and 1100 after 35 minutes. Assuming the…
Q: 8. Explain one difference in how & and 8 are used in the definition of limits. 9. For f(x) = 2x²,…
Q: (a)Consider a t distribution with 29 degrees of freedom. Compute P(t ≥−1.63). Round your answer to…
Q: Each of the regions A, B, and C bounded by the graph of f and the x-axis has area 3. Find the value…
Q: 1. Suppose P(A) = 4/10, P(B) = 5/10, and P(AB) = 2/10. (a) Compute P(AC). (b) Compute P(AUB). (c)…
Q: Which acid would be best to use when preparing a buffer with a pH of 4.72? A list of Ka values can…
Q: A study was conducted to determine the proportion of people who dream in black and white instead of…
Q: In a poll of 225randomly selected U.S. adults, 117 said they favored a new proposition. Based on…
Q: Colter Steel has $5,300,000 in assets. Temporary current assets $ 2,600,000 Permanent current…
Q: Solute S has a distribution constant of 4.7 between water (phase 1) and hexane (phase 2). A 75.0 mL…
Q: If you are not able to remember your best friend’s dog’s name, that is an issue of:   retrieval…
Q: Benedict's reagent is blue in solution. Which compound when added to a solution of Benedict's…