Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8669093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:23:06+00:00 2026-06-12T18:23:06+00:00

Fellow SO users, I’m trying to calibrate a resistive humidity sensor that I’m reading

  • 0

Fellow SO users,

I’m trying to calibrate a resistive humidity sensor that I’m reading values from the ADC. The ADC outputs an 8-bit value. I’m using a Vref value of 5V.

My first step in calibrating is to divide the number by 255 and multiply by the Vref value.
Hence, calibrated value = (output / 255) * Vref.

Now, in VHDL, I’ve come across some VHDL code to divide two numbers. The one I have divides two unsigned numbers so that shouldn’t be a problem. It is over here;
VHDL divide two unsigned numbers

Now, in my VHDL file, I have the 8 bit ADC value (humidity) and I have defined two constants, max_val (11111111 = 255) and Vref (00000101 = 5) both as unsigned.
I’m first converting humidity to an unsigned by using unsigned(humidity) and then passing this value and the max_num value into the division function. With the result, I’m multiplying it by Vref.

Now, my question is;

  1. Is this a good approach? I.e; the way I’m dividing and multiplying.
  2. How do I convert the unsigned value back into a std_logic_vector?

Kind regards.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:23:07+00:00Added an answer on June 12, 2026 at 6:23 pm
    1. I think it should divided by 256? Or with 255 i think your result will almost similar (note that max distance is between 255/256 and 255/255: = 0.00390625). Result will be with fixed point number. Multiply by 5: shift right 2 = multiply by 4 then add with this number (A*5 = A*4 + A), your code should like:

      A_Multiply_4 <= A&”00″;
      A_Multiply_5 <= A_Multiply_4 + A;

    2. To convert from unsigned to std_logic_vector (i remember it exist in std_logic_1164):

      slv_array <= std_logic_vector(unsigned_number);

    If you wanna divide by 255, i think you should divide your num by 256 and add a little number after shift:

    1/255 = 1/256 + 1/x

    with x = 2 power something. Shifter is the best way.

    I tried with 1/3 and have to pleasant with this method.

    P/s x = 2^16 and you got diff between 2 case is 5.9838388480392156862745098039216e-8. But i don’t think number you want have more than 8 bit after point.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is driving me nuts so any advice from fellow users would be welcome.
Fellow SO users, I'm programming my ADC (ADC0804 which is mounted on a breadboard
Hi fellow django users, How can I add a field from a related object
Hi fellow Stackoverflow users, I am trying to optimize my iphone application startup time
With some help from some fellow stack users, I currently have this: http://jsfiddle.net/wZETP/ The
Hello fellow python users, I bring forth a question that I have been wondering
With some help from fellow stack users I currently have this: http://jsfiddle.net/XRCvE/ I would
I'm hoping there are some fellow doctrine users out there. Here is a simplified
Hi fellow Umbraco users, I'm currently building my first umbraco website and since I'm
Newb question of the day: I'm trying to select all the users with this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.