Advertisement
zmatt

default adc config with comments

Mar 3rd, 2022 (edited)
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.58 KB | None | 0 0
  1. &tscadc {
  2.     status = "okay";
  3.  
  4.     adc {
  5.         // Configure one or more (up to 8) steps for the adc to execute:
  6.  
  7.  
  8.         // For each step, the channel to sample.
  9.         //  range: 0 .. 7
  10.         ti,adc-channels = <0 1 2 3 4 5 6 7>;
  11.         //
  12.         // BeagleBone Black (and most other variants):
  13.         //  ch 0    P9.39
  14.         //  ch 1    P9.40
  15.         //  ch 2    P9.37
  16.         //  ch 3    P9.38
  17.         //  ch 4    P9.33
  18.         //  ch 5    P9.36
  19.         //  ch 6    P9.35
  20.         //  ch 7    measures 0.5 * VDD_3V3B with 2.4 kΩ source impedance
  21.         //
  22.         // PocketBeagle:
  23.         //  ch 0    P1.19
  24.         //  ch 1    P1.21
  25.         //  ch 2    P1.23
  26.         //  ch 3    P1.25
  27.         //  ch 4    P1.27
  28.         //  ch 5    P2.35 via 10k/10k voltage divider
  29.         //  ch 6    P1.02 via 10k/10k voltage divider
  30.         //  ch 7    P2.36 via pmic mux
  31.         //
  32.         // The divider used on PocketBeagle channels 5 and 6 makes the effective voltage V_eff and
  33.         // source impedance Z_eff seen by the adc on these channels depend on the voltage V_src and
  34.         // impedance Z_src of the source connected to the corresponding pin as follows:
  35.         //
  36.         //  V_eff = V_src / (2 + Z_src / (10 kΩ))
  37.         //  Z_eff = 5 kΩ * (1 + Z_src / (Z_src + 20 kΩ))
  38.         //      ≈ 5 kΩ + Z_src / 4    for small values of Z_src (up to 2 kΩ or so)
  39.  
  40.  
  41.         // For each step, number of adc clock cycles to wait between setting up muxes and sampling.
  42.         //  range: 0 .. 262143
  43.         //  optional, default is 152 (XXX but why?!)
  44.         ti,chan-step-opendelay = <152 152 152 152 152 152 152 152>;
  45.         //`
  46.         // XXX is there any purpose to set this nonzero other than to fine-tune the sample rate?
  47.  
  48.  
  49.         // For each step, how many times it should sample to average.
  50.         //  range: 1 .. 16, must be power of two (i.e. 1, 2, 4, 8, or 16)
  51.         //  optional, default is 16
  52.         ti,chan-step-avg = <16 16 16 16 16 16 16 16>;
  53.         //
  54.         // If you're using periodic sampling (using the iio block device rather than sysfs) then
  55.         // you should consider setting this to 1 and if desired reduce the samplerate in userspace
  56.         // instead since averaging isn't a particularly good low-pass filter.
  57.         //
  58.         // If you're using sysfs to occasionally read a value, then the default value of 16 will
  59.         // still get you the most accurate readings.
  60.  
  61.  
  62.         // For each step, number of adc clock cycles to sample minus two.
  63.         //  range: 0 .. 255   (resulting in sampling time of 2 .. 257 cycles)
  64.         //  optional, default is 0
  65.         ti,chan-step-sampledelay = <0 0 0 0 0 0 0 0>;
  66.         //
  67.         // If this is set too low, accuracy will deteriorate when the thing you're measuring has a
  68.         // high source impedance.  The maximum source impedance recommended (by erratum 1.0.32) is:
  69.         //  (2 + sampledelay) * 2.873 kΩ - 0.2 kΩ
  70.         // which means that the default should be fine for source impedance up to 5.5 kΩ.
  71.         //
  72.         // (This seems to ensure the sampling time is at least 21 times the RC constant, based on
  73.         // the 5.5 pF nominal capacitance specified in the datasheet.)
  74.  
  75.  
  76.         // After sampling, conversion time is 13 adc clock cycles.
  77.         //
  78.         // The adc clock frequency is 3 MHz, therefore the total time per step in microseconds is:
  79.         //  ( opendelay + avg * ( 2 + sampledelay + 13 ) ) / 3
  80.         //
  81.         // If all steps use the same timings then the sample rate will be:
  82.         //  3 MHz / ( opendelay + avg * ( 2 + sampledelay + 13 ) ) / number_of_steps
  83.         //
  84.         // The highest samplerate obtainable (avg=1, opendelay=0, sampledelay=0) is therefore:
  85.         //  200 kHz / number_of_steps
  86.         //  = 25 kHz    when using all 8 steps.
  87.         //
  88.         // Using avg=16 reduces that to:
  89.         //  12.5 kHz / number_of_steps
  90.         //  = 1.5625 kHz    when using all 8 steps.
  91.         //
  92.         // Using the default values (avg=16, opendelay=152, sampledelay=0) reduces that to:
  93.         //  7.653 kHz / number_of_steps
  94.         //  = 0.9566 kHz    when using all 8 steps.
  95.     };
  96. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement