You are here

Using UART to transmit data converted by ADC | Cypress Semiconductor

Using UART to transmit data converted by ADC

Summary: 13 Replies, Latest post by milinds.747_1696896 on 05 May 2017 07:57 AM PDT
Verified Answers: 1
Last post
Log in to post new comments.
milinds.747_1696896's picture
User
9 posts

I am doing this as  my masters' project. I started from scratch by making a plotter. That part is done and works okay. For acquiring data I am using CY8C3866AXI-040. I am able to convert using ADC. The problem I face is I am unable to receive transmitted data. I used TeraTerm initially to check if the data is being received before further processing it, I got nothing. The schematic of the kit provided is attached below. I attach this assuming the possibility of incorrect pin entered in cydwr file. The number of samples transmitted will depend on the adjustment of time/div setting on the PC. So the number of samples transmitted will vary. How do I use the Rx interrupt to do that?  What addition should be made to the program to transmit the converted data?

user_1377889's picture
User
10803 posts

First you need to wait for a sample ready before calling ADC_GetResult8().

To get a fixed timing as 100 sps you will need a timer and an interrupt to sample the ADC.

Consider using a well-defined standard baud-rate for the UART.

 

Bob

milinds.747_1696896's picture
User
9 posts

Done. I am able to transmit and plot the waveform. However, the reproduced waveform has a lot of noise. So I implemented a moving average filter. 

  1. How many samples would you recommend for the filter?
  2. How can I detect the slope of the plotted signal? I am trying to calculate the frequency. I already obtained the min, max and peak to peak voltage.

EDIT:

The sampling rate is 187500 sps, the baud rate is 230400 bps.

user_1377889's picture
User
10803 posts

Slope is DeltaY/DeltaX, could be calculated when the average is built.

Can you please post your complete project, so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.

 

Bob

 

milinds.747_1696896's picture
User
9 posts

Sure. I am not doing any calculations PSoC. All of them are done on PC side. Code is written in C#. Ping if you wish to take a look at that too.

user_1377889's picture
User
10803 posts

You are able to transmit 2000 bytes per second, your ADC with the conversion is producing more than 750000 bytes. When you reduce the ADC sample rate and do the averaging on PSoC side you will get better results.

 

Bob

milinds.747_1696896's picture
User
9 posts

Done. A simple moving average filter on the PSoC side. 64 samples taken at a time. Reduced the ADC sampling rate to 1 Msps. Baud Rate unchanged. Kindly tell me if this setting is okay.

user_1377889's picture
User
10803 posts

Your sample frequency is now 100ksps. Straighten your code, the division should be taken out of the loop. You are calculating a mean, but you are still transmitting all 64 samples instead of the mean value.

Increase the main clock to 64MHz to get some more headroom for processing.

As a hint, I would toggle a pin to see if the measuring is at full / wanted speed or if there are gaps.

 

Bob

milinds.747_1696896's picture
User
9 posts

Implemented a filter on the pc side instead and wrote a snippet for getting the frequency of the signal. The number of samples occurring in the positive half cycle are counted, zero crossing detection is used. The ADC is used in single ended configuration, as seen in the workspace bundle sent above. Whenever I connect the signal generator to the board, it throws a lot of garbage values to the UART. The frame received looks something like this $18 18 18 18 18 18 18 18 18 18%. On the signal generator, the amplitude set is 1Vpp with 1V dc offset at a frequency of 100Hz. This problem did not occur when I tried connecting a DC power supply. The settings on the workspace bundle are unchanged.

user_1377889's picture
User
10803 posts

"18" looks a bit uncommon, because you are sending three digits. Of more interest would be the contents of the result array when you debug.

 

Bob

 

milinds.747_1696896's picture
User
9 posts

Yes. When I read the component data sheet, it mentioned obtaining a 16 bit result for 8 bit resolution to avoid wrap around. When I obtained 16 bit result, I got 277 instead of 18. The peak amplitude applied is 1.5V

Log in to post new comments.