User avatar
joan
Posts: 12738
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

New pigpio Python module

Tue Jan 14, 2014 4:01 pm

I have released an updated version of the pigpio Python module. The only change is to ensure callbacks work properly under Windows.

The module provides access to the Pi's gpios with the principal features
  • PWM may be output to all gpios (PWM is used to position servos, control motor speed, control LED brightness etc).
  • Callbacks for fast reaction to changes in gpio levels.
  • Reading/writing of individual gpios or all gpios in one operation.
  • Setting gpio modes.
  • Setting gpio pull-up down state.
Preparation

To download and install cut & paste the following into a Pi terminal window (all steps should be complete in less than 3 minutes).

Code: Select all

wget abyz.co.uk/rpi/pigpio/pigpio.zip
unzip pigpio.zip
cd PIGPIO
make
make install

If you don't have wget click on http://abyz.co.uk/rpi/pigpio/pigpio.zip and do the unzip/make manually.

Test

The Python module requires the services of the pigpio daemon. As a quick test. Start the daemon.

sudo pigpiod

Start Python.

python

Enter the following code (you can cut & paste but do not use the SELECT ALL button as that corrupts the formatting).

Code: Select all

import pigpio

pigpio.start()

for g in range(0,32):
   print("gpio {} is {}".format(g, pigpio.read(g)))

pigpio.stop()

The code prints the level of the first 32 gpios.

To exit Python type exit() or ctrl-D.

A script to show the status of the first 32 gpios with updates is at http://abyz.co.uk/rpi/pigpio/code/gpio_status_py.zip.

Documentation

You can use help(pigpio) within python or refer to the on-line documentation at http://abyz.co.uk/rpi/pigpio/python.html

Remote Processing

There are almost certainly performance advantages in running the Python code on a networked machine separate to the Pi. The pigpio daemon must still be running on the Pi.

The simplest method is to copy the setup.py and pigpio.py files from the PIGPIO directory to a temporary directory on the remote machine. Then move to the temporary directory and enter.

On Linux

sudo python setup.py install

On Windows something like

c:\python33\python setup.py install

On the remote machine you need to specify the address of the Pi (either by hostname or IP address).

On Linux something like

export PIGPIO_ADDR=myPi

On Windows something like

set PIGPIO_ADDR=myPi

Alternatively, rather than pigpio.start(), you could use pigpio.start('myPi').

I don't know what needs to be done on a Mac.

Performance Comparison

The following table gives an idea of the performance gains to be had from running remotely. In each test each of 14 gpios were raising 8000 measurable events per second for a total of 112,000 events per second. The 000's EPS column show the number of events captured by the Python module. My pretty poor desktop caught them all, my pretty poor laptop nearly all, and the Pi's were obviously swamped.

Code: Select all

000's  Python  O/S            Machine
EPS    version

113    2.7     Debian         remote Desktop
113    2.7     Windows(XP)    remote Desktop
113    3.3     Debian         remote Desktop
113    3.3     Windows(XP)    remote Desktop

99.2   3.3     Debian         remote Laptop
98.9   2.7     Debian         remote Laptop
90.6   2.7     Windows(Vista) remote Laptop
78.3   3.3     Windows(Vista) remote Laptop

9.69   2.7     Raspbian       local Pi
8.58   2.7     Debian         local Pi
6.49   3.2     Raspbian       local Pi
6.25   3.2     Debian         local Pi
The test code used is at http://abyz.co.uk/rpi/pigpio/code/bench_1_py.zip. Don't try the code yourself unless you remove everything connected to the gpios (LEDs are probably OK but other devices could be damaged).

qtfp
Posts: 32
Joined: Sat May 25, 2013 2:00 pm

Re: New pigpio Python module

Tue Nov 25, 2014 6:53 pm

Hey,
Thanks for this extremely useful library! I am really happy with the pigpio.pwm and pigpio.waves. Now, I have some question.

First, When I tried library "bcm2835", I found its PWM can run as fast as 4MHz. I tried to use it together with pigpio, but they seemed to cancel each other. Do you know why? And its pwm can divide 19.2MHz by integrals, that is to say, we can create almost any desire frequency by dividing it. Although it can only be used in GPIO18.
http://www.airspayce.com/mikem/bcm2835/

Another, is there any possibility to configure pigpio.pwm waveform like RPIO(two pulse in one cycle)?
http://pythonhosted.org/RPIO/pwm_py.htm ... cilloscope

In my application, controlling frequency continuously(like tuning fre from 1000~2000 ) is desired. And in pigpio.pwm, the frequency can only be some value depending on sampling rate. I just try to get as much port to send different frequency as possible.

It will be grateful if you can give me some advise on continuous frequency manipulation. THX!!

User avatar
joan
Posts: 12738
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: New pigpio Python module

Tue Nov 25, 2014 8:08 pm

bcm2835 uses the hardware PWM peripheral to generate pwm on one gpio.

pigpio generated pwm works on any gpio but is restricted to certain update rates.

By default pigpio uses the PCM peripheral for timing thus leaving the PWM peripheral to be used for audio or pwm.

However waves can't use PCM for timing as that would break gpio sampling, servo and pwm pulses. waves use the hardware PWM peripheral for timing.

If you don't use waves you should be able to use bcm2835 generated pwm.

You should be able to generate any waveform you want within reason. If you can specify the waveform I may be able to tell you the simplest way to create it using pigpio.

qtfp
Posts: 32
Joined: Sat May 25, 2013 2:00 pm

Re: New pigpio Python module

Wed Nov 26, 2014 5:32 am

joan wrote: You should be able to generate any waveform you want within reason. If you can specify the waveform I may be able to tell you the simplest way to create it using pigpio.
Thanks for some knowhow. I want to control the pulsing speed to a4988 and step motor. And there will be at least 5 step motor, so I need 5 pwm output with different frequency(500~20000Hz). I also need to update the frequency in the program.
So my program will be like:
pi.set_PWM_frequency(4,1000)
pi.set_PWM_frequency(5,1200)
time.sleep(1)
pi.set_PWM_frequency(4,1100)
pi.set_PWM_frequency(5,1100)
time.sleep(1)
pi.set_PWM_frequency(4,1200)
pi.set_PWM_frequency(5,1000)
I think to use pigpio.wave combining lots of pigpio.pulse in different port before, but there are upper limit of the pigpio.pulse number. Also, the period will be the multiple of the longest period like:
1pulse/10000us
2pulse/10000us
3pulse/10000us
4pulse/10000us

User avatar
joan
Posts: 12738
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: New pigpio Python module

Wed Nov 26, 2014 8:30 am

See if the following makes sense.

Another guy wanted square waves with different periods on 4 gpios.

Take the comments with a pinch of salt. They were more thinking out loud. Ignore the LED type stuff. I had some RGB LEDs set-up and used them for testing.

Code: Select all

#!/usr/bin/env python

# 2014-11-26
# tarte.py
# Public Domain

import time

import pigpio

"""
7.5 10 12 16

Find the number of cycles needed for an integral switch on/off for each LED.

That's 2*7.5 which is 2 seconds worth.

In 2 seconds there will be this many cycles of on/off

15  20 24 32

How many micros for each cycle?

15 66666 on 66667 off = 1999995
20 50000 on 50000 off = 2000000
24 41666 on 41667 off = 1999992
32 31250 on 31250 off = 2000000

There will be a slight error which will not be detectable by most means.
"""

def wave(pi, gpio, hz, secs, on=1, offset=0):
   """
   Generate a hz cycles per second square wave on gpio for
   secs seconds.  The first transition is to level on at
   offset microseconds from the start.
   """
   micros_left = int(secs * 1000000)
   transitions = int(2 * hz * secs)
   micros = micros_left / transitions

   if (offset < 0) or (offset > micros):
      print("Illegal offset {} for hz {}".format(offset, hz))
      exit()

   pi.set_mode(gpio, pigpio.OUTPUT)

   wf = [] # Empty waveform.

   if offset:
      wf.append(pigpio.pulse(0, 0, offset))
      micros_left -= micros
      last_micros = micros - offset
      transitions -= 1

   for t in range(transitions, 0, -1):
      micros = micros_left / t
      if (t & 1) == (on & 1):
         wf.append(pigpio.pulse(0, 1<<gpio, micros))
      else:
         wf.append(pigpio.pulse(1<<gpio, 0, micros))
      micros_left -= micros

   if offset:
      if on:
         wf.append(pigpio.pulse(1<<gpio, 0, last_micros))
      else:
         wf.append(pigpio.pulse(0, 1<<gpio, last_micros))

   pi.wave_add_generic(wf)


F=[
   1.0/60, 1.0/30, 1.0/20, 1.0/15, 1.0/12, 1.0/10, 1.0/6, 1.0/5,
   1.0/3,  1.0/2,  1,      2,      3,      4,      5,     6]

pi = pigpio.pi() # Connect to local host.

pi.wave_clear()

LEDS = [
   [21, 20, 16], [26, 19, 13], [12,  7,  8], [ 6,  5, 11], 
   [25, 24, 23], [ 9, 10, 22], [18, 15, 14], [27, 17,  4]]

hz=100
LIMIT=100000

"""
for l in range(len(LEDS)):
   for c in LEDS[l]:
      pi.write(c, 0)
   wave(pi, LEDS[l][0], hz, 1)
   wave(pi, LEDS[l][1], hz+1, 1)
   wave(pi, LEDS[l][2], hz+2, 1)
   hz += 3
   if hz >= LIMIT:
      hz -= LIMIT
"""

wave(pi, LEDS[0][0], 7.5, 2, 0, 23456)
wave(pi, LEDS[1][0], 10,  2)
wave(pi, LEDS[2][0], 12,  2, 1,17123)
wave(pi, LEDS[3][0], 16,  2)

wid = pi.wave_create()

pi.wave_send_repeat(wid)

pi.stop()

scotty101
Posts: 2237
Joined: Fri Jun 08, 2012 6:03 pm

Re: New pigpio Python module

Wed Nov 26, 2014 1:11 pm

Joan, Have you considered moving the pigpio project to GitHub?
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

User avatar
joan
Posts: 12738
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: New pigpio Python module

Wed Nov 26, 2014 1:17 pm

scotty101 wrote:Joan, Have you considered moving the pigpio project to GitHub?
Most of it is on github.

https://github.com/joan2937/pigpio/tree/master

piscope isn't. I'll probably create a new repository for that.

scotty101
Posts: 2237
Joined: Fri Jun 08, 2012 6:03 pm

Re: New pigpio Python module

Wed Nov 26, 2014 1:24 pm

Excellent thanks :D
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

Massi
Posts: 1598
Joined: Fri May 02, 2014 1:52 pm
Location: Italy

Re: New pigpio Python module

Wed Nov 26, 2014 2:03 pm

damn, i missed also V23 :D

does this deserve an update?

User avatar
joan
Posts: 12738
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: New pigpio Python module

Wed Nov 26, 2014 2:07 pm

pattagghiu wrote:damn, i missed also V23 :D

does this deserve an update?
I added read backs for PWM dutycycles and servo pulsewidths. I (hopefully) corrected another string handling bug depending on the Python version in use. Nothing significant.

qtfp
Posts: 32
Joined: Sat May 25, 2013 2:00 pm

Re: New pigpio Python module

Thu Nov 27, 2014 7:12 pm

Thanks for the code, I tried it. I got error

Code: Select all

Traceback (most recent call last):                                                                                                                                                                            
  File "pigpio_wave_4pwm.py", line 74, in <module>                                                                                                                                                            
    wave(pi, 23, 200, 2, 0, 0)                                                                                                                                                                                
  File "pigpio_wave_4pwm.py", line 70, in wave                                                                                                                                                                
    pi.wave_add_generic(wf)                                                                                                                                                                                   
  File "pigpio.py", line 1486, in wave_add_generic                                                                                    
    self.sl, _PI_CMD_WVAG, 0, 0, len(pulses)*12, extents))                                                                                                                                                    
  File "pigpio.py", line 724, in _pigpio_command_ext                                                                                  
    dummy, res = struct.unpack('12sI', sl.s.recv(16))                                                                                                                                                         
socket.error: [Errno 104] Connection reset by peer
When the frequency is higher and needs a lot of "wf.append(pigpio.pulse(0, 1<<gpio, micros))", it will fail.
But this code did inspire me to build simpler one with less "wf.append(pigpio.pulse(0, 1<<gpio, micros))"!!!
Is there any possibility to get more pigpio.pulse, or this is a dma limit?
Thanks for your efforts, your library is such a important reason that I use raspi but not other board like BBB :D :D :D

Massi
Posts: 1598
Joined: Fri May 02, 2014 1:52 pm
Location: Italy

Re: New pigpio Python module

Thu Nov 27, 2014 7:36 pm

Try to see if this topic helps :)

http://www.raspberrypi.org/forums/viewt ... 37&t=79978

joan's teaching..

qtfp
Posts: 32
Joined: Sat May 25, 2013 2:00 pm

Re: New pigpio Python module

Thu Nov 27, 2014 7:46 pm

pattagghiu wrote:Try to see if this topic helps :)

http://www.raspberrypi.org/forums/viewt ... 37&t=79978

joan's teaching..
The code in that topic is amazing :o
I should learn from that too!!

Massi
Posts: 1598
Joined: Fri May 02, 2014 1:52 pm
Location: Italy

Re: New pigpio Python module

Thu Nov 27, 2014 7:53 pm

qtfp wrote:
pattagghiu wrote:Try to see if this topic helps :)

http://www.raspberrypi.org/forums/viewt ... 37&t=79978

joan's teaching..
The code in that topic is amazing :o
I should learn from that too!!
ahahah yes, that was my first real PI project and thanks to joan now i can controll my three AC splits with the raspberry..

good for us to have joan here around :)

qtfp
Posts: 32
Joined: Sat May 25, 2013 2:00 pm

Re: New pigpio Python module

Sun Nov 30, 2014 6:57 pm

It's good to have joan here!
I tried the code with different time period and now it work fine.
I find one difference between "wave_tx_repeat()" and "wave_send_repeat"
The updating "wave_send_repeat" will get about 10ms delay between old and new waveform while "wave_tx_repeat()" will not.
The "wave_tx_repeat()" is about to be remove according your website, so I am worried it will be removed :o
Thanks again, I have learned a lot from your code, not only coding but also thinking. :ugeek:

User avatar
joan
Posts: 12738
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: New pigpio Python module

Sun Nov 30, 2014 8:05 pm

qtfp wrote:It's good to have joan here!
I tried the code with different time period and now it work fine.
I find one difference between "wave_tx_repeat()" and "wave_send_repeat"
The updating "wave_send_repeat" will get about 10ms delay between old and new waveform while "wave_tx_repeat()" will not.
The "wave_tx_repeat()" is about to be remove according your website, so I am worried it will be removed :o
Thanks again, I have learned a lot from your code, not only coding but also thinking. :ugeek:
I'd have thought wave_tx_repeat would have the longer delay as it has to generate the DMA control blocks for the waveform. wave_send_repeat doesn't need that step as it has already been done during the wave_create call.

I probably won't remove the function. It's more work to remove it then it is to leave it in place.

By the way, the maximum socket message size has increased from 8192 bytes to 65536 bytes.

Howard
Posts: 64
Joined: Sun Mar 04, 2012 7:38 pm
Contact: Website

Re: New pigpio Python module

Tue Dec 16, 2014 7:29 am

I would like to use pigpio to provide 4 rs232 style interfaces on a Pi to be used remotely (socket interface) from my own java program.

Q1. Is it possible to invoke wave_add_serial, wave_send_once for one gpio while another gpio is still sending?

Q2. Assuming the answer to Q1 is yes, then is it possible to know if a pulse stream on an individual gpio has finished, and it is therefore safe to send another message.

If the answer to Q2 is no, then is the best approach to invoke wave_add_serial, wave_get_micros, wave_send_once and remember the time at which the send is due to finish?

User avatar
joan
Posts: 12738
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: New pigpio Python module

Tue Dec 16, 2014 8:25 am

Howard wrote:I would like to use pigpio to provide 4 rs232 style interfaces on a Pi to be used remotely (socket interface) from my own java program.

Q1. Is it possible to invoke wave_add_serial, wave_send_once for one gpio while another gpio is still sending?

Q2. Assuming the answer to Q1 is yes, then is it possible to know if a pulse stream on an individual gpio has finished, and it is therefore safe to send another message.

If the answer to Q2 is no, then is the best approach to invoke wave_add_serial, wave_get_micros, wave_send_once and remember the time at which the send is due to finish?
Only one waveform may be being transmitted at any one moment in time. A waveform is transmitted using the wave_send_once/repeat functions. A transmitted waveform may contain serial data (at the same or different baud rates) for multiple gpios.

wave_tx_busy will return True if a waveform is being transmitted and False when it is finished. Note, a waveform sent with wave_send_repeat will never finish, it needs either to be stopped with wave_tx_stop or the use of a new wave_send_once/repeat.

To find the length of the waveform in microseconds call wave_get_micros just before calling wave_create (wave_create zeros the number of micros).

While a waveform is being transmitted other waveforms may be constructed with the wave_add_generic/serial and wave_create functions. wave_create will return a unique id for each waveform. The limit is the amount of resources allocated to waveforms.

Be aware that I am changing wave_add_serial to take databits (1..32, default 8) and stophalfbits (2..8, default 2) parmeters. This will be invisible to Python code as eight data bits, one stop bit (2 half bits) will be the default. The underlying socket message will be altered.

slawekw79
Posts: 31
Joined: Tue Dec 30, 2014 3:36 pm

Re: New pigpio Python module

Sun Jan 18, 2015 7:50 pm

Hi
I have a issue after install pigpio library, i can't run my script because :

Code: Select all

Traceback (most recent call last):
  File "/home/pi/mtest.py", line 3, in <module>
    import pigpio
ImportError: No module named pigpio
I've checked :

Code: Select all

pi@raspberrypi ~/PIGPIO $ sudo ./x_pigpio
2015-01-18 19:39:50 gpioInitialise: Can't lock /var/run/pigpio.pid
pigpio initialisation failed.
and i installed again and still have this issue. Can somebody help me?

User avatar
joan
Posts: 12738
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: New pigpio Python module

Sun Jan 18, 2015 7:55 pm

Make sure the daemon isn't running

sudo killall -9 pigpiod

Delete any lock file

sudo rm /var/run/pigpio.pid

Then sudo ./x_pigpio should run.

The other tests need the daemon to be running.

slawekw79
Posts: 31
Joined: Tue Dec 30, 2014 3:36 pm

Re: New pigpio Python module

Sun Jan 18, 2015 9:13 pm

still not running

Code: Select all

pi@raspberrypi ~/PIGPIO $ sudo ./x_pigpio
Version.
pigpio version 25.
Hardware revision 16.
Mode/PUD/read/write tests.
TEST  1.1  PASS (set mode, get mode: 0)
TEST  1.2  PASS (set pull up down, read: 1)
TEST  1.3  PASS (set pull up down, read: 0)
TEST  1.4  PASS (write, get mode: 1)
TEST  1.5  PASS (read: 0)
TEST  1.6  PASS (write, read: 1)
PWM dutycycle/range/frequency tests.
TEST  2.1  PASS (set PWM range, set/get PWM frequency: 10)
TEST  2.2  PASS (get PWM dutycycle: 0)
TEST  2.3  PASS (set PWM dutycycle, callback: 0)
TEST  2.4  PASS (get PWM dutycycle: 128)
TEST  2.5  PASS (set PWM dutycycle, callback: 40)
TEST  2.6  PASS (set/get PWM frequency: 100)
TEST  2.7  PASS (callback: 400)
TEST  2.8  PASS (set/get PWM frequency: 1000)
TEST  2.9  PASS (callback: 4000)
TEST  2.10 PASS (get PWM range: 255)
TEST  2.11 PASS (get PWM real range: 200)
TEST  2.12 PASS (set/get PWM range: 2000)
TEST  2.13 PASS (get PWM real range: 200)
PWM/Servo pulse accuracy tests.
TEST  3.1  PASS (get servo pulsewidth: 500)
TEST  3.2  PASS (set servo pulsewidth: 40000)
TEST  3.3  PASS (get servo pulsewidth: 1500)
TEST  3.4  PASS (set servo pulsewidth: 13333)
TEST  3.5  PASS (get servo pulsewidth: 2500)
TEST  3.6  PASS (set servo pulsewidth: 8000)
TEST  3.7  PASS (set/get PWM frequency: 1000)
TEST  3.8  PASS (set PWM range: 200)
TEST  3.9  PASS (get PWM dutycycle: 20)
TEST  3.10 PASS (set PWM dutycycle: 200)
TEST  3.11 PASS (get PWM dutycycle: 40)
TEST  3.12 PASS (set PWM dutycycle: 400)
TEST  3.13 PASS (get PWM dutycycle: 60)
TEST  3.14 PASS (set PWM dutycycle: 600)
TEST  3.15 PASS (get PWM dutycycle: 80)
TEST  3.16 PASS (set PWM dutycycle: 800)
Pipe notification tests.
TEST  4.1  PASS (notify open/begin: 0)
TEST  4.2  PASS (notify pause: 0)
TEST  4.3  PASS (notify close: 0)
TEST  4.4  PASS (sequence numbers ok: 1)
TEST  4.5  PASS (gpio toggled ok: 1)
TEST  4.6  PASS (number of notifications: 80)
Waveforms & serial read/write tests.
TEST  5.1  PASS (callback, set mode, wave clear: 0)
TEST  5.2  PASS (pulse, wave add generic: 4)
TEST  5.3  PASS (wave tx repeat: 9)
TEST  5.4  PASS (callback: 50)
TEST  5.5  PASS (wave tx stop: 0)
TEST  5.6  PASS (serial read open: 0)
TEST  5.7  PASS (wave clear, wave add serial: 3405)
TEST  5.8  PASS (wave tx start: 6811)
TEST  5.9  PASS (NOT APPLICABLE: 0)
TEST  5.10 PASS (NOT APPLICABLE: 0)
TEST  5.11 PASS (wave tx busy, serial read: 0)
TEST  5.12 PASS (serial read close: 0)
TEST  5.13 PASS (wave get micros: 6158148)
TEST  5.14 PASS (wave get high micros: 6158148)
TEST  5.15 PASS (wave get max micros: 1800000000)
TEST  5.16 PASS (wave get pulses: 3405)
TEST  5.17 PASS (wave get high pulses: 3405)
TEST  5.18 PASS (wave get max pulses: 12000)
TEST  5.19 PASS (wave get cbs: 6810)
TEST  5.20 PASS (wave get high cbs: 6810)
TEST  5.21 PASS (wave get max cbs: 25016)
Trigger tests
TEST  6.1  PASS (gpio trigger count: 5)
TEST  6.2  PASS (gpio trigger pulse length: 150)
Watchdog tests.
TEST  7.1  PASS (set watchdog on count: 200)
TEST  7.2  PASS (set watchdog off count: 0)
Bank read/write tests.
TEST  8.1  PASS (read bank 1: 0)
TEST  8.2  PASS (read bank 1: 16)
TEST  8.3  PASS (clear bank 1: 0)
TEST  8.4  PASS (set bank 1: 1)
TEST  8.5  PASS (read bank 2: 60)
TEST  8.6  PASS (clear bank 2: 0)
TEST  8.7  PASS (NOT APPLICABLE: 0)
TEST  8.8  PASS (set bank 2: 0)
TEST  8.9  PASS (NOT APPLICABLE: 0)
Script store/run/status/stop/delete tests.
TEST  9.1  PASS (store/run script: 100)
TEST  9.2  PASS (run script/script status: 201)
TEST  9.3  PASS (run/stop script/script status: 110)
TEST  9.4  PASS (delete script: 0)
pi@raspberrypi ~/PIGPIO $ cd /home/pi/
pi@raspberrypi ~ $ sudo pigpiod
pi@raspberrypi ~ $ python3 mtest.py
Traceback (most recent call last):
  File "mtest.py", line 3, in <module>
    import pigpio
ImportError: No module named pigpio
pi@raspberrypi ~ $ 


User avatar
joan
Posts: 12738
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: New pigpio Python module

Sun Jan 18, 2015 9:22 pm

That's a feature of Python. You need to install the module separately for each version of Python. By default it will be installed for the default version of Python, which will be Python 2.

To install for Python 3 use the following command in the PIGPIO directory.

sudo python3 setup.py install

slawekw79
Posts: 31
Joined: Tue Dec 30, 2014 3:36 pm

Re: New pigpio Python module

Wed Jan 21, 2015 4:33 pm

hi
I installed pigpio for python3, but now I have issue like this:

Code: Select all

pi@raspberrypi ~ $ sudo pigpiod
pi@raspberrypi ~ $ python3 mtest.py
Traceback (most recent call last):
  File "mtest.py", line 7, in <module>
    pigpio.start()
AttributeError: 'module' object has no attribute 'start'
pi@raspberrypi ~ $ 
And i'm not sure problem is with my code or pigpio

bigredpit
Posts: 1
Joined: Tue Feb 10, 2015 10:17 pm

Re: New pigpio Python module

Tue Feb 10, 2015 10:19 pm

Did anyone solve this previous problem with the no module start? I can't seem to get the pigpio library to function for PWM on a dc motor?

User avatar
joan
Posts: 12738
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: New pigpio Python module

Wed Feb 11, 2015 11:56 pm

bigredpit wrote:Did anyone solve this previous problem with the no module start? I can't seem to get the pigpio library to function for PWM on a dc motor?
It should work.

At a minimum your Python should contain

Code: Select all

import pigpio

pi = pigpio.pi() # Connect to local Pi.

# your program

pi.stop() # Disconnect from local Pi.
Post your code.

Return to “Python”

Who is online

Users browsing this forum: No registered users and 17 guests