User avatar
mattrix
Posts: 132
Joined: Mon Mar 02, 2015 6:20 am
Location: Christchurch, New Zealand
Contact: Website

Re: New pigpio Python module

Thu Nov 19, 2015 11:19 pm

Would you library allow for accurately sending IR pulses?
I have an Odroid XU4 that I want to use to blast some IR at my heat-pump.
www.matthuisman.nz

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

Re: New pigpio Python module

Thu Nov 19, 2015 11:41 pm

mattrix wrote:Would you library allow for accurately sending IR pulses?
I have an Odroid XU4 that I want to use to blast some IR at my heat-pump.
Almost certainly. Do you have any details of the IR pulse? E.g. do you know the protocol used or have you captured the waveform?

User avatar
mattrix
Posts: 132
Joined: Mon Mar 02, 2015 6:20 am
Location: Christchurch, New Zealand
Contact: Website

Re: New pigpio Python module

Fri Nov 20, 2015 12:41 am

If I recall (was a while ago), I had a reciever and used that library (can't remember name) to record the pulses.
But it errored.

I think it was due to the AirCon remote sends a lot of data?
www.matthuisman.nz

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

Re: New pigpio Python module

Fri Nov 20, 2015 8:04 am

Try capturing the IR data with piscope. You can save the waveform to a file using the '1' and '2' keys to select a portion. That should allow identification of the broad type of protocol. If the protocol can't be identified it would be possible just to regurgitate the signal (which is what LIRC does as far as I can make out).

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

Re: New pigpio Python module

Sun Nov 22, 2015 8:12 pm

joan wrote:If you can put together a small program which shows the problem I'll have a look.
so it seems that it's an hardware problem and not a software problem.
Some of the cables were crossing each other and probably in this way causing some interferences.
Moved the cables, no problem at all.
i'm scared of this :)

thanks

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

Re: New pigpio Python module

Sun Nov 22, 2015 8:36 pm

Massi wrote: ...
Moved the cables, no problem at all.
i'm scared of this :)
...
Not much you can do about dodgy connections (apart from fix them).

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

Re: New pigpio Python module

Mon Nov 23, 2015 9:04 am

well i don't think it's the case of dodgy connections, and that's why i'm scared.
i use all dupont cables, but in the specific case I THINK that the problem is that for installation purpouse some data cables where very close to other data cables, with an angle of exactly 90 degrees.
So i think it's something about interference.. even because if a connections is bad, you should get errors on the specific device connected, but in my case i had errors on different devices than the one causing the errors.

so, happy it got fixed, but strange behaviour :)

DBordello
Posts: 38
Joined: Tue Nov 03, 2015 6:20 pm

Re: New pigpio Python module

Tue Dec 08, 2015 6:28 pm

Great work. pigpio is a joy to work with.

It appears to chew some CPU (8% on a RPi A+) even when idle. Just curious, what is it up to?

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

Re: New pigpio Python module

Tue Dec 08, 2015 6:47 pm

DBordello wrote:Great work. pigpio is a joy to work with.

It appears to chew some CPU (8% on a RPi A+) even when idle. Just curious, what is it up to?
By default it samples GPIO 0-31 200 thousand times a second. The time is being spent checking to see which GPIO have changed state. It's a constant overhead, and pretty pointless if you are not interested in GPIO changes. You could start the daemon with 10 µs sampling to reduce that overhead. On the plus size the overhead doesn't change if you start PWM or servo pulses on any number of GPIO. Also on the plus side once you are interested in more than a few hundred GPIO state changes per second it's less of an overhead than the alternative methods.

DBordello
Posts: 38
Joined: Tue Nov 03, 2015 6:20 pm

Re: New pigpio Python module

Tue Dec 08, 2015 8:57 pm

joan wrote:
DBordello wrote:Great work. pigpio is a joy to work with.

