Creating lookup table from analog waveform - Page 1
Forum section: electronics / general

author: blue2thabone
author_rank: Newbie
timestamp: December 01, 2023, 07:10:26 pm
content: Greetings,I need some assistance with solving my issue of creating a lookup table from a waveform that is not perfectly sinusoidal. My first thought was to record the sample with my digital Oscope and save it out as a cvs file. But that doesn’t provide me with a lookup table that can be used in a AVR attiny micro.The other thought I had was to get one of those cheap sparkfun logic analyzer kits that work with an Arduino board and open source software. I am an analog electronics guy, so im not very familiar with the data acquisition and conversion part.Any suggestions? Oh, and I believe the lookup table needs to be a 0-512 bit x-axis and 2-4095 bit in the y-axis. Again, im not familiar with the digital side of the force..

author: ataradov
author_rank: Super Contributor
timestamp: December 01, 2023, 07:27:38 pm
content: Why does CSV file not work for you? You will get floating point values, which you can scale in any spreadsheet program according to your needs. The capture would likely have more points, so you would need to decimate the data until you get a number of samples you want.Assuming you mean 512 samples of 12 bits (4096 levels), you would need a 1 KByte table. I don't know if there are any ATTiny micros that can support that, so you may need to compress that somehow.EDIT: Actually nevermind that. If you need the table to be fixed, you can store it in the flash, and plenty of tinys have that.

author: blue2thabone
author_rank: Newbie
timestamp: December 02, 2023, 04:28:48 am
content: Thanks for the reply.so after a little more research and figuring some things out, forget about what i said about the 512/4096 etc. I need to segment the period of the waveform into 100 equal time values, then get the amplitude (Y-values) at that specific time value. with a CSV file of the captured waveform, i don't understand how to split the time axis into 100 then find the amplitude of each 100 time values. from this data i would input it into a lookup table.any ideas?

author: ataradov
author_rank: Super Contributor
timestamp: December 02, 2023, 04:45:25 am
content: I don't really understand what you need to do. You mean take 100 equally spaced points? Then for Excel you can do thathttps://www.ablebits.com/office-addins-blog/select-every-other-row-excel/Select every N-th row to get 100 remaining.

author: WattsThat
author_rank: Frequent Contributor
timestamp: December 02, 2023, 11:48:05 am
content: QuoteYes, it does. You just need to translate the values from floating point to integers that fit the size of your DAC.If you’re working with Arduino, have a look the MCP4725 library code, it sounds like it is exactly what you want. You just have to figure out the changes required to fit your data into the resolution of your DAC and the timing required to match your sample.https://github.com/RobTillaart/MCP4725/blob/master/examples/MCP4725_wave_generator/MCP4725_wave_generator.ino

author: T3sl4co1l
author_rank: Super Contributor
timestamp: December 02, 2023, 02:28:08 pm
content: You might also consider a curve fitting operation, though how much depends on how fast you need the samples, and how much time you can spend calculating them beforehand. (As you've said nothing about application, I take that as free license to suggest anything that might possibly be applicable.)Tim

author: ledtester
author_rank: Super Contributor
timestamp: December 03, 2023, 09:30:02 am
content: Quote from: blue2thabone on December 02, 2023, 04:28:48 amSounds like you want to interpolate a time series. Spreadsheets should be able to do it, e.g.:https://exceloffthegrid.com/interpolate-values-using-the-forecast-function/

author: radiolistener
author_rank: Super Contributor
timestamp: December 03, 2023, 08:06:24 pm
content: if you want to transform waveform captured with oscilloscope to a usable lookup table, you're needs to downsample record from oscilloscope to a DAC clock used on your circuit. In order to do it, you're needs to apply low pass filter with cut-off below Fs/2 where Fs is your DAC sample clock, after that you can decimate filtered record to your DAC sample clock, you can do by skipping unused samples.But you're needs to apply low pass filter before decimation, because if you do it with no filtering, you will get aliased distortions on the output.If your circuit DAC has higher sample rate than your recording, then you're needs to upsample it. You can to it by adding zero samples and then apply low pass filter with cut-off at Fs/2 where Fs is your recording sample rate.

author: langwadt
author_rank: Super Contributor
timestamp: December 03, 2023, 08:10:49 pm
content: Quote from: radiolistener on December 03, 2023, 08:06:24 pmmaybe as slight tangent, but you can do low pass filtering at the same time as decimation, no point in calculating samples you are going throw away

author: radiolistener
author_rank: Super Contributor
timestamp: December 03, 2023, 08:13:42 pm
content: Quote from: langwadt on December 03, 2023, 08:10:49 pmYes, you can combine decimation with FIR low pass filter, since you can skip calculation for samples which will be rejected, it allows to reduce required computation resources. This is how it usually implemented.