0

I am currently trying to trigger a MAPIR NDVI Camera with a PWM Signal. The camera is connected via this HDMI trigger cable. The white wire is connected to GPIO PIN 17, the black wire is connected to a grounding pin.

For the camera to trigger i need a 1.80 - 2.15ms long signal. For the signal i used 500Hz, which is about 2ms. The timings can be found on the first link provided.

Things i have tried:

  • This basic python script

    import RPi.GPIO as GPIO
    import time
    
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(17, GPIO.OUT)
    
    p = GPIO.PWM(17, 500)
    p.start(100.0)
    p.stop()
    
    GPIO.cleanup()
    
  • This Matlab code

    mypi = raspi('ip','name','pw');
    
    configurePin(mypi, 17, 'PWM');
    writePWMDutyCycle(mypi, 17, 1);
    writePWMFrequency(mypi, 17, 500);
    
  • And the same Matlab Code recreated in Simulink

I don't know if i'm doing something wrong, or if it's not possible for the pi to create such short signals, as it should be possible to trigger the camera via PWM.

Any help is appreciated!

0

Your code has no delay in it. After starting the PWM channel, you immediately stop it. You're also using a duty-cycle of 100%, which will be approximately DC.

It sounds like you need a ~2ms pulse, in which case you'll need e.g. a PWM frequency of 100Hz and a duty-cycle of 20%. I've chosen those values so that the timing can be done by hardware (PWM) instead of software (the delay)

Perhaps something like this is closer to what you need:

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT)

p = GPIO.PWM(17, 100)
p.start(20.0)
time.sleep(0.002)
p.stop()

GPIO.cleanup()
| improve this answer | |
1

It might not in python but you can also do something like this to take a photo from a MAPIR Survey3 camera:

sudo pigpiod
pigs s 17 2000 mils 100 s 17 1000

It's already installed by default on the raspberry pi.

Just for info, pin 17 is this pin.

Source: Triggering of MAPIR using PWM signal

However, if you really want a solution that works with python you can use that one:

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT)
GPIO.output(17, 1)
time.sleep(0.002)
GPIO.cleanup()

time.sleep(0.1)

GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT)
time.sleep(0.001)
GPIO.cleanup()
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.