element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
BeagleBoard
  • Products
  • Dev Tools
  • Single-Board Computers
  • BeagleBoard
  • More
  • Cancel
BeagleBoard
Forum ADC not getting correct value for pressure sensor- Pocketbeagle iobb
  • Blog
  • Forum
  • Documents
  • Quiz
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join BeagleBoard to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 4 replies
  • Subscribers 99 subscribers
  • Views 470 views
  • Users 0 members are here
Related

ADC not getting correct value for pressure sensor- Pocketbeagle iobb

chrischristian14
chrischristian14 over 5 years ago

I am using this pressure sensor

 

https://www.amazon.com/dp/B07WR3NV3F/ref=cm_sw_r_cp_apa_i_csbSDbBGT3NZ1

 

for zero pressure/ room pressure, it outputs 0.5V and for 30psi it outputs 4.5V. I am trying to measure it with AIN0 (P1.19) on pocketbeagle . I am using iobb library.

This is my schematic

image

The ADC reads random values when sensor is connected to J4. But the multimeter reads correct voltage on Pin 3 J4 and on AIN0. Also If I try any other voltage via an additional voltage divider using +5V  connected to J4 and give 0.5V to pin 3 on J4, and not use the sensor  AIN0 reads correct value of 0.16V. Is this related to current ? I have also tried replacing R15 and R16 with 200K and 100K values hoping that it will reduce current leakage but that also doesn't work. Below is my example code.

float do_adc(void)
{
unsigned int sample, sum_of_samples,final;
int i ,j;
float result;
unsigned int buffer_AIN_0[BUFFER_SIZE] ={0};


iolib_init();


/* using ADC_CALC toolkit to decide the ADC module argument . Example Sample rate : 10000 sample/s
*
* #./ADC_CALC -f 10000 -t 5
*
* Suggest Solution :
* Clock Divider : 160 ,   Open Dly : 0 ,  Sample Average : 1 ,    Sample Dly : 1
*
*/
// const int clk_div = 34 ;
const int clk_div = 160;
const int open_dly = 0;
const int sample_dly = 1;


BBBIO_ADCTSC_channel_ctrl(BBBIO_ADC_AIN0, BBBIO_ADC_STEP_MODE_SW_CONTINUOUS, open_dly, sample_dly, \
BBBIO_ADC_STEP_AVG_1, buffer_AIN_0, BUFFER_SIZE);




// for(i = 0 ; i < 5 ; i++)
{
BBBIO_ADCTSC_channel_enable(BBBIO_ADC_AIN0);
// while(1)
{
BBBIO_ADCTSC_work(SAMPLE_SIZE);


for(j = 0 ; j < SAMPLE_SIZE ; j++) 
{
sample = buffer_AIN_0[j];
sum_of_samples=+sample;
}
result = ((float)sample / 4095.0f) * 1.8f ;
//result = voltage_divider(result);
// printf("ADC result is %f", result);
// printf("\t[sample : %d , %f v]\n", sample, ((float)sample / 4095.0f) * 1.8f);
sleep(2);

}




}



iolib_free();
return result;
}

  • Sign in to reply
  • Cancel

Top Replies

  • chrischristian14
    chrischristian14 over 5 years ago +2
    Thank you everyone for reply, it was a noisy power supply, 1000uF capacitor across power lines just before the sensor made it work, still not perfect but getting better results. If anyone has a better…
  • chrischristian14
    chrischristian14 over 5 years ago +1
    Just to give update, I have tried connecting the pressure sensor directly to AIN0, at normal room pressure, there is 0.5V output from the sensor, I can also measure 0.5V on the AIN0 pin but the ADC keeps…
  • Jan Cumps
    Jan Cumps over 5 years ago in reply to chrischristian14 +1
    Do you have a spare opamp available? You could breadboard a buffer between tooutput and divider to check if it's due to the load at the output of the transducer.
  • chrischristian14
    0 chrischristian14 over 5 years ago

    Just to give update, I have tried connecting the pressure sensor directly to AIN0, at normal room pressure, there is 0.5V output from the sensor, I can also measure 0.5V on the AIN0 pin but the ADC keeps reading random values. If I put 0.5V using a voltage divider then AIN0 reads correct value.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Jan Cumps
    0 Jan Cumps over 5 years ago in reply to chrischristian14

    Do you have a spare opamp available? You could breadboard a buffer between tooutput and divider to check if it's due to the load at the output of the transducer.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • michaelkellett
    0 michaelkellett over 5 years ago in reply to chrischristian14

    The first thing you should do is find the description of the ADC hardware in the data sheet and understand exactly how it works.

     

    If you would rather try a few more experiments then, based on you observation that 0.5V from a power supply work OK, try putting a 100nF cap in // with R16. - the reasoning being that if a meter shows 0.5V  the average voltage must be 0.5V, but if the ADC sees 0.5V from a low impedance source but not from the pressure sensor and its divider then there is likely something about its source impedance that doesn't work with the ADC. However, I wouldn't be that hopeful because most uP ADCs give consistent but wrong results if the source impedance is too high.

     

    You could try increasing open_dly and sample_dly, but this would be much better done when you know what they actually do !

     

    MK

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • chrischristian14
    0 chrischristian14 over 5 years ago

    Thank you everyone for reply, it was a noisy power supply, 1000uF capacitor across power lines just before the sensor made it work, still not perfect but getting better results. If anyone has a better idea, I would appreciate.  

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube