Ceyhun Kirimli has a PhD. in Biomedical Engineering with areas of competence in Molecular Biology, Genetics & Biomedical Engineering and Computational Sciences with focus on Development and Design of Biosensors.

http://www.linkedin.com/in/ceyhunkirimli
http://ceyhunkirimli.com

Ad Unit

Thursday, December 26, 2013

How to control a SUPER4 USB RELAY Module?

What the heck is a Super4 USB relay module?


It is a very easy to use USB relay module with 4 relays which can be controlled via a computer (PC, Mac etc.)

Why would anyone need it?
You may have electronic devices which need to be turned on or off using a computer. Use of a computer makes it easily programmable so that you can turn on and off different devices (simultaneously or asynchronously) with precise timing.

Ingredients:










How to?

First of all you need to make sure all the drivers and software in the link above is installed in your PC. You can control it using Matlab. One way of doing this is calling the relayset.exe which would work in dos environment (you can run dos commands in command prompt).

Download and unzip the Relayset 3.0 Released 29-01-2008 in a folder. Type "cmd" in the search box which appears when you click on the windows start button (left on the taskbar) and hit enter. This would run the cmd.exe and will open the command prompt. Navigate into the folder you installed the exe by entering "cd %folder name%" (%folder name% = name of the folder you want to navigate into...) one by one, until you reach the final folder. Type "relayset " and hit enter to see a list of commands to control the super4 relay as you can see in the picture below;


As you can see it is really easy to control the board. For the setup i used during my PhD. in Drexel University in Drs. Wei-Heng and Wan Shih's lab i only used the turn on and off commands. 
All you need to do is navigate into the folder which has the relayset.exe in command prompt and turn on any relay or set of relays on a board by entering; -u(boardname)(condition of relays in binary turned in to decimal)

so if you want to turn on all relays; 
represent this in binary as : 1111 which equals to 15 in decimal;
so you need to type -s(boardname),15

or if you want to turn on relays 2 and 4 and turn off relays 1 and 3;
represent this in binary as; 0101 which equals to 5 in decimal.
so you need to type -s(boardname),5

You can turn off every relay by typing -u(boardname),15 or by setting all of them in open circuit by typing -s(boardname),0

In order to change the name of the board you need to install the Relay Mapper . A screenshot of the software is shown below;



In this case 4 boards (so totally 4x4=16 relays are controlled) are controlled; which are named "board1", "board2", "board3" and "upumpcontroller" (i am guessing this was controlling a pump..) . You can change the name of any board in this program by double clicking the board name. And do not forget to turn on the relays by checking the box on the top right. 

So, luckily Matlab has a built-in function called "system", which calls dos commands from matlab, so you can write your own function to control the relay using Matlab. An example of a Matlab function can be seen here;

You can call this function in matlab by typing;

relay(relayID, action, relaynumber) where action is simply 1 to turn on and 0 to turn off any relay, relay ID is the name given to the board you want to control and relaynumber is the decimal form of the binary set of relays you want to control;

For example if you want to turn on the relays 1 and 4 on the board named "board1" in the above picture; you can simply call;

relay(board1,1,9);

and then if you want to turn these relays off you need to call: 

relay(board1,0,9);

That is all you need. Please comment below if you have any questions....





No comments:

Post a Comment

Bumerang - Yazarkafe