bigtrumpet
Posts: 5
Joined: Thu Aug 17, 2017 12:33 am

pigpio nanosecond pulse generation

Fri Aug 25, 2017 8:36 pm

http://abyz.co.uk/rpi/pigpio/code/nanopulse_c.zip

Hello,

I was able to run on a RPI3, the python code wave_PWM.py, and get square waves on GPIO23 ( pin 16)

however, i cannot get any output from same pin , if I run the nanopulse.c program...

Did I miss anything?

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

Re: pigpio nanosecond pulse generation

Fri Aug 25, 2017 8:47 pm

I seem to remember the code was a sort of one-shot. Do you have a good oscilloscope attached to the GPIO? Can the 'scope see very short pulses?

bigtrumpet
Posts: 5
Joined: Thu Aug 17, 2017 12:33 am

Re: pigpio nanosecond pulse generation

Sat Aug 26, 2017 3:26 pm

Hello Joan,


I believe mine is good enough. I was checking on GPIO18 ( pin 12).

Code: Select all

sudo ./nanopulse 1000 10000 2000
which reports:

10000 pulses of 1000 nanos with gap of 2000 nanos (div=4 bits=125)

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

Re: pigpio nanosecond pulse generation

Sat Aug 26, 2017 5:44 pm

That code was written before such as the Pi3 which uses a different memory addressing scheme for the GPIO. If you are using it on a recent Pi model you will have to update the code to reflect the new GPIO peripheral address.

bigtrumpet
Posts: 5
Joined: Thu Aug 17, 2017 12:33 am

Re: pigpio nanosecond pulse generation

Sat Aug 26, 2017 9:11 pm

I changed

#define GPIO_BASE 0x20200000

to

#define GPIO_BASE 0x3F000000

besides this define, is there any other thing I need to bear in mind?

thanks

Joseph

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

Re: pigpio nanosecond pulse generation

Sat Aug 26, 2017 10:05 pm

I think that's the base address of all the peripherals. The GPIO address will be offset from there.

Have a look at http://abyz.co.uk/rpi/pigpio/examples.h ... _tiny_gpio which I did update to work on all Pi models.

bigtrumpet
Posts: 5
Joined: Thu Aug 17, 2017 12:33 am

Re: pigpio nanosecond pulse generation

Mon Aug 28, 2017 12:03 am

Thanks Joan

I will take use this new example.

I just took a quick look at both, a lot of updates has been done. That's really big step forward from the previous one.

:D

zmalsberg
Posts: 2
Joined: Sun May 12, 2019 5:59 am

Re: pigpio nanosecond pulse generation

Sun May 12, 2019 6:16 am

Sorry for necroposting, but after trying both of the listed solutions on my 3B+ (changing base address value, swapping header definitions with joan's linked updated file) I simply cannot get 'nanopulse.c' to work on any GPIO. Been having a tough time with pigpio in general trying create a sub-pulse waveform with 'wvcha'; the first time I called this command on GPIO4, it seemed to permanently insert a ceaseless wave pattern onto the pin. No amount of clearing, stopping, killing pigpiod, restarting or unplugging seems to make stop it. "pigs s 4 0" makes it halt briefly, but then the pattern resumes on my oscilloscope within seconds. I remember reading Raspbian Lite has issues... Is an OS wipe in order, or are there any solutions for such things?
Regards,
-Zach M.

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

Re: pigpio nanosecond pulse generation

Mon May 13, 2019 5:22 pm

zmalsberg wrote:
Sun May 12, 2019 6:16 am
Sorry for necroposting, but after trying both of the listed solutions on my 3B+ (changing base address value, swapping header definitions with joan's linked updated file) I simply cannot get 'nanopulse.c' to work on any GPIO. Been having a tough time with pigpio in general trying create a sub-pulse waveform with 'wvcha'; the first time I called this command on GPIO4, it seemed to permanently insert a ceaseless wave pattern onto the pin. No amount of clearing, stopping, killing pigpiod, restarting or unplugging seems to make stop it. "pigs s 4 0" makes it halt briefly, but then the pattern resumes on my oscilloscope within seconds. I remember reading Raspbian Lite has issues... Is an OS wipe in order, or are there any solutions for such things?
Regards,
-Zach M.
Have you code with compile and run instructions?

As to GPIO 4 it sounds like you have a 1-wire bus running (which defaults to GPIO 4).

zmalsberg
Posts: 2
Joined: Sun May 12, 2019 5:59 am

Re: pigpio nanosecond pulse generation

Mon May 13, 2019 8:16 pm

So it was 1-wire making the mystery waveform!... I hadn't checked GPIO4 with my oscilloscope until after attempting to generating a similarly shaped waveform with wavechain command, so I confused myself big time by turning on that option a while back without understanding what it did. :oops: Thanks for pointing that out.
As for nanopulse.c, I found a solution here http://www.pieter-jan.com/node/15

Code: Select all

#define BCM2708_PERI_BASE       0x20000000
#define GPIO_BASE               (BCM2708_PERI_BASE + 0x200000)	
Swapped the 'BCM2708_PERI_BASE' value with the new one for RPi 2-3 and voilà, it works. Doesn't work without the '0x200000' offset.

Return to “C/C++”