Recent Changes - Search:

Main

Robotics I Fall 2007

Robotics II Spring 2007

Robotics I Fall 2006

Vision Servoing Laboratories

FPGA-Based Vision

VDSP

LabVIEW Embedded

Code

Site Admin

edit SideBar

VisionUsingVDSP

This material was developed by Andrew Chanler.

OV7620 Example

The good example is here: Attach:camera-vdsp.zip

Look in main.c to see how it works. It is pretty simple however there are some project settings that have been set to enable the the 64MB of RAM. Also before you run the example make sure the camera is plugged in correctly. If it is plugged in wrong bad things could happen.

Using the VDSP Image Viewer

Visual DSP++ has a bunch of nifty debugging tools. One of the tools lets you view an image that is in memory. This section will show you how to use this tool with the example application.

1. Open VDSP and connect to the Handy Board

2. Open the camera example project ( download link is above ).

3. Build the project. Now this should cause the program to be downloaded to the Handy Board and the program will be halted at the start of main() like usual.

4. Set a break point on the line that toggles the LED after every frame is grabbed. See picture below.

5. Run the program. After it is running push the start button on the Handy Board since there is a HB_Buttons_WaitForStart() function call at the top. Then a few moments later the program should get to the break point you just set and halt at that line of code. At this point we have an image stored in a buffer named Frame that is allocated in global scope at the top of the program.

6. To view the image in memory, select the following menus: View -> Debug Windows -> Image Viewer.

7. Setup the Image Viewer settings the same as they are in the following picture and then push the OK button.

8. Then the image is automatically downloaded into the image viewer window. See picture below.

9. If you mouse over the image you can see the YUV values of the pixel under the mouse cursor.

10. To get a new image, select run from the debug menu and it should get a new image and halt back at your break point. The right click on the image in the image viewer and select refresh.

Adding Camera Support in an Existing Project

1. Copy the following files from the camera example to your project: camera.c, ov7620.c, ssl_init.c, camera.h, ov7620.h, ssl_init.h.

2. Go to your project options. On the left click on "Add Startup Code/LDF" and select the radio button "Add an LDF and startup code". Do not close the project options window. See picture below.

3. Now on the left of the project options window, scroll down on the left and select "External Memory". Then on the right check the box labeled "Use external memory (SDRAM)?" and set the size to 64MB and partition to "default". Then push the OK button. See picture below.

4. Add the header files to the top of your code with main():

    #include "ssl_init.h"
    #include "camera.h" 

5. Next you need to add code to initialize the the device drivers and camera immediately after HB_HandyBoard_Init():

     // Initialize Handy Board
     HB_HandyBoard_Init();

     // Initialize Services
     rc = ssl_Init();
     if( rc != ADI_DEV_RESULT_SUCCESS )
     {
         printf( "Failed to run ssl_Init(): return code = 0x%08X\n", rc );
         return( rc );
     }

     // Initialize the camera and open PPI driver.
     rc = CameraInit();
     if( rc != ADI_DEV_RESULT_SUCCESS )
     {
         printf( "CameraInit() failed: return code = 0x%08X\n", rc );
         return( rc );
     }

6. Now in your code, you capture a frame using

    rc = CameraReadFrame( Frame );
    if( rc != ADI_DEV_RESULT_SUCCESS )
    {
        printf( "CameraReadFrame() failed: return code = 0x%08X\n", rc );
        return( rc );
    }

7. Don't forget that the buffers you allocate are pretty big. In the example code I allocated a frame buffer named Frame as follows below. The PIXEL_PER_LINE value is 320 and the LINES_PER_FRAME value is 240 and it is multiplied by 2 because there are 2 bytes per pixel. So each image buffer is 150KB in size.

    char Frame[PIXEL_PER_LINE * LINES_PER_FRAME * 2];

Reprogramming CPU Core Execution Speed

After calling the ssl_Init() function, the core switches to run at 250Mhz. To get the board running back at the regular 600Mhz speed, run the following code. Note that putting zeros in for core and bus speed sets them to max.

        //Optimal Speed 
        adi_pwr_SetFreq( 
                                0, // Core clock frequency (MHz) 
                                0, // System clock frequency (MHz) 
                                ADI_PWR_DF_OFF    // Disable PLL input divider 
                                ); 
Edit - History - Print - Recent Changes - Search
Page last modified on October 22, 2007, at 06:08 PM