Jump to content

Analog/ADC example for TM4C129

Recommended Posts

I am using this current sensor in my project. The Vout pin needs to be connected to the ADC. The best way to do this is to connect it to some analog pin and tie that analog pin to ADC through the code. Anything else?


Can you refer to a sample code for this?

Share this post

Link to post
Share on other sites

Since you didn't reference which platform you are using can't give you a definite answer on the ADC input voltage.  Most Launchpads have a 3.3V max input for the ADC so you will have to scale the voltage down so you don't exceed that with your sensor. Please double check the maximum ADC input voltage for the Launchpad you are using.  For the ADC code portion, the examples at the Energia.nu website or, if you are using CCS, the TI website should be good starting points.

Share this post

Link to post
Share on other sites

Hi @@lilyhack,


I don't use the TM4C129 and am not familiar with that sensor, but here are some thoughts....


In the link you have posted there is a link to a datasheet.  Of interest:

  • The supply voltage to the sensor, assuming a LaunchPad is powering it, will need to be 5V
  • The offset voltage will be Vcc/2 or 2.5 V
  • Voltage will go up or down by 0.017 V per A depending on whether current is forwards or backwards

I can't remember if the TM4C129 pins are 5V tolerant or not.  It seems like they are, but in any case you don't want the voltage to go above say 3.3 V for measurement.  With only 0.017 V per A, you would have to have pretty high current levels to do that but I would put a voltage divider in.


The datasheet gives some Arduino code:

  Current = ((analogRead(1)*(5.00/1024))- 2.5)/ .017;

This code assumes 5V input to the sensor with no voltage divider for the output to Analog pin 1 of the microcontroller.  You will need to modify that as the Arduino only has 10 bit ADC and the TM4C129 has 12 bit.  So, divide by 4095 instead of 1024 and subtract 1.65 if you have a voltage divider that gives 3.3 V with a 5 V input.


EDIT:  Didn't see your post when I started writing dubnet

Share this post

Link to post
Share on other sites

@@Fmilburn   No problem.  Your answer was far more complete than mine.  You induced curiosity so I did a quick check of the TM4C1294 datasheet (http://www.ti.com/lit/ds/symlink/tm4c1292ncpdt.pdf , page 1750/figure 27-1 and page 1793/figure 27-44) which confirms that digital pins are not 5V tolerant and the max analog input is equal to Vdda (Analog supply voltage) which has a stated max of 3.63V (nominal 3.3V).


EDIT:  For the sake of clarity it is not to infer that the analog inputs will tolerate 3.63V as the supply on the Launchpad is likely 3.3V.  So the 3.3V figure given by @@Fmilburn is correct.


EDIT2:  I always seem to miss the information contained in the title of the post, in this case the MCU model. My apologies to the OP.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now