need a help with my code for mesuring a ph and voltage

Supporting Visual Studio on Windows
elou1987
Fresh meat
Posts: 2
Joined: Wed Mar 14, 2012 3:07 am
Contact:

need a help with my code for mesuring a ph and voltage

Postby elou1987 » Sun Mar 18, 2012 7:09 am

Hi
i am french so my english is not the best ...
I have an 8/8/8 interface kit in which I want to measure the pH and the voltage sensor precison (1135).
But I only get the pH measurement and not the voltage measurements.
I wanted you said me what's wrong in my code.
Best regards
here is my code:

Code: Select all

Public Class Form1
' Declaration des evenements dont je veux mesurer leur variation
Dim WithEvents phidgetIFK As Phidgets.InterfaceKit
Dim WithEvents phidgetSens As Phidgets.InterfaceKitAnalogSensor
'declaration des variables globale dont on va utiliser
Private _ph_value As Double
Private sensorcount As Double
Private _volt_value As Double
Public Sub New()
' Cet appel est requis par le concepteur.
InitializeComponent()
' Ajoutez une initialisation quelconque après l'appel InitializeComponent().
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' instanciation de notre phidgetIFK et ouverture DU programme pour pouvoir utiliser les capteurs
phidgetIFK = New Phidgets.InterfaceKit
phidgetIFK.open()
' sachant ue sensor c'est le pH et sensor2 c'est le vomtmetre
Me.TXT_StatusIFK.Enabled = True
Me.TXT_StatusIFK.Text = "Brancher l'interface Kit"
Me.TXT_StatusSensor.Enabled = False
Me.TXT_StatusSensor2.Enabled = False
Me.TXT_SerialNumber.Enabled = False
Me.TXT_SerialNumber2.Enabled = False
Me.TXT_SensorCount2.Enabled = False
Me.TXT_Sensorcount1.Enabled = False
Me.TXT_ValeurSensor.Enabled = False
Me.TXT_ValeurSensor2.Enabled = False
End Sub
Private Sub phidgetIFK_Attach(ByVal sender As Object, ByVal e As Phidgets.Events.AttachEventArgs) Handles
phidgetIFK.Attach
If sender.attached.ToString Then
Me.TXT_StatusSensor.Enabled = True
Me.TXT_StatusSensor2.Enabled = True
Me.TXT_SerialNumber.Enabled = True
Me.TXT_SerialNumber2.Enabled = True
Me.TXT_SensorCount2.Enabled = True
Me.TXT_Sensorcount1.Enabled = True
Me.TXT_ValeurSensor.Enabled = True
Me.TXT_ValeurSensor2.Enabled = True
TXT_StatusIFK.Text = "Interface connecté"
_ph_value = phidgetIFK.sensors(6).Value
_volt_value = phidgetIFK.sensors(1).Value
Me.TXT_ValeurSensor.Text = _ph_value.ToString
Me.TXT_StatusSensor2.Text = _volt_value.ToString
Me.TXT_SerialNumber.Text = phidgetIFK.SerialNumber
Me.TXT_SerialNumber2.Text = phidgetIFK.SerialNumber
End If
End Sub
Private Sub phidgetIFK_Detach(ByVal sender As Object, ByVal e As Phidgets.Events.DetachEventArgs) Handles
phidgetIFK.Detach
If Not CBool(sender.attached.ToString) Then
Me.TXT_StatusIFK.Text = " Interface deconnectée"
End If
End Sub
Private Sub phidgetIFK_Error(ByVal sender As Object, ByVal e As Phidgets.Events.ErrorEventArgs) Handles
phidgetIFK.Error
MsgBox(e.Description)
End Sub
Private Sub phidgetIFK_SensorChange(ByVal sender As Object, ByVal e As Phidgets.Events.
SensorChangeEventArgs) Handles phidgetIFK.SensorChange
_ph_value = (0.0178 * phidgetIFK.sensors(6).Value ‐ 1.889)
Me.TXT_ValeurSensor.Text = _ph_value.ToString
_volt_value = (phidgetIFK.sensors(2).Value / 13.62) ‐ 36.7107
' I dont have the voltage value
Me.TXT_ValeurSensor2.Text = _volt_value.ToString
phidgetIFK.sensors(6).Sensitivity = 1.35
phidgetIFK.sensors(1).Sensitivity = 1.35
sensorcount += 1
Me.TXT_SensorCount2.Enabled = True
Me.TXT_Sensorcount1.Enabled = True
Me.TXT_Sensorcount1.Text = sensorcount.ToString
Me.TXT_SensorCount2.Text = sensorcount.ToString
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.
FormClosingEventArgs) Handles Me.FormClosing
RemoveHandler phidgetIFK.Attach, AddressOf phidgetIFK_Attach
RemoveHandler phidgetIFK.Detach, AddressOf phidgetIFK_Detach
RemoveHandler phidgetIFK.Error, AddressOf phidgetIFK_Error
Application.DoEvents()
phidgetIFK.close()
End Sub
Private Sub BT_Quitter_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BT_Quitter.
Click
If MsgBox("Voulez vous vraiment quitter ?", MsgBoxStyle.YesNo, "QUITTER") = MsgBoxResult.Yes Then
Me.Close()
End If
End Sub
Private Sub BT_ResetpH_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BT_ResetpH.
Click
If MsgBox("Voulez vous faire une reset des mesure de pH", MsgBoxStyle.YesNo, "Reset") = MsgBoxResult.
Yes Then
Me.TXT_ValeurSensor.Enabled = True
Me.TXT_ValeurSensor.Text = ""
End If
End Sub
Private Sub BT_ResetVolt_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BT_ResetVolt.
Click
If MsgBox("Voulez vous faire une reset des mesure de Tension", MsgBoxStyle.YesNo, "Reset") =
MsgBoxResult.Yes Then
Me.TXT_ValeurSensor2.Enabled = True
Me.TXT_ValeurSensor2.Text = ""
End If
End Sub
End Class

elou1987
Fresh meat
Posts: 2
Joined: Wed Mar 14, 2012 3:07 am
Contact:

Re: need a help with my code for mesuring a ph and voltage

Postby elou1987 » Thu Mar 22, 2012 2:16 am

My problem is solved. finally i found what was wrong in my code.


Return to “VB .NET”

Who is online

Users browsing this forum: No registered users and 1 guest