Software examples

Software examples (74)

Children categories

Monday, 25 March 2013 12:48

VB example for WEB 2 relay board

Written by

 

 

 

 

 

 

KMTronic_WEB_2_RELAYS_Control_VB_Code.zip

 

 

---------------------------------

 

 

Imports System.ComponentModel
Imports System.Text
Imports System.Threading
Imports Microsoft.Win32
Imports System.Web
Imports System.Net
Imports System.IO

Namespace WebRelays
    Partial Public Class Form1
        Inherits Form

        Private HTTP_Req As String = Nothing
        Private myWebRequest As WebRequest
        Private myWebResponse As WebResponse
        Private myWebRequest1 As WebRequest
      '  WebResponse myWebResponse1;
        Private myWebRequest2 As WebRequest
       ' WebResponse myWebResponse2;
        Private webCredential As Boolean = True
        Private uStatus As Thread
        Private content As String = Nothing
        Private run As Boolean = False


        Public Sub New()
            InitializeComponent()
            txtbxIP.Text = "88.87.29.148"
            txtbxUN.Text = "admin"
            txtbxPW.Text = "admin"
            txtbxHP.Text = "1234"
            button1.Enabled = False
            button2.Enabled = False
            lblR1.Text = Nothing
            lblR2.Text = Nothing
            txtbxPW.PasswordChar = "*"c

        End Sub

        Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button1.Click
            Try
                HTTP_Req = "http://" & txtbxIP.Text & ":" & txtbxHP.Text & "/relays.cgi?relay=1"
                myWebRequest1 = WebRequest.Create(HTTP_Req)
                myWebRequest1.Credentials = New NetworkCredential(txtbxUN.Text, txtbxPW.Text)
                myWebRequest1.Method = "POST"
                myWebRequest1.ContentType = ""
                myWebRequest1.ContentLength = 0
                Dim dataStream As Stream = myWebRequest1.GetResponse().GetResponseStream()
                dataStream.Close()
            Catch
            End Try
        End Sub

        Private Sub button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button2.Click
            Try
                HTTP_Req = "http://" & txtbxIP.Text & ":" & txtbxHP.Text & "/relays.cgi?relay=2"
                myWebRequest2 = WebRequest.Create(HTTP_Req)
                myWebRequest2.Credentials = New NetworkCredential(txtbxUN.Text, txtbxPW.Text)
                myWebRequest2.Method = "POST"
                myWebRequest2.ContentType = ""
                myWebRequest2.ContentLength = 0
                Dim dataStream As Stream = myWebRequest2.GetResponse().GetResponseStream()
                dataStream.Close()
            Catch
            End Try
        End Sub


        Private Sub updateStatus()
            Do While run = True
                Try
                    HTTP_Req = "http://" & txtbxIP.Text & ":" & txtbxHP.Text & "/relays.cgi"
                    myWebRequest = WebRequest.Create(HTTP_Req)
                    myWebRequest.Credentials = New System.Net.NetworkCredential(txtbxUN.Text, txtbxPW.Text)
                    myWebRequest.Method = "POST"
                    myWebRequest.ContentType = ""
                    myWebRequest.ContentLength = 0
                    Dim dataStream As Stream = myWebRequest.GetResponse().GetResponseStream()
                    dataStream.ReadTimeout = 1000
                   ' StreamReader objReader = new StreamReader(dataStream, Encoding.UTF8);
                   ' myWebResponse = myWebRequest.GetResponse();
                    'Stream receiveStream = myWebResponse.GetResponseStream();
                    Dim reader As New StreamReader(dataStream, Encoding.UTF8)
                    content = reader.ReadToEnd()
                    dataStream.Close()
                    Me.Invoke(New EventHandler(AddressOf tBox))
                    Thread.Sleep(5)
                Catch
                End Try
            Loop
        End Sub


        Private Sub tBox(ByVal sender As Object, ByVal e As EventArgs)

            Dim status(10) As Char
            Dim relay1(37) As Char
            Dim relay2(37) As Char
            Dim relay1name As String = Nothing
            Dim relay2name As String = Nothing

            For i As Integer = 0 To content.Length - 11 - 1
                For j As Integer = 0 To 10
                    status(j) = content.Chars(i + j)
                Next j

                If status(0) = "S"c AndAlso status(1) = "t"c AndAlso status(2) = "a"c AndAlso status(3) = "t"c AndAlso status(4) = "u"c AndAlso status(5) = "s"c Then
                    If status(8) = "0"c Then
                        button1.BackColor = Color.Green
                        button1.Text = "Click to TURN ON"

                    Else
                        button1.BackColor = Color.Red
                        button1.Text = "Click to TURN OFF"
                    End If

                    If status(10) = "0"c Then
                        button2.BackColor = Color.Green
                        button2.Text = "Click to TURN ON"

                    Else
                        button2.BackColor = Color.Red
                        button2.Text = "Click to TURN OFF"
                    End If
                End If
            Next i


            For i As Integer = 0 To content.Length - 38 - 1
                For j As Integer = 0 To 37
                    relay1(j) = content.Chars(i + j)
                Next j

                If relay1(0) = "R"c AndAlso relay1(1) = "e"c AndAlso relay1(2) = "l"c AndAlso relay1(3) = "a"c AndAlso relay1(4) = "y"c AndAlso relay1(5) = "1"c AndAlso relay1(6) = ":"c AndAlso relay1(7) = " "c Then
                    For z As Integer = 0 To 29
                        relay1name &= relay1(z + 8)
                    Next z
                    lblR1.Text = relay1name
                End If
            Next i


            For i As Integer = 0 To content.Length - 38 - 1
                For j As Integer = 0 To 37
                    relay2(j) = content.Chars(i + j)
                Next j

                If relay2(0) = "R"c AndAlso relay2(1) = "e"c AndAlso relay2(2) = "l"c AndAlso relay2(3) = "a"c AndAlso relay2(4) = "y"c AndAlso relay2(5) = "2"c AndAlso relay2(6) = ":"c AndAlso relay2(7) = " "c Then
                    For z As Integer = 0 To 29
                        relay2name &= relay2(z + 8)
                    Next z
                    lblR2.Text = relay2name
                End If
            Next i




        End Sub

        Private Sub button3_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button3.Click
            If button3.Text = "Start" Then
                button3.Text = "Stop"
                run = True
                uStatus = New Thread(New ThreadStart(AddressOf updateStatus))
                Try
                    uStatus.IsBackground = True
                    uStatus.Start()

                Catch
                End Try
                button1.Enabled = True
                button2.Enabled = True
                txtbxIP.Enabled = False
                txtbxUN.Enabled = False
                txtbxPW.Enabled = False
                txtbxHP.Enabled = False

            ElseIf button3.Text = "Stop" Then
                button3.Text = "Start"
                run = False
                If uStatus.IsAlive = True Then
                    Try
                        uStatus.Abort()
                    Catch
                    End Try
                End If
                button1.Enabled = False
                button2.Enabled = False
                txtbxIP.Enabled = True
                txtbxUN.Enabled = True
                txtbxPW.Enabled = True
                txtbxHP.Enabled = True
            End If
        End Sub

    End Class
End Namespace

 

 

 

 

 

 

Monday, 25 March 2013 12:20

C# example for WEB 2 relay board

Written by

 

 

 

 

 

 

KMTronic_WEB_2_RELAYS_Control_C#_Code.zip

 

 

 

 

-----------------------------------------------------------------------------------------

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using Microsoft.Win32;
using System.Web;
using System.Net;
using System.IO;

namespace WebRelays
{
    public partial class Form1 : Form
    {

        private string HTTP_Req = null;
        WebRequest myWebRequest;
        WebResponse myWebResponse;
        WebRequest myWebRequest1;
      //  WebResponse myWebResponse1;
        WebRequest myWebRequest2;
       // WebResponse myWebResponse2;
        private Boolean webCredential = true;
        Thread uStatus;
        private string content = null;
        private Boolean run = false;


        public Form1()
        {
            InitializeComponent();
            txtbxIP.Text = "88.87.29.148";
            txtbxUN.Text = "admin";
            txtbxPW.Text = "admin";
            txtbxHP.Text = "1234";
            button1.Enabled = false;
            button2.Enabled = false;
            lblR1.Text = null;
            lblR2.Text = null;
            txtbxPW.PasswordChar = '*';
                        
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                HTTP_Req = "http://" + txtbxIP.Text + ":" + txtbxHP.Text + "/relays.cgi?relay=1";
                myWebRequest1 = WebRequest.Create(HTTP_Req);
                myWebRequest1.Credentials = new NetworkCredential(txtbxUN.Text, txtbxPW.Text);
                myWebRequest1.Method = "POST";
                myWebRequest1.ContentType = "";
                myWebRequest1.ContentLength = 0;
                Stream dataStream = myWebRequest1.GetResponse().GetResponseStream();
                dataStream.Close();
            }
            catch
            {
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                HTTP_Req = "http://" + txtbxIP.Text + ":" + txtbxHP.Text + "/relays.cgi?relay=2";
                myWebRequest2 = WebRequest.Create(HTTP_Req);
                myWebRequest2.Credentials = new NetworkCredential(txtbxUN.Text, txtbxPW.Text);
                myWebRequest2.Method = "POST";
                myWebRequest2.ContentType = "";
                myWebRequest2.ContentLength = 0;
                Stream dataStream = myWebRequest2.GetResponse().GetResponseStream();
                dataStream.Close();
            }
            catch
            {
            }
        }


