Setting up two pan-tilt Pi cameras on the Xavier

Today’s project was to get two Pi cams going on the Nvidia Jetson Xavier NX. Initially, I set this up with one Pi 2 cam and one Logitech webcam. Since that time, I have found out the lessons I’m following with Paul McWhorter will be utilizing two Pi 2 cams with pan/tilt servos. I decided I wanted to replicate that setup, especially since I plan to do more robotics projects in the future. This post will show the steps I took to get both cameras working.

Hold up, Now is the time to increase airflow!

Before setting up the two cameras, I figured it was an excellent time to make a couple of other changes. I decided that maybe getting a little more airflow through the chassis would help keep the Xavier cool. To do this, I would use two 30mm quiet fans I have on hand. At first, I was going to modify the 3D file I used to print the current case. But after trying to decide where to create screw holes on the back of the case, I found the screw holes from the fan align nicely with the gaps present in the case. I only put the top two screws in for each fan, as the bottom screws would have lined up with the board and caused issues. Two screws per fan are more than enough to keep them secure.

Two fans mounted on the back of the Xavier case.

In the picture above, you may notice there are silicone feet mounted under the case. I put one in each corner to allow air to flow through the holes in the bottom of the case. I feel much better about air flowing through the chassis between the new fans and silicone feet.

I used the header pinout posted over at JetsonHacks to figure out where to get power. The fans’ red wires are hooked up to pins 2 and 4, which provide 5.0V DC. The black wires are hooked up to pins 6 and 9, which are ground pins. Luckily these little fans are quiet, so I don’t even notice they are always running. It’s possible these fans are not necessary. But I feel a lot more comfortable with air flowing through the case.

Hardware used for the Pi cam installs.

The Pan-Tilt Platforms I ordered from Amazon are pretty good little kits. Below is a picture of one of them (I ordered two).

Pan-Tilt Platform Kit for the Raspberry Pi Camera created by Arducam.

The kit comes with the following items:

  • Two mini servo motors
  • Plastic platform pieces
  • PTZ Control Board
  • Jumpers needed to go between the control board and Xavier
  • Screws needed to assemble and mount the kit

I already have a Raspberry Pi Cam 2 for my Xavier. But, I needed a second one. Here is everything that came with the kit I bought.

Pi Cam 2 package contents.

Previously I just bought the camera and a longer cable. The kit I bought this time comes with the following:

  • Pi Cam 2
  • 15cm FFC cable
  • 50cm FFC cable
  • 15cm FPC cable for Pi Zero
  • Acrylic Case

The thing I liked about this kit is that it included the 50cm cable and the acrylic case. I plan to use the acrylic case for a camera I have hooked up to a Pi Zero-W.

To provide power to the servo controller, I am using my desktop DC power supply. I did not want another wall wart or USB cable at my desk!

Getting it all hooked together.

I had Paul McWhorter’s assembly video going as I put it all together. But honestly, I really didn’t follow him much for the hardware part. The cams come with basic instructions on how to assemble the servos and platforms. I did install the Pi cam on before putting the platform together; it just seemed it would be a pain to do it afterward. Here is a look at an assembled platform with servos and Pi cam.

Pi Cam 2 mounted to the Arducam pan-tilt platform.

After getting both pan-tilt kits fully assembled, I hooked the Pi cams up to the Xavier. I had to make sure the ribbon cables were fed through the chassis and then into their ports. Luckily the nice 3-foot cable I ordered from Adafruit came for my other Pi cam. Now I have plenty of room to maneuver both Pi cams.

Pi ribbon cables hooked up to the Xavier.

Hooking up the servo controller to the Xavier is pretty straightforward. I used the pinout chart provided by JetsonHacks to determine where each pin from the servo controller to the Xavier header. The only problem I had was figuring out where the OE pin went, and luckily McWhorter had mentioned in his video that this pin was not used.

Here is how I hooked up each pin on the servo controller board to the Xavier header:

  • GND pin on the servo controller board to pin 14 on the Xavier. McWhorter connected to a different ground pin, one which I had already used for a fan.
  • OE pin on the servo controller board skipped.
  • SCL pin on the servo controller board to pin 5 on the Xavier.
  • SDA pin on the servo controller board to pin 3 on the Xavier.
  • VCC pin on the servo controller to pin 1 on the Xavier. Pin 1 on the Xavier provides 3.3V DC.
  • V+ pin on the servo controller board skipped. I used the power input connector to get 5V DC from my benchtop power supply.
Two fans and one servo controller hooked up to the Xavier.

I did not connect the V+ on the servo controller board to the Xavier header. That would be a bad idea to try powering servos with the Xavier. The servos require their own external power, which I provided via my benchtop DC power supply. The positive wire went to V+ on the power input connector, and the negative wire went to GND.

I then hooked up the four servo motors. Staring with pin 0 on the controller board, I hooked up the four servos as listed below. The wires go black wire to black pin, red wire to red pin, and white wire to yellow pin.

  • Camera 1 pan servo (bottom) to servo pin 0 on the servo controller board.
  • Camera 1 tilt servo (top) to servo pin 1 on the servo controller board.
  • Camera 2 pan servo (bottom) to servo pin 2 on the servo controller board.
  • Camera 2 tilt servo (top) to servo pin 3 on the servo controller board.
Servo controller hooked up to the Xavier, the servos, and the 5VDC benchtop power supply. If you look closely, you can see I put the connector for servo 3 in wrong accidentally; luckily, I caught it while taking this picture.

With the controller hooked up, I was able to close up my Xavier case. The whole process was pretty painless!

A couple of minor adjustments during testing

After booting up, I tested the servos and cameras out with some simple commands through Python. I did have to install the CircuitPython ServoKit from Adafruit to utilize the controller. The first thing I had to fix during testing was one of the tilt (top) servos. It was installed on the horn in a way, so I could only go about 170 degrees or risk crashing into the platform behind it. To fix that, I had to remove the horn from the servo and adjust it to the same position as the tilt servo for the other camera, already being positioned correctly.

The other thing I had to fix was a more significant issue. During testing, each camera’s ribbon cables would continuously get tangled up with the servo controller board. This was eventually going to either pull a wire out of the servo controller board or one of the Pi cam’s ribbon cables. To fix this, I mounted the controller board just above the cams on my monitor stand. This solution seems to work perfectly. Long-term, I’m probably going to 3D print a better solution. But for now, a thick piece of double-sided tape is working fine.

The servo controller has been mounted higher than the Pi cam platforms. This solution allows the ribbon cables to move freely without getting tangled in the servo controller board.

Test run

Here is a short video of the Pi cams and servos being more thoroughly tested. Thanks to the help of Paul McWhorter’s excellent video, I was able to program the servos to pan and tilt automatically and show up as one window on my screen. I actually wrote most of the coding before watching his video. But my inexperience with Python led me to believe this was a more challenging task than I thought it would be. I feel no shame, though; I tried and learned a lot in the process. It is nice to have the videos from McWhorter to fall back on, though!

Both pan-tilt Pi Cam 2 platforms are working great!

Song of the Day: Who Wants To Live Forever

I just noticed I happen to have Queen playing when I recorded the above video. Well, I can’t play only part of a song like that. Here is the whole piece as performed by Queen live.

Bonus Song: Land of confusion

We just had our presidential election here in the US. Due to that, I can’t get this awesome 80’s Genesis video out of my mind.

Leave a Reply