Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 38

Thread: FB v6 & Visual Basic

  1. #11
    Constant Bitrate
    Join Date
    Jun 2004
    Posts
    148
    random is probably not the correct term to use.

    I looks like it is reading a value, but it is not stable at all & A) jumps around, B) eventually settles to 0 (less than 2sec, sometimes less than 1 or immediately).

    Either I'm interpreting what the Ain is sending (and recording in the array) OR there is something wrong with both of my v6 brains. I doubt #2, but I can't rule it out yet.
    Multimeter needs a battery & I need to get some resistors from home to make a definite test & see what is going on.

  2. #12
    Fusion Brain Creator 2k1Toaster's Avatar
    Join Date
    Mar 2006
    Location
    Colorado, but Canadian!
    Posts
    10,053
    Remember if there is nothing there, then the reading is undetermined for the analogue inputs. Once you connect something, it is different. But floating nodes are unpredictable by nature.
    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. #13
    Constant Bitrate
    Join Date
    Jun 2004
    Posts
    148
    Quote Originally Posted by 2k1Toaster View Post
    Remember if there is nothing there, then the reading is undetermined for the analogue inputs. Once you connect something, it is different. But floating nodes are unpredictable by nature.
    Just put FuseGL on work PC & it works as expected (assuming .8V is room temperature, it goes up if I the ssr up) & my port selection was correct.

    I don't understand what is going on with this line:

    Code:
    Dim aValue_INT As Integer = ((_AllAnalogues(a) And &H3) << 8) + _AllAnalogues(a + 1)
    doesn't seem to be picking anything up when I put a break there & step through the loop. when a=0, _AllAnalogues(a) = 128 & &H3=3 & a+0=0, but the result is aValue_INT=0 (I have no idea what most of this line says and 128 = .42V, FuseGL reports the temp ssr as .8v)

    What does <<8 mean?
    If i step through, _AllAnalogues(a) increments by 4 each time through the loop, but aValue_INT never gets a value other than 0

  4. #14
    Fusion Brain Creator 2k1Toaster's Avatar
    Join Date
    Mar 2006
    Location
    Colorado, but Canadian!
    Posts
    10,053
    Quote Originally Posted by Iamthehor View Post
    Just put FuseGL on work PC & it works as expected (assuming .8V is room temperature, it goes up if I the ssr up) & my port selection was correct.

    I don't understand what is going on with this line:

    Code:
    Dim aValue_INT As Integer = ((_AllAnalogues(a) And &H3) << 8) + _AllAnalogues(a + 1)
    doesn't seem to be picking anything up when I put a break there & step through the loop. when a=0, _AllAnalogues(a) = 128 & &H3=3 & a+0=0, but the result is aValue_INT=0 (I have no idea what most of this line says and 128 = .42V, FuseGL reports the temp ssr as .8v)

    What does <<8 mean?
    If i step through, _AllAnalogues(a) increments by 4 each time through the loop, but aValue_INT never gets a value other than 0
    0.8v is slightly colder than room temp. (0.8-0.4) / 0.0195 ~= 20C or 68F-70F

    "<<" is "left shift". So if you have 0b00000010 (0x02) and you left shift by 1 ( << 1), you will get 0b00000100 (0x04). Do it again and you get 0b00001000 (0x08). The ADC is 10bits in the Fusion Brain. A byte only holds 8bits. So you need to store 1 10 bit value in 2 bytes and then combine them.

    My code for analogues:

    Code:
       int aValue_INT = ((readInArray[(i * 1) + (j * 2) + 0] & 0x03) << 8) + readInArray[(i * 1) + (j * 2) + 1];
       double aValue_DBL = (this.fusionBrain_version.VREF * ((double)aValue_INT) / (double)this.fusionBrain_version.ANALOGUE_INPUT_MAXVAL);
    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. #15
    Constant Bitrate
    Join Date
    Jun 2004
    Posts
    148
    My brain just exploded. You lost me on the byte stuff (other than the 10bits can't fit in a byte....)

    With this:
    Code:
            For x = 1 To TotalInstances ' loops through all FB instances connected
                FusionBrain_WinUSB.MainUSBClass.allFusionBrains(FusionBrain_WinUSB.MainUSBClass.allFusionBrains.Count - 1).ReadDataFromFusionBrain(_AllAnalogues, &H2)
                Dim i As Integer
                For a As Integer = 0 To 15 * 2 - 1 Step 2
                    Dim aValue_INT As Integer = ((_AllAnalogues(a) And &H3) << 8) + _AllAnalogues(a + 1)
                    ' The raw 0 through 1023 digital value
                    ' Converting that value to a real voltage and storing in some temp List
    
                    AnalogInRaw(x, i) = aValue_INT 'provides the raw data analog input values from VB
                    AnalogInVoltage(x, i) = (3.3 * CDbl(aValue_INT) / 1023.0) 'converts the raw data to voltage form
                    i = i + 1
                Next
            Next
    
            Label3.Text = CStr(AnalogInRaw(1, 0))
            Label4.Text = Microsoft.VisualBasic.Left(CStr(AnalogInVoltage(1, 0)), 4)
    After unplugging/reconnecting the brain, I get the correct raw & voltage (~0.81V) for ~10sec, then it steps to 0, holds for ~5sec, then returns to 0.81, then sometimes steps down & right back up)
    there's a pattern there, I just don't know what it is. So something in the loop stepping must be off.
    It also seems that the 'correct' reading doesn't change without resetting the brain - I can run the program, let it step up/down a couple times & put the ssr in my jacket & the 'correct' reading doesn't change. Unplug/reconnect & the next 'correct' reading is higher, and so on.

    In the ReadDataFromFusionBrain, the end byte is &H2, but in the other line I don't get, the byte is &H3. Typo? Changing them to match didn't seem to affect it.

  6. #16
    Constant Bitrate
    Join Date
    Jun 2004
    Posts
    148
    Could somebody try this? I think it will work if you just un-zip to a folder & have a v6 Brain connected & drivers installed (can't test as both my systems have VB.net installed to develop this.) IIRC, copying the files in the bin/release folder is all you need....


    I'm having a helluva issue with the analog in. It will read the correct voltage, but not at every tick event. I think it has to do with these 2 lines, but I don't understand them. So far, I havent found anything from google that helps me understand what is going on, so any explanation is also helpful, maybe I'm just being dense...
    Code:
    For a As Integer = 0 To 15 * 2 - 1 Step 2
                    Dim aValue_INT As Integer = ((_AllAnalogues(a) And &H3) << 8) + _AllAnalogues(a + 1)
    On both my systems (XP & W7x64), when I run the program, it will read either 0 or the correct voltage for ~10sec. It will then step to either 0 or toward the correct voltage (depending on where it starts). Once it has been at the correct voltage, it will step to 0, hold at 0, then flash some readings up to 2x the correct reading (There is a pattern, but it is too fast for me to detect)

    The full code for this sub is:
    Code:
    Private Sub FBReadTmr_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
    
            For x = 1 To TotalInstances ' loops through all FB instances connected
                FusionBrain_WinUSB.MainUSBClass.allFusionBrains(FusionBrain_WinUSB.MainUSBClass.allFusionBrains.Count - 1).ReadDataFromFusionBrain(_AllAnalogues, &H2)
                Dim i As Integer
                Dim a As Integer = 0
                For a = 0 To 15 * 2 - 1 Step 2
                    Dim aValue_INT As Integer = ((_AllAnalogues(a) And &H3) << 8) + _AllAnalogues(a + 1)
                    ' The raw 0 through 1023 digital value
                    ' Converting that value to a real voltage and storing in some temp List
    
                    AnalogInRaw(x, i) = aValue_INT 'provides the raw data analog input values from VB
                    AnalogInVoltage(x, i) = (3.3 * CDbl(aValue_INT) / 1023.0) 'converts the raw data to voltage form
                    i = i + 1
    
                Next
                Label3.Text = CStr(AnalogInRaw(1, 0))
                Label4.Text = Microsoft.VisualBasic.Left(CStr(AnalogInVoltage(1, 0)), 4)
            Next
    Attached Files Attached Files

  7. #17
    Constant Bitrate
    Join Date
    Jun 2004
    Posts
    148
    This text file is what is being output into AnalogInRaw(i,x), I don't understand the pattern at all.

    I've been trying to read about how to use the byte structure, but I'm not finding anything that really fits with how this works. Glad it's friday, I'm frustrated.
    Attached Files Attached Files

  8. #18
    Mo' Programming Mo' Problems
    Auto Apps:loading...
    Sonicxtacy02's Avatar
    Join Date
    Sep 2004
    Location
    Woodbridge, VA
    Posts
    8,153
    Blog Entries
    51
    This post is old but the question still remains. The code that i listed in post #8 worked for my beta FB6, but doesnt work for the most recent version, as I have the same problems Iamthor describes. So how exactly do we iterate through analog sensors to obtain their value? FuseGL doesnt even appear to read my temp sensors properly
    Attached Images Attached Images  
    Last edited by Sonicxtacy02; 06-29-2012 at 01:24 PM.
    mp3Car.com Senior Tech Blogger (Want a product reviewed? Contact me.)
    Find my plugins on the MP3Car App Store!
    Follow Me on Twitter or Facebook
    Live mp3Car Facebook Chat

  9. #19
    Fusion Brain Creator 2k1Toaster's Avatar
    Join Date
    Mar 2006
    Location
    Colorado, but Canadian!
    Posts
    10,053
    First step would be to try this new firmware: http://www.mp3car.com/fusion-brain/1...sion-2-0a.html

    Then see how it goes. If you have old firmware that sort of thing will happen. I will post my C# code to read inputs tonight. Someone bump this thread if I forget!
    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

  10. #20
    Mo' Programming Mo' Problems
    Auto Apps:loading...
    Sonicxtacy02's Avatar
    Join Date
    Sep 2004
    Location
    Woodbridge, VA
    Posts
    8,153
    Blog Entries
    51
    Quote Originally Posted by 2k1Toaster View Post
    First step would be to try this new firmware: http://www.mp3car.com/fusion-brain/1...sion-2-0a.html

    Then see how it goes. If you have old firmware that sort of thing will happen. I will post my C# code to read inputs tonight. Someone bump this thread if I forget!
    I was going to try that but the reset pins mentioned in that post arent present on my board. So where are the new reset pins? Or is that step no longer needed?
    mp3Car.com Senior Tech Blogger (Want a product reviewed? Contact me.)
    Find my plugins on the MP3Car App Store!
    Follow Me on Twitter or Facebook
    Live mp3Car Facebook Chat

Page 2 of 4 FirstFirst 1234 LastLast

Similar Threads

  1. Visual Basic on a Mac
    By sdashiki in forum MacCar
    Replies: 6
    Last Post: 06-08-2005, 03:08 PM
  2. OBD-II and Visual Basic
    By nicgalla in forum Engine Management, OBD-II, Engine Diagnostics, etc.
    Replies: 10
    Last Post: 05-16-2005, 05:46 PM
  3. Visual Basic & LCD
    By farolfo in forum Software & Software Development
    Replies: 2
    Last Post: 04-28-2004, 12:03 PM
  4. Wmp for Visual Basic
    By Bj in forum Software & Software Development
    Replies: 0
    Last Post: 11-10-2003, 08:07 AM
  5. Visual Basic?
    By pinkysqueaks in forum Software & Software Development
    Replies: 2
    Last Post: 06-25-2001, 11:08 AM

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
  •