        private void updateStatus()
        {
            while (run == true)
            {
                try
                {
                    HTTP_Req = "http://" + txtbxIP.Text + ":" + txtbxHP.Text + "/relays.cgi";
                    myWebRequest = WebRequest.Create(HTTP_Req);
                    myWebRequest.Credentials = new System.Net.NetworkCredential(txtbxUN.Text, txtbxPW.Text);
                    myWebRequest.Method = "POST";
                    myWebRequest.ContentType = "";
                    myWebRequest.ContentLength = 0;
                    Stream dataStream = myWebRequest.GetResponse().GetResponseStream();
                    dataStream.ReadTimeout = 1000;
                   // StreamReader objReader = new StreamReader(dataStream, Encoding.UTF8);
                   // myWebResponse = myWebRequest.GetResponse();
                    //Stream receiveStream = myWebResponse.GetResponseStream();
                    StreamReader reader = new StreamReader(dataStream, Encoding.UTF8);
                    content = reader.ReadToEnd();
                    dataStream.Close();
                    this.Invoke(new EventHandler(tBox));
                    Thread.Sleep(5);
                }
                catch
                {
                }
            }
        }


        private void tBox(object sender,EventArgs e)
        {

            char[] status = new char[11];
            char[] relay1 = new char[38];
            char[] relay2 = new char[38];
            string relay1name = null;
            string relay2name = null;

            for (int i = 0; i < content.Length - 11; i++)
            {
                for (int j = 0; j < 11; j++)
                {
                    status[j] = content[i + j];
                }

                if (status[0] == 'S' && status[1] == 't' && status[2] == 'a' && status[3] == 't'
                    && status[4] == 'u' && status[5] == 's')
                {
                    if(status[8] == '0')
                    {
                        button1.BackColor = Color.Green;
                        button1.Text = "Click to TURN ON";
                    }

                    else
                    {
                        button1.BackColor = Color.Red;
                        button1.Text = "Click to TURN OFF";
                    }

                    if (status[10] == '0')
                    {
                        button2.BackColor = Color.Green;
                        button2.Text = "Click to TURN ON";
                    }

                    else
                    {
                        button2.BackColor = Color.Red;
                        button2.Text = "Click to TURN OFF";
                    }
                }
            }


            for (int i = 0; i < content.Length - 38; i++)
            {
                for (int j = 0; j < 38; j++)
                {
                    relay1[j] = content[i + j];
                }

                if (relay1[0] == 'R' && relay1[1] == 'e' && relay1[2] == 'l' && relay1[3] == 'a'
                                     && relay1[4] == 'y' && relay1[5] == '1' && relay1[6] == ':' && relay1[7] == ' ')
                {
                    for (int z = 0; z < 30; z++)
                    {
                        relay1name += relay1[z + 8];
                    }
                    lblR1.Text = relay1name;
                }
            }


            for (int i = 0; i < content.Length - 38; i++)
            {
                for (int j = 0; j < 38; j++)
                {
                    relay2[j] = content[i + j];
                }

                if (relay2[0] == 'R' && relay2[1] == 'e' && relay2[2] == 'l' && relay2[3] == 'a'
                                     && relay2[4] == 'y' && relay2[5] == '2' && relay2[6] == ':' && relay2[7] == ' ')
                {
                    for (int z = 0; z < 30; z++)
                    {
                        relay2name += relay2[z + 8];
                    }
                    lblR2.Text = relay2name;
                }
            }




        }

