Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: ADC & Smoothing

  1. #1
    Junior Member
    Join Date
    Jul 2014
    Posts
    2

    ADC & Smoothing

    Hi everyone,

    I am currently getting further and further in to flight sims, and have decided that I need a custom controller. While I have been programming for years I have no electronics knowledge. This is something I am keen to rectify to the extent that I can play around with Arduino/Teensy and similar for fun projects.

    My current main flight sim is Il2 Cliffs of Dover, and I am branching out in to DCS world. One of my most immediate controller issues is that I need accurate trim controls. I currently have a CH throttle quadrant which the axes give about 69 degrees of turn? I was thinking of going for some 1, 3 or 5 turn pots.

    So I bought a Teensy 3.1 and headed down to Jaycar for some parts. End result code is below a very basic diagram.


    Code:
    void setup()
    {                
      Serial.begin(38400);
    }
    
    int val;
    
    void loop()                     
    {
      val = analogRead(4);
      Serial.print("analog 0 is: ");
      Serial.println(val);
      delay(250);
    }
    Pin 4 should be AGND
    Pin 6 should be 3.3V
    Pin 18 is A4.

    Click image for larger version. 

Name:	Untitled.png 
Views:	108 
Size:	11.6 KB 
ID:	2590

    My output is this
    analog 0 is: 716
    analog 0 is: 738
    analog 0 is: 758
    analog 0 is: 784
    analog 0 is: 742
    analog 0 is: 736
    analog 0 is: 759
    analog 0 is: 744
    analog 0 is: 741
    analog 0 is: 810
    analog 0 is: 764
    analog 0 is: 713
    analog 0 is: 729
    analog 0 is: 724
    analog 0 is: 747
    analog 0 is: 748
    analog 0 is: 753
    analog 0 is: 728
    analog 0 is: 714
    analog 0 is: 760
    analog 0 is: 759
    analog 0 is: 760
    analog 0 is: 743
    analog 0 is: 715
    analog 0 is: 760
    analog 0 is: 723
    analog 0 is: 754
    analog 0 is: 728
    analog 0 is: 715
    analog 0 is: 804
    analog 0 is: 713
    analog 0 is: 744
    analog 0 is: 737
    analog 0 is: 743
    analog 0 is: 772
    analog 0 is: 750
    analog 0 is: 732
    analog 0 is: 762
    analog 0 is: 737
    analog 0 is: 769
    analog 0 is: 776
    analog 0 is: 722
    analog 0 is: 717
    analog 0 is: 730
    analog 0 is: 765

    As you can see values vary wildly. I have been poking around the forums so have tried a few capacitors between the 3.3V and AGND but that makes no difference. I really don't know what I am doing. Can anyone suggest how I should be troubleshooting this?

  2. #2
    Senior Member Constantin's Avatar
    Join Date
    Nov 2012
    Location
    In the yard with a 17' Dia. Ferris Wheel
    Posts
    1,408
    A couple of things: Swap pin 6 for AREF. That should be quieter. For even tighter control, tell the teensy ADC to use a external AREF and use a shunt style voltage regulator to pull the voltage down to 3V or less.

    A 0.1uF cap from A4 to AGND should also smooth things by creating a charge reservoir and RC filter - the teensy 3 doesn't handle input impedance over a few kOhms well. Even better would be use of a buffer op-Amp.

    Last but not least, put a 100uF cap from 3.3V to GND. There may be something else going on (communications?) that is sagging the local voltages.

  3. #3
    Senior Member
    Join Date
    Sep 2013
    Location
    Hamburg, Germany
    Posts
    894
    If all else fails, filter in software. But only if you couldn't improve the hardware.

  4. #4
    Junior Member
    Join Date
    Jul 2014
    Posts
    2
    Quote Originally Posted by Constantin View Post
    A couple of things: Swap pin 6 for AREF. That should be quieter. For even tighter control, tell the teensy ADC to use a external AREF and use a shunt style voltage regulator to pull the voltage down to 3V or less.

    A 0.1uF cap from A4 to AGND should also smooth things by creating a charge reservoir and RC filter - the teensy 3 doesn't handle input impedance over a few kOhms well. Even better would be use of a buffer op-Amp.

    Last but not least, put a 100uF cap from 3.3V to GND. There may be something else going on (communications?) that is sagging the local voltages.

    Thanks for the replies. I have more questions.
    1. What is the recommended way to connect to AREF for bread boarding given that it is on the "inside row" of pins and I have soldered header pins to both outside rows? I could solder a header pin to AREF and use an alligator clip, however that just seems nasty.
    2. Does consistent 3.254v count as voltage sag, or only if I see it dip. I get that from AREF to AGND and from 3.3V to AGND? If this voltage is consistent will it be an issue or only if it changes over time/load?

    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •