Go to Post That seems like a pretty cool idea! Who'da thunk o' dat?! :rolleyes: - dlavery [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 05-04-2006, 14:05
Dave Flowerday Dave Flowerday is offline
Software Engineer
VRC #0111 (Wildstang)
Team Role: Engineer
 
Join Date: Feb 2002
Rookie Year: 1995
Location: North Barrington, IL
Posts: 1,366
Dave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond repute
Re: Fix for CMU cam initalization code 131 error.

Quote:
Originally Posted by Don Reid
After writing my own PC program to work with the CMUCam, I realized that part of the problem in the robot is that reseting the RC doesn't directly reset the camera. It expects the code to reset the camera over the serial link, but if the camera is in an odd mode (or even raw mode), that may not always work.

The only way to really reset the camera is to cycle its power. With the camera powered by a RC PWM port, that doesn't happen.
Don & others,
We ran into this problem last year with our camera. We do not use any of the provided camera code as our camera is controlled by our custom circuit. This presents an interesting problem because whenever the "reset" button is pushed on the RC the camera seems to get reset as well (apparently power to the PWM ports is disrupted? It doesn't happen when the "RC Reset" button is pressed on the OI.) We use raw mode when communicating with the camera, and so anyway the bottom line is that when our custom circuit initially talks to the camera it can be in either normal or raw mode. Below is my camera_reset() routine which works effectively to reset the camera regardless of it's current state. We haven't had any trouble with it using this reset sequence. camera_send() and camera_recv() are just aliases for sending/reading from the serial port. camera_flush() just flushes the serial input buffer.

Anyway, just posting it in case it is helpful to someone...
Code:
CameraReturnType camera_reset(void)
{
    CameraReturnType ret_val = CAM_FAILURE;
    UINT8 buf;

    // Send the reset command to the camera.  If the camera is already in raw
    // mode, then this command should succeed.  If the camera is not in raw
    // mode, the camera will NCK this command.  If we try to send the normal
    // mode reset command first, and the camera is in raw mode, then it gets
    // stuck trying to read in 32 more bytes from us (because the space after
    // RS is decimal 32, which in raw mode indicates the number of arguments
    // that we're sending to the command).  Bottom line is that it needs to be
    // done this way for it to work reliably in either mode.
    camera_send("RS\0\r", 4);

    // Read in the first character of the response from the camera.
    camera_recv(&buf, 1);

    // Take appropriate action depending on whether the camera 'A'cked or
    // 'N'cked the command.
    if(buf == 'N')
    {
        // NCK received.  This likely means we are not in RAW mode, so
        // try a non-raw reset command.
        camera_send("RS\r", 3);

        camera_flush();

        ret_val = CAM_SUCCESS;
    }
    else if(buf == 'A')
    {
        // ACK received.  Camera should now be reset.  Nothing else to do.
        ret_val = CAM_SUCCESS;
    }

    // Flush the input buffer from any garbage that might be remaining.
    // When the CMUcam is reset, it outputs a version string, but also
    // sometimes truncates the previous ACK statement, so it's easiest
    // to just get rid of whatever is in the buffer before continuing.
    camera_flush();

    return ret_val;
}
  #2   Spotlight this post!  
Unread 05-04-2006, 14:34
Mike Bortfeldt Mike Bortfeldt is offline
Registered User
FRC #1126 (& 1511)
Team Role: Mentor
 
Join Date: Oct 2004
Rookie Year: 2004
Location: Rochester, NY
Posts: 119
Mike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud of
Re: Fix for CMU cam initalization code 131 error.

Like Dave, we have our own custom camera code. However, we use the raw mode only for the output from the camera (RM 1). This eliminates the need to determine what mode the camera is in before sending commands.

Mike
  #3   Spotlight this post!  
Unread 05-04-2006, 15:36
Dave Flowerday Dave Flowerday is offline
Software Engineer
VRC #0111 (Wildstang)
Team Role: Engineer
 
Join Date: Feb 2002
Rookie Year: 1995
Location: North Barrington, IL
Posts: 1,366
Dave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond repute
Re: Fix for CMU cam initalization code 131 error.

Quote:
Originally Posted by Mike Bortfeldt
Like Dave, we have our own custom camera code. However, we use the raw mode only for the output from the camera (RM 1). This eliminates the need to determine what mode the camera is in before sending commands.
How do you handle knowing which mode the camera is in when you power up? If the camera was previously initialized, it should be in raw mode, but if it just powered up as well, it'll be in normal mode.
{edit} Sorry, didn't read closely enough - I missed the part about "only for the output", so that obviously changes things. {/edit}

Last edited by Dave Flowerday : 06-04-2006 at 09:25.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Code error on RC after downloading "bells and whistles" version of Kevins camera code DanDon Programming 6 10-01-2006 18:07
Intermittent Code Error Plloyd Programming 9 09-04-2005 21:37
CAM ERROR! magical hands Programming 0 03-02-2005 13:44
Error w/ FRC code JamesBrown Programming 2 08-01-2005 16:17
heres the code. y this not working omega Programming 16 31-03-2004 15:18


All times are GMT -5. The time now is 03:18.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi