Shop OBEX P1 Docs P2 Docs Learn Events
What is the easiest way to use a 0 to 5 volts and turn in to 0 to 250 bite not 255 — Parallax Forums

What is the easiest way to use a 0 to 5 volts and turn in to 0 to 250 bite not 255

sam_sam_samsam_sam_sam Posts: 2,286
edited 2014-12-07 20:45 in General Discussion
I have to build a testing jig for some air transducer on
a plasma cutting machine

Comments

  • ercoerco Posts: 20,256
    edited 2014-12-04 16:24
    You mean an ADC scaled to read 250 at 5.0V? Input to a Stamp or Prop?
  • Hal AlbachHal Albach Posts: 747
    edited 2014-12-04 16:34
    I would try setting Vref on an 8-bit ADC to 2.55 volts and running the sample voltage through a voltage divider of equal precision resistors. That should yield a count of 250 for 5 volts.
  • kwinnkwinn Posts: 8,697
    edited 2014-12-04 20:14
    If you are using an 8 bit adc you could use a precision 2.56 voltage reference which would give 1mV per bit, then use a voltage divider as Hal suggested to reduce the 0 - 5 volt input to 0 - 2.5V.

    If you don't want to deal with adding a voltage reference and voltage divider use Vcc as the reference and adjust it to 5.12V. That gives you 2mV per bit so 5V in would result in a reading of 250 from the adc.
  • GordonMcCombGordonMcComb Posts: 3,366
    edited 2014-12-05 08:01
    A software-only solution would be to use a 'map' statement. If your language of choice for whatever processor you're using doesn't have one, perhaps there's an add-on library you can find for it that will provide the functionality. When mapped, you apply an input value from one range of numbers, and it correlates to an output value of the other range.

    In the future, could you post more specifics about the tools are you using, in order to assist others in helping you? Solutions like these are often based on what microcontroller board and programming software you are using. You mention "Propeller Proto" in your profile but it doesn't have an ADC, so there's no clear-cut pointer to your toolset.
  • $WMc%$WMc% Posts: 1,884
    edited 2014-12-07 16:19
    Kwinn has a good idea for your 0-255 problem.
    '
    I would use the USA standard of 1v-5v, Instead of 0v-5v. Anything less then 1volt would generate an error, And prove the loop has been compromised. It makes the difference of landing on Mars or burning up in Mars's atmosphere for a Rover.
  • kwinnkwinn Posts: 8,697
    edited 2014-12-07 20:45
    $WMc% wrote: »
    Kwinn has a good idea for your 0-255 problem.
    '
    I would use the USA standard of 1v-5v, Instead of 0v-5v. Anything less then 1volt would generate an error, And prove the loop has been compromised. It makes the difference of landing on Mars or burning up in Mars's atmosphere for a Rover.

    For critical applications I do something similar to that for signals that should be in the 0 to some upper limit range. Have the range of the incoming signal cover about 80% of the adc range, add an offset of about 10% to the analog signal, and have the software check to see that the measurement is in that range.
Sign In or Register to comment.