USB Relaiskarte

Dies ist das deutsche Forum für alle Themen um den IO-Warrior. Beiträge bitte nur in Deutsch.

Moderator: Guido Körber

Post Reply
hank00
Posts: 6
Joined: Tue Jan 15, 2013 3:24 pm

USB Relaiskarte

Post by hank00 »

Hallo zusammen,
ich habe eine 10 Kanal USB Relaiskarte RK10-05USBV1.

die Relais 1 bis 8 kann ich ansteuern.
z. B. so :
z=RND
Call WriteLEDs(Int(256*z) AND &HFF)

aber ... mit welchem Befehlscode steuer ich die Relais 9 und 10 an ?
Kann mir da jemand helfen ?
MfG Hank
User avatar
Christoph Jung
Posts: 670
Joined: Sun Oct 08, 2006 3:43 pm
Location: Germany / Berlin
Contact:

Re: USB Relaiskarte

Post by Christoph Jung »

Ein paar mehr Infos wäre hilfreich.
Von welchem Hersteller ist diese oder ist diese selbst entwickelt?
Welche Programmiersprache?
Abteilung: Softwareentwicklung
Folge uns auf Twitter
Follow us on twitter
hank00
Posts: 6
Joined: Tue Jan 15, 2013 3:24 pm

Re: USB Relaiskarte

Post by hank00 »

Hi, hier sind noch ein Paar Infos.
Die Karte ist von GWR.
Der Code ist in Visual Basic.
Der Aufruf von "WriteLEDs(Value As Byte)" verlangt nur ein Byte.
Guido Körber
Site Admin
Posts: 2856
Joined: Tue Nov 25, 2003 10:25 pm
Location: Germany/Berlin
Contact:

Re: USB Relaiskarte

Post by Guido Körber »

"WriteLEDs" ist keine Funktion von uns. Ist auf der Karte ein IO-Warrior verbaut?
User avatar
Christoph Jung
Posts: 670
Joined: Sun Oct 08, 2006 3:43 pm
Location: Germany / Berlin
Contact:

Re: USB Relaiskarte

Post by Christoph Jung »

Wäre es möglich den Quellcode der WriteLED-Funktion mal zu posten?
Abteilung: Softwareentwicklung
Folge uns auf Twitter
Follow us on twitter
hank00
Posts: 6
Joined: Tue Jan 15, 2013 3:24 pm

Re: USB Relaiskarte

Post by hank00 »

Hi, hier der Quellcode.
Falls es eine andere Routine (in VB) gibt mit der ich die
zehn Relais schalten kann ... nehme ich gerne.
Schon mal vielen Dank.
MfG Hank

Dim iowHandles(IOWKIT_MAX_DEVICES) As Long' IO-Warrior handles
Dim numIows As Long' Number of IOWs
Dim data(8) As Byte' Basic data buffer is 8 bytes long: 1 byte for report id, max 7 bytes for data
'------------------------------
Private Sub WriteLEDs(Value As Byte)
Dim nWritten As Long ' Number of bytes written
Dim i As Long ' Loop variable
Dim Pid As Long ' ProductID of IOWarrior

' Set up Report ID
data(0) = 0
For i = 0 To numIows - 1
' Set up bytes
data(1) = &HFF
data(2) = &HFF
data(3) = &HFF
data(4) = &HFF
data(5) = &HFF
data(6) = &HFF
data(7) = &HFF

Pid = IowKitGetProductId(iowHandles(i))
If Pid = IOWKIT_PID_IOW24 Then
data(1) = Value ' First byte is controlling standard LED
nWritten = IowKitWrite(iowHandles(i), IOW_PIPE_IO_PINS, data(0), 3) ' Write to IOW 24
Else
If Pid = IOWKIT_PID_IOW40 Then
data(4) = Value ' Fourth byte is controlling standard LEDs
nWritten = IowKitWrite(iowHandles(i), IOW_PIPE_IO_PINS, data(0), 5) ' Write to IOW 40
Else
If Pid = IOWKIT_PID_IOW56 Then
data(7) = Value ' Seventh byte is controlling standard LEDs
nWritten = IowKitWrite(iowHandles(i), IOW_PIPE_IO_PINS, data(0), 8) ' Write to IOW 56
End If
End If
End If
Next i
End Sub

Private Sub ClearAllButton_Click()
' Clear all LEDs (negative logic)
Call WriteLEDs(&HFF)
End Sub
'------------------------------
Private Sub RandomButton_Click()
Dim z
Randomize
z = Rnd
Call WriteLEDs(Int(256 * z) And &HFF) ' Write random bits to LEDs
End Sub
User avatar
Christoph Jung
Posts: 670
Joined: Sun Oct 08, 2006 3:43 pm
Location: Germany / Berlin
Contact:

Re: USB Relaiskarte

Post by Christoph Jung »

Die Funktion sieht aus wie eine aus unserem SDK.
Und So wie die Relaiskarte aussieht ist dort ein IO-Warrior24 verbaut.

Code: Select all

Dim iowHandles(IOWKIT_MAX_DEVICES) As Long' IO-Warrior handles
Dim numIows As Long' Number of IOWs
Dim data(8) As Byte' Basic data buffer is 8 bytes long: 1 byte for report id, max 7 bytes for data
'------------------------------



Private Sub WriteLEDs(Value As Byte, Value1 As Byte)
Dim nWritten As Long ' Number of bytes written
Dim i As Long ' Loop variable
Dim Pid As Long ' ProductID of IOWarrior

' Set up Report ID
data(0) = 0
For i = 0 To numIows - 1
' Set up bytes
data(1) = &HFF
data(2) = &HFF
data(3) = &HFF
data(4) = &HFF
data(5) = &HFF
data(6) = &HFF
data(7) = &HFF

Pid = IowKitGetProductId(iowHandles(i))
If Pid = IOWKIT_PID_IOW24 Then
data(1) = Value ' First byte is controlling standard LED
data(2) = Value1 '!!!!! ADD
nWritten = IowKitWrite(iowHandles(i), IOW_PIPE_IO_PINS, data(0), 3) ' Write to IOW 24
Else
If Pid = IOWKIT_PID_IOW40 Then
data(4) = Value ' Fourth byte is controlling standard LEDs
nWritten = IowKitWrite(iowHandles(i), IOW_PIPE_IO_PINS, data(0), 5) ' Write to IOW 40
Else
If Pid = IOWKIT_PID_IOW56 Then
data(7) = Value ' Seventh byte is controlling standard LEDs
nWritten = IowKitWrite(iowHandles(i), IOW_PIPE_IO_PINS, data(0), 8) ' Write to IOW 56
End If
End If
End If
Next i
End Sub

Private Sub ClearAllButton_Click()
' Clear all LEDs (negative logic)
Call WriteLEDs(&HFF, &HFF)
End Sub
'------------------------------
Private Sub RandomButton_Click()
Dim z
Randomize
z = Rnd
Call WriteLEDs(Int(256 * z) And &HFF, Int(256 * z) And &HFF) ' Write random bits to LEDs
End Sub


Diesen Beitrag melden
Ich habe nur den Teil für den IO-Warrior24 angepasst, da ich nicht weiß welche Ports genau genutzt werden ists auch nur ein Schuss ins blaue (und ungetestet).

Zur Erklärung, ich sende ein weiteres Byte in der Funktion und setz das für den zweiten Port in die Schreibroutine. Alle Aufrufe der WriteLEDs() müssen jetzt geändert werden und ein zweites Byte eingetragen werden. Das sollte dann die anderen Prots setzen.

Aber ich weiß nicht welche Pins vom zweiten Port verwendet werden. Also am besten mal schaun und evtl. noch die überflüssigen Bits ausmaskieren.
Abteilung: Softwareentwicklung
Folge uns auf Twitter
Follow us on twitter
hank00
Posts: 6
Joined: Tue Jan 15, 2013 3:24 pm

Re: USB Relaiskarte

Post by hank00 »

Vielen Dank für die schnelle Hilfe.
Hat alles wunderbar funktionert.
MfG Hank
Post Reply