-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend_text_string_PAM.m
More file actions
50 lines (36 loc) · 1.15 KB
/
send_text_string_PAM.m
File metadata and controls
50 lines (36 loc) · 1.15 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
48
49
50
function [transmitted,binary] = send_text_string_PAM(text,rate)
%Start up the Daq
samplesperbit =4;
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 = [5; 0; 5; 0; 5; 0; 5; 0];
%For now, just read in all at once. To send from CSV uncomment
%data = csvread(datafile);
%get binary version of text
binary = string2double(text);
%% Transmit once
%convert to pam values
datatotransmit = bin_to_PAM(binary)
%Scale
datatotransmit = 5/(max(datatotransmit))*datatotransmit;
%Add in header
datatotransmit = vertcat(header,datatotransmit);
%Upsample the data
dataup = upsample(datatotransmit,4);
dataupoff = upsample(datatotransmit,4,1);
dataupoffagain = upsample(datatotransmit,4,2);
dataupoffagainagain = upsample(datatotransmit,4,3);
datatotransmit = dataup + dataupoff + dataupoffagain + dataupoffagainagain;
queueOutputData(DAQ,datatotransmit);
DAQ.startForeground;
%% Return on completion
transmitted = datatotransmit;
end