Author Topic: Creating lookup table from analog waveform  (Read 1343 times)

0 Members and 1 Guest are viewing this topic.

Offline blue2thaboneTopic starter

  • Newbie
  • Posts: 3
  • Country: us
Creating lookup table from analog waveform
« on: December 01, 2023, 07:10:26 pm »
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..
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11269
  • Country: us
    • Personal site
Re: Creating lookup table from analog waveform
« Reply #1 on: December 01, 2023, 07:27:38 pm »
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.
« Last Edit: December 02, 2023, 12:26:22 am by ataradov »
Alex
 

Offline blue2thaboneTopic starter

  • Newbie
  • Posts: 3
  • Country: us
Re: Creating lookup table from analog waveform
« Reply #2 on: December 02, 2023, 04:28:48 am »
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?
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11269
  • Country: us
    • Personal site
Re: Creating lookup table from analog waveform
« Reply #3 on: December 02, 2023, 04:45:25 am »
I don't really understand what you need to do. You mean take 100 equally spaced points? Then for Excel you can do that https://www.ablebits.com/office-addins-blog/select-every-other-row-excel/ Select every N-th row to get 100 remaining.
Alex
 

Offline WattsThat

  • Frequent Contributor
  • **
  • Posts: 767
  • Country: us
Re: Creating lookup table from analog waveform
« Reply #4 on: December 02, 2023, 11:48:05 am »
Quote
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.

Yes, 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
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21698
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Creating lookup table from analog waveform
« Reply #5 on: December 02, 2023, 02:28:08 pm »
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
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Online ledtester

  • Super Contributor
  • ***
  • Posts: 3039
  • Country: us
Re: Creating lookup table from analog waveform
« Reply #6 on: December 03, 2023, 09:30:02 am »
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?

Sounds 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/
 

Offline radiolistener

  • Super Contributor
  • ***
  • Posts: 3391
  • Country: ua
Re: Creating lookup table from analog waveform
« Reply #7 on: December 03, 2023, 08:06:24 pm »
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.
« Last Edit: December 03, 2023, 08:09:55 pm by radiolistener »
 

Online langwadt

  • Super Contributor
  • ***
  • Posts: 4437
  • Country: dk
Re: Creating lookup table from analog waveform
« Reply #8 on: December 03, 2023, 08:10:49 pm »
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.

maybe 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
 

Offline radiolistener

  • Super Contributor
  • ***
  • Posts: 3391
  • Country: ua
Re: Creating lookup table from analog waveform
« Reply #9 on: December 03, 2023, 08:13:42 pm »
maybe 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

Yes, 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.
« Last Edit: December 03, 2023, 08:15:46 pm by radiolistener »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf