0

See attached my waveform of input to channel of ADS1115, my code, and my output that I am getting

I cannot get the output matplotlib waveform to plot smoothly like my input waveform from oscilloscope

Input frequency is 50Hz Code -

import matplotlib.pyplot as plt
import adafruit_ads1x15.ads1115 as ADS
from adafruit_ads1x15.analog_in import AnalogIn
import board
import busio
import numpy as np
import time

i2c = busio.I2C(board.SCL, board.SDA)

ads = ADS.ADS1115(i2c,gain=1,data_rate=860)
ads.data_rate=860

Channel0 = AnalogIn(ads, ADS.P0)

times = []
voltages = []

start_time = time.time()

while True:
    current_time = time.time() - start_time
    voltage0 = Channel0.voltage 


    times.append(current_time)
    voltages.append(voltage0)

    plt.clf()
    plt.plot(times, voltages)
    plt.xlabel('Time (s)')
    plt.ylabel('Channel Voltage (V)')
    plt.title('Voltage over Time')
    plt.pause(0.005)

This is the input waveform:

Input Waveform

This is what I'm getting:

Output Waveform

I was expecting the output waveform to still have same sinusoidal output.

1
  • Matplotlib might not be fast enough for this kind of plotting. Instead, check out PyQtGraph Commented Jan 7 at 9:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.