Log in

View Full Version : Attaching the CMUcam to the Vex controller


987HighRoller
05-06-2006, 18:37
Hi,


I am attempting to connect the CMUcam2 to the Vex controller, and am pretty confused. Can anyone who has been successful in using the camera with the Vex controller post some pictures of how they connected the camera's TTL port to the vex and how they powered the camera? Also, any instructions or additional descriptions on how to complete this task would be much appreciated :) Thanx!

skimoose
05-06-2006, 19:25
Well I haven't had time to complete this project yet, but it is on my very long list of summer projects. Here's my plan:


camera power - use Vex motor port to camera power input - standard PWM cable.
pan servo power - use 2nd Vex motor port to pan servo - standard PWM cable.
tilt servo power - use 3rd Vex motor port to tilt servo - standard PWM cable.
data connection - I planned to use the three wire RS-232 port on the camera out to the IFI TTL driver circuit just like on the full size FRC controller with a standard PWM cable. There is a schematic for the TTL driver at IFI here. (http://www.ifirobotics.com/docs/ttl-232-converter.pdf) The TTL drivers are available through IFI at $10 or you can build your own with components from Mouser, Digikey, or Jameco (sorry RadioShack doesn't stock the RS-232 driver chip) for about the same price. Modify two very short PWM cables. Tie the +5v (red) together from the Vex controller RX/TX ports and connect to the +5v (pin #4) on the TTL driver. Tie the two Gnd (black) together from the Vex controller RX/TX ports and connect to the Gnd (pin #1) on the TTL driver. Then take the signal (white) wires from the Vex controller RX/TX ports and connect to the TX and RX (pins #2 & 3) on the TTL driver respectively. Remember transmit from the camera would be receive on the controller and camera receive would be transmit on the Vex controller. Keep the TTL connection to the Vex controller very short. Use two sided foam tape to hold the TTL driver on the top of the Vex controller case.


Then comes the coding. I haven't even started thinking about the code yet. :ahh:

I'm considering using two Vex batteries connected in parallel to give longer working time. The camera drained the standard 7.2v backup batteries rather quickly.

This is the start of my plan, again I haven't had time to try it yet. Good Luck.

Matt Krass
05-06-2006, 19:39
Instead of dealing with the driver chip and going from RS-232 to TTL (and dealing with intermittent and loose connections) why not use the camera's built on TTL port straight to the Vex controller?

987HighRoller
06-06-2006, 00:24
So where do i get the tx/rx from? The digital/analog ports, the motors, the interrupts, or does it matter?

Donut
06-06-2006, 01:21
There are seperate TX and RX ports along the same side as the digital/analog inputs and outputs.

foobert
06-06-2006, 21:05
data connection - I planned to use the three wire RS-232 port on the camera out to the IFI TTL driver circuit just like on the full size FRC controller with a standard PWM cable. There is a schematic for the TTL driver at IFI here. (http://www.ifirobotics.com/docs/ttl-232-converter.pdf) The TTL drivers are available through IFI at $10 or you can build your own with components from Mouser, Digikey, or Jameco (sorry RadioShack doesn't stock the RS-232 driver chip) for about the same price. Modify two very short PWM cables. Tie the +5v (red) together from the Vex controller RX/TX ports and connect to the +5v (pin #4) on the TTL driver. Tie the two Gnd (black) together from the Vex controller RX/TX ports and connect to the Gnd (pin #1) on the TTL driver. Then take the signal (white) wires from the Vex controller RX/TX ports and connect to the TX and RX (pins #2 & 3) on the TTL driver respectively. Remember transmit from the camera would be receive on the controller and camera receive would be transmit on the Vex controller. Keep the TTL connection to the Vex controller very short. Use two sided foam tape to hold the TTL driver on the top of the Vex controller case.



is there a reason to not just use the programming cable? sure you've got to kludge a connector, but you've already blown $100 for an extra fancy level shifter, or did ifi obfuscate the functionality to the point that it won't work for plain old serial comms?

Mark McLeod
06-06-2006, 21:32
Here's what I do and what Matt was referring to in his post. See if the snapshots I took help make the wiring clear.

Male-to-male PWM-style cables are needed (purchase, combine old cables, or make your own).
Camera power can come from any regulated +5v pin on the Vex controller (all the middle pin positions). Driving servos directly from the CMUcam requires the extra power available from the unregulated Vex motor outputs. Use a regular male-to-male PWM cable.
Serial communication is simplest from the native CMU TTL port to the nativeVex TTL port. It’s cleanest with a 4-pin housing at the camera end, but you can rig a solution from a pair of 3-pin connectors or a 3-pin/single unhoused pin combination too. The Vex end needs two side-by-side connectors, because the Vex TX/RX pins are themselves side-by-side.

Carefully note the location of each TTL port pin in Thumbnail 2 and avoid the CMUcam2 TTL port power pin, so you’ll need a 4-pin connector with the third pin missing.
Note the Tx of one device is connected to the Rx of the other, so:

Ground-to-ground
CMU Rx to Vex Tx
CMU Tx to Vex Rx


See Thumbnails 1 & 3 for photos of the wiring. Note however that the green Rx wire leaving the CMUcam2 arrives at the Vex controller as a white wire, because I added a male-to-male cable. I made sure you can see the Tx/Rx labels where numbers normally are in Thumbnail 3.
For software Kevin has an EDU version that will work or it's a pretty simple transition if you want to move existing FRC code over. See http://www.chiefdelphi.com/forums/showpost.php?p=497592&postcount=2


We don't run the servos from the CMUcam2 board, but if you choose to then take the camera power from the Vex motor outputs for the extra voltage (unregulated-straight from the battery). We tend to prefer the consistency of the regulated 5v from any of the other Vex outputs, but it's inadequate to also power servos driven directly from the camera. It's a personal choice to not use the CMUcam's servo control capabilities because the uses we put the camera to sometimes involve servos and sometimes don't and when we do use them we want to control the programming.


is there a reason to not just use the programming cable? ... or did ifi obfuscate the functionality to the point that it won't work for plain old serial comms?You can use the programming port as well if you prefer and even run two cameras easily.

skimoose
06-06-2006, 21:55
Instead of dealing with the driver chip and going from RS-232 to TTL (and dealing with intermittent and loose connections) why not use the camera's built on TTL port straight to the Vex controller?

You can, but TTL is not reliable for other than short runs. Serial data can be transmitted further and more reliably. Whether you change signal levels or not, a loose connection is a loose connection.

skimoose
06-06-2006, 22:05
is there a reason to not just use the programming cable? sure you've got to kludge a connector, but you've already blown $100 for an extra fancy level shifter, or did ifi obfuscate the functionality to the point that it won't work for plain old serial comms?

The RX and TX ports on the vex controller are TTL. If you keep the camera close to the controller, you can use the TTL on the camera. If you wanted to use the serial comm through the programming port, that should work, but then you'd need to unplug the camera every time you wanted to download new code. Faster to develop code if I can keep the camera and the comm line on at the same time.

Everything people have mentioned here should work, there's always more than one way to make it work.

DonRotolo
06-06-2006, 22:27
So where do i get the tx/rx from? The digital/analog ports, the motors, the interrupts, or does it matter?
So, it kind of goes without saying, that you won;t generally get plug-n-play answers from Chief Delphi. However, the information presented is more than enough for the motivated student to figure out what is needed.

I strongly urge you to follow this through. You will learn more from this than anything else you do this summer. This is where the phrase "hardest fun ever" comes from. Once you are done, you will understand CMU Cam, serial data, and Vex programming more than most of the people here. Then, you can teach us something.

Come back and ask, ask, ask, until you get what you need. We're all here to help, but we can't make you do it. Push yourself, and the rewards will be tremendous.

Don

David55
06-06-2006, 22:57
Thanks for all your advice guys!!!

I figured out the wiring side (not too hard when you have such detailed instructions :D ).

Now...what's there to do with the software side?
I think that's where the big problems will be...

David

Matt Krass
06-06-2006, 23:30
You can, but TTL is not reliable for other than short runs. Serial data can be transmitted further and more reliably. Whether you change signal levels or not, a loose connection is a loose connection.

We used straight TTL for the robot this year, and we covered at least 5 feet without any communication trouble, plus the connection was a lot steadier and less prone to wiggling free than with the driver chip. Plus that little (breakable) chip being a failure point for our targeting functions made us nervous.

Mark McLeod
07-06-2006, 08:45
We used straight TTL for the robot this year, and we covered at least 5 feet without any communication trouble... You should note that we use shielded cable for those long runs and tested lengths, more than twice what we planned to use, for TTL signal degradation.
Always question, examine, measure, and test your solutions.

Ctrl Alt Delete
13-01-2007, 15:12
For the programming side of it. I just swapped in the vex library file, Vex_alltimers_wauton_jmpr.lib and it seems to work. I haven't tried the wiring yet, but the only thing you have to remember is that there are only 8 free pwm's instead of 16.

Culvan Van Li
13-03-2007, 18:19
I'm trying to connect a CMU2 camera to my vex kit. Electrically I think I've got everything working. I'm using PWM1&2 for the pan/tilt and I'm using PWM3 to power the camera. I made a custom cable to connect the TTL serial to the VEX ports that are next to the digital16 port. I've got a laptop setup with the programming kit/cable and I've got a second laptop connected to the RS232 serial port on the camera monitoring it with Procom plus.

I've been adding in modules from Kevin Watson's frc_camera_s_21 set. I've used the instructions in the readme files to add serial_ports.c/h, camera.c/h, tracking.c/h, terminal.c/h. I've added in the following commands into the Process data from master routine:

Tracking_Info_Terminal();
Camera_Handler();
Servo_Track();

I've also turned on debugging. When it fires up it runs through the initilization and I can see it perform all 17 steps. The servos start panning all ofer the place and I get "searching..." messages. The camera never seems to lock onto anything (incluging my green target). I tried using it with labview's software and I can pull an image and check the color of my target. It comes up with 235+/-5 for all three colors. I tried changing the settings in camera.h to match those, but I can't get it to pick anything up. I get T packets with a parenthesis after it. I'm assuming that's because I'm in raw mode.

Anyone have any good suggestions of what to try next? I can get the camera working in non-raw mode directly to my computer running procomm plus, but I'm struggling to get it working with the vex kit.

Andy

billbo911
13-03-2007, 19:02
I made a custom cable to connect the TTL serial to the VEX ports that are next to the digital16 port....and I've got a second laptop connected to the RS232 serial port on the camera monitoring it with Procom plus.

The servos start panning all over the place and I get "searching..." messages. The camera never seems to lock onto anything (incluging my green target).


Andy

To quote one of the "Myth Busters" "There's your problem right there"

The CMU Cam can not drive both the TTL and RS232 connections at the same time. So, when the controller never receives tracking data from the camera, it just keeps searching. Try disconnecting the RS232 to the second laptop. You should start seeing better performance.

yara92
15-10-2007, 16:02
Hi Andy!
I tried this long way I Confused with the friends helping me how to connect and different codes but I did not succeed the camera dos not Tracking.
So may be you did not given up and you succeed to work it out.
Please try to send me any information met help. I'm struggling to get it working with the vex kit.
Mohamed team 1946

Culvan Van Li
23-10-2007, 17:10
I did make some more progress on this, but I haven't worked on it for months. I was able to get the camera to find objects. My previous setup worked (even the part about having two laptops connected at the same time.) I can't get the tracking code to properly control my servos, but that's a different problem.

My problem was that I was calibrating the search color in Labview and it was defaulting to RGB mode. The default camera code from Kevin Watson is in YCrCb mode. It will work with both set the same way, but YCrCb is closer to the way the camera sees the world. RGB is basically calculated from the YCrCb data. You will probably have better results using YCrCb.

The setting is controlled inside the COMA register on the camera. It's only one bit so you will change it by adding or subtracting that bit (the number 8, I believe). I found the following thread that clued me into my problem.

http://www.chiefdelphi.com/forums/showthread.php?t=41828&highlight=COMA

Hope this helps.

Andy