PWM Control (from RasPi)
Python scripts to control the Survey3 using a Raspberry Pi computer
Last updated
Python scripts to control the Survey3 using a Raspberry Pi computer
Last updated
Using our HDMI PWM Trigger cable you can send a PWM command to the Survey3 cameras to perform a couple of actions.
Connect the HDMI cable to the camera and the single servo connectors to the appropriate GPIO pins on the RasPi GPIO header, as shown below:
For our below code examples we connected the white signal connector to pin 12 (GPIO18) and the black ground connector to pin 14.
We also connect the included Survey3 USB cable to one of the RasPi USB ports. If you do not need to Mount/Unmount the SD card or power the cameras using USB then you can leave it disconnected.
If the RasPi fails to boot and the USB cable is connected there may be too much current draw required to charge the internal camera battery. We suggest removing the camera battery and then when the USB cable is powered on boot it will automatically turn the camera on.
The required PWM signal needs to always send the "do nothing" pulse width. We then change the pulse width only when we want to perform a particular command. It just requires one pulse with the longer width to perform each command.
PWM Commands:
1000us: Do nothing
1500us: Mount/UnMount uSD memory card (inside Survey3 camera)
2000us: Trigger photo capture
The 1500us command is sent once to unmount (in software) the uSD memory card inside the camera then mount to the connected USB computer (RasPi), and then 1500us again to mount the uSD back to the camera. This is commonly used to transfer captured photos to the RasPi or to perform post processing on the images.
While the uSD is unmounted from the camera it cannot save newly captured images. To view images while mounted you need to use the WIFI connection and corresponding url commands.
To send the PWM signals you need to send the 1000us "do nothing" pulse width all the time and then when you want to perform a command you send a momentary 1500us or 2000us width pulse.
The above code will set the PWM to the do nothing 1000us, then send a 2000us trigger command to capture a photo, then go back to sending the do nothing 1000us. The quickest the 2000us command should be sent is about once every 1.5s as the camera cannot capture JPG images more quickly than 1.5s. For RAW+JPG mode we recommend a 2.5-3.0s wait time.
The code can be set up to loop until the user exits (CTRL+Z), triggering the capture command every 1.5s:
You could also set it up to take user keyboard inputs:
The code above allows you to type the letter "t" and then press the "Enter" key and it will take a photo. You can type "s + Enter" and it will unmount the uSD card from the camera and the RasPi will then show it as a removable drive. Typing "s + Enter" again will unmount from RasPi and mount the uSD back to the camera. Typing "e + Enter" exits the program.