matrix1233
Posts: 5
Joined: Tue Jun 07, 2016 12:51 am

low frequency generator

Tue Jun 07, 2016 1:02 am

hi,
what is the correct method to do a low frequency generator (1hz .. 500khz) on raspberry pi ?

thanks

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

Re: low frequency generator

Tue Jun 07, 2016 8:10 am

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

matrix1233
Posts: 5
Joined: Tue Jun 07, 2016 12:51 am

Re: low frequency generator

Tue Jun 07, 2016 11:48 am

hi,
but how can i know the frequency generated ?

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

Re: low frequency generator

Tue Jun 07, 2016 12:08 pm

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?

matrix1233
Posts: 5
Joined: Tue Jun 07, 2016 12:51 am

Re: low frequency generator

Tue Jun 07, 2016 12:24 pm

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

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

Re: low frequency generator

Tue Jun 07, 2016 12:28 pm

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%)

User avatar
MarkHaysHarris777
Posts: 1820
Joined: Mon Mar 23, 2015 7:39 am
Location: Rochester, MN
Contact: Website

Re: low frequency generator

Tue Jun 07, 2016 3:59 pm

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
marcus
:ugeek:

matrix1233
Posts: 5
Joined: Tue Jun 07, 2016 12:51 am

Re: low frequency generator

Wed Jun 08, 2016 1:01 am

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 )
Attachments
frequency.JPG
frequency.JPG (15.1 KiB) Viewed 5341 times

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

Re: low frequency generator

Wed Jun 08, 2016 6:33 am

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?

matrix1233
Posts: 5
Joined: Tue Jun 07, 2016 12:51 am

Re: low frequency generator

Wed Jun 08, 2016 10:42 am

hi
am trying to do a personalised frequency generator where i can program all possibility of signal output

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

Re: low frequency generator

Wed Jun 08, 2016 10:51 am

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

Return to “General discussion”