HANcoder/Training Material/AutomaticLightControlSystem/4

From OpenMBD
Jump to: navigation, search

<<<Go back to part 3

>>>Go to part 5

LED Control System Part 4

Part 4: Using HANtune to visualize signals

You can use HANtune to visualize the value of an analog input, in this case the potentiometer that was added to the model in step 3. 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 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&REG; template model.

P1figure10.png Figure 10 Add ASAP2 file to HANtune P1figure11.png Figure 11 File location of ASAP2 file


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 be able to accommodate HANtune to use the added signals and parameters from MATLAB&REG;. To be able to show signals onto a dashboard, a layout needs to be created. Right click "Layouts" and then click New layout. A message will pop up that prompts you to name your layout, name it whatever you want and press "OK".

Next, you can build a dashboard that shows different signals and parameters. Click the ASAP Elements tab on the left side of the HANtune window.

P1figure12.png

Figure 12 HANtune ASAP2 Elements


One parameter and 5 signals should now be available in the ASAP 2 Elements tab of HANtune. Parameters can be adjusted within HANtune. With HANtune, these adjusted parameters can be sent directly to the Olimexino. Signals can only be read by HANtune, they're not adjustable. We want to make the output of the potentiometer visible using a GaugeViewer. Select and drag the “Potmeter_Out” 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.


P1figure14.png Figure 14 HANtune dashboard with GaugeViewer P1figure13.png Figure 13 Change GaugeViewer range

  Lastly, we 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 computer should have assigned a COM port to the 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.

P1figure15.png

Figure 15 COM port of connected Olimexino


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.

P1figure16.PNG

Figure 16 Setting the COM connection for HANtune


Now we 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.  


<<<Go back to part 3

>>>Go to part 5