Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Using Raspberry Pi to read signal generated by a function generator

Status
Not open for further replies.

john1998

Newbie level 6
Joined
Jun 8, 2018
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
152
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.
Output when signal from Function Generator was not attached.jpgOutput when Function Generator was attached.jpgConnection between ADC and Function Generator.jpgPython Code used.jpg
 

My first guess is that you're not sampling fast enough. What does the command "time.sleep(0.1)" do? You probably want to sample at least as fast as 10khz to get a reasonable result. In your picture it looks like you've got an unconnected black wire, is that intentional? My second guess is that you've got a bad connection (missing ground?). You can definitely see higher values when the signal generator is connected.
 
Thanks a lot for your reply. How can I increase the sampling rate? I removed the 'time.sleep(0.1)' statement but even now its not working fast enough.
 

Hello,


You can't get 1Khz values, if you want to printout each of them...
Store the getting values into RAM, during maybe 1 second, then get back from ram buffer to print them..

Or do your test at 1Hz !
 

You're using ADC that is I2C clock driven - that means max sampling rate is given by I2C-bus speed.
For that ADC the max sampling freq is 11.1 kHz (from Datasheet https://www.nxp.com/docs/en/data-sheet/PCF8591.pdf).

1. What clock freq has your python driven I2C-bus?

2. What is the signal generated? Does generator generate signal continuously or has a dead time?

3. What value has Vref?

Without an oscilloscope you will go nowhere.

Please note that your ADC has "Analog voltage range from Vss(GND) to Vdd" - that means potentials below Vss won't be converted in a proper way.
 
Last edited:
Hi,

I don´t recommend a software timed ADC for any AC input signal.

Do this if your input signal has DC character.

****
For true AC input I recommend a hardware driven conversion rate.
If you are not after high precision you may user interrupt driven sampling.
I don´t know if this is possible with Raspberry.

Klaus
 

It was not clear which of the PI distros you are running in the Rraspberry, but I believe it is not bare metal, and even if it were based on Linux OS, certain latency is expected in the execution of the Python commands, since several other processes will be running in the sequence. Keep in mind that operating systems do not deal well with processes with high update rate; in such cases it would be necessary to make use of some kind of hardware interruption in order to promote the desired process to a higher priority level. Also, you did not inform to where the Print output is being directed (serial ?, console?) , which depending on the case could generate an additional delay; note that each float value has a different amount of bytes to be sent. By the way, the aerial wiring you did is not adequate to handle I2C bus, put the shield as close as possible of the main board and wirings shortest.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top