Relay demo


Whilst we do try to integrate everything that may be required for behavioural experiments into the Zantiks units, there may be a need to utilise other external stimuli such as motors or screens. The Zantiks units have capability for operating additional stimuli using relays.

Top

The script below demonstrates how to use the relay connections to operate external stimuli (e.g., LED lights, peristaltic pumps, motors, screens and audio) in the integrated Zanscript software.

External stimuli can be plugged into one of two socket connections at the back of the unit, CN3 or CN4. This can be via an external relay board or directly into the socket itself.

At the start of a script, the relay corresponding to socket CN4 is connected to the 12V power supply by default; where CN3 needs to have the power circuit completed through the relay command.

For example, when plugging in a light stimulus to CN4 the light will be on upon plugging in. If plugged into CN3, the light will need to be switched on via the relay commands.

CN4 input is controlled through the RELAY1 or the C1 operation within ZCOMMAND, whereas CN3 input is controlled via RELAY2 or the C2 operation in ZCOMMAND.

Top

Script explanation

The script below uses two separate commands to energise or release the relays.

DEFINE WAIT_TIME 5
 
 
ACTION MAIN 
 
 INVOKE(RELAY_TEST,2) 
 
COMPLETE 
 
ACTION RELAY_TEST
 
 SET(RELAY1,OFF)
 #SET(RELAY2,OFF)
 WAIT(WAIT_TIME)
 
 SET(RELAY1,ON)
 #SET(RELAY2,ON)
 WAIT(WAIT_TIME)
 
 SET(RELAY1,OFF)
 #SET(RELAY2,OFF)
 WAIT(WAIT_TIME)
 
 ZCOMMAND("C1#1 P250 C1#0 P500")
 #ZCOMMAND("C2#1 P250 C2#0 P500")
 
COMPLETE

SET(RELAY#,ON) and SET(RELAY#,OFF) - set the chosen relay either 'ON' or 'OFF', which will activate or shut down the circuit which powers the stimulus.

The ZCOMMAND controls the relay and any wanted pauses. "C1#1" turns on RELAY1. "P250" delays (or Pauses) for 250ms before the next operation within ZCOMMAND begins. Increasing or decreasing "P" here will increase or decrease the time the stimulus is activated or off. "C1#0" turns off RELAY1. C2#1" turns on RELAY2 and "C2#0" turns off RELAY2. See the ZCOMMAND page for more details on this command.

The script begins with a command to turn relay 1 off. The stimulus is then activated for the WAIT_TIME of 5 seconds and then turns off again. This is then followed by the ZCOMMAND activating the stimulus for 250 ms and then off for 500ms before repeating the entire script two more times.

NOTE: RELAY2 commands are written into the script but hashed out for easy switching between the two CN sockets.

Top

Script download

To download the relay_demo script as a .zs file (file type Zantiks software reads), choose the Save File As option in the right-click dialogue box. Clicking on the script name hyperlink will open a read-only version of the script.

Script download:
relay_demo.zs

Top

Video demo

Below is a video demonstration of a number of different items controlled via the same Zanscript using connectors and the relay commands outlined in the code above.

demonstration of multiple stimuli operated by relays in the Zantiks LT unit