Announcement

Collapse
No announcement yet.

Pb9

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

  • Pb9

    Does anyone know if PB9 can address devices via USB

  • #2
    I've seen some recent discussions in the forum on USB interfacing. Have you searched for them?
    Rick Angell

    Comment


    • #3
      If the USB device includes a software driver or other communication method (such as COM port access), then YES it can be used with PB/WIN.
      kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

      Comment


      • #4
        @Brian
        What sort of devices?

        I am not sure, but I think Kev and Richard may be eluding to some of the following??? (<INSERT My Shameless Plug here>)

        Available Serial Ports
        USB Device Attach
        and of course My most favorites
        List USB Info (VID PID)
        USB In-Complete
        All the above I know Kev and Pierre had some hand at assisting me with so they get credit too.
        And many more that Kev and Pierre have done in the past as well
        Engineer's Motto: If it aint broke take it apart and fix it

        "If at 1st you don't succeed... call it version 1.0"

        "Half of Programming is coding"....."The other 90% is DEBUGGING"

        "Document my code????" .... "WHYYY??? do you think they call it CODE? "

        Comment


        • #5
          Pb9

          Hi Cliff
          I have a VM110 USB interface board from Maplin which gives examples in VB but I would prefer to use PBx.
          Regards
          Brian.

          Comment


          • #6
            Does it use a DLL or ocx to interface to the usb device via VB ?

            A vb code snippet on how you call the usb device would help.
            A dozen what.

            Comment


            • #7
              VB examples.....Heck if VB can do it, PB can do it (only BETTER )

              If you can post the VB Example, I am sure its just a matter of porting (and correcting VB mistakes) to Pure PB code.

              You will probably have to zip it up including the DLL they supply (according to the quick drive by peruse I did to see what the board does)
              Engineer's Motto: If it aint broke take it apart and fix it

              "If at 1st you don't succeed... call it version 1.0"

              "Half of Programming is coding"....."The other 90% is DEBUGGING"

              "Document my code????" .... "WHYYY??? do you think they call it CODE? "

              Comment


              • #8
                Copy of listing from the documentation, hope ypu can help?

                Using the K8055D.DLL in Visual Basic
                In the listing of an application example there are the declarations of the K8055D.DLL procedures and
                functions and an example how to use the two most important DLL function calls: OpenDevice and
                CloseDevice.
                Note: Make sure that the file K8055D.DLL is copied to the Windows' SYSTEM32 folder:
                Option Explicit
                Private Declare Function OpenDevice Lib "k8055d.dll" (ByVal CardAddress As Long) As Long
                Private Declare Sub CloseDevice Lib "k8055d.dll" ()
                Private Declare Function ReadAnalogChannel Lib "k8055d.dll" (ByVal Channel As Long) As Long
                Private Declare Sub ReadAllAnalog Lib "k8055d.dll" (Data1 As Long, Data2 As Long)
                Private Declare Sub OutputAnalogChannel Lib "k8055d.dll" (ByVal Channel As Long, ByVal Data As
                Long)
                Private Declare Sub OutputAllAnalog Lib "k8055d.dll" (ByVal Data1 As Long, ByVal Data2 As
                Long)
                Private Declare Sub ClearAnalogChannel Lib "k8055d.dll" (ByVal Channel As Long)
                Private Declare Sub SetAllAnalog Lib "k8055d.dll" ()
                Private Declare Sub ClearAllAnalog Lib "k8055d.dll" ()
                Private Declare Sub SetAnalogChannel Lib "k8055d.dll" (ByVal Channel As Long)
                Private Declare Sub WriteAllDigital Lib "k8055d.dll" (ByVal Data As Long)
                Private Declare Sub ClearDigitalChannel Lib "k8055d.dll" (ByVal Channel As Long)
                Private Declare Sub ClearAllDigital Lib "k8055d.dll" ()
                Private Declare Sub SetDigitalChannel Lib "k8055d.dll" (ByVal Channel As Long)
                Private Declare Sub SetAllDigital Lib "k8055d.dll" ()
                Private Declare Function ReadDigitalChannel Lib "k8055d.dll" (ByVal Channel As Long) As
                Boolean
                Private Declare Function ReadAllDigital Lib "k8055d.dll" () As Long
                Private Declare Function ReadCounter Lib "k8055d.dll" (ByVal CounterNr As Long) As Long
                Private Declare Sub ResetCounter Lib "k8055d.dll" (ByVal CounterNr As Long)
                Private Declare Sub SetCounterDebounceTime Lib "k8055d.dll" (ByVal CounterNr As Long, ByVal
                DebounceTime As Long)
                Private Sub Connect_Click()
                Dim CardAddress As Long
                Dim h As Long
                CardAddress = 0
                CardAddress = 3 - (Check1(0).Value + Check1(1).Value * 2)
                h = OpenDevice(CardAddress)
                Select Case h
                Case 0, 1, 2, 3
                Label1.Caption = "Card " + Str(h) + " connected"
                Case -1
                Label1.Caption = "Card " + Str(CardAddress) + " not found"
                End Select
                End Sub
                Private Sub Form_Terminate()
                CloseDevice
                End Sub

                Comment


                • #9
                  when you post code it helps everyone (some more than others, OK it helps me) if you use the # symbol in the editor to mark it as code. Thanks!

                  Comment


                  • #10
                    Assuming the code is VB6 (which it seems to be), here is an almost direct translation:

                    Code:
                    #Dim All
                    #Compile Exe
                     
                    Declare Function OpenDevice Lib "k8055d.dll" Alias "OpenDevice" (ByVal CardAddress As Long) As Long
                    Declare Sub CloseDevice Lib "k8055d.dll" Alias "CloseDevice" ()
                    Declare Function ReadAnalogChannel Lib "k8055d.dll" Alias "ReadAnalogChannel" (ByVal Channel As Long) As Long
                    Declare Sub ReadAllAnalog Lib "k8055d.dll" Alias "ReadAllAnalog" (Data1 As Long, Data2 As Long)
                    Declare Sub OutputAnalogChannel Lib "k8055d.dll" Alias "OutputAnalogChannel" (ByVal Channel As Long, ByVal Data As Long)
                    Declare Sub OutputAllAnalog Lib "k8055d.dll" Alias "OutputAllAnalog" (ByVal Data1 As Long, ByVal Data2 As Long)
                    Declare Sub ClearAnalogChannel Lib "k8055d.dll" Alias "ClearAnalogChannel" (ByVal Channel As Long)
                    Declare Sub SetAllAnalog Lib "k8055d.dll" Alias "SetAllAnalog" ()
                    Declare Sub ClearAllAnalog Lib "k8055d.dll" Alias "ClearAllAnalog" ()
                    Declare Sub SetAnalogChannel Lib "k8055d.dll" Alias "SetAnalogChannel" (ByVal Channel As Long)
                    Declare Sub WriteAllDigital Lib "k8055d.dll" Alias "WriteAllDigital" (ByVal Data As Long)
                    Declare Sub ClearDigitalChannel Lib "k8055d.dll" Alias "ClearDigitalChannel" (ByVal Channel As Long)
                    Declare Sub ClearAllDigital Lib "k8055d.dll" Alias "ClearAllDigital" ()
                    Declare Sub SetDigitalChannel Lib "k8055d.dll" Alias "SetDigitalChannel" (ByVal Channel As Long)
                    Declare Sub SetAllDigital Lib "k8055d.dll" Alias "SetAllDigital" ()
                    Declare Function ReadDigitalChannel Lib "k8055d.dll" Alias "ReadDigitalChannel" (ByVal Channel As Long) As Long
                    Declare Function ReadAllDigital Lib "k8055d.dll" Alias "ReadAllDigital" () As Long
                    Declare Function ReadCounter Lib "k8055d.dll" Alias "ReadCounter" (ByVal CounterNr As Long) As Long
                    Declare Sub ResetCounter Lib "k8055d.dll" Alias "ResetCounter" (ByVal CounterNr As Long)
                    Declare Sub SetCounterDebounceTime Lib "k8055d.dll" Alias "SetCounterDebounceTime" (ByVal CounterNr As Long, ByVal DebounceTime As Long)
                     
                     
                    Function PBMain
                     
                      Dim CardAddress As Long
                      Dim h As Long
                      Dim Value1 As Long
                      Dim Value2 As Long
                     
                      ' Enter values for Value1 and Value2
                      'Value1 = ???
                      'Value2 = ???
                     
                      CardAddress = 0
                      CardAddress = 3 - (Value1 + Value2 * 2)
                     
                      h = OpenDevice(CardAddress)
                      Select Case h
                             Case 0, 1, 2, 3
                                  ? "Card " + Str$(h) + " connected"
                             Case -1
                                  ? "Card " + Str$(CardAddress) + " not found"
                      End Select
                     
                      CloseDevice
                     
                    End Function
                    Note: You'd have to edit the values for "Value1" and "Value2" as they were checkbox values on the VB form.
                    kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

                    Comment


                    • #11
                      ah -ha

                      That is a Vellman Kit... I recognize the DLL. I made a interface program for a buddy with PB. PB works fine with that.
                      A dozen what.

                      Comment


                      • #12
                        Originally posted by Michael Mayerhoffer View Post
                        ah -ha

                        That is a Vellman Kit... I recognize the DLL. I made a interface program for a buddy with PB. PB works fine with that.
                        Rudy Elyn wrote that DLL for Velleman using PowerBasic.
                        See:
                        http://www.powerbasic.com/support/pb...light=Velleman
                        The most exasperating part of the "rat race" is how often the rats are in the lead!

                        Comment


                        • #13
                          I wrote an application and used that DLL.

                          I just know that PB has no issues working with that DLL. Now I can say it was all done in PB.

                          I know it has been working flawlessly, the app sends data every hour and reboots the computer every 20 days as a precaution. If there was an issue. I would know, my buddy is rather anal about what he is logging.
                          A dozen what.

                          Comment


                          • #14
                            Thanks to you all, I will now get on with it, let you know how I get on.
                            BrianKeep flying

                            Comment

                            Working...
                            X