dScope Series III Scripting and automation
IR Control
Overview
The dScope III has the ability to
simplify the process of running the tests by using infra-red remote
control. This is done with VB Scripts and can be used to control
devices under test, or to access the test tracks of a test DVD
etc.. This scripting note describes the set-up and operation
of this IR automation.
Requirements
This scripting note describes using the
IRTrans IR emitter. This connects via USB to the host computer so
it is important that you have a PC with USB support and two USB ports
if you wish to use it in conjunction with a dScope. More
information on the IRTrans IR transmitter is available from www.irtrans.com. It can also be ordered directly from them online. PC software required is MS Windows 98 or later
PC with USB support (not NT). In order to control the IRTrans, the IRTransTray USB Server must be loaded and running.
IRTrans Installation
The IRTrans system consists of
several components. IRTrans
hardware is a small blue box that is connected to the PC by the USB
cable. Although it has a DC socket, it is not usually
necessary
to power it as it takes it’s power from the USB
connection.
If connected to a USB port without power, a DC supply will be
needed. A USB driver is required and, at the time of writing,
does not seem to be installed by the default installation, but can be downloaded and installed separately.
In terms of software, the IRTrans system works using a TCP/IP
Server/Client architecture. This means that the hardware can
be
controlled over a network connection, or even over the
internet.
It does, however, mean that installation is a little more complex than
would otherwise be the case.
In addition, this script makes use of the Active-X
control supplied with the IRTrans device, and not the normal IRTrans
GUI client.
IRTrans installation is best carried out as a default full installation
as available from www.irtrans.com
. There may be several
additional steps:
· Install a USB
driver. The driver is
available separately on the "downloads" section of the IRTrans web
site. Instructions are given on the site.
· Register the IRTrans ActiveX
control:
to do this, from the “start” menu, select
“run”, then type in regsvr32 and the full path of
the file
IRTrans.OCX in quotes and press enter. The OCX file is
included
in the default installation. The resulting command will look
something like:
regsvr32 "C:\Program Files\IRTrans\plugins\Active-X\IRTrans.ocx" |
Overview of running IRTrans
As explained in the previous
section, IRTrans software is based on
server/client architecture. For this reason, any time the
IRTrans
system is needed, the server must be running. This is done by
running the program “IRTranstray USB” which is
accessible
from the start menu. When this is running, a small
“IR” icon appears in the system tray (at the right
of the
toolbar). Once this is running, you can access the
hardware
either using the IRTrans GUI Client or via the ActiveX
control.
In the text that follows, it is assumed that the IRTrans server is
already running.
Configuring
the IR remote control
For the purposes of
illustrating the principles involved, we will consider the script
"IRTrans Remote.vbs".
This is a basic remote control set up for a
Toshiba SD-120e DVD player that uses the IRTrans device. Although it is
a VB Script and not a dScope DSS script, it
still makes use of the dScope ScriptDlg DLL for the interface so it
will only normally work when the dScope software is installed.
It is very unlikely that
the IR control will work “out of the
box” for anything much other than this DVD player and
possibly other Toshiba players of a similar design.
Almost every manufacturer of IR controllable devices has a
different way of controlling their equipment with IR and it is
impossible
to cater for all these options from the outset. Instead, the script has been written in such a way that re-configuration
is as easy as possible, but it does assume some knowledge of scripting
in VB script. The-configuration falls into several steps:
Finding or
Generating the IR control library
For each player there needs to
be a library of IR commands that the
software uses to access tracks etc. Using the
IRTrans GUI
client, it is possible to select an already learnt IR library, or
“learn” your own. If a suitable
file is not
found, learning the codes is straightforward. There are
several
steps to this:
· Change the GUI mode to
“learn command”,
· Tell the software the name
of the remote you
are learning (it will save the library of learnt commands with this
name).
Do this by:
· Typing the name of the
remote in the drop list box
· Press “Open /
Create Remote”
· Learn a remote timing (this
tells IRTrans
what frequency to use etc.) Normally, you will only need to
learn
one timing per remote. Once you have opened or created a
remote,
do this by:
· Press the “Learn
Timing” button
· Press a button on the remote
while pointing it at the IRTrans
· Learn the remote codes for
each button
Do this by:
· Typing the name of the
remote button you want to learn in the edit box
· Press “Learn
Command”
· Point the remote control at
the IRTrans and press the remote button.
· The code for that button
will appear on the screen
· Continue with all the other
buttons you want to learn.
Once you have learned all the buttons you need, just press
“finish learning” – the commands are
stored by the
IRTrans software.
Learning infra-red commands is notoriously difficult to do with complete
consistency and reliability. A simple way to get an idea if
the
remote codes have been learnt correctly is to open the remote file in a
text editor. The remote file is found in the program
files/IRTrans/remotes folder with the name you entered. Below
is
the first part of a remote file for a Toshiba SD-120E DVD player
remote. Note that the commands are all the same length and
have a
similar format.
[REMOTE] |
If you see any commands
that are longer or shorter than all the rest,
or have a different format, they are quite likely to have been learnt
incorrectly and may not work. You can test them by using the
“Send”, “Send
Command” option from the
IRTrans GUI client and check that you get the expected
result. If
not, the command will need to be re-learnt.
Linking to
the IR control library
Once the IR library is set up,
you will need to link to it from within
the IRTrans Remote Script. The script is written in such a
way
that the player to use is selected near the beginning of the script by
setting the value of the variable "devname" to the name of the library
that is to be used. This must be set to be exactly the same as the
device name that was entered in the IRTrans GUI client when learning
the remote commands.
The configuration section of the script has a section where the command name of the IR library can be set for each button. This sets which IR command will be triggered when that button is pressed. There are also four "spare" or "user" buttons that can be re-named or can be taken off the interface if not required.
How the Script works and how to
modify it
The key part of
the script is starting up the IRTrans object and then accessing its
methods and properties using ActiveX controls. In practice,
we need to start the IRTranstray USB server before we can access the
control. We do this manually using the "start" menu link to the IRTrans
installation. Once we have done that, we can use the
following code to connect to it and operate it in the script.
'Set up IRTrans |
In the above code, "IRTrans" is a variable. It could be called anything we like. We have simply set up an IRTrans object called "IRTrans". From this point on, we can access the IRTrans methods and properties using commands like:
IRTrans.SendIR Cstr(devname), Cstr(play) |
The above command sends an IR command. The command to be sent is the "play" command from the "devname" library. both "play" and "devname" are variables that will be set previously in the script to make them access the correct library and command within that library. It is easy to hard-code these too, so that if you are writing a script to control a particular bit of hardware and you know the IR commands in the library, you can write the automation directly into the script. At the end of the IR control session, you should set the IRTrans object to "nothing" using the command below.
set IRTrans = nothing |
In practice, when the system is working correctly, you will see the LED on the top of the IRTrans hardware light up each time a command is sent.
Fine Tuning
Some hints for getting the hardware to work optimally: The weakest link
in this system is likely to be the actual IR link itself between the IR
emitter and the IR receiver in the DVD player. If you have
trouble controlling the device with the remote control, the script
is likely to have similar trouble. You have the advantage
over
the script that you can tell what the DVD player has done with each
command you send on a remote control and you can press the button again
if needed. The script has no feedback from the device and
cannot
tell if the command has been acted on.
The IRTrans has particularly powerful IR emitters but even they may not
be able to compete with strong sunlight. If reception of the
IR
signal is a problem, try to shade the IRTrans and receiver from strong
light.
Known Issues
The IRTrans ActiveX control provides feedback to the script by means of
firing events. These events cannot be handled in the scripts
so we have no feedback from the IRTrans server in
the event of trouble running the IR automation. If the
IRTrans
server is not running when the script is started, we will typically get
a Winsock
error when attempting to access it. Likewise if the server is
running, but there is no IRTrans hardware connected, we get a
"connection was forcefully rejected" message.