<< return to Pixycam.com

Pixy Signature Color Codes strange, not Octal

To reduce the false positives on my Pixy Rover I have switched to Menu -->Expert --> Color Mode 2 (not default 1) and have set CC signatures 1, 2 and 3. When I serial print the signatures of what it “sees” I was expecting numbers like
14-octal for CC 12
173-octal for CC 123
15-octal for CC 13
27-octal. for CC 23
324-octal for CC 212

but what I am seeing is a lot of numbers that I can use, but do not understand, such as:
1
10
138

The last number can not be in octal form since it has an 8 in it but if I convert it into Octal I get 212 which would make some sense.
Also 10 converts to octal 12, which also would make some sense. Any opinions about this data? My files are up-to-date.

The Spark Core .ino file (Similar to an Adruino RobotC program with a few header differences) I am using is at

It basically flashes LED D7 at different rates depending on the largest CC objects angle.

Hello Jeremy,
Here’s what you should expect:

12-octal for CC 12
123-octal for CC 123
13-octal for CC 13
23-octal. for CC 23
212-octal for CC 212

Your second set of numbers
1
10
138

are probably decimal, just as you guessed.

It sounds like what you are getting on the screen is decimal, but you’re expecting octal?

Some older versions of the Arduino library printed the color code numbers in decimal. The latest Arduino library prints octal though. You should make sure you’re using the latest.

The octal thing throws a lot of people. Let me know if you have any other questions.

Edward

Thanks for the reply Edward. I checked my Pixy.h and TPixy.h files and I think they are up-to-date version 0.1.7 . I have re-trained the Pixy to just have 2 CC signatures. I spent a fair bit of time getting the Cooked screen set really well. This time I got the codes:

10 for CC 12

81 for CC 121

These values were really consistent. I can work with this, but it does seem strange. I think I will make some code to convert the decimal values into octal.

Hello Jeremy,
It still sounds like you are running the older code. Here’s how to make sure. Go into the documents/arduino/libraries/Pixy directory and take a look at TPixy.h. It should have this routine:

struct Block 
{
  // print block structure!
  void print()
  {
    int i, j;
    char buf[128], sig[6], d;
	bool flag;	
    if (signature>PIXY_MAX_SIGNATURE) // color code! (CC)
	{
      // convert signature number to an octal string
      for (i=12, j=0, flag=false; i>=0; i-=3)
      {
        d = (signature>>i)&0x07;
        if (d>0 && !flag)
          flag = true;
        if (flag)
          sig[j++] = d + '0';
      }
      sig[j] = '\0';	
      sprintf(buf, "CC block! sig: %s (%d decimal) x: %d y: %d width: %d height: %d angle %d\n", sig, signature, x, y, width, height, angle);
    }			
	else // regular block.  Note, angle is always zero, so no need to print
      sprintf(buf, "sig: %d x: %d y: %d width: %d height: %d\n", signature, x, y, width, height);		
    Serial.print(buf); 
  }
  uint16_t signature;
  uint16_t x;
  uint16_t y;
  uint16_t width;
  uint16_t height;
  uint16_t angle;
};

This routine does the octal conversion and tells you you have a CC, etc.

Try deleting the Pixy directory in the libraries direcotory in reinstall the new Pixy Arduino library.

Edward

Thanks Edward. That is the file I am using. The problem is probably that I am using it on a Spark Core instead of an Arduino and I have made a few changes to the include files so perhaps something is not working quite right. Anyway I can live with it, my next problem is that I seem to have a good fast flow of information from the Pixy and then a lag of a few seconds where it gets no blocks, then things are fine again. Almost like the micro controller or Pixy are getting overloaded and need a break. I have put small delays in my code delay(5); to try to help but I am not sure if I am making things worse. Any suggestions.

Hello Jeremy,
Hmmm, nothing rings a bell as far as the cause of a couple second delay. Try running PixyMon in default mode so you can see if Pixy is still detecting objects when this happens. (You can run PixyMon while Pixy is talking to your Arduino) Let me know what you find.

Edward