RZUDP
Custom software applications are fully supported for any computer language that supports IP network protocols.
Getting Started
TDT provides wrapper classes and demo files for communicating with the RZUDP interface from MATLAB or Python. You'll also need the IP address of the RZ UDP interface. See RZ-UDP Interface.
Note
If you are communicating with the emulated UDP interface in Corpus, use 'localhost' for the RZ IP address if your script is running on the same computer as Corpus, or use the computer's IP address if your script is running on a different computer on the network.
MATLAB
You can download the latest MATLAB SDK files here.
The TDTUDP class installs to:
C:\TDT\TDTMatlabSDK\TDTSDK\UDP
Example scripts install to:
C:\TDT\TDTMatlabSDK\Examples\UDP
Python
The Python TDTUDP class interfaces with the RZ UDP hardware. It is available in the tdt pypi package (pip install tdt).
Other Languages
C++ example files are available on request. A C# implementation can be found on github.
MATLAB Examples
Reading from RZ UDP
RZ_IP = '10.1.0.100'; % find remote IP address of RZ device using zBusMon
% read demo
u = TDTUDP(RZ_IP, 'TYPE', 'single', 'VERBOSE', 1);
while 1
u = u.read();
if isempty(u.data)
continue
end
u.data
% do something with the data here
end
Writing to RZ UDP
RZ_IP = '10.1.0.100'; % find remote IP address of RZ device using zBusMon
% write demo
u = TDTUDP(RZ_IP);
for i = 1:10
cmd = [i zeros(1,15)];
u = u.write(cmd);
end
Python Examples
Reading from RZ UDP
import tdt
RZ_IP = '10.1.0.100'
# this example has UDPSend hal connected to SortBinner gizmo for spike counts
udp = tdt.TDTUDP(host=RZ_IP, sort_codes=4, bits_per_bin=4)
while 1:
data = udp.recv()
# if looking at binner packets, extract sort codes
channel = 4
sort_code = 2
print('CHANNEL:', channel, 'SORT:', sort_code, '\t', data[sort_code-1][channel-1], end='\t\t\t\r')
Writing to RZ UDP
import time
import tdt
RZ_IP = '10.1.0.100'
udp = tdt.TDTUDP(host=RZ_IP, send_type=np.float32)
SEND_PACKETS = 1
ct = 0
while 1:
ct += 1
fakedata = range(ct % 10, SEND_PACKETS + ct % 10)
if udp.send_type == float:
fakedata = [x * 2. for x in fakedata]
udp.send(fakedata)
time.sleep(.1) # slow it down a bit
Reading and Writing
import tdt
RZ_IP = '10.1.0.100'
udp = tdt.TDTUDP(host=RZ_IP, send_type=np.float32, recv_type=np.float32)
SEND_PACKETS = 8
ct = 0
while 1:
ct += 1
fakedata = range(ct % 10, SEND_PACKETS + ct % 10)
if udp.send_type == float:
fakedata = [x * 2. for x in fakedata]
data = udp.recv()
print(data)
udp.send(fakedata)
Note
The listening port on the UDP Ethernet interface is 22022 and cannot be changed.
UDP Interface Performance
The UDP interface is a 10 Mb Ethernet interface, but the usable bandwidth is significantly lower due to overhead and serialization of the data. All data is transferred as single channel or multi-channel packets from Synapse. Sort code data can be highly compressed to increase speed using the SortBinner gizmo.
The table below displays the expected throughput for different channel counts.