<< return to Pixycam.com

Colour Code blocks

Hi.

I’m working with Netduino, .Net microframework. and trying to connect by I2C.
I’ve already made communication and I’m receiving and treating all the data I need… Of colour signatures only.
(I’m receiving the raw data, searching for index and putting everything in it’s place, something like this)

But now, I’m starting to do the same with Colour codes. The code is almost the same except for the angle. And that is all fine for me.
But I’m having a problem (or not, I don’t know). I’m receiving two blocks in the same message (I only have one block in pixymon, CC number 123, octal), almost identical. probably it’s supposed to be like this, but I’m not sure.

So… My questions are:

1 - Is it normal to receive two blocks in the same message? like this:

@85
170
86
189
1
83
0
56
157
0
112
84
0
209
255
0
0
0
0
0
0
0
0
85
170
86
170
182
1
83
0
54
0
157
0
108
0
84
0
208
255
@

(these are actual values I’m getting, I understand them all unless the 2 occurrences, and the last ones I ask in the next question)

2 - How does the angle work? I don’t understand how @208 and 255@ work as an angle… it’s Hex? Octal?

sorry if I’m not explicit enough. English is not my native language, not even my second one…

Hello Jonatas,
It is normal to see several blocks. I’m not sure what you mean by “in the same message though”.

Regarding the angle, it’s confusing to look at the bytes. The angle is two bytes and can range between -180 and 180. The value you are seeing is negative (represented at 2’s complement)

Hope this helps!

Hi. thank you for your answer.

I’m not understanding it yet. -180 180? what? I’m getting 298 255… I’m confused…

I have another question. I’m now testing my “write functions”. I’m changing Led colour, adjust camera brightness… and doing something with the servo control… but, what? I don’t know where I’m changing. lol.

I know I have
@Bytes 16-bit word Description

0, 1 y servo sync (0xff00)
2, 3 y servo 0 (pan) position, between 0 and 1000
4, 5 y servo 1 (tilt) position, between 0 and 1000@

but, how?

Hello Jonatas,

Two’s complement can be confusing. For example, -2 in two’s complement is 0xfe (8-bit representation), and 0xfffe (16-bit representation). It’s a little odd, but it’s what all modern computers use to represent integers. Pixy sends 16-bit words as 2 bytes, with the least significant byte first (something called “little-endian” another technical term). So if Pixy wanted to send a -2 (16-bit), it would send 0xfe first then 0xff. This hopefully clarifies what you are seeing for the angle. The main takeaway here (I think) is that looking at the byte-stream can be confusing unless you think like a computer.

Regarding sending commands, it helps to know what processor you are using. Most processors are little-endian, which makes things easier when communicating with Pixy.

What processor/controller are you using? Maybe someone has done this port (or similar) for your processor and can help.

Edward

I’m using Netduino Plus 2.

I understand the 2 complements, but I’m not a programmer and this byte and bit things sometimes is too much for me.
I get the little endian. But I’m not really getting the angle…
I will look into it some more and try to understand.