From The Blackfin Handy Board

LabVIEW: HandyBoardTutorial

This is the tutorial for programming the Blackfin HandyBoard using LabVIEW Embedded. It should be noted that many parts of this tutorial will need revisions as the software advances and more VI's become available. This tutorial will walk you through the creation of a VI (Virtual Instrument) that will run on the Blackfin HandyBoard. In this tutorial we will control the speed of a motor connected to port 1.

Plug the USB emulator into the Blackfin HandyBoard Make sure the HandyBoard has power, and connect it to the development PC through the emulator.

'''Launch LabVIEW Embedded Edition.

In the main LabVIEW Embedded screen, at the bottom, you must select 'Blackfin Project' as your target:

Select New from the file menu

Select "Blackfin Project"
Note: Selecting "Go" from the main page will bring to Project setup once the target blackfin is chosen if there were more than one target

Select a new "Blackfin Project" blank VI and choose Next

Select ADSP-BF537 from the drop down menu and choose next

Check the build specification box and click finish

The Pop-ups will ask to set up build specification. Select yes. The following pop-ups will ask you to save the project and the VI. Save both files as HBMotorDemo.lprovj and HBMotorDemo.vi

The from Panel will will show up. Drag it aside and reveal the Project Explorer. Right click on Analog Devices ADSP-BF537. A menu will pop up. Choose Add File....
Follow the path (C:\Program Files\National Instruments\Lab View 8.2\vi.lib\LabVIEW Targets\Embedded\vdk\bf537\lib\0.2\) and add the HandyBoard.dlb file.

The Project will look like the following if correctly added.

Right Click on the VDK application. A window will open showing the following

In the middle of the window, Analog device ADSP-BF537 will show up. From there select the BF_Handy_Board.dlb file and select the arrow to place it in the additional file area.

Select Application Information. The window will switch displaying the following

You should select Debug if you are planing to use the from panel to interact with the handy board in real time.Otherwise select release to which will ran without and any debugging capabilities. With the Debug option it recommended that you select the non-instrumented option. From the same window select the Processor option and select version 0.2

Select "OK" to exit. You should be back to the project Explorer. next you make sure LabVIEW is configured properly to run the target (HandyBoard)

Right click on Analog device ADSO-BF537 and select configure. the following windowing will show up.

Make sure the Platform is ADSP-BF537 Handy Board via Debug Agent and the Processor is ADSP-BF537. Select configure and copy ADSP-BF537 EZ-KIT Lite. This show up in the name file on the next window that will pop-up. In the type filed select the browse option to select the Blackfin HandyBoard emulator.
Note: If you are not able to do this, check the handy board connection to the PC as it may not be connected properly.

Select "Ok" and you are ready to create a new program

The Front Panel - The Front Panel will likely be the only window to appear on the screen. The Front Panel is where all controls and indicators of the VI are placed. These controls and indicators can be interacted with by the user or by other VI's however for this demo, only one control will be created.

Switch to the Block Diagram by hitting Ctrl-E - Ctrl-E is used from either the Front Panel or the Block Diagram to quickly switch to the other window.

Block Diagram - The Block Diagram is where all program elements and sub VI's will be located.

Blackfin HandyBoard VI's - The current set of VI's available for the HandyBoard should be located in LabVIEW's VI Library. To find the Library right click on the Block Diagram. Hover your mouse over the Blackfin icon to expand the Blackfin VI Library. Hover your mouse over the Handy Board icon to expand that library. This is where you can easily access any premade VI's for the Blackfin Handy Board.

First VI - To begin with, locate the 'HB Motor Enable' VI It Should be in the sub Library called 'Motors'. This VI is necessary whenever using the motors. If you do not include this VI for each of the motors you intend to use. The motors will be unresponsive.

Attaching components to a VI - The first thing we do with this VI is attach constants. Move your mouse to the left hand edge of the VI. A tool-tip should display describing the connection your mouse is closest too. Locate the input connection called 'mode' and right click. Select 'create>>constant'. Do this same process for the input connection called 'motor number.'

Changing Constant Data - The two constant values you've created need to be change for our VI to operate. If you havent altered the 'motor number' constant yet it should still be 0. Double click the constant and enter 1.
91.450 Students: PLEASE USE SIGN-MAGNITUDE PWM, not Locked Anti-Phase.

The Wonderful World of Loops. The Wonderful World of Loops. The Wonderful World of Loops. ...etc
Loops are a necessity in robotics. Here we will create our first loop. Right click on a blank space of the Block Diagram workspace. The functions panel will display itself. Select 'Structures>>While Loop'. Now click drag a blank section of the Block Diagram workspace. You now have a loop.

Important to know that all items in the loop will run and refresh their data. However all items not in a loop will run only once. Also important to know is that all loops have a 'Loop Condition.' For this loop we want it to run continously. We therefore must attach a constant value of false to the 'Loop Condition.' Attach the constant in the same way you atttached the constant to the 'HB Motor Enable' VI.

We now have a VI and a loop. Now answer this question: Which one runs first? You may have the right answer but the software may not know the right order to run the components in. We have two options the first is to use a sequence structure or we could use a trick to show the VI the right order to run things in. Move your mouse over the right edge of the 'HB Motor Enable' VI. A tool-tip should display 'error out.' Now click drag this output connection to the edge of the While Loop. You should now have something resembling the picture below.
If the line you just made remains segmented with a large red 'X' then you made a mistake. Hit Ctrl-B to remove the broken wire and try again. With this connection LabVIEW will assume that the 'HB Motor Enable' VI should run before anything in the loop runs. This is because the output of the VI leads to the loop.

Now place the 'HB Motor Set' VI from the library to the inside of the loop. It should resemble the image below.
91.450 Students: Make sure to use the HB Motor Set VI, NOT the one called "HB Set PWM."

Control, how to send data to your robot
We first want to ensure that the 'HB Motor Set' VI is affecting the correct motor. We therefore attach a constant to the 'PWM channel' input connector. Do this in the same way you've done with the other constants. Once that has been completed we will create a control for the 'duty cycle' input connector. Move your mouse over the left edge of the 'HB Motor Set' VI. Once a tool-tip displays 'duty cycle', then right click and select 'Create>>Control'. This will attach a component known as 'duty cycle' to the VI.

Now switch to the Front Panel window. You will notice a new item on the workspace labeled 'duty cycle.' This component is the representation of the control you just created. From this control you can change the value of the input while your program is running. Which will change the speed of the motor. This control can also be placed wherever you choose to place it on the Front Panel. Drag select the control and move it to the center of the window.

With the 'HB Set Motor PWM' VI in Locked Anti-phase PWM a value of 99 sends the motor into full forward, 50 stops the motor completely and 0 sends the motor into full reverse. We want our motor to remain stopped once the VI starts to run. However the control is unaltered and therfore has a default value of 0 at start. We therefore must change the default value. From the Front Panel window, enter a value of 50 into the control. Then you must right click the control and select 'Data Operations>>Make Current Value Default.' This will ensure that when the VI begins to run, the motor will remain stopped until the value of the control is changed.

Now that your VI is running you can control the motor speed from the control on the Front Panel. The Front Panel is where you will change any values necessary for testing of the robot. Set the control to 99. If your motor is running backwards then you placed the connector of the motor in backwards. Experiment with the motor values. It is important to remember that any control or indicators used in future VI's must be within a loop. Otherwise the data sent into or recieved out of the components will only be read once from the Front Panel.

So what exactly did I just do?
LabVIEW is mostly a visual programming experience. In order to relate a lot of the VI's and components, treat any subVI's as functions of the larger program your creating. The wires on the block diagram can also be described as the passing of arguments between the functions. Any loops or if-else arguments can be located in the structures category of the VI library.

Retrieved from http://www.cs.uml.edu/blackfin/index.php/LabVIEW/HandyBoardTutorial
Page last modified on September 28, 2007, at 05:26 PM