        private void button3_Click(object sender, EventArgs e)
        {
            if (button3.Text == "Start")
            {
                button3.Text = "Stop";
                run = true;
                uStatus = new Thread(new ThreadStart(updateStatus));
                try
                {
                    uStatus.IsBackground = true;
                    uStatus.Start();
                }

                catch
                {
                }
                button1.Enabled = true;
                button2.Enabled = true;
                txtbxIP.Enabled = false;
                txtbxUN.Enabled = false;
                txtbxPW.Enabled = false;
                txtbxHP.Enabled = false;
            }

            else if (button3.Text == "Stop")
            {
                button3.Text = "Start";
                run = false;
                if (uStatus.IsAlive == true)
                {
                    try
                    {
                        uStatus.Abort();
                    }
                    catch { }
                }
                button1.Enabled = false;
                button2.Enabled = false;
                txtbxIP.Enabled = true;
                txtbxUN.Enabled = true;
                txtbxPW.Enabled = true;
                txtbxHP.Enabled = true;
            }
        }

        }
}

 

 

 

 

Monday, 25 March 2013 07:36

SoftGuard Alarm monitoring Software

Written by

 

 

 

SoftGuard Alarm monitoring Software

 

 

 

 

 

Coming soon ...

 

 

 

 

Thursday, 08 November 2012 14:12

How to control KMTronic USB relays using Perl script

Written by

 

 

 

Perl example

 

( thanks Pascal! )

 

 

 

 

 

 

Control KMTronic USB relays using Perl script:

http://www.info.kmtronic.com/software/USB_Relays/KMTronic_USB_relay_board_perl.zip

 

 

 

Friday, 03 August 2012 08:57

Control KMTronic USB relays - the python library

Written by

 

 

 

 

This package allows one to control a USB relay bank. This code currently is only tested with a KMTronic USB eight bank relay, however, can be extended to work with any device.

 

This package was created with and includes only free software and is licensed under GPLv3 or any later version. A copy of this license is found in the file gpl-3.0.txt.

 

The python-usbrelay library uses the excellent python-serial library.

 

Examples and details are available in the Sphinx documentation.

 

Link:

https://bitbucket.org/schryer/usbrelay

 

Download:

info.kmtronic.com/software/USB_Relays/schryer-python-kmtronic-usbrelay.zip

 

Many thanks David for this example!

 

 

 

 

 

Controlling USB Relay controller - One Channel

via Microsoft Office PowerPoint 2007

 

 

