Products for USB Sensing and Control
It is currently Thu Jun 20, 2013 3:03 am

All times are UTC - 7 hours [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Phidget Bridge
PostPosted: Tue May 22, 2012 2:10 am 
Offline
Fresh meat

Joined: Tue May 22, 2012 2:00 am
Posts: 1
Does anybody have a working test program for a PhidgetBridge? I can't get it working, and I can't understand if it depends on hardware or software:

Code:
Option Explicit
Dim BridgesCount As Integer
Dim WithEvents PhidEvent As PhidgetBridge ' Attiva rilevamento eventi del phidget
Dim c, x As Integer

'Dim PhidObject As PhidgetBridge ' Dichiara oggetto-phidget


Private Sub PhidEvent_OnAttach()
Application.StatusBar = "Connesso!"
Cells(1, 6) = PhidEvent.IsAttached
Call InitPhidget
MsgBox ("Inizializzazione completata, premere OK per creare file di esempio")
Call WriteTestData
End Sub

Private Sub PhidEvent_OnDetach()
Application.StatusBar = "DISonnesso!"
Cells(1, 6) = PhidEvent.IsAttached
Close #1
End Sub

Private Sub PhidEvent_OnBridgeData(ByVal Index As Long, ByVal Value As Double)
Application.StatusBar "Rilevato dato: val=", Value
Print #1, Index, Value
End Sub


Private Sub PhidEvent_OnError(ByVal Description As String, ByVal SCODE As Phidget21COM.PhidgetCOM_Error)
MsgBox ("Errore phidget #" & SCODE & ": " & Description)
End Sub

Private Sub Workbook_Open()
Set PhidEvent = New PhidgetBridge ' Assegna oggetto-phidget
BridgesCount = 4 ' PhidEvent.InputCount
Cells.Clear

Cells(1, 5) = "Phidget connesso?"
Cells(1, 6) = PhidEvent.IsAttached

If PhidEvent.IsAttached = True Then
Call InitPhidget
Call WriteTestData
Else
MsgBox ("Collegare il phidget")
Exit Sub
End If
End Sub

Private Sub InitPhidget()
Cells(3, 1) = "Numero di bridge supportati: "
Cells(3, 2) = BridgesCount

For c = 1 To BridgesCount
Cells(4, c + 1) = "Min " & Str(Val(c))
Cells(5, c + 1) = PhidEvent.BridgeMin(c)
Cells(7, c + 1) = "PhidEvent " & Str(Val(c))
Cells(8, c + 1) = PhidEvent.BridgeMax(c)
Next

Cells(10, 2) = "Min rate: "
Cells(10, 3) = PhidEvent.DataRateMin
Cells(11, 2) = "Max rate: "
Cells(11, 3) = PhidEvent.DataRateMax

Cells(12, 2) = "Current Rate:"
Cells(12, 3) = PhidEvent.DataRate

Cells(13, 2) = "Current gains:"
For c = 1 To BridgesCount
Cells(14, c + 1) = PhidEvent.Gain(c)
Next

PhidEvent.Gain(1) = PHIDGETCOM_BRIDGE_GAIN_128 ' Imposta guadagno

PhidEvent.DataRate = 8 ' Imposta datarate

Open "C:\temp\logtest.txt" For Output As #1
End Sub

Sub WriteTestData()
For x = 1 To 10
For c = 1 To BridgesCount ' Stampa i valori di tutti i bridges supportati, per 1000 volte
Print #1, PhidEvent.BridgeValue(c),
Next
Print #1, ""
Next
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
'PhidEvent.Close ' Dealloca oggetto-phidget
Set PhidEvent = Nothing
Close #1
End Sub


Phidget is never detected.


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 7 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group