It appears to chew some CPU (8% on a RPi A+) even when idle. Just curious, what is it up to?
By default it samples GPIO 0-31 200 thousand times a second. The time is being spent checking to see which GPIO have changed state. It's a constant overhead, and pretty pointless if you are not interested in GPIO changes. You could start the daemon with 10 µs sampling to reduce that overhead. On the plus size the overhead doesn't change if you start PWM or servo pulses on any number of GPIO. Also on the plus side once you are interested in more than a few hundred GPIO state changes per second it's less of an overhead than the alternative methods.
Great, thank you for the prompt reply.

I am interested in PVM, so it looks like the overhead is justified.

sonicjenova
Posts: 2
Joined: Thu Dec 17, 2015 8:53 pm

Re: New pigpio Python module

Thu Dec 17, 2015 9:04 pm

Hi,

I need to read and write 9 bit UART data for my project. I noticed your library can do it. I tried connecting together the two exact GPIO pins of my two pi boards, and changed RX and TX pin numbers in my python code. I used wave_add_serial to send 9 bit data from one pi to the other one and tried reading bb_serial_read on the other pi. I keep getting unusual reading. Can you give me sample code in python to show me how to write a 9 bit serial data through a specific pin of one pi board, and read that sen t data on another specific board of the other pi board.

Thank you,

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

Re: New pigpio Python module

Fri Dec 18, 2015 5:26 pm

have you connected also the ground between the 2 pis?

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

Re: New pigpio Python module

Fri Dec 18, 2015 5:37 pm

...also make sure you set the TX GPIO to be outputs (I think the receive side is done for you).

sonicjenova
Posts: 2
Joined: Thu Dec 17, 2015 8:53 pm

Re: New pigpio Python module

Sat Dec 19, 2015 4:14 am

Yeay it worked now I need to use this 9 bit serials to communicate with a vending machine's MDB.

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

Re: New pigpio Python module

Fri Jan 15, 2016 10:38 am

joan,
i think there's a typo here:

http://abyz.co.uk/rpi/pigpio/python.html#serial_open

never seen 9500bps for a serial :)

btw, since i'm having problems with "common" serial commands (here: viewtopic.php?f=91&t=131551 ) i wanted to try with yours, how can i set parity, stop bits and byte size? (if i can :))

thanks :)

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

Re: New pigpio Python module

Fri Jan 15, 2016 11:24 am

@massi

Thanks, have internally changed 9500 to 9600.

I don't know why you can't set parity, bits, stop bits. I may have meant to add them as there is an unused flags parameter. I probably decided there was so little you can actually configure it wasn't worth the effort, e.g. bits 5-8, stop bits 1-2. Is any of that any use to you?

http://abyz.co.uk/rpi/pigpio/python.htm ... _read_open may be the way to go for variable word size and stop bits, still no parity checking though, that would be up to the receiver.

I have been working on a Python class to encapsulate bit banged serial send/receive (just wrappers for the existing functions). That would probably be the simplest if I ever get back to it.

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

Re: New pigpio Python module

Fri Jan 15, 2016 11:55 am

joan wrote:I don't know why you can't set parity, bits, stop bits. I may have meant to add them as there is an unused flags parameter. I probably decided there was so little you can actually configure it wasn't worth the effort, e.g. bits 5-8, stop bits 1-2. Is any of that any use to you?.
well, probably it's ok even the default, since i ended up with this config

Code: Select all

parity = serial.PARITY_NONE,
stopbits = serial.STOPBITS_ONE,
bytesize = serial.EIGHTBITS,
but it sounded strange to me the impossibility to set up the configuration :)

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

Re: New pigpio Python module

Fri Jan 15, 2016 1:55 pm

Sorry for debugging your webpage, but i think that this is not existing :lol:

http://abyz.co.uk/rpi/pigpio/python.html#set_filter

maybe it's the first idea before creating these two?

http://abyz.co.uk/rpi/pigpio/python.htm ... tch_filter
http://abyz.co.uk/rpi/pigpio/python.htm ... ise_filter

i always discover something new :)

(deleting a watchdog is not impacting on callbacks, isn't it?)

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

Re: New pigpio Python module

Fri Jan 15, 2016 3:06 pm

@Massi

Correct, updated internally. I changed the calls to set_glitch_filter and set_noise_filter.

Removing a watchdog won't have any effect on callbacks, other than the callback will no longer receive watchdog timeout messages.

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

Re: New pigpio Python module

Fri Jan 15, 2016 3:09 pm

joan wrote:Removing a watchdog won't have any effect on callbacks, other than the callback will no longer receive watchdog timeout messages.
perfect, exactly what i was expecting.
Very good method to understand how long a button is pressed..

thanks

pickledgator
Posts: 7
Joined: Fri Feb 12, 2016 2:41 am

Re: New pigpio Python module

Fri Feb 12, 2016 2:43 am

Is it possible to use the pigpio library to generate a ppm signal for 6-8 channels with a 18ms frame on a rpi? If so, can someone point me in the right direction for which pigpio function calls would allow me to achieve this?

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

Re: New pigpio Python module

Fri Feb 12, 2016 8:26 am

pickledgator wrote:Is it possible to use the pigpio library to generate a ppm signal for 6-8 channels with a 18ms frame on a rpi? If so, can someone point me in the right direction for which pigpio function calls would allow me to achieve this?
I don't understand PPM.

I presume there is a repeating 18 ms waveform (at least in a steady state).

How are the channel settings encoded on to the waveform? Does each channel get a separate time slot within the 18 ms (if so how long?) and is the position of the pulse (how long?) within the time slot the encoding? i.e. a pulse at the start of the time slot is 0%, a pulse at the end of the time slot is 100%, a pulse in the middle is 50%?

pickledgator
Posts: 7
Joined: Fri Feb 12, 2016 2:41 am

Re: New pigpio Python module

Tue Feb 16, 2016 4:12 am

Thanks for the reply, Joan. Hopefully this video clarifies how the ppm encoding works:
https://www.youtube.com/watch?v=sEChFDRf8Ek

The whole frame is a set length (let's say 27ms, for example). Then each of 8 channels are encoded in the single frame, where each channel's pulse is 2ms long when the channel is at max and 1ms long when at min. So that allows for a total of 16ms worth of encoded signals. The remaining ~11ms (minus the gaps between pulses) is considered a sync pulse, which allows the receiver to find the start of the next frame. In the 18ms frame example, you'll only be able to encode 6 channels to maintain the sync pulse (which has to be larger than the max channel pulse length, ie, >2ms)

I'm trying to achieve this encoding/generation from a rpi. The pigpio library looks like the best library option to achieve it, despite not supporting combined ppm signals out of the box. Having never used it before, I'm hoping for some direction. Thanks for any pointers you may have for this.

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

Re: New pigpio Python module

Tue Feb 16, 2016 6:56 am

pickledgator wrote:Thanks for the reply, Joan. Hopefully this video clarifies how the ppm encoding works:
https://www.youtube.com/watch?v=sEChFDRf8Ek

The whole frame is a set length (let's say 27ms, for example). Then each of 8 channels are encoded in the single frame, where each channel's pulse is 2ms long when the channel is at max and 1ms long when at min. So that allows for a total of 16ms worth of encoded signals. The remaining ~11ms (minus the gaps between pulses) is considered a sync pulse, which allows the receiver to find the start of the next frame. In the 18ms frame example, you'll only be able to encode 6 channels to maintain the sync pulse (which has to be larger than the max channel pulse length, ie, >2ms)

I'm trying to achieve this encoding/generation from a rpi. The pigpio library looks like the best library option to achieve it, despite not supporting combined ppm signals out of the box. Having never used it before, I'm hoping for some direction. Thanks for any pointers you may have for this.
nice, i didn't know that.
with pigpio's waves you can achieve this quite easily, the problem can be the time you need to generate waves before sending them..
what you want to do? reproduce a controller?

pickledgator
Posts: 7
Joined: Fri Feb 12, 2016 2:41 am

Re: New pigpio Python module

Tue Feb 16, 2016 7:19 am

Yea, I'm basically spoofing a controller signal from the rpi. To generate the 27ms frame, it'll have to run at ~37 Hz. Are the waveform generations expensive?

Return to “Python”