cmucam2 MPLAB on VEX controller ??

Congratulations on surviving another build season!!

During this build season I came across a cmucam2 revA which I believe to be from the 2007 season. Now that build season is over I thought it would be an interesting home project to see if we can get it working on a little VEX controller so we can use it to teach the basics of cameras to our younger students.

That was about a week ago… I’ve collected a lot of information and software since then including several example programs for Brad Miller’s WPILIB and Kevin Watson’s cmucam code.

I know the camera works just fine since using the Java applet CMUcamGUI2_fe I can track colors reliably. Further I know that both Brad & Kevin’s code sucessfully initializes and starts the camera tracking (from LEDs and Brad’s easy to use SetCameraDebugMode(1) function).

But after that the results are completely consistant. The T-type packets appear to be sent but when you do printfs for the tracking variables you always get zeros.

Its interesting that with Kevin’s code (at startup) the first output is ‘no camera data’. It always happens once at startup, and from then on it just outputs 'Searching…". If you unplug the serial connection, Kevin’s code just streams ‘no camera data’. That makes me think that the camera is sending the data, but the VEX has something just a little different that causes the data to be ‘lost’. ( And I double checked my pointer logic many times. The variables are really empty. )

So after reading and trying everything that I can think of, and must admit I’m stumped. I’ve been using MPLAB and WPILIB for programming these little VEX machines for quite a while now and it is, generally speaking, rock-solid.

So if you have any suggestions, or know something about the how the VEX CPU might be different, please pass it along. It would sure be nice to make use of this camera with the younger students – rather than just have this equipment and code sitting on a shelf collecting dust.

Thank-you,
KHall, Mentor
Team 2171
Crown Point RoboDogs

There’s no real difference from the software perspective that prevents the CMUCAM from working on the Vex. We used the Vex platforms for FRC training for several years, including following objects with the CMUCAM.

“Searching…” should mean that packets are being received from the CMUCAM successfully, but just that no target has been identified. So I’d imagine you just have issues with the color space you are searching or another setup characteristic.

Thank-you for the reply Mark,

I finally ended up using the WPILIB just to set up the camera and then read the data as ASCII directly from the serial port. That works fine. Although to make it easier on myself I set the camera to polling mode and used a mask to limit the Tpacket to only four of its eight data points.

Just curious now, but do you happen to recall which version of MPLAB you were using? I’m using MPLAB 8.10. And I found something in Kevin’s code that specifies using an earlier version. That is something that I have not tried.

I can say this much, with the Ver 7 VEX code and MPLAB 8.1 both Keven’s code and the WPILIB do not recieve data. And I have several controllers so its not specific to one piece of hardware.

Sure would be nice to know what is causing this. But in the meantime, I have a squarebot that now faithfully follows a green plastic bag with a flashlight behind it.:slight_smile:

Thanks,
KHall
2171.

The MPLAB version should not matter at all. MPLAB itself is just an editing tool. I’ve run with older and newer versions.
What would matter is the mcc18 toolset version that MPLAB is running for us. That should be version 2.4 in any case.

Kevin originally developed his CMUCAM code on an EDU, a precurser to Vex, so it will work. You’re having some sort of conversion problem, but it sounds like you worked around it. :slight_smile:

You can checkout our workshop Vex code if it helps any. Probably look about halfway down the page.
We didn’t use the Vex version 7 code as a starting point though.

Thanks Mark,

When I clicked on the link to your website I immediately recognized it. Found it once before using Google. Tried your code and got the same results. And I just double checked the mcc18 that is on this machine, it is ver 2.4.

So it must be the lastest VEX code. I can go see if they have an older version still posted on VEX and see if that works.

Thanks, this is all very helpful.

Keith

I took a look and version 7 of the Master code doesn’t affect the CMUCAM code.

I suspect there might be a setting in the code being missed. For instance, the code may be connecting to the wrong serial port. There are three serial ports on the CMUCAM and two on the Vex controller. If the code is listening to the wrong one it won’t get any messages.

Here’s a description of how our camera gets connected: http://team358.org/files/programming/edu_vex/Vex%20CMUcam2.doc
See if you are doing anything different. You can use different ports, but the code has to be told which one to use.