Results 1 to 6 of 6

Thread: Interpreting values

  1. #1
    Newbie
    Join Date
    Oct 2008
    Posts
    11

    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. #2
    Fusion Brain Creator 2k1Toaster's Avatar
    Join Date
    Mar 2006
    Location
    Colorado, but Canadian!
    Posts
    10,049
    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

  3. #3
    Newbie
    Join Date
    Oct 2008
    Posts
    11

    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

  4. #4
    Fusion Brain Creator 2k1Toaster's Avatar
    Join Date
    Mar 2006
    Location
    Colorado, but Canadian!
    Posts
    10,049
    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

  5. #5
    Newbie
    Join Date
    Oct 2008
    Posts
    11
    Thanks that was what I was hoping for I just wanted to make sure before I made any wrong assumptions.

  6. #6
    North of the land of Hey Huns
    Auto Apps:loading...

    Join Date
    Jun 2004
    Location
    Westminster, MD
    Posts
    2,127
    Edit: nevermind
    "stop with the REINSTALLS, what do you think we got some lame-o installer!!!" - mitchjs
    RevFE
    My Shop

Similar Threads

  1. Replies: 1
    Last Post: 12-10-2008, 03:36 PM
  2. Fluctuating Input Values
    By thwack in forum Fusion Brain
    Replies: 4
    Last Post: 09-22-2008, 09:32 PM
  3. Thermometer values WAY too low. Maybe displaying voltages?
    By Sonicxtacy02 in forum Fusion Brain
    Replies: 8
    Last Post: 03-27-2008, 08:13 PM
  4. WinAMP Preset Values in .PST File
    By Tissy in forum Road Runner
    Replies: 2
    Last Post: 01-09-2007, 07:00 PM
  5. Anyone knows how can I convert the mileage to digital values?
    By e1fnd in forum Software & Software Development
    Replies: 22
    Last Post: 06-18-2003, 12:35 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •