clc;
clear all;
close all;
warning off;
%****************ht7600*******************//
%ref_hex 1=external ref;0=internal ref
%vco_cal_hex 1=AUXDAC1;0=ADF4001
%fdd_tdd_hex 1=FDD 0=TDD
%trx_sw_hex 1=TX 0=RX
%****************ht7600*******************//
rcount=dec2hex(10,4);%reference clock divide
ncount=dec2hex(26,4);%internal vctcxo divide
ref_hex=dec2hex(0,8);%1=external ref 0=internal ref
vco_cal_hex=dec2hex(1,8);%1=auxdac 0=reference clock
aux_dac1_hex=dec2hex(0,8);
fdd_tdd_hex=dec2hex(1,8);
trx_sw_hex=dec2hex(1,8);
samp_hex=dec2hex(20e6,8);
bw_hex=dec2hex(18e6,8);
freq_hex=dec2hex(999e6,10); %%for ad9361
tx_att1=dec2hex(5000,8);
tx_att2=dec2hex(30000,8);
tx_chan=3;%1=tx1;2=tx2;3=tx1&tx2
%=====以下为数据调制部分=====%
%-----数据源数量-----%
bit_Num = 500;
%-----产生随机数据帧,length=500-----%
bit_trans = randint(1,bit_Num);
%-----产生两个载频,分别为1MHz和2MHz
carrier_I1=round(cos(2*pi/20*[0:19]).*30000);
carrier_Q1=round(sin(2*pi/20*[0:19]).*30000);
carrier_1M=carrier_I1+1i*carrier_Q1;
carrier_I2=round(cos(2*pi/10*[0:9]).*30000);
carrier_Q2=round(sin(2*pi/10*[0:9]).*30000);
carrier_2M=carrier_I2+1i*carrier_Q2;
%-----2MHz载波扩展为20bit,和1MHz载波等宽
carrier_2M=repmat(carrier_2M,1,2);
%-----键控调频,1-->1MHz,0-->2MHz
m1=[];
for i=1:length(bit_trans)
if bit_trans(i)==1
m=carrier_1M;
else
m=carrier_2M;
end
m1=[m1 m];
end
mod_data=m1;
%-----创建帧同步训练序列-----%
[training]=creat_training();
%-----数据组帧-----%
txdata=[training mod_data];
%% copy to 2chanel
if tx_chan==1 || tx_chan==2
txdata2=txdata;
elseif tx_chan==3
txdata2=zeros(1,length(txdata)*2);
txdata2(1:2:end)=txdata;
txdata2(2:2:end)=txdata;
end
%% iq mux
txdatas=zeros(1,length(txdata2)*2);
txdatas(1:2:end)=real(txdata2);
txdatas(2:2:end)=imag(txdata2);
%% add pad
rem=-1;
i=0;
while (rem<0)
rem=1024*2^i-length(txdatas);
i=i+1;
end
txdata1=[txdatas zeros(1,rem)];
txd1=(txdata1<0)*65536+txdata1;
txd2=dec2hex(txd1,4);
txd3=txd2(:,1:2);
txd4=txd2(:,3:4);
txd5=hex2dec(txd3);
txd6=hex2dec(txd4);
txd7=zeros(length(txd6)*2,1);
txd7(1:2:end)=txd6;
txd7(2:2:end)=txd5;
%% open control port
ctrl_link = udp('192.168.1.10', 5006);
fopen(ctrl_link);
%% open data port
data_link = tcpip('192.168.1.10', 5005);
set(data_link,'InputBufferSize',128*1024);
set(data_link,'OutputBufferSize',128*1024);
fopen(data_link);
%% tx samp rate
samp=[0 5 hex2dec('22') hex2dec('f0') hex2dec(samp_hex(7:8)) hex2dec(samp_hex(5:6)) hex2dec(samp_hex(3:4)) hex2dec(samp_hex(1:2))];
fwrite(ctrl_link,samp,'uint8');
%% tx bandwidth rate
bw=[0 7 hex2dec('22') hex2dec('f0') hex2dec(bw_hex(7:8)) hex2dec(bw_hex(5:6)) hex2dec(bw_hex(3:4)) hex2dec(bw_hex(1:2))];
fwrite(ctrl_link,bw,'uint8');
%% send tx freq set cmd
tx_freq=[hex2dec(freq_hex(1:2)) 3 hex2dec('22') hex2dec('f0') hex2dec(freq_hex(9:10)) hex2dec(freq_hex(7:8)) hex2dec(freq_hex(5:6)) hex2dec(freq_hex(3:4))];
fwrite(ctrl_link,tx_freq,'uint8');
%% send tx vga set cmd
tx_vga=[0 9 hex2dec('22') hex2dec('f0') hex2dec(tx_att1(7:8)) hex2dec(tx_att1(5:6)) hex2dec(tx_att1(3:4)) hex2dec(tx_att1(1:2))]; %TX1
fwrite(ctrl_link,tx_vga,'uint8');
tx_vga=[0 11 hex2dec('22') hex2dec('f0') hex2dec(tx_att2(7:8)) hex2dec(tx_att2(5:6)) hex2dec(tx_att2(3:4)) hex2dec(tx_att2(1:2))]; %TX2
fwrite(ctrl_link,tx_vga,'uint8');
%% send tx channel set cmd
channel=[tx_chan 0 hex2dec('20') hex2dec('f0') 0 0 0 0];
fwrite(ctrl_link,channel,'uint8');
%% custom rf control command
% adf4001 config
adf4001=[0 40 hex2dec('18') hex2dec('f0') hex2dec(ncount(3:4)) hex2dec(ncount(1:2)) hex2dec(rcount(3:4)) hex2dec(rcount(1:2))];
fwrite(ctrl_link,adf4001,'uint8');
% ref_select
ref_select=[0 40 hex2dec('22') hex2dec('f0') hex2dec(ref_hex(7:8)) hex2dec(ref_hex(5:6)) hex2dec(ref_hex(3:4)) hex2dec(ref_hex(1:2))];
fwrite(ctrl_link,ref_select,'uint8');
% vco_cal_select
vco_cal_select=[0 41 hex2dec('22') hex2dec('f0') hex2dec(vco_cal_hex(7:8)) hex2dec(vco_cal_hex(5:6)) hex2dec(vco_cal_hex(3:4)) hex2dec(vco_cal_hex(1:2))];
fwrite(ctrl_link,vco_cal_select,'uint8');
% fdd_tdd_select
fdd_tdd_select=[0 42 hex2dec('22') hex2dec('f0') hex2dec(fdd_tdd_hex(7:8)) hex2dec(fdd_tdd_hex(5:6)) hex2dec(fdd_tdd_hex(3:4)) hex2dec(fdd_tdd_hex(1:2))];
fwrite(ctrl_link,fdd_tdd_select,'uint8');
% trx_sw
trx_sw=[0 43 hex2dec('22') hex2dec('f0') hex2dec(trx_sw_hex(7:8)) hex2dec(trx_sw_hex(5:6)) hex2dec(trx_sw_hex(3:4)) hex2dec(trx_sw_hex(1:2))];
fwrite(ctrl_link,trx_sw,'uint8');
% aux_dac1
aux_dac1=[0 44 hex2dec('22') hex2dec('f0') hex2dec(aux_dac1_hex(7:8)) hex2dec(aux_dac1_hex(5:6)) hex2dec(aux_dac1_hex(3:4)) hex2dec(aux_dac1_hex(1:2))];
fwrite(ctrl_link,aux_dac1,'uint8');
%% send handshake cmd
handshake=[2 0 hex2dec('16') hex2dec('f0') 0 0 0 0];
fwrite(ctrl_link ,handshake, 'uint8');
%% send handshake2 cmd
data_length = dec2hex((2^(i-1)*2)*1024,8);
handshake=[2 0 hex2dec('17') hex2dec('f0') hex2dec(data_length(7:8)) hex2dec(data_length(5:6)) hex2dec(data_length(3:4)) hex2dec(data_length(1:2))];
fwrite(ctrl_link ,handshake, 'uint8');
%% Write data to the zing and read from the host.
fwrite(data_link,txd7,'uint8');
%% send handshake2 cmd to stop adc output
%handshake=[hex2dec('ff') 0 hex2dec('17') hex2dec('f0') 0 0 0 0];
%fwrite(ctrl_link,handshake,'uint8');
%% close all link
fclose(data_link);
delete(data_link);
clear data_link;
fclose(ctrl_link);
delete(ctrl_link);
clear ctrl_link;
disp('data tansfer done');
四散
- 粉丝: 67
- 资源: 1万+
最新资源
- 基于matlab实现的锁模光纤激光器仿真源码+文档说明(高分项目)
- 基于OpenCV全景图像拼接系统源代码(完整前后端+mysql+说明文档+LW).zip
- 基于matlab实现的锁模光纤激光器仿真源码(高分项目)
- 基于python的大学生就业信息管理系统(django)源代码(完整前后端+mysql+说明文档+LW).zip
- 简单好用的移动手机端ASP报名程序(含access数据库)
- 基于深度学习的安全帽佩戴检测wlw源代码(完整前后端+mysql+说明文档+LW).zip
- 群晖NAS中搭建WordPress站点
- 基于python的语音和背景音乐分离算法及系统源代码(完整前后端+mysql+说明文档+LW).zip
- 2023-2008年上市公司企业耐心资本数据、耐心资本所占比重数据集.txt
- 三菱电梯主板地址表参数 三菱电梯地址码, KCD-116主板地址参数, MAXIEZ电梯主板地址参数, VFGLC电梯主板地址参数, 可以修改电梯楼层显示、基站、强迫关门、消防功能、开关门时间等参数
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0