1. Download the drivers. If you are working with Windows7 or VISTA, you don’t need to download them. The device should be installed automatically. If it does NOT, please click on the following link :

http://www.info.kmtronic.com/installing-ftdi-drivers.html

Here you will find the steps you have to undertake in order to install it.

 

2. Connect the USB Relay. Wait for the Device Driver to install successfully.

 

3. Check in Device Manager COM port where the Relay is installed.

 

4. Download and unzip:

http://info.kmtronic.com/software/USB_Relays/Office/KMTronic_USB_Relay_Control_Software.zip

 

- You will find all files for controlling USB Relay Controllers from 1 to 8 channel in the folder.

 

5. Right-click on Relay_1_OFF and choose Properties. Change the COM Port to yours and click OK

(in our case it is COM3).

 

- Make sure you type the same digit as the COM Port;

    

-  There are two types of commands:
usbrelay.exe -c:3 -r:1#1 (this will turn relay ON );


usbrelay.exe -c:3 -r:1#0 (this will turn relay OFF);


- It will be even easier for you if you use the same name for the Folder and the File as the example above

(D:\ USBrelay\USBrelay.exe);

- Click Apply.

 

6. Now follow the same procedure for Relay_on. However, use the command:

usbrelay.exe -c:3 -r:1#1.
                                    

- Click Apply. The Relay should turn ON now.

The first thing you did was to make sure that the USB One Relay Controller- One Channel turns on and off without any troubles. Now open Microsoft Office PowerPoint 2007.

 

7. With the Presentation open, hit Alt+F11 to open the VBE (Microsoft Visual Basic).

 

8. Click on Insert > Class Module.

 

9. Rename the module (in the Properties pane, bottom left) to cEventClass.

 

10. Copy- Paste the following code:

Public WithEvents PPTEvent As Application
 
Private Sub PPTEvent_SlideShowNextSlide(ByVal Wn As SlideShowWindow)
    Dim RetVal
    If Wn.View.Slide.Shapes.HasTitle Then
        If Wn.View.Slide.Shapes.Title.TextFrame.TextRange.Text = "Model with lights on" Then
            RetVal = Shell("D:\USBrelay\USBRelay.exe -c:3 -r:1#1", 1)
        ElseIf Wn.View.Slide.Shapes.Title.TextFrame.TextRange.Text = "Model with lights off" Then
            RetVal = Shell("D:\USBrelay\USBRelay.exe -c:3 -r:1#0", 1)
        End If

 

End If

   

End Sub

 

 

- Make sure the PPTEvent and Slide ShowNextSlide appear on the top.

 

- Click to “Save” the file.

 

 

 

11. Click on the Insert- Module.

 

12. Copy-Paste the following code:

Public cPPTObject As New cEventClass
Sub Auto_Macros_On()
Set cPPTObject.PPTEvent = Application
End Sub

 

 

- Make sure the Auto_Macros_On, appears again on the top; - Click to “Save” the file.

 

13. Add a Action Button to your first slide: Insert -> Shapes-> Action Button bottom. This will need to be clicked to enable the Auto Macros. Give that shape an Action so it runs the Auto_Macros_On macro when clicked.

 

14. Now go back to the cEventClass, module. The text "Model with lights on/off" needs to be changed so it matches the titles of the slides you want the lights to switch. Do the same for lights off. Let’s name them Start and Stop. Save the file when you are done.

 

-Go back to the PowerPoint Presentation and give a Title the slides.

 

 

 

15. Save the Presentation as macro enabled .pptm.

 

16. Set a time for the slides and Start the slideshow from the beginning. Don’t forget to click the Action Button in the beginning. The USB Relay should turn on and off automatically.

 

 

 

 

 

 

 

 

 A tutorial showing how to set up GBTimelapse to control the Dynamic Perception MX2 Dolly using a USB relay.

 

 

GBTimelapse/MX2 Dolly Initial Setup

 

 

 

 

 

Monday, 27 February 2012 14:00

KMTronic C# NET 2010 example

Written by

 

 

 

C# Software example for KMTronic USB One Relay

 

 

 

 

 

Source Code:

------------------------------------------------------------------------------------------------------------------------------

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace KMTronic_USB_Relay
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            panel1.BackColor = Color.Red;
            panel2.BackColor = Color.Black;
            label1.Text = "Please select COM port";
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            comboBox1.Items.Clear(); //
            foreach (string com in System.IO.Ports.SerialPort.GetPortNames()) //
            comboBox1.Items.Add(com); //
        }

        private void Button_OPEN_Click(object sender, EventArgs e)
        {
            if (serialPort1.IsOpen)
            {
                serialPort1.Close();
                serialPort1.PortName = comboBox1.Items[comboBox1.SelectedIndex].ToString();
            }
            else
            {
                serialPort1.PortName = comboBox1.Items[comboBox1.SelectedIndex].ToString();
                serialPort1.Open();
                if (serialPort1.IsOpen)
                {
                    label1.Text = "Port is opened successfully!";
                }
                else
                {
                    label1.Text = "Impossible to open port!";
                }
            }
        }

        private void Button_CLOSE_Click(object sender, EventArgs e)
        {
            serialPort1.Close();
            label1.Text = "Port successfully closed!";
        }

        private void Button_ON_Click(object sender, EventArgs e)
        {
            serialPort1.Write(new byte[] { 0xFF, 0x01, 0x01 }, 0, 3);
            panel1.BackColor = Color.Lime;
            panel2.BackColor = Color.Lime;
        }

        private void Button_OFF_Click(object sender, EventArgs e)
        {
            serialPort1.Write(new byte[] { 0xFF, 0x01, 0x00 }, 0, 3);
            panel1.BackColor = Color.Red;
            panel2.BackColor = Color.Black;
        }


    }
}

 

------------------------------------------------------------------------------------------------------------------------------

 

 

 

 

Downloads

Software

http://www.info.kmtronic.com/software/USB_Relays/KMTronic_CS_NET_example.zip

Source code

http://www.info.kmtronic.com/software/USB_Relays/KMTronic_CS_NET_example_source_code.zip

 

 

 

Monday, 27 February 2012 11:21

KMTronic VB NET 2010 example

Written by

 

 

 

Visual Basic Software example for KMTronic USB One Relay

 

 

 

 

 

Source Code:

------------------------------------------------------------------------------------------------------------------------------

 

Imports System.IO.Ports

Public Class Form1

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        Panel1.BackColor = Color.Red
        Panel2.BackColor = Color.Black
        Label1.Text = "Please select COM port"

        ComboBox1.Items.Clear()
        Dim com As String() = SerialPort.GetPortNames()

        For Each port In com
            ComboBox1.Items.Add(port)
        Next port

    End Sub

    Private Sub Open_Click(sender As System.Object, e As System.EventArgs) Handles Button_Open.Click

        If (SerialPort1.IsOpen) Then
            SerialPort1.Close()
            SerialPort1.PortName = ComboBox1.Text
        Else
            SerialPort1.PortName = ComboBox1.Text
            SerialPort1.Open()
        End If

        If (SerialPort1.IsOpen) Then
            Label1.Text = "Port is opened successfully!"
        Else
            Label1.Text = "Impossible to open port!"
        End If

    End Sub


    Private Sub Button_CLOSE_Click(sender As System.Object, e As System.EventArgs) Handles Button_CLOSE.Click
        SerialPort1.Close()
        Label1.Text = "Port successfully closed!"
    End Sub


    Private Sub Button_ON_Click(sender As System.Object, e As System.EventArgs) Handles Button_ON.Click
        If (SerialPort1.IsOpen) Then
            Dim data(3) As Byte
            data(0) = 255 'data for entering comand mode
            data(1) = 1 'data to select which relay 1-8, in this case 1
            data(2) = 1 '1 turn on the relay, or 0 to turn it off
            SerialPort1.Write(data, 0, 3) 'write the data to the serial port
            Panel1.BackColor = Color.Lime
            Panel2.BackColor = Color.Lime
        End If

    End Sub


    Private Sub Button_OFF_Click(sender As System.Object, e As System.EventArgs) Handles Button_OFF.Click
        If (SerialPort1.IsOpen) Then
            Dim data(3) As Byte
            data(0) = 255 'data for entering comand mode
            data(1) = 1 'data to select which relay 1-8, in this case 1
            data(2) = 0 '1 turn on the relay, or 0 to turn it off
            SerialPort1.Write(data, 0, 3) 'write the data to the serial port
            Panel1.BackColor = Color.Red
            Panel2.BackColor = Color.Black
        End If
    End Sub

 

Private Sub Button_STATUS_Click(sender As Object, e As EventArgs) Handles Button_STATUS.Click
        If (SerialPort1.IsOpen) Then
            Dim data(3) As Byte
            data(0) = 255 'data for entering comand mode
            data(1) = 1 'data to select which relay 1-8, in this case 1
            data(2) = 3 'Read status
            SerialPort1.Write(data, 0, 3) 'write the data to the serial port

            For i As Integer = 0 To 2 Step 1
                data(i) = SerialPort1.ReadByte()
            Next


            If data(2) = 1 Then

                Panel1.BackColor = Color.Lime
                Panel2.BackColor = Color.Lime

            Else
                Panel1.BackColor = Color.Red
                Panel2.BackColor = Color.Black
            End If

        End If
    End Sub


End Class

 

------------------------------------------------------------------------------------------------------------------------------

 

 

 

 

Downloads

Software

https://www.info.kmtronic.com/software/USB_Relays/KMTronic_VB_NET_example.zip

Source code

https://www.info.kmtronic.com/software/USB_Relays/KMTronic_VB_NET_example_source_code.zip

 

 

 

Monday, 20 February 2012 12:57

KMTronic USB One Relay Linux test script

Written by

 

 

KMTronic USB One Relay Linux test script

 

 

 

Download test script from:

http://www.info.kmtronic.com/software/USB_Relays/KMtronic_USB_Relay_Linux_Script_OpenSUSE.zip

http://www.info.kmtronic.com/software/USB_Relays/KMtronic_USB_Relay_Linux_Script_Ubuntu.zip

          (Thanks to Karl for this script)

-------------------------

 

Create folder and extract these 4 files :

        You will need to mark it as executable with this command 

        chmod + x *.* 

        1. ubrelayspeed.sh   -      This script will set the speed to 9600

        2. usbrelayon.sh       -      This script will switch "ON" the relay

        3. usbrelayoff.sh       -      This script will switch "OFF" the relay

        4. usbrelaystatus.sh -      This script will read the status of the relay       

 

 

-----------------------------------

The script “usbrelaystatus”  gets the status of the relay (on/off) and there are places to insert code to run commands.  Hopefully included comments explain things (I left the echo’s and comments in that I used while I wrote/tested the script).  Let me know if you have questions.

If you do test this, I’d appreciate knowing if it worked for you or not.

 

I’m using OpenSUSE 12.1 – had to install libftdi1 – but it came with the OpenSUSE 12.1 install.

I never got the “.cats” program to work.

The usbrelaystatus script does not require any other programs to be installed (except for the ftdi drivers – at least on my system)

And I also discovered I have to run the usbrelayspeed script before I can send/receive data to/from the usb relay card.

Also I discovered if I include the usbrelayspeed in a cron job @reboot it doesn’t work – perhaps the @reboot executes before the usb relay card is loaded.

 

I am not a computer expert, so there may be a more efficient/better way to get the status of the relay – if you/someone publishes a better way I won’t feel sad.  But this works.

 

Hope this saves someone some time.

 

Karl

---------------------

 

 

Page 5 of 6