Page 1 of 1
low frequency generator
Posted: Tue Jun 07, 2016 1:02 am
by matrix1233
hi,
what is the correct method to do a low frequency generator (1hz .. 500khz) on raspberry pi ?
thanks
Re: low frequency generator
Posted: Tue Jun 07, 2016 8:10 am
by joan
How will you measure correctness?
If you only want one or two channels the answer is probably use the PWM peripheral.
See
http://abyz.co.uk/rpi/pigpio/pigs.html#HP
Re: low frequency generator
Posted: Tue Jun 07, 2016 11:48 am
by matrix1233
hi,
but how can i know the frequency generated ?
Re: low frequency generator
Posted: Tue Jun 07, 2016 12:08 pm
by joan
matrix1233 wrote:hi,
but how can i know the frequency generated ?
I don't understand.
You set the frequency.
Do you mean how do you know if the frequency is being generated properly?
Re: low frequency generator
Posted: Tue Jun 07, 2016 12:24 pm
by matrix1233
hi,
for example on the gpio 18 i wanna to generate a frequency = 3 khz .. can you give me an example to do that
thanks
Re: low frequency generator
Posted: Tue Jun 07, 2016 12:28 pm
by joan
matrix1233 wrote:hi,
for example on the gpio 18 i wanna to generate a frequency = 3 khz .. can you give me an example to do that
thanks
pigs hp 18 3000 500000 # GPIO18, 3000Hz, 500000/1000000 dutycycle (50%)
Re: low frequency generator
Posted: Tue Jun 07, 2016 3:59 pm
by MarkHaysHarris777
matrix1233 wrote:hi,
for example on the gpio 18 i wanna to generate a frequency = 3 khz .. can you give me an example to do that
thanks
see
this link.
Code: Select all
## Import the necessary header modules
import RPi.GPIO as GPIO
## Setup the GPIO for PWM on pin12 {GPIO18}
GPIO.setmode(GPIO.BOARD)
GPIO.setup(12, GPIO.OUT)
p = GPIO.PWM(12, 300)
p.start
... that code will generate 300Hz ... change 30 to 440 and get concert A. ... change to 30000
for 30KHz
Re: low frequency generator
Posted: Wed Jun 08, 2016 1:01 am
by matrix1233
it work thanks

can i combinate 2 frequency for example 3 khz and 125 Mhz on the same output on the gpio ? ( see the picture )
Re: low frequency generator
Posted: Wed Jun 08, 2016 6:33 am
by joan
I'm not sure. The PWM hardware might be programmable to do that, but my hardware_PWM function does not support that mode.
Why? That looks vaguely like an IR remote control signal. I.e. you have a high frequency carrier switched on/off in pulses. What are you trying to do?
Re: low frequency generator
Posted: Wed Jun 08, 2016 10:42 am
by matrix1233
hi
am trying to do a personalised frequency generator where i can program all possibility of signal output
Re: low frequency generator
Posted: Wed Jun 08, 2016 10:51 am
by joan
matrix1233 wrote:hi
am trying to do a personalised frequency generator where i can program all possibility of signal output
At anything over a megahertz you are going to have to program your own solution.
Have a look at the PWM / PCM documentation in
http://www.raspberrypi.org/documentatio ... herals.pdf
For sub-megahertz pigpio waves might work.
http://abyz.co.uk/rpi/pigpio/cif.html#gpioWaveCreate