Maker Pro
Maker Pro

Using Raspberry Pi to read signal generated by a function generator

John Manuel

Jun 7, 2018
20
Joined
Jun 7, 2018
Messages
20
I am trying to work with the signals generated by a function generator using Raspberry Pi. Since Raspberry Pi does not have an inbuilt ADC, I used pcf8591. Now, I do not know how to feed the signal generated by the function generator into the input pins of pcf8591. Please help.
 

kellys_eye

Jun 25, 2010
6,473
Joined
Jun 25, 2010
Messages
6,473
Have you looked at the datasheet for the device?

It's a simple matter of applying it to the analog input pin(s) !!! Just make sure the ground connections of both circuits are commoned together and power them accordingly.

Or look at this website:

http://henrysbench.capnfatz.com/hen...duino-tutorial-1-a-simple-analog-measurement/

As for the BNC part, the signal goes through the centre 'core' and the screen of the cable is connected to ground.
 

John Manuel

Jun 7, 2018
20
Joined
Jun 7, 2018
Messages
20
I am using a Raspberry Pi 3 Model B to read the signal generated by a function generator. I have used PCF8591 fitted in YL-40 PCB as the ADC. I have used python for establishing the I2C communication between the Rpi and PCF8591. But, I am getting undesirable values when I run the setup.

The connection between the Rpi and PCF8591 are as follows-
(Rpi) (PCF8591)
Pin 1 -> VCC
Pin 3 -> SDA
Pin 5 -> SCL
Pin6 -> GND

The generated wave was: Frequency = 1KHz; Amplitude = 1 Vpp; DC offset = 0

A picture of the python code I used, the output when the function generator is not connected, the output when the function generator is attached and the connection between the ADC and the function generator is attached below.
 

Attachments

  • Connection between ADC and Function Generator.jpg
    Connection between ADC and Function Generator.jpg
    171.8 KB · Views: 67
  • Output when Function Generator was attached.jpg
    Output when Function Generator was attached.jpg
    236.7 KB · Views: 71
  • Output when signal from Function Generator was not attached.jpg
    Output when signal from Function Generator was not attached.jpg
    153.3 KB · Views: 77
  • Python Code used.jpg
    Python Code used.jpg
    296.9 KB · Views: 61

kellys_eye

Jun 25, 2010
6,473
Joined
Jun 25, 2010
Messages
6,473
I am getting undesirable values when I run the setup.
In what way are they 'undesirable'?

What are you 'expecting' to see?

The values you get will correspond to the instantaneous value of the waveform at the time when the sample is taken i.e. if you sample it at the peak of the waveform you will 'consistently' measure the peak amplitude but if your samples are taken 'at random' you will see values that could be from anywhere on the waveform cycle.

Equally, if you are sampling at a too low frequency (sample rate) you won't see enough values to reconstitute the original signal - if that's your intention.

Are you looking to measure peak, average or frequency values? etc?
 

Alec_t

Jul 7, 2015
3,580
Joined
Jul 7, 2015
Messages
3,580
I do not know how to feed the signal generated by the function generator into the input pins of pcf8591.
Make sure that the function generator signals are within the allowed input range of the ADC module. You may need a DC offset. Check the datasheets/specs of both the generator and the module.
 

John Manuel

Jun 7, 2018
20
Joined
Jun 7, 2018
Messages
20
In what way are they 'undesirable'?

What are you 'expecting' to see?

The values you get will correspond to the instantaneous value of the waveform at the time when the sample is taken i.e. if you sample it at the peak of the waveform you will 'consistently' measure the peak amplitude but if your samples are taken 'at random' you will see values that could be from anywhere on the waveform cycle.

Equally, if you are sampling at a too low frequency (sample rate) you won't see enough values to reconstitute the original signal - if that's your intention.

Are you looking to measure peak, average or frequency values? etc?
I wanted to measure the frequency
 

kellys_eye

Jun 25, 2010
6,473
Joined
Jun 25, 2010
Messages
6,473
You will need a peak detector and a timer interrupt to do that.

Currently all you are doing is taking repeated measurement of the amplitude of the signal - which tells you nothing!
 
Top