Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

PSoC™ 5, 3 & 1 Forum Discussions

Anonymous
Not applicable

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?

0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

View solution in original post

0 Likes
13 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

0 Likes
Anonymous
Not applicable

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.     
  3. 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.
  4.    
   

EDIT:

   

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

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

0 Likes
Anonymous
Not applicable

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.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

0 Likes
Anonymous
Not applicable

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.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

0 Likes
Anonymous
Not applicable

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.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

"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

0 Likes
Anonymous
Not applicable

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

0 Likes
Anonymous
Not applicable

UART RX 

   

hello ,

   

please

   

HOW TO READ DATA RX AND TRANSMIT IT TO INTEGER

   

i have this tx exemple working good.... (see attachments)

   

i want to read data THE SAME DATA by an other psoc 5lp

0 Likes
Anonymous
Not applicable

High level programming languages such as Java, C# provide API to directly convert string or characters into integers directly. I haven't used MATLAB, so cannot comment on that. To read the data, the Readline API will take input only up to \n ata a time, like Bob said. I had trouble opening your code, so could not take a look at it. You may consider using sprintf for converting the data in to string directly. Just use the #include<string.h> header file.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You need to capture all data into a buffer until a '\n' is found (ignore '\r'). This can be made into a legal string by appending a '\0'.

   

This string can be converted into an integer

   

Set Result to 0 initially

   

Check if  Char '0' to '9' else error

   

Result = Result * 10 + Char - '0'

   

Repeat that until the last char == '\0'

   

 

   

Happy coding

   

Bob

0 Likes