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

Thread: analog input for T3.6

  1. #1

    analog input for T3.6

    hi
    from the pjrc website it is not clear - in the case of T3.6 , the analog input reads the range of 0-3.3V ? in that case what is the meaning of a negative voltage ?

    bottom line is that i want to read analog input that ranges from -5 to 5 (might be -10 to 10) and i'm not sure what kind of voltage divider to use ,if any .

  2. #2
    trying again (:
    i'm getting lost in the reference manual and other threads so i'll try to explain my goal and maybe someone could specify the steps i should perform -
    i have a sensor that sends an analog signal in the range of [-10 , 10] V .
    i want teensy (3.6) to read that signal and do something in response .
    not sure what other details are important in this case .

  3. #3
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    3,653
    There are many others up here who can answer this a lot better than I can...

    The only experience I have with something like this is using a CT sensor (Current transformer) to try to understand when power was active, which created an AC signal, which with burden resistor converted to voltage which was +-, which you then need to scale (voltage divider) and then in this used a bias circuit to make the signal always positive, in my case centered around 1.65v...

    A site that showed this is: https://learn.openenergymonitor.org/...-power-adapter

    My guess is there are better ways for you to do it, but maybe something like this, might get you going.

  4. #4
    i will look into the link !
    could you explain what is the ADC reference and when should i use it?
    also about analog ground , which is related in a way i can wrap my head around ...

  5. #5
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    1,908
    Converting bipolar signals (i.e. -5V to +5V) to unipolar signals (i.e. 0 to +3.3V) requires scaling and DC-shifting the signal (a simple y = ax + b operation) which can be done sometimes with resistor dividers and sometimes with op-amps.
    The ADC reference is the voltage which is needed at the input for a full scale reading. Thus, if you select the ADC reference to be 3.3V, you will see full scale reading (0xFFF for the 12bit ADCs in the Teensy) when 3.3V are applied at the input.
    Let's admit that you go with the 3.3V reference which means that (for an input range of +/- n Volts) an input of -n Volt needs to be 0V at the ADC input, an input of +n Volt needs to be 3.3V at the ADC input, and logically, an input of 0V would need to be a half scale signal = 1.65V at the ADC input.
    From this, we can deduce that our conversion function would need to be Vadc = 1.65V + (1.65V / n) * Vin.
    Last edited by Theremingenieur; 10-07-2018 at 03:36 PM.

  6. #6
    got it ! but did you mean Vadc?

    choosing the reference at 3.3v is the highest option for T3.6 ? or can i change it to 5v or even higher ?

  7. #7
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    2,786
    3.3v is as high as you can go on Teensy 3.x/LC. On some Teensys (3.1/3.2./3.5) digital input pins can handle reading up to 5v as a digital signal, but analog read can only read up to 3.3v. On all pins on the 3.6/LC as well as the analog only pins on the 3.1/3.2/3.5, if you have more than 3.3v on the pin you can damage your Teensy.

  8. #8
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    1,908
    Sorry, I meant Vadc. Will fix my posting above. And no, the highest reference is 3.3V. The alternative is the Teensy's internal 1.2V bandage reference, which is very convenient for audio signals at line level.

    Scaling down higher input signals is not rocket science. A plus is that this allows at the same time to match the signal input and the ADC input source impedance.

  9. #9
    as for the analog ground and analog power (VDDA,VSSA), should they concern me in any way ?

    i would appreciate a short explanation of their roles .

    the rest - i feel like i know what to do , thanks!

  10. #10
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,367
    Quote Originally Posted by gony View Post
    bottom line is that i want to read analog input that ranges from -5 to 5 (might be -10 to 10) and i'm not sure what kind of voltage divider to use ,if any .
    You must use a circuit to scale the voltage to a range Teensy can accept.

    Here's the simplest possible circuit. There's also a link on that page to a conversation about better but more complex circuits.

    https://www.dorkbotpdx.org/blog/paul...alog_input_pin




    Quote Originally Posted by gony View Post
    could you explain what is the ADC reference and when should i use it?
    The reference is how the ADC "knows" what voltage is. Internally it compares your signal to the known reference voltage.

    If the reference voltage changes, so will the result. For reading pots, where you signal is the power divided by resistors, you *want* the ADC to scale its results if the power changes.

    But for reading an external voltage, you want to the reference voltage to remain stable, even if the power supply changes. So for this sort of use, you would want to select the internal 1.2V reference. Or if you need extreme accuracy, you might buy a really high quality reference and connect it to the AREF pin. But the 1.2V internal one is pretty good and very easy to use, so go with that first.


    also about analog ground , which is related in a way i can wrap my head around ...
    If in doubt, just connect everything to GND and don't use AGND at all. For many projects, it makes no difference.

    The sort of case where it does matter is usually when you have a PWM pin controlling a motor or LEDs, or you use a servo motor. If the analog signal changes in response to the large & unrelated power consumption, then the AGND pin might help.


    Quote Originally Posted by gony View Post
    or can i change it to 5v or even higher ?
    NO. If you try connecting 5V to AREF or any pin on Teensy 3.6 other than VIN, you will very likely destroy the board. Don't do that!

    The 1.2V internal reference works very nicely if you use a circuit to scale the voltage, like the one I linked above.

Posting Permissions

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