General

CMUcam4 and Romeo V2

userHead anonymous 2015-04-15 09:20:03 3968 Views1 Replies

Hello! I've a problem to use my CMUcam4 with my Romeo V2

I've connected the cam to the Romeo with a simple 2 pins connection (and ground, of course).
The RXI of the cam to the pin 1 (TX1) of the Romeo, and the TXO at the pin 0 (dfrobot).

With this code:

 

Code: Select all#include <CMUcam4.h>
#include <CMUcom4.h>

#define RED_MIN 110
#define RED_MAX 255
#define GREEN_MIN 0
#define GREEN_MAX 60
#define BLUE_MIN 0
#define BLUE_MAX 60
#define LED_BLINK 5 // 5 Hz
#define WAIT_TIME 5000 // 5 seconds

CMUcam4 cam(CMUCOM4_SERIAL1);

void setup()
{   
  cam.begin();

  // Wait for auto gain and auto white balance to run.

  cam.LEDOn(LED_BLINK);
  delay(WAIT_TIME);

  // Turn auto gain and auto white balance off.

  cam.autoGainControl(false);
  cam.autoWhiteBalance(false);

  cam.LEDOn(CMUCAM4_LED_ON);
  
  // Settaggio servi pan e tilt
  cam.setServoPosition(0, 1, 1500);
  cam.setServoPosition(1, 1, 1500);
}

void loop()
{
  CMUcam4_tracking_data_t data;

  cam.trackColor(RED_MIN, RED_MAX, GREEN_MIN, GREEN_MAX, BLUE_MIN, BLUE_MAX);

  for(;;)
  {
    cam.getTypeTDataPacket(&data); // Get a tracking packet.

    cam.automaticPan(true, false);
    cam.automaticTilt(true, false);
    // Process the packet data safely here.
  }

  // Do something else here.
}



the Romeo and the CMUcam4 doesn't communicate. I've tried whit CMUCOM4_SERIAL, CMUCOM4_SERIAL1, CMUCOM4_SERIAL2 and CMUCOM4_SERIAL3. Nothing...

With the ArduinoUNO (CMUCOM4_SERIAL), the program run without problems.

My question at this point is, what is the serial port to connenct CMUcam4 and Romeo V2?

Thanks!

2015-05-07 02:07:08 Hi Piero,

Since the sketch runs well on UNO but not remeo, so I guess it's the "Serial problem".

The TX1/dfrobot on Romeo can be used by Serial1.read/ println/ write(); but not Serial.

I am not familiar with your library, I guess in the library CMUcom4.h, it use Serial but not Serial1, you can make some change about the library.
userHeadPic Leff