Real time data plotting using MSP430 on python

358 views Asked by At

Actually I am using a function generator to give an external analog signal to input to the ADC of MSP430F5438A

After that I tried to monitor the ADC data of MSP430 through UART of MSP430 on my PC, that I have done by using Tera term

Now I am trying to plot the same data (which is receiving from UART) on python (Instead of using tera term because there we cannot plot the data)

My problem is, In python I am able reproduce the signal (the signal which is given from function generator) for some certain frequency range(in my case only 0- 10hz)

But my requirement is to reproduce the signal ranging from (0hz-5khz). If you want to see any waveform for various ranges I am ready to attach it.

My question is, Is it possible to reproduce that maximum frequency range (0hz-5khz) ?? Is there anyway to do it??

If you want further clarification I am ready to give you..

I am attaching python code :

 import sys
 import serial
 import numpy as np
 import matplotlib.pyplot as plt
 from collections import deque

 port = "COM14"
 baud = 460800
 timeout=1

 ser = serial.Serial()
 ser.port = port
 ser.baudrate = baud
 ser.timeout = timeout

 a1 = deque(([0.0])*1000)

 plt.title("Real Time Data Monitoring")
 line, = plt.plot(a1)
 plt.ion()
 plt.xlabel("Time_Period")
 plt.ylabel("Amplitude")
 plt.ylim([0,300])
 plt.grid()

 try:
   ser.open()
 except:
   sys.stderr.write("Error opening serial port %s\n" % (ser.portstr) )
   sys.exit(1)

while 1:
 data = ser.read(3)
 reading = int(data)
 print(a1)
 a1.appendleft((data))
 datatoplot = a1.pop()
 line.set_ydata(a1)
 plt.draw()
 plt.pause(0.0001)

and i am attaching the sample data format which is received on python deque(['066', '117', '206', '108', '212', '063', '117', '206', '057', '130', '197', '048', '138', '068', '111', '188', '042', '154', '178', '035', '100', '216', '070', '108', '218', '073', '105', '214', '067', '117', '208', '056', '126', '207', '058', '123', '204', '047', '140', '190', '046', '140', '191', '042', '152', '180', '035'])

my ADC configuration is

Resolution  :   8-bit
ADC12A_CLK  :   4 Mhz
Sampling rate   :   15094 Samples per second
                         (Or)
                       15 ksps

my UART configuration is Baud rate : 460800 USCI_CLK : 12Mhz

Thanks in advance.

0

There are 0 answers