- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
Solved! Go to Solution.
- Labels:
-
PSoC 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- How many samples would you recommend for the filter?
- 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
"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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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