Shop OBEX P1 Docs P2 Docs Learn Events
Fun deviation into ADC/DAC — Parallax Forums

Fun deviation into ADC/DAC

frank freedmanfrank freedman Posts: 1,983
edited 2011-10-27 17:03 in Propeller 1
Decided to fork off a small experimental branch from the curve tracer project. Te current setup eats about 3 cogs, main control, clock generator and the sample acquisition / storage unit. Thought it would be interesting to take the start stop off and make it continuous capture and export the 12 bit results to the outa pins 08-19. After fighting with the #$#^ or function, I got the bits going out and fed them into an 12 bit R2R DAC patterned after the IKAlogic circuit found on the internet.

The R's are all 200K 2% (fry's/NTE) so R=100K and 2R=200K. I had bought about 100 of them, so picked the values closest to a center average to minimize deviations between steps. the output device is an NTE928S (8dip was not available at the time). Maybe i will make the second op amp in the package a gain stage so that I can get higher output. (Powered by 9V battery for now, could have used the 12V (old wall wart) Vin of my gg usb board as easily)

Here are the results as recorded via o'scope. No surprises for analog hands, but the aliasing effects once nyquist exceeded make a good example of aliasing for those not as familiar with analog sampling systems. It approximates electronically the graph paper excercise in the Caxton Foster book on real-time programming which also seeks to demonstrate the effects of aliasing.

All in a couple of nights fun........

Frank

MCP3201 sampling at 100 ksps, 1.6Mhz sample clock .
12bit_R2R_DAC.jpg

R2R DAC
way_under_nyquist.jpg

Input freq well below Nyquist
approaching_nyquist.jpg

Almost there......
aliasing.jpg

about 53 kHz input output way below that now
1024 x 768 - 120K
1024 x 768 - 78K
1024 x 768 - 82K
1024 x 768 - 76K

Comments

  • frank freedmanfrank freedman Posts: 1,983
    edited 2011-10-02 17:11
    Ok. Here is the code for driving the hardware in the initial post. If I spent a month playing with this circuit (and I probably shall) there is a lot for me to learn and get a feel for and not just in the actual circuit itself. The scope itself adds some interesting artifacts, I know my function gen needs some service and a good cal......

    As to the prop and ADC/DAC, I tried to set up the most likely to change parameters to be placed in the con part of the top module and passed through shared memory locations into the individual cog. Feel free to fold, spindle, or mutilate it as you will. If any comments, suggestions or improvements, feel free to let me know. I may or may not decide to use them depending on usefulness, relevance or phase of the moon but will value most comments appropriately. One little discovery was playing with the bit count, and somehow obtained a CSC function from the input sine wave. Not sure why, but with a couple weeks downtime, might figure it out.

    Frank

    Sorry about the edit, almost forgot. The reason for the modularity comes from the curve tracer. Also, the way it is now, multiple acq modules can be used by adding in the appropriate pin and cog and launching another acq_module for that device.

    acq_module.spin
    clockgen.spin
    adc_master.spin
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-10-02 19:33
    It is rather beautiful seeing those sine waves on the scope at those frequencies. Well done!
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-10-03 18:47
    WRT a PM on this topic, I see you are up at 100,000 samples a second. So if you say, filtered that with a low pass filter at about 44khz, that ought to reduce aliasing and get some pretty decent audio. 12 bits record and playback.

    Ought to be able to store that into an sd card in real time as well.

    Do we have any resident FFT experts who might have some ideas regarding add vs multiply vs using the log lookup tables to do a FFT in real time, and if so, at what sort of resolution?
  • frank freedmanfrank freedman Posts: 1,983
    edited 2011-10-04 12:50
    I have placed the objects into the object exchange. I have made a couple very minor changes as suggested so, now into the wild they go...............

    Frank

    Still playing with them, I may try passing the samples through another cog to try inline processing. maybe start with log compression since the prop has that built in. I work with digital image subtraction all the time in Angio suites, wonder what the audio equivalent will sound like as well. ...
  • frank freedmanfrank freedman Posts: 1,983
    edited 2011-10-27 17:03
    I have placed the objects into the object exchange. I have made a couple very minor changes as suggested so, now into the wild they go...............

    Frank

    Still playing with them, I may try passing the samples through another cog to try inline processing. maybe start with log compression since the prop has that built in. I work with digital image subtraction all the time in Angio suites, wonder what the audio equivalent will sound like as well. ...

    Time to have more fun. New TI samples have arrived. Some (former Nat Semi) A/D with a higher speed of digitization. I am still learning the intricacies of A/D and D/A. Seeing the effects of sampling frequency and samples per time has been quite interesting to see as opposed to reading the theory behind everything.

    Frank
Sign In or Register to comment.