I wouldn't bother. I'd just apply the PID and if it results in no change in duty cycle then so be it.PlanB wrote:So 25000 steps at 10kHz. Does that mean my PID loop should increment the duty cycle in blocks of 40 between 0 & 1000000?Code: Select all
dc=dc+40 pi.hardware_PWM(18, 10000, dc)
Re: New pigpio Python module
Re: New pigpio Python module
I tried just ramping the 10kHz duty cycle in steps of 40 for starters Joan but the CRO trace is all broken up, 30-40ms of 10kHz separated by similar intervals of gpio18 at 3.3v. Is this normal? I thought DMA based pwm ensured a steady stream uninterrupted by the OS like the software based versions?
Re: New pigpio Python module
No, that isn't normal. I suspect a dodgy connection on your CRO or an error in your script.PlanB wrote:I tried just ramping the 10kHz duty cycle in steps of 40 for starters Joan but the CRO trace is all broken up, 30-40ms of 10kHz separated by similar intervals of gpio18 at 3.3v. Is this normal? I thought DMA based pwm ensured a steady stream uninterrupted by the OS like the software based versions?
Re: New pigpio Python module
Absolutely right, some weird aliasing effect on the digital CRO triggering, tried an old analog oscilloscope & it vanished like the phantom it was. Feeding that rock solid 10kHz pwm into a 100k/100nf RC now for some smoothing makes for a nice agile control loop, very nice. Thnx for the hand holding Joan.
Re: New pigpio Python module
hello Joan,
i have a script that creates and cancels callback on single gpio in a "strange" way, so i'd have some problems saving the callback var for each gpio.
Is there a way to cancell "all callbacks" from a GPIO without knowing the name of the previous callback created?
I mean, if i create a callback like this:
pi.callback(22, pigpio.EITHER_EDGE, cbf)
how can i cancel the callback from gpio 22?
thanks
i have a script that creates and cancels callback on single gpio in a "strange" way, so i'd have some problems saving the callback var for each gpio.
Is there a way to cancell "all callbacks" from a GPIO without knowing the name of the previous callback created?
I mean, if i create a callback like this:
pi.callback(22, pigpio.EITHER_EDGE, cbf)
how can i cancel the callback from gpio 22?
thanks

Re: New pigpio Python module
You can't.Massi wrote:hello Joan,
i have a script that creates and cancels callback on single gpio in a "strange" way, so i'd have some problems saving the callback var for each gpio.
Is there a way to cancell "all callbacks" from a GPIO without knowing the name of the previous callback created?
I mean, if i create a callback like this:
pi.callback(22, pigpio.EITHER_EDGE, cbf)
how can i cancel the callback from gpio 22?
thanks
You have to do the following.
cbid = pi.callback(22, pigpio.EITHER_EDGE, cbf)
...
cbid.cancel()
Re: New pigpio Python module
sad.joan wrote:You can't.
You have to do the following.
cbid = pi.callback(22, pigpio.EITHER_EDGE, cbf)
...
cbid.cancel()
and atm i can't send on a websocket connection from a callback
it's gonna be an hard time for me

Re: New pigpio Python module
You could raise a github issue if you think it might be a common problem (or even if you think it'll be of no use to anyone but you).
https://github.com/joan2937/pigpio/issues
https://github.com/joan2937/pigpio/issues
Re: New pigpio Python module
this is not an issue at alljoan wrote:You could raise a github issue if you think it might be a common problem (or even if you think it'll be of no use to anyone but you).
https://github.com/joan2937/pigpio/issues

i'm trying to build a websocket app (in python) where the client asks the server for specific GPIOs to monitor, so the server has to set up callbacks on GPIOs when they are requested.
Obviously, when the last client requesting a specific GPIO disconnects, the server has to cancel the callback on that gpio.
It was easier for me to work only on gpio number. But i'll keep an array of vars for gpio's callbacks..
it can be done

thanks as always
Re: New pigpio Python module
It may be possible to do what I do in piscope, the Python module, and the pigpiod C I/F.Massi wrote: ...
i'm trying to build a websocket app (in python) where the client asks the server for specific GPIOs to monitor, so the server has to set up callbacks on GPIOs when they are requested.
Obviously, when the last client requesting a specific GPIO disconnected, the server has to cancel the callback on that gpio.
It was easier for me to work only on gpio number. But i'll keep an array of vars for gpio's callbacks..
it can be done
...
I set up a socket dedicated to notifications (PI_CMD_NOIB) and use the notification commands (on another "command" socket) to update the GPIO of interest. When the socket is closed all the notifications are purged.
Re: New pigpio Python module
Hello,
is it possible to send two wave_chains simultaneously on two different pins? I need this to drive two steppers with the A4988-driver board. As soon as the second chain is created the first one stops to send pulses to the first pin.
is it possible to send two wave_chains simultaneously on two different pins? I need this to drive two steppers with the A4988-driver board. As soon as the second chain is created the first one stops to send pulses to the first pin.
Re: New pigpio Python module
[ot] [definitely we need a section of the forum dedicated to pigpio
]
Joan do you remember in which file is defined the list of user accessable gpios for each PI model?
yesterday i was playing with my old B rev2 and i expected an error trying to set the gpio 16 (like i got for gpio 26) - and this is also specified on your site ( http://abyz.co.uk/rpi/pigpio/index.html#Type_2 ), while i got no error (but the gpio wasn't set)
i wanted to check in source files on github, but i did not understand how you use bitmask to set gpio access, so.. sorry

Joan do you remember in which file is defined the list of user accessable gpios for each PI model?
yesterday i was playing with my old B rev2 and i expected an error trying to set the gpio 16 (like i got for gpio 26) - and this is also specified on your site ( http://abyz.co.uk/rpi/pigpio/index.html#Type_2 ), while i got no error (but the gpio wasn't set)
i wanted to check in source files on github, but i did not understand how you use bitmask to set gpio access, so.. sorry

Last edited by Massi on Wed Jun 22, 2016 9:02 am, edited 1 time in total.
Re: New pigpio Python module
Sorry again, maybe i got it 
Bitmask for model b rev 2
User gpio allowed:
Theres an error on gpio 16
So i think it should be 0xFBC6CF9C in place of 0xFBC7CF9C
or probably i'm wrong
Edit to add:
line 5214 of pigpio.h
i've never used github, should i make a pull request? (i've always dreamt to say that
)

Bitmask for model b rev 2
Code: Select all
1111 1011 1100 0111 1100 1111 1001 1100
From the right..User GPIO 2-4, 7-11, 14-15, 17-18, 22-25, 27-31
Theres an error on gpio 16

So i think it should be 0xFBC6CF9C in place of 0xFBC7CF9C
or probably i'm wrong

Edit to add:
line 5214 of pigpio.h
Code: Select all
#define PI_DEFAULT_UPDATE_MASK_A_B2 0xFBC7CF9C

Re: New pigpio Python module
[Not strictly related to the Python module, but this seemed like the best long-running threaad for comments about pigpio... ]
I'd like to take the opportunity to thank @joan for pigpio and related tools and utilities.
I've been aware of it and played with it for a year or more. Yesterday piscope really solved a problem for me.
I was working, for the first time, with an spi device - an mcp3008 adc chip.
It didn't work. I assumed it was my understanding of the software and libraries I was using. Tried several different approaches - still getting '0' returned on all channels, even thought some were hardwired to 3.3v.
Finally fired up piscope to look at the 4 logic lines related to SPI. Clock, Chip Select, and Data Out all OK. No data on the Data In line!
Continuity-checked path from relevant pin on mcp3008 to the header on the RPi: no connection.
Examined the PCB with a magnifier, and found that the related track had a tiny break.
I might have resolved this eventually by more continuity-testing, but I hadn't really expected a hardware fault - my mindset was that I didn't understand this new (to me) software technology. Piscope really helped me take a short-cut to the underlying problem. If I had to fire up a 'real' oscilloscope to do this I might not have bothered with the test.
Thanks @joan!
I'd like to take the opportunity to thank @joan for pigpio and related tools and utilities.
I've been aware of it and played with it for a year or more. Yesterday piscope really solved a problem for me.
I was working, for the first time, with an spi device - an mcp3008 adc chip.
It didn't work. I assumed it was my understanding of the software and libraries I was using. Tried several different approaches - still getting '0' returned on all channels, even thought some were hardwired to 3.3v.
Finally fired up piscope to look at the 4 logic lines related to SPI. Clock, Chip Select, and Data Out all OK. No data on the Data In line!
Continuity-checked path from relevant pin on mcp3008 to the header on the RPi: no connection.
Examined the PCB with a magnifier, and found that the related track had a tiny break.
I might have resolved this eventually by more continuity-testing, but I hadn't really expected a hardware fault - my mindset was that I didn't understand this new (to me) software technology. Piscope really helped me take a short-cut to the underlying problem. If I had to fire up a 'real' oscilloscope to do this I might not have bothered with the test.
Thanks @joan!
- elParaguayo
- Posts: 1943
- Joined: Wed May 16, 2012 12:46 pm
- Location: London, UK
Re: New pigpio Python module
I'd second this. Very impressed with pigpio but piscope really helped me with an issue that was driving me mad.
Thank you for all your work.
Thank you for all your work.
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.
Re: New pigpio Python module
Time to compile it for windows!




Re: New pigpio Python module
It works on my Rev.2 B (/proc/cpuinfo revision 000f).Massi wrote:Sorry again, maybe i got it
Bitmask for model b rev 2
User gpio allowed:Code: Select all
1111 1011 1100 0111 1100 1111 1001 1100
From the right..User GPIO 2-4, 7-11, 14-15, 17-18, 22-25, 27-31
Theres an error on gpio 16
So i think it should be 0xFBC6CF9C in place of 0xFBC7CF9C
or probably i'm wrong
Edit to add:
line 5214 of pigpio.hi've never used github, should i make a pull request? (i've always dreamt to say thatCode: Select all
#define PI_DEFAULT_UPDATE_MASK_A_B2 0xFBC7CF9C
)
Is 16 inverse logic?
I just did a pigs pfs 16 0 p 16 128 and the LED flashes okay.
Re: New pigpio Python module
@B.Goode
@elParaguayo
Thanks.
@elParaguayo
Thanks.
Re: New pigpio Python module
Wait, what do you mean with "works"?joan wrote: It works on my Rev.2 B (/proc/cpuinfo revision 000f).
isn't gpio 16 out of rev2 B headers? isn't it "not allowed"?
(as reported above, from your page 16 is out of user gpio list)
i don't know (but this would be the first time to hear thisIs 16 inverse logic?

i could pi.write() to it, but could not get correct levels.
I'll give it another try tonight..
wait again, what led?I just did a pigs pfs 16 0 p 16 128 and the LED flashes okay.
where did you connect the led?

i fear i missed something

Edit: i did. GPIO 16 is the onboard led. Ok i need to give it another try (sorry).
Re: New pigpio Python module
Some Pi model exceptions are made to which GPIO may be written. See Exceptions in http://abyz.co.uk/rpi/pigpio/pigpiod.html
Re: New pigpio Python module
damn.. sorry..joan wrote:Some Pi model exceptions are made to which GPIO may be written. See Exceptions in http://abyz.co.uk/rpi/pigpio/pigpiod.html
Re: New pigpio Python module
I have made several errors in this area which people have pointed out to me, you could just as easily have been right.Massi wrote:damn.. sorry..joan wrote:Some Pi model exceptions are made to which GPIO may be written. See Exceptions in http://abyz.co.uk/rpi/pigpio/pigpiod.html
Re: New pigpio Python module
I have made a new release, V55, http://abyz.co.uk/rpi/pigpio/download.html
The following features are added
The following features are added
- get and set the pad drive strength with get_pad_strength and set_pad_strength.
- Execute shell scripts (remotely).
The scripts must be located in the /opt/pigpio/cgi directory. - Access files (remotely) with file_open, file_close, file_read, file_write, file_seek, and file_list.
Access is controlled by entries in /opt/pigpio/access.
Re: New pigpio Python module
Hey, I've been using pigpio now and it's working great for controlling both a servo motor and a brushless fan.
A couple of issues thought. The fan needs a relatively high PWM frequency - it's recommended to do 25khz in order to avoid the audible spectrum - indeed, if I set the frequency to 20k I can hear a nasty squeal from the fan motor. It's quiet at 40k but then the poor Pi Zero (which also has to run and paint the NodeRed dashboard, seems to lag.
I would have thought that if I set a lower sample rate I could get a freq somewhere in the middle, but it seems that all of the sample rates ahve overlapping frequencies rather than "alternating" so that somewhere lower in the sample rate support I could get say 25k
A couple of issues thought. The fan needs a relatively high PWM frequency - it's recommended to do 25khz in order to avoid the audible spectrum - indeed, if I set the frequency to 20k I can hear a nasty squeal from the fan motor. It's quiet at 40k but then the poor Pi Zero (which also has to run and paint the NodeRed dashboard, seems to lag.
I would have thought that if I set a lower sample rate I could get a freq somewhere in the middle, but it seems that all of the sample rates ahve overlapping frequencies rather than "alternating" so that somewhere lower in the sample rate support I could get say 25k
Re: New pigpio Python module
Try to use one of the hardware PWM GPIO, see http://abyz.co.uk/rpi/pigpio/python.html#hardware_PWMbraddo wrote:Hey, I've been using pigpio now and it's working great for controlling both a servo motor and a brushless fan.
A couple of issues thought. The fan needs a relatively high PWM frequency - it's recommended to do 25khz in order to avoid the audible spectrum - indeed, if I set the frequency to 20k I can hear a nasty squeal from the fan motor. It's quiet at 40k but then the poor Pi Zero (which also has to run and paint the NodeRed dashboard, seems to lag.
I would have thought that if I set a lower sample rate I could get a freq somewhere in the middle, but it seems that all of the sample rates ahve overlapping frequencies rather than "alternating" so that somewhere lower in the sample rate support I could get say 25k