Announcement

Collapse
No announcement yet.

Negative Analog Integers

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Negative Analog Integers

    Just to confirm negative integers are:
    Code:
    Volts = Counts * LSB + minRange
    ... for example ...
    Code:
    Volts = 0 * 0.00030518044 + (-10) = -10.00
    Volts = 65535 * 0.00030518044 + (-10) = 10.00
    [/CODE]

    ... versus doing anything with a signed bit.
    Last edited by cBiscuit; 03-10-2020, 08:16 PM.

  • #2
    Your code is off. Work with the Hex number.
    Remember it is just bits in a word.
    https://accautomation.ca/what-everyb...ering-systems/
    Example:
    -100 Signed Decimal =
    FF9C Hex
    1111 1111 1001 1100 Binary
    65,436 Unsigned Decimal

    Regards,
    Garry
    _________________________________________________
    Garry
    ACC Automation
    https://www.accautomation.ca
    Connect with us on Facebook: facebook.com/accautomation/

    Comment


    • #3
      I should have been a little more specific, I'm looking for how to scale an analog input to the Productivity1000 system of modules.

      I'm confused by the LSB they document in their Cut-Sheet (https://cdn.automationdirect.com/sta...cs/P1-04AD.pdf), which specifies 0.000305 V/Count. You can only get that with 16 bits of data (10 - (-10)) / ((2^16)-1)), which then implies no sign bit, so it'd almost have to be scaled like I had in my initial example. If we use a sign bit (as in your 2's compliment example), it wouldn't be possible to get +/- 10V with a LSB of 0.000305V/Count (since the usable range is +32767/-32768 Counts, the LSB would be 0.00061)

      Thanks!

      Comment


      • #4
        the manual shows this

        Data Range 0-65535 counts unipolar -32768 to +32767 counts bipolar
        https://cdn.automationdirect.com/sta...cs/P1-04AD.pdf

        Comment


        • #5
          I've got it... sorry for the confusion.

          Comment


          • #6
            Yeah if you look at the BlockTransferAnalog example, in the description states that analog channels use 4 bytes of data regardless of the resolution if that helps any.

            Comment


            • #7
              Yea, that just dawned on me too. I was trapped in thinking we were working with an int16. I was way more confused about all this last night... thanks everyone.

              I'll try not to drop the soap again, Prison Mike... just stay safe in the clink okay?

              Comment


              • #8
                Lol np will do. Glad we can help.

                Comment

                Working...
                X