Difference between revisions of "HANcoder/Training Material/ThrottleValveController/ClosedLoopTest"

From OpenMBD
Jump to: navigation, search
(Created page with "{{HANcoder}} ==Testing the closed loop control== Open HANtune and make a new project. Add and load the ASAP2 file “ThrottlebodyClosed.a2l” file that was created when you...")
 
Line 23: Line 23:
 
| || Value full throttle position||
 
| || Value full throttle position||
 
|}
 
|}
 +
 +
As you can see from the values, the positional feedback has a different operating range than the input of the potentiometer. To compensate for that, an offset and a gain need to be added to the model. The offset value that you’ll need to add to the throttle pedal is equal to the feedback value of the throttle valve in its idling position. After all, when the potentiometer is turned to its minimal value, you’d want the throttle valve to be in its idling position. Add an “Add” block from the Math Operations category in your Simulink Library to your model as well as a Constant block. Place the Add block between Analog Input A1 and the ThrottlePositionFeedback input and connect the lines. Connect the constant block to the second input of the Add block. Then change the constant value to the correct offset value, that you’ve found with HANtune.
 +
 +
[[File:ThrottleValveControllerAddOffset.png]]
 +
 +
Now that an offset has been created, the value of the throttle pedal will match that of the feedback signal while the throttle is in the idling position. However, it won’t match the full throttle position. Because of this, a gain needs to be added. To keep the program nice and clean, it’s sensible to convert the inputs values percentages. This makes it much easier to work with the different inputs. The gain value that needs to be added to get a range from 0 to 100%, can be found using the following formula:
 +
Gain = 100 / range = 100 / (maximum value – minimum value)
 +
 +
Q: What’s the gain value for the potentiometer?
 +
 +
Q: What’s the gain value for the position feedback?
 +
 +
Drag a “Gain” block from the Math Operations category in the Simulink Library into your model and double click it to enter the calculated gain value. Place the Gain block between the Analog Input A0 and the Add block. Also place a Gain block in between the Add block and the ThrottlePositionFeedback input of the PID H-bridge Controller. Make sure to name the line to the ThrottlePedal input “Desired” and the line to the ThrottlePositionFeedback input “Measured” by double clicking the lines in question.
 +
 +
[[File:ThrottleValveControllerRangeCompensation.png]]
 +
 +
Build the model and upload it onto your Olimexino. Then go to HANtune, reload the ASAP2 file under the “Project Data” tab and connect the Olimexino to HANtune by pressing (F5) and clicking “Connect & Request”. Turn on the power supply and see how the throttle controller functions.

Revision as of 12:41, 25 January 2018


Testing the closed loop control

Open HANtune and make a new project. Add and load the ASAP2 file “ThrottlebodyClosed.a2l” file that was created when you built the model. Go to the “ASAP2 elements” tab and drag the P, I and D parameters into the model as slider editors. Also drag the ThrottleFeedback and ThrottleInput signals into the dashboard as a scopeview.

ThrottleValveControllerHANtuneScreenshot.png

Now press (F5) and connect the Olimexino to HANtune.

Q: Write down the values that HANtune shows for both the minimum potentiometer value, and the value for the positional feedback, when the throttle valve is in its idle position.

Now turn the power supply on and turn the potentiometer until the throttle valve has opened completely. Write down the maximum value of the potentiometer and write down the feedback value of the throttle valve when it’s in its full throttle position. Turn the power supply off again.


Potentiometer Minimum value _______
Maximum value
Feedback Value idle throttle position
Value full throttle position

As you can see from the values, the positional feedback has a different operating range than the input of the potentiometer. To compensate for that, an offset and a gain need to be added to the model. The offset value that you’ll need to add to the throttle pedal is equal to the feedback value of the throttle valve in its idling position. After all, when the potentiometer is turned to its minimal value, you’d want the throttle valve to be in its idling position. Add an “Add” block from the Math Operations category in your Simulink Library to your model as well as a Constant block. Place the Add block between Analog Input A1 and the ThrottlePositionFeedback input and connect the lines. Connect the constant block to the second input of the Add block. Then change the constant value to the correct offset value, that you’ve found with HANtune.

ThrottleValveControllerAddOffset.png

Now that an offset has been created, the value of the throttle pedal will match that of the feedback signal while the throttle is in the idling position. However, it won’t match the full throttle position. Because of this, a gain needs to be added. To keep the program nice and clean, it’s sensible to convert the inputs values percentages. This makes it much easier to work with the different inputs. The gain value that needs to be added to get a range from 0 to 100%, can be found using the following formula: Gain = 100 / range = 100 / (maximum value – minimum value)

Q: What’s the gain value for the potentiometer?

Q: What’s the gain value for the position feedback?

Drag a “Gain” block from the Math Operations category in the Simulink Library into your model and double click it to enter the calculated gain value. Place the Gain block between the Analog Input A0 and the Add block. Also place a Gain block in between the Add block and the ThrottlePositionFeedback input of the PID H-bridge Controller. Make sure to name the line to the ThrottlePedal input “Desired” and the line to the ThrottlePositionFeedback input “Measured” by double clicking the lines in question.

ThrottleValveControllerRangeCompensation.png

Build the model and upload it onto your Olimexino. Then go to HANtune, reload the ASAP2 file under the “Project Data” tab and connect the Olimexino to HANtune by pressing (F5) and clicking “Connect & Request”. Turn on the power supply and see how the throttle controller functions.