OpenLoopTest

From OpenMBD
Jump to: navigation, search


<Go back to part 2

>Go to part 4

Testing the open loop controller

Once the model has been uploaded to the Olimexino board, you can test the functioning of the throttle body. Set the lab bench power supply to 12 volts and ask a teacher to make sure the power supply has been set up correctly. Then connect the positive to the red input jack of the throttle body setup and the negative to the black input jack of the setup. Don’t connect anything to the green, blue and yellow input jack. Doing so may break your Olimexino board.

Q: What are your findings?

When you build a model, two important files will be created: an S record file (.srec) and an ASAP2 file (.a2l). The S record file contains the compiled model. It contains the machine code that is used to program the microcontroller. The ASAP2 file has information about the model with, amongst other things, the signals that will be visible in HANtune. HANtune needs this file to know which parameters and signals are available in the microcontroller to read or change. To your model, you have added the analog input which the potentiometer is connected to. Now we want to visualize the value using HANtune. Open HANtune from the directory you have saved it to. Tip: Save the HANtune directory under “Documents” and save a HANtune.exe shortcut to your desktop. When HANtune has finished loading up, make a new project. File -> New project

ThrottleValveControllerAddASAP2.png


ThrottleValveControllerSelectASAP2.png

Now, open the ASAP2 file (a2l) by right clicking “ASAP2 files” and click “Add ASAP2 file”. The ASAP2 file can be found in the same folder as the Simulink template model. The ASAP2 file needs to be loaded up before it can be used. Either right click the “HANcoder_Olimexino.a2l” ASAP2 file and click “(un)Load file” or double click “HANcoder_Olimexino.a2l”.+

Now the ASAP2 file will accommodate HANtune to use the added signals and parameters from MATLAB®. Next, you’ll put together a dashboard. Click the ASAP Elements tab on the left side of the HANtune window.

ThrottleValveControllerASAP2Elements.png

Under the “ASAP2 elements” tab, there should now be a signal that represents the value of the potentiometer. It will be named the same as the line that you’ve named previously, in the case of this example it will be called “ThrottlePedal”. Select and drag this signal to your dashboard and select GaugeViewer. If you want to move, adjust or remove anything on your dashboard, press CTRL + R. Now you’ll be able to move things around, change sizes or remove something from the dashboard entirely. After you’re done arranging the layout, press CTRL + R again to lock everything in place. Right click the GaugeViewer to change its properties. Click Modify display range to change the range of the GaugeViewer. We want to set the display range to 0 to 4095, because this is the maximum range that the microcontroller can use to convert an analog signal to a digital value, using its 12-bit ADC.

ThrottleValveControllerGaugeThrottlePedal.png

ThrottleValveControllerGaugeLimits.png

Lastly, you need to connect the Olimexino to the computer to actually be able to read the value of the potentiometer. The Olimexino uses a serial USB connection. If you’ve installed the USB driver properly, your laptop should have assigned a COM port to your Olimexino. The first time you connect the Olimexino to HANtune, you’ll need to select the COM port which has been assigned to the Olimexino. To do this, press (F5) to connect and go to settings. Go to the “USB/UART” tab, select the proper COM port and click OK.

To figure out which COM port the Olimexino is using, right click the Windows/Start button on your screen and click Device Manager. Then go to Ports (COM & LPT) and click on it. Now look for STMicroelctronics Virtual COM Port and see which port has been assigned to it.

ThrottleValveControllerPorts.png

Choose XCP on USB/UART as your connection type. In this example, the Olimexino is connected to COM5. This is the port we will need to pick in Settings.

ThrottleValveControllerHANtuneConnectionWindow.png

Now you can connect our Olimexino to HANtune by clicking Connect & Request. Once it’s connected, you can check if the signal of the potentiometer is being shown in the GaugeViewer in HANtune.

Q: Turn the potentiometer and write down how the throttle body acts for different potentiometer values given in HANtune.

Potentiometer Throttle valve
0
500
1000
1500
2000
2500
3000
3500
4000

Turn off the power supply.

<Go back to part 2

>Go to part 4