-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend_text_string.m
More file actions
47 lines (35 loc) · 1.01 KB
/
send_text_string.m
File metadata and controls
47 lines (35 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
function completed = send_text_string(text,rate)
%Start up the Daq
samplesperbit = 2;
DAQ = daq.createSession('digilent')
DAQ.DurationInSeconds =5;
%This is W1.
DAQ.addAnalogOutputChannel('AD1', 1, 'Voltage')
% Turn on power supplies
DAQ.setPowerSupply('positive','on');
DAQ.setPowerSupply('negative','on');
%Set the rate
DAQ.Rate = samplesperbit*rate;
%define header
header = [1; 0; 1; 0; 1; 0; 1; 0];
%For now, just read in all at once. To send from CSV uncomment
%data = csvread(datafile);
%get binary version of text
data = string2double(text);
%% Transmit once
%TO TRANSMIT FROM RANDOM DATA
datatotransmit = vertcat(header,data);
dataup = upsample(datatotransmit,2);
dataupoff = upsample(datatotransmit,2,1);
datatotransmit = dataup + dataupoff;
%TO TRANSMIT FROM CSV
% dataup = upsample(data,2);
% dataupoff = upsample(data,2,1);
% datatotransmit = dataup + dataupoff;
% Scale
datatotransmit = 10*datatotransmit - 5;
queueOutputData(DAQ,datatotransmit);
DAQ.startForeground;
%% Return on completion
completed = 1;
end