Page 6 of 8 FirstFirst 12345678 LastLast
Results 51 to 60 of 76

Thread: Sdk?

  1. #51
    Fusion Brain Creator 2k1Toaster's Avatar
    Join Date
    Mar 2006
    Location
    Colorado, but Canadian!
    Posts
    10,049
    Quote Originally Posted by mx270a View Post
    Well that works. I might un-code the digital input stuff then, so I'm not tempted to use them. Might make things a lot easier in the future if I want to make the software compatible with the new brains.
    Well you can check for version in the last few bytes of the stream, so you could do a if/else with the version just to add an other option.

    Quote Originally Posted by mx270a View Post
    You might want to look at that code I posted in reply #43. Doing the math on both bytes as decimal numbers might be more efficient than going to a string and back, plus you can do it all in one line of code.
    I wasn't really worried about efficiency when I wrote it, it was more for testing. TO visualize what the stream looked like, I like strings. But now that optimization is getting more important as it has grown, I think I just may switch to all math, no strings.

    Quote Originally Posted by mx270a View Post
    I haven't written any code to do that yet, but I have thought about it. Other companies do things such as have the computer start beeping when your 100 feet away from the end. That can get annoying though. I also read somewhere that one of the systems, if it thinks there is no operator in the machine, will turn the wheels to the far left so the tractor just does circles. Tying it into a kill switch on the engine would be the ultimate in safety, but is a bit of a challenge to do on some tractors.
    Oh boy! I can just see in my head some operator getting out of the tracktor only to be chased down cartoon style in circles!
    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

  2. #52
    Newbie
    Join Date
    Feb 2008
    Posts
    9
    Quote Originally Posted by 2k1Toaster View Post
    Yes the 2 other bits are the least significant bits, so dumping them is no problem if you dont want them. But to combine them, I found the easiest way was just to convert them into strings, concatonate the strings, and convert back to a number. May not be efficient, but on todays processors even a P3, it makes no difference to make an extra 10byte array.
    Actually it makes a hell of a difference even on a Core Duo cause you're adding way more than a 10 byte array to get 2 binary strings, pad them, concat, trim and then convert back to a value. I hear you on fast computers but if you poll and calculate 10 inputs @ 50-60Hz, it more than adds up and noticeably so. To get full value out of those two bytes it's a pretty short formula:

    var res = ( b1 << 2 ) | ( ( b2 >> 7 ) & 1 ) | ( ( b2 >> 5 ) & 2 );

    b1, b2 are the odd/even AI bytes respectively. Lightning fast too.

    Oh boy! I can just see in my head some operator getting out of the tracktor only to be chased down cartoon style in circles!
    too funny.

  3. #53
    Newbie
    Join Date
    Mar 2008
    Posts
    13
    Can someone upload the source code for vb? i cant get the code thats show in this tread to work properly, i only need the code to control relays with the fusionusb.

  4. #54
    Constant Bitrate mx270a's Avatar
    Join Date
    Aug 2003
    Location
    Iowa
    Posts
    167
    Quote Originally Posted by pskogly View Post
    Can someone upload the source code for vb? i cant get the code thats show in this tread to work properly, i only need the code to control relays with the fusionusb.
    Go back to post #33 in this thread - I posted the source code there. I think the only change after that was how I was reading the analog inputs with either 8 or 10 bits of precision.

    If that doesn't work for you, post back here and let me know. I'm reluctant to post my current code because of all the code I'd have to pull out to get down to just the fusion brain stuff.

    Also, there is a word document around here somewhere that describes the data stream, and what bytes do what. One thing to be aware of, you need to constantly be sending commands to the FB. In the command, one bit has to be toggled back and fourth so the FB knows the PC is awake. I run my send command off a timer at 10Hz.

  5. #55
    Newbie
    Join Date
    Mar 2008
    Posts
    13
    this is the code, whats wrong? the program hangs when i click on the InitFB button. im a newbie in programing with .net
    i have 3 buttons and one timer.

    Code:
    Public Class Form1
        Dim VIDPID As String = "USB\VID_04D8&PID_000C\5&2688286F&0&3"
        Dim Uint0 As UInt32 = Convert.ToUInt32(0)   'Uint representing zero
        Private KeepAliveBit As Integer
        Private OutputArray(64) As Byte
        Private DigOut(12) As Integer
        Public Sub SendDataToFusionBrain()
            'This sub is called from a Timer_Tick event, which runs at 10Hz.
            For i = 0 To 11
                OutputArray(i) = Convert.ToByte(0 & KeepAliveBit & DigOut(i))
            Next
            USBIO.FUSB_Send(Uint0, OutputArray)
    
            'Toggle the keepalive bit for nexttime.
            If KeepAliveBit = 0 Then
                KeepAliveBit = 1
            Else
                KeepAliveBit = 0
            End If
        End Sub
        Private Sub InitFB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InitFB.Click
            'Lets check to see of the DLL file exists in this folder.
          
            'DLL exists, lets check the status to see if it is already connected
            If USBIO.FUSB_GetFUSBstatus(Uint0) = 0 Then
                'Status is 0, meaning it is already connected. Can't connect it again.
            Else
                'Status isn't 0, lets try to connect to the Fusion Brain
                If USBIO.FUSB_Initialize(Uint0, VIDPID, Uint0) Then
                    'Init was successful
                    For i = 0 To 63
                        OutputArray(i) = CByte(0)
                    Next
                    For i = 0 To 11
                        DigOut(i) = 0
                    Next
    
                    KeepAliveBit = 1
    
                    'Start the timer for sending data to the FB
                    ProcessFBDataOnTimerTick.Enabled = True
                Else
                    MsgBox("Failed to initialize that Fusion Brain. Make sure it is connected and that you are specifying the correct USB VID/PID number.")
                End If
    
            End If
    
        End Sub
    
        Private Sub Turn0on_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Turn0on.Click
            DigOut(0) = 1
        End Sub
    
        Private Sub Turn0off_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Turn0off.Click
            DigOut(0) = 0
        End Sub
    
        Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
            Call CloseHandlesOnExit()
        End Sub
        Public Sub CloseHandlesOnExit()
            'This gets called from the MyBase.FormClosed event as the app closes
            'Disable timer, Set all outputs to off, send data to the FB one last time, then disconnect from the FB
            ProcessFBDataOnTimerTick.Enabled = False
            For i = 0 To 11
                DigOut(i) = 0
            Next
            SendDataToFusionBrain()
            USBIO.FUSB_Free(Uint0)
        End Sub
    
        Private Sub ProcessFBDataOnTimerTick_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProcessFBDataOnTimerTick.Tick
            Call SendDataToFusionBrain()
        End Sub
    End Class
    Public Class USBIO
        <System.Runtime.InteropServices.DllImport("FusionUSB.dll")> _
        Public Shared Function FUSB_Initialize(ByRef pFusionUSB As UInt32, ByVal deviceID As String, ByVal instanceNumber As UInt32) As Boolean
        End Function
    
        <System.Runtime.InteropServices.DllImport("FusionUSB.dll")> _
        Public Shared Function FUSB_Receive(ByVal pFusionUSB As UInt32, ByVal buffer As Byte()) As Boolean
        End Function
    
        <System.Runtime.InteropServices.DllImport("FusionUSB.dll")> _
        Public Shared Function FUSB_Send(ByVal pFusionUSB As UInt32, ByVal buffer As Byte()) As Boolean
        End Function
    
        <System.Runtime.InteropServices.DllImport("FusionUSB.dll")> _
        Public Shared Function FUSB_Free(ByRef pFusionUSB As UInt32) As UInt32
        End Function
    
        <System.Runtime.InteropServices.DllImport("FusionUSB.dll")> _
        Public Shared Function FUSB_printf(ByVal pFusionUSB As UInt32) As Boolean
        End Function
    
        <System.Runtime.InteropServices.DllImport("FusionUSB.dll")> _
        Public Shared Function FUSB_GetWinUSBerror(ByVal pFusionUSB As UInt32) As UInt32
        End Function
    
        <System.Runtime.InteropServices.DllImport("FusionUSB.dll")> _
        Public Shared Function FUSB_GetFUSBstatus(ByVal pFusionUSB As UInt32) As UInt32
        End Function
    
        <System.Runtime.InteropServices.DllImport("FusionUSB.dll")> _
        Public Shared Function FUSB_GetDeviceInstanceID(ByVal pFusionUSB As UInt32) As String
        End Function
    End Class

  6. #56
    Constant Bitrate mx270a's Avatar
    Join Date
    Aug 2003
    Location
    Iowa
    Posts
    167
    What line is it failing on?
    Is your VID/PID correct?
    Do you have the FusionUSB.dll file in the same folder as the exe?

  7. #57
    Constant Bitrate mx270a's Avatar
    Join Date
    Aug 2003
    Location
    Iowa
    Posts
    167
    Here's my current code for the init part. Notice the try statement.

    Code:
            Try
                If FUSB_GetFUSBstatus(Uint0) = 0 Then
                    'Status is 0, meaning it is already connected. Can't connect it again.
                Else
                    'Status isn't 0, lets try to connect to the Fusion Brain
                    FUSB_Free(Uint0)
    
                    If FUSB_Initialize(Uint0, VIDPID, Uint0) Then
                        'Init was successful
                        For i = 0 To 63
                            OutputArray(i) = CByte(0)
                        Next
                        OutputArray(61) = CByte(255) 'This is needed to wake up the FB, for firmwares after November 2007
                        For i = 0 To 11
                            DigOut(i) = 0
                        Next
                        FUSB_Send(Uint0, OutputArray)
                        If (FUSB_Receive(Uint0, InputArray)) Then
                            lblFirmwareVersion.Text = InputArray(63).ToString & "." & InputArray(62).ToString
                        End If
    
                        KeepAliveBit = 1
    
                        'Set the flag so the timer knows to send data to the FB
                        FBisConnectedFlag = True
    
                    Else
                        MsgBox("Failed to initialize that Fusion Brain. Make sure it is connected and that you are specifying the correct USB VID/PID number." & vbCrLf & vbCrLf & "The VID/PID specified was: " & VIDPID)
                    End If
                End If
    
            Catch ex As Exception
                MsgBox("Error: DLL not found. Are you sure the fusion brain drivers are installed and the FusionUSB.dll file is in the same folder as the .exe?" & vbCrLf & vbCrLf & "The reported error is:" & vbCrLf & ex.ToString)
            End Try

  8. #58
    Newbie
    Join Date
    Mar 2008
    Posts
    13
    its not failing on any lines, the program just hangs, like its failing to comunicate with he fusion brain.
    yes my vid/pid is correct i get the initialize.

    i'm not using the FusionUSB.dll the way you are, if you see the lines at the bottom of my code. it's that the problem?

  9. #59
    Constant Bitrate mx270a's Avatar
    Join Date
    Aug 2003
    Location
    Iowa
    Posts
    167
    The DLL file has to be in the same directory as the exe. Those 8 "Public Shared Function..." lines are in the same class as the rest of my code. I only have 1 class in this file. They are at the very top of the class before I have any other Subs defined.

  10. #60
    Newbie
    Join Date
    Mar 2008
    Posts
    13
    ok. i was trying that now. and i get a little more respons, i got 40.0 in the text box lblFirmwareVersion, it havent happend before, but the program stil hangs.. do you know why? i'm running a amd 64 3000+, with vista.

Page 6 of 8 FirstFirst 12345678 LastLast

Similar Threads

  1. iGuidance SDK
    By Quattro in forum GPS
    Replies: 57
    Last Post: 06-23-2006, 08:37 AM
  2. SDK commands over the serial port ????
    By tolisn in forum Road Runner
    Replies: 4
    Last Post: 12-14-2005, 01:03 PM
  3. Developing Touchscreen SDK -- need feedback!
    By kevlar in forum Software & Software Development
    Replies: 3
    Last Post: 07-14-2005, 06:55 PM
  4. Replies: 9
    Last Post: 03-31-2005, 03:40 AM
  5. Destinator 3 SDK features working
    By loscooby in forum GPS
    Replies: 4
    Last Post: 09-21-2004, 01:46 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
  •