How can I save analogue input values as *.TXT (not for bar-graph indication)? I bought K8055 board and I want to get analogue input values in Visual Basic 2008 program.
Thank you,
Mark
How can I save analogue input values as *.TXT (not for bar-graph indication)? I bought K8055 board and I want to get analogue input values in Visual Basic 2008 program.
Thank you,
Mark
You can save the values for example in the following way:
In the examples folder go to K8055NDemoVB_2008 and open the K8055Demo project.
Add these two lines to the declarations section: Dim file As System.IO.StreamWriter
Dim counter As Integer
In the Button1_Click procedure change:If h >= 0 Then Timer1.Enabled = True
to If h >= 0 Then
Timer1.Enabled = True
file = My.Computer.FileSystem.OpenTextFileWriter("test.txt", True)
End If
Change the Sub Timer1_Tick to look like this: Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim i As Integer
Dim Data1 As Integer
Dim Data2 As Integer
Timer1.Enabled = False
i = ReadAllDigital
CheckBox4.Checked = i And 1
CheckBox5.Checked = (i >> 1) And 1
CheckBox6.Checked = (i >> 2) And 1
CheckBox7.Checked = (i >> 3) And 1
CheckBox8.Checked = (i >> 4) And 1
ReadAllAnalog(Data1, Data2)
VScrollBar3.Value = 255 - Data1
VScrollBar4.Value = 255 - Data2
Label6.Text = CStr(Data1)
Label7.Text = CStr(Data2)
counter = counter + 1
If counter < 10 Then
file.WriteLine(Label6.Text + " " + Label7.Text)
End If
If counter = 10 Then
file.Close()
End If
TextBox1.Text = CStr(ReadCounter(1))
TextBox2.Text = CStr(ReadCounter(2))
Timer1.Enabled = True
End Sub
The added code section is: counter = counter + 1
If counter < 10 Then
file.WriteLine(Label6.Text + " " + Label7.Text)
End If
If counter = 10 Then
file.Close()
End If
Now the first 10 analogue input values are saved to file test.txt.
The file is located in the folder \K8055Demo\bin\x86\Debug
How much time is it between two acquisition analogue input values, roughly? How to calculate the time gap between 2 saved analogue input value?
Thank you,
Mark
In the K8055Demo program the timer (Timer1) interval is 50ms.
So the time cap between the samples in this case is 50ms.
Thank you, sir. Your reply is very helpful. By the way, can we change the time gap (1ms, for example) between the sampling input analogue signals?
Thank you,
Mark
[quote]By the way, can we change the time gap (1ms, for example) between the sampling input analogue signals?[/quote]Yes you can by changing the timer interval.
The lowest possible value is 2ms for the K8055N and 20ms for the K8055 due to USB communication limitations.
velleman.eu/products/view/?id=404880
“general conversion time: 2ms per command”
velleman.eu/products/view/?id=351346
“general conversion time: 20ms per command”
Okay. I will buy another board — K8055N. I use Visual Basic 2008 software to develop application program. If I get K8055N, is it easy to change sampling time as 2ms?
Thank you,
Mark