Controlling USB Relay controllers via Microsoft Office PowerPoint

 

 

 

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.

 

 

 

 

 

Read 5778 times