×

INDI Library v2.0.7 is Released (01 Apr 2024)

Bi-monthly release with minor bug fixes and improvements

gpio pulse after each image?

  • Posts: 163
  • Thank you received: 26
For an experiment at work I would like to use my monochrome camera to record images of a spectrum, and would like to have a simple 5V pulse after each image is recorded. (To signal the hardware to move to the next position)

What would be the best approach for this?

Is there a way to run a (small) Python script after each image maybe?

Thanks for your thoughts!
3 years 5 months ago #62392

Please Log in or Create an account to join the conversation.

Yes this can be done via a script and added to the Ekos sequence.
3 years 5 months ago #62395

Please Log in or Create an account to join the conversation.

  • Posts: 163
  • Thank you received: 26

Replied by Bart on topic gpio pulse after each image?

Thanks Jasem! Will try it out later today.

By the way, any idea about that 'less than 2 second integration time not possible' issue? Is it only with me?
3 years 5 months ago #62399

Please Log in or Create an account to join the conversation.

  • Posts: 163
  • Thank you received: 26

Replied by Bart on topic GPIO pulse after each image?

I can't get it to work.

What I've done:
Make a file: GPIO_Pulse.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from time import sleep
from gpiozero import LED
Pin17 = LED(17)
Pin17.on()
sleep(1)
Pin4.off()
exit(0)
In that directory (I made a new dir: Scripts) run the command:
stellarmate@stellarmate:~/Scripts $ chmod +x GPIO_Pulse.py
to make it an executable, correct?

Next in the sequence editor, I select the script: /home/stellarmate/Scripts/GPIO_Pulse.py

It does run, but returns (in the messages) 1, not 0.
Also I don't get any pulses on Pin17.

Apparently, the gpiozero library is already pre-installed (I tried installing it).
I also set raspberry pi configuration 'GPIO remote' to enable after it didn't work.

Any smart insights or suggestions? Thanks a lot! :-)
3 years 5 months ago #62619

Please Log in or Create an account to join the conversation.

Sounds like permissions issue? Does this script now works outside of Ekos? what does it return? you can type echo $? after you execute it to get the last exit code.
3 years 5 months ago #62623

Please Log in or Create an account to join the conversation.

  • Posts: 163
  • Thank you received: 26

Replied by Bart on topic gpio pulse after each image?

First of all: What -does- work is this:
#!/bin/bash
gpio mode 0 out
gpio write 0 1
sleep 0.1
gpio write 0 0
Really happy! :lol:

What happened with the earler (GPIO_Pulse.py) script, as run following:
stellarmate@stellarmate:~/Scripts $ python GPIO_Pulse1.py
returns:
/usr/lib/python2.7/dist-packages/gpiozero/devices.py:279: PinFactoryFallback: Falling back from rpigpio: No module named RPi
  'Falling back from %s: %s' % (name, str(e))))
/usr/lib/python2.7/dist-packages/gpiozero/devices.py:279: PinFactoryFallback: Falling back from rpio: No module named RPIO
  'Falling back from %s: %s' % (name, str(e))))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Can't connect to pigpio at localhost(8888)
 
Did you start the pigpio daemon? E.g. sudo pigpiod
 
Did you specify the correct Pi host/port in the environment
variables PIGPIO_ADDR/PIGPIO_PORT?
E.g. export PIGPIO_ADDR=soft, export PIGPIO_PORT=8888
 
Did you specify the correct Pi host/port in the
pigpio.pi() function? E.g. pigpio.pi('soft', 8888)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/usr/lib/python2.7/dist-packages/gpiozero/devices.py:279: PinFactoryFallback: Falling back from pigpio: failed to connect to localhost:8888
  'Falling back from %s: %s' % (name, str(e))))
/usr/lib/python2.7/dist-packages/gpiozero/devices.py:279: PinFactoryFallback: Falling back from native: unable to open /dev/gpiomem or /dev/mem; upgrade your kernel or run as root
  'Falling back from %s: %s' % (name, str(e))))
Traceback (most recent call last):
  File "GPIO_Pulse1.py", line 9, in <module>
    Led = LED(Pin)
  File "/usr/lib/python2.7/dist-packages/gpiozero/devices.py", line 124, in __call__
    self = super(GPIOMeta, cls).__call__(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/gpiozero/output_devices.py", line 211, in __init__
    pin, active_high, initial_value, pin_factory=pin_factory
  File "/usr/lib/python2.7/dist-packages/gpiozero/output_devices.py", line 93, in __init__
    super(OutputDevice, self).__init__(pin, pin_factory=pin_factory)
  File "/usr/lib/python2.7/dist-packages/gpiozero/mixins.py", line 106, in __init__
    super(SourceMixin, self).__init__(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/gpiozero/devices.py", line 512, in __init__
    super(GPIODevice, self).__init__(**kwargs)
  File "/usr/lib/python2.7/dist-packages/gpiozero/devices.py", line 243, in __init__
    Device.pin_factory = Device._default_pin_factory()
  File "/usr/lib/python2.7/dist-packages/gpiozero/devices.py", line 280, in _default_pin_factory
    raise BadPinFactory('Unable to load any default pin factory!')
gpiozero.exc.BadPinFactory: Unable to load any default pin factory!

I tried before: sudo pip install RPi
and I got:
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting RPi
Could not install packages due to an EnvironmentError: 404 Client Error: Not Found for url: https://pypi.org/simple/rpi/
3 years 5 months ago #62640

Please Log in or Create an account to join the conversation.

  • Posts: 71
  • Thank you received: 6
Hello Bart,

Try this : pip install RPi.GPIO

Take a look at this, in french but that would help you !
deusyss.developpez.com/tutoriels/RaspberryPi/PythonEtLeGpio/
The following user(s) said Thank You: Bart
Last edit: 3 years 5 months ago by TuxAstro.
3 years 5 months ago #62641

Please Log in or Create an account to join the conversation.

Time to create page: 0.576 seconds