Announcement

Collapse
No announcement yet.

Interpreting values

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

  • Interpreting values

    Hi I was wondering if you could explain whats happening in this piece of code please. I'v tried to figure it out as best as I can but still have some problems especially with the scaling_reF variable. I can't find what MainMDX.AllAnalogueInputs[accurate_index].CurrentValue; is in the source code.

    Code:
    case MainMDX.BrainVersion.Version_04:
                        {
                            digital_value = (int)(input_byte1 * 256) + (int)input_byte2;
                        }
                        break;
                }
                double scaling_reF = 5.0;
                if (accurate_index >= 0 && accurate_index < MainMDX.AllAnalogueInputs.Count)
                {
                    scaling_reF = MainMDX.AllAnalogueInputs[accurate_index].CurrentValue;
                    if (scaling_reF == 0)
                    {
                        scaling_reF = 5.0;
                    }
                }
                double reF = ((double)digital_value / 1023.0f) * scaling_reF;
                return reF;
            }
    Thanks
    Jeff

  • #2
    It is an old piece of code that can be fully deleted.

    Basically it was for taking a value off of an analogue input, and using that for the reference voltage to do the digital to analogue conversion with instead of just blindly assuming it was 5v.

    Since the voltage regulator on the brain will put out slightly less voltage when hot, it was thought of in a hurry to mabe compensate for that. However we shortly (within hours) realized we were being stupid as the reference voltage would be compared off of the same bad regulator voltage! duh... So it is still in there because... I just havent taken it out.
    Fusion Brain Version 6 Released!
    1.9in x 2.9in -- 47mm x 73mm
    30 Digital Outputs -- Directly drive a relay
    15 Analogue Inputs -- Read sensors like temperature, light, distance, acceleration, and more
    Buy now in the MP3Car.com Store

    Comment


    • #3
      New Question then

      Ok so that explains that, my next question is what are the bytes being put into the byte array by SendAndReceiveViaInterruptTransfers, and why is the low byte alyaws 0 for me.

      Are they bytes from the ADC or someting else?

      I am using the temperature sensor to try and figure out the meaning of the values returned to me but no joy so far.

      I know that 10mv = 1 degree celsius, that 0 = -40 degrees celsius and 400 = 0 degrees celsius but in a room that is quite comfortable around 23 degrees celcius to sit in im getting 232 returned as the value which if divided by 10 is the right temperature.

      Jeff

      Comment


      • #4
        it returns voltage. That's it. All analogue inputs are voltage only. If you attach a temperature sensor or photosensor, it doesnt care, it just returns the voltage.

        Whatever is returned is the digital value read in. It is 10bit, and 5v reference. Hence the 5 * (value/1023) to get the raw voltage.

        Then you send that through an equation to get whatever the sensor is. That is the point of the whole logic section.
        Fusion Brain Version 6 Released!
        1.9in x 2.9in -- 47mm x 73mm
        30 Digital Outputs -- Directly drive a relay
        15 Analogue Inputs -- Read sensors like temperature, light, distance, acceleration, and more
        Buy now in the MP3Car.com Store

        Comment


        • #5
          Thanks that was what I was hoping for I just wanted to make sure before I made any wrong assumptions.

          Comment


          • #6
            Edit: nevermind
            "stop with the REINSTALLS, what do you think we got some lame-o installer!!!" - mitchjs
            RevFE
            My Shop

            Comment

            Working...
            X