I am a newby to the 8055 and VB6. I have the 8055 up and running and have progressed quite a way along the VB6 program including putting time and other relevant info working in VB6. My project is to control Hydroponic watering of tomatoes in my greenhouse, controlling water feeds, PH corrector feeds and nuetriant feeds. An interest to keep me active.
I am 66 so the old grey matter is not a quick as it was, my problem, that I can’t seem to overcome is that>
How do I write the code in VB6 to detect the activation on a digital input (say i/p 1) to activate a digital output? When I have one working I can adapt to other inputs etc.
I have tried many variations but no luck, I have some very large books on VB6 , but all seem to assume that I am an expert already.
Any help please!!!
Here’s the link to download the K8055 software package with examples and with new K8055D.DLL: velleman.eu/downloads/files/ … rsion4.zip
Please see the example in the subfolder \examples\K8055DemoVB6
To detect the activation on a digital input 1 you can use the following code:
Dim in1 As Boolean
in1 = ReadDigitalChannel(1)
If in1 Then
SetDigitalChannel 1
Else
ClearDigitalChannel 1
End If
Put this code to the Timer1 subroutine to “echo” the digital input 1 status (button Inp1 press) to the digital output 1.
Before running the example project, please copy the file K8055D.DLL from the folder \DLL_v4.0.0.0 to the \Windows\System32 folder.
In 64-bit environment copy the file to \Windows\SysWOW64 folder.
Thanks for your help, tried it and it works fine, the only thing I noticed was that the Digital Output Box Check(0) did not have a tick placed in it. I also had to alter the timer interval before it would work.
Pushing my luck now.
I have the (Now) hh,mm, AM/PM time in a box (Label8) , and the date in another box. (Label12)
My need is that I can write a time in box and when this coincides with the (now) time box (Label8) an output is derived into a label.
Thanks fore your help, I hope this will put me on the right path>
Here a minor code snippet showing how you may compare the entered time with the system time.
You can enter the “target” time to a TextBox.
Convert the entered string to Date using CDate function.
Then just compare the two time values to do some actions with the K8055 card…
[code]Private Sub Command3_Click()
Dim d1 As Date
Dim d2 As Date
d1 = CDate(Text3.Text) ' Convert to Date
d2 = Time ' Get current system time.... or
' d2 = Now ' Get current system date and time.
Label6.Caption = d1
Label8.Caption = d2
If d1 = d2 Then ' Compare the time values
SetDigitalChannel 1
Else
ClearDigitalChannel 1
End If
End Sub[/code]
Hi Vel255,
I’m sorry to being a pain, I have tried the code and every combination but can’t get it to work. I have changed the two labels to 14 (d1) and 15 (d2) as label 6 was Analog Input V. I am inputting the time as “7, 40 AM” (Text3.Text) which is after the PC clock time. Nothing is happening on either label or output of board. I am assuming that label 15 should show PC Time. Label 14 should show the time typed into Text 3. Or am I completely wrong? Do I need to alter any properties?
Actual date is not required only time of day.
Thanks for your help.
[quote]I am inputting the time as “7, 40 AM” (Text3.Text) which is after the PC clock time. Nothing is happening on either label or output of board.[/quote] Indeed, only pressing the button Command3_Click() updates the labels and card settings in this example code.
[quote]I am assuming that label 15 should show PC Time. Label 14 should show the time typed into Text 3.[/quote] You are right. Do you get this happen when you click the button where this code example is assigned?
To get everything work automatically, the code snippet should be put to the timer subroutine.
Now the time program works automatically.
I added one text box and a 500ms timer and assigned the following code to this timer:
Private Sub Timer3_Timer()
Dim d0 As Date
Dim d1 As Date
Dim d2 As Date
If IsDate(Text3.Text) And IsDate(Text4.Text) Then ' Check if the expressions are valid date
d0 = CDate(Text3.Text) ' Convert to Date
d1 = CDate(Text4.Text) ' Convert to Date
d2 = Time ' Get current system time
Label14.Caption = d0
Label15.Caption = d1
Label16.Caption = d2
If d0 = d2 Then ' Compare the time values
SetDigitalChannel 1
ElseIf d1 = d2 Then
ClearDigitalChannel 1
End If
Else
Label14.Caption = "Wrong time data"
End If
End Sub
When the time you entered to the Text3 box is equal to the system time the digital output 1 of the K8055 is set on.
When the system time is equal to the time entered to Text4, the digital output is set off.
Here an example screenshot:
The digital output is now ON
Hi Vel255,
I does just what I wanted, thank you so very much.