Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
colorEagleStdio
taskbus_course
提交
afad5b3c
taskbus_course
项目概览
colorEagleStdio
/
taskbus_course
通知
28
Star
5
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
taskbus_course
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
afad5b3c
编写于
3月 12, 2024
作者:
丁劲犇
😸
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
为 8PSK加入上插值同步均衡器,以收敛结果
上级
9f6fad19
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
109 addition
and
86 deletion
+109
-86
src/a2psk_demod/main.cpp
src/a2psk_demod/main.cpp
+109
-86
未找到文件。
src/a2psk_demod/main.cpp
浏览文件 @
afad5b3c
...
...
@@ -424,13 +424,14 @@ void demod_8psk(const short (*iqdata)[2], const int splen)
static
double
fir_cache_i
[
25
]
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
};
static
double
fir_cache_q
[
25
]
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
};
//fir filter
static
unsigned
long
long
clk
=
0
,
bad_angle
=
0
,
last_synclk
=
0
;
static
const
int
WINSZ
=
4000
;
static
unsigned
long
long
clk
=
0
,
last_synclk
=
0
;
static
const
int
WINSZ
=
4000
,
WINSZx4
=
WINSZ
*
4
;
static
double
stati_win
[
WINSZ
][
2
],
sum_win
[
2
]
=
{
0
,
0
};
static
double
cache_win
[
WINSZ
][
2
];
static
double
cache_win
[
WINSZ
x4
][
2
];
//smp best pos
static
double
clk_offset
[
4
]
=
{
0
,
0
,
0
,
0
};
static
double
clk_offset
[
16
]
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
};
static
double
clk_offsetLast
[
16
]
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
};
static
bool
bInited
=
false
;
static
double
curr_dp
=
0
;
...
...
@@ -441,7 +442,8 @@ void demod_8psk(const short (*iqdata)[2], const int splen)
for
(
int
i
=
0
;
i
<
WINSZ
;
++
i
)
{
stati_win
[
i
][
0
]
=
stati_win
[
i
][
1
]
=
0
;
cache_win
[
i
][
0
]
=
cache_win
[
i
][
1
]
=
0
;
for
(
int
j
=
0
;
j
<
4
;
++
j
)
cache_win
[
i
*
4
+
j
][
0
]
=
cache_win
[
i
*
4
+
j
][
1
]
=
0
;
}
}
//iq dem buf
...
...
@@ -487,89 +489,110 @@ void demod_8psk(const short (*iqdata)[2], const int splen)
stati_win
[
clk
%
WINSZ
][
1
]
=
fval_q
;
const
double
dcremoved
[
2
]
{
fval_i
-
sum_win
[
0
]
/
WINSZ
,
fval_q
-
sum_win
[
1
]
/
WINSZ
};
cache_win
[
clk
%
WINSZ
][
0
]
=
dcremoved
[
0
];
cache_win
[
clk
%
WINSZ
][
1
]
=
dcremoved
[
1
];
//3. 最佳采样位置跟踪
const
int
curr_offv
=
clk
%
4
;
clk_offset
[
curr_offv
]
+=
(
dcremoved
[
0
]
*
dcremoved
[
0
]
+
dcremoved
[
1
]
*
dcremoved
[
1
]);
double
phy
=
0
;
if
(
curr_offv
==
bestOff
)
{
//旋转
static
const
double
beautiful_rt225
[
2
]{
cos
(
c_pi
/
8
),
sin
(
c_pi
/
8
)};
double
rt1
[
2
]{
cos
(
-
curr_dp
),
sin
(
-
curr_dp
)};
double
rt2
[
2
]{
cos
(
-
curr_dp
-
c_pi
/
4
),
sin
(
-
curr_dp
-
c_pi
/
4
)};
double
rt3
[
2
]{
cos
(
-
curr_dp
-
c_pi
/
2
),
sin
(
-
curr_dp
-
c_pi
/
2
)};
double
rt4
[
2
]{
cos
(
-
curr_dp
-
3
*
c_pi
/
4
),
sin
(
-
curr_dp
-
3
*
c_pi
/
4
)};
const
double
out
[
2
]{
cache_win
[(
clk
+
4
)
%
WINSZ
][
0
],
cache_win
[(
clk
+
4
)
%
WINSZ
][
1
]};
double
rp1
[
2
]{
out
[
0
]
*
rt1
[
0
]
-
out
[
1
]
*
rt1
[
1
],
out
[
0
]
*
rt1
[
1
]
+
out
[
1
]
*
rt1
[
0
]
};
double
rp2
[
2
]{
out
[
0
]
*
rt2
[
0
]
-
out
[
1
]
*
rt2
[
1
],
out
[
0
]
*
rt2
[
1
]
+
out
[
1
]
*
rt2
[
0
]
};
double
rp3
[
2
]{
out
[
0
]
*
rt3
[
0
]
-
out
[
1
]
*
rt3
[
1
],
out
[
0
]
*
rt3
[
1
]
+
out
[
1
]
*
rt3
[
0
]
};
double
rp4
[
2
]{
out
[
0
]
*
rt4
[
0
]
-
out
[
1
]
*
rt4
[
1
],
out
[
0
]
*
rt4
[
1
]
+
out
[
1
]
*
rt4
[
0
]
};
double
rpf
[
2
]{
rp1
[
0
]
*
beautiful_rt225
[
0
]
-
rp1
[
1
]
*
beautiful_rt225
[
1
],
rp1
[
0
]
*
beautiful_rt225
[
1
]
+
rp1
[
1
]
*
beautiful_rt225
[
0
]
};
//测角
double
phy1
=
atan_r
(
rp1
[
1
],
rp1
[
0
]);
double
phy2
=
atan_r
(
rp2
[
1
],
rp2
[
0
]);
double
phy3
=
atan_r
(
rp3
[
1
],
rp3
[
0
]);
double
phy4
=
atan_r
(
rp4
[
1
],
rp4
[
0
]);
phy
=
phy1
;
if
(
fabs
(
phy2
)
<
fabs
(
phy
))
phy
=
phy2
;
if
(
fabs
(
phy3
)
<
fabs
(
phy
))
phy
=
phy3
;
if
(
fabs
(
phy4
)
<
fabs
(
phy
))
phy
=
phy4
;
//调整比例以调整跟踪的步进。
curr_dp
+=
phy
/
2
;
while
(
curr_dp
>
2
*
c_pi
)
curr_dp
-=
2
*
c_pi
;
while
(
curr_dp
<-
2
*
c_pi
)
curr_dp
+=
2
*
c_pi
;
//上采样到16倍
dp_iqbuf
[
output_sps
][
0
]
=
rpf
[
0
];
dp_iqbuf
[
output_sps
][
1
]
=
rpf
[
1
];
double
angfinal
=
atan2
(
rpf
[
1
],
rpf
[
0
]);
dp_bitbuf
[
output_sps
]
=
get_sym8psk
(
angfinal
);
++
output_sps
;
}
//错开最佳点进行判断
if
(
last_synclk
+
WINSZ
<
clk
&&
((
clk
+
2
)
%
4
)
==
bestOff
)
static
double
fir_up
[
2
][
25
]
=
{{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
},{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
}};
static
unsigned
long
long
up_clock
=
0
;
//1:4 pre-shaping filter
//x4
for
(
int
sym
=
0
;
sym
<
4
;
++
sym
)
{
last_synclk
=
clk
;
int
maxo
=
0
;
double
maxv
=
clk_offset
[
0
];
if
(
clk_offset
[
1
]
>
maxv
)
{
maxo
=
1
;
maxv
=
clk_offset
[
1
];}
if
(
clk_offset
[
2
]
>
maxv
)
{
maxo
=
2
;
maxv
=
clk_offset
[
2
];}
if
(
clk_offset
[
3
]
>
maxv
)
{
maxo
=
3
;
maxv
=
clk_offset
[
3
];}
//qDebug() << maxo;
bestOff
=
maxo
;
if
(
clk
%
(
WINSZ
*
10
)
==
0
)
fprintf
(
stderr
,
"BestOffset=%d,clk = %lld, pyherr = %lf, large ang = %lld
\n
"
,
bestOff
,
clk
,
phy
,
bad_angle
);
clk_offset
[
0
]
=
0
;
clk_offset
[
1
]
=
0
;
clk_offset
[
2
]
=
0
;
clk_offset
[
3
]
=
0
;
fir_up
[
0
][
up_clock
%
25
]
=
sym
==
0
?
(
dcremoved
[
0
])
:
0
;
fir_up
[
1
][
up_clock
%
25
]
=
sym
==
0
?
(
dcremoved
[
1
])
:
0
;
double
fval
[
2
]
=
{
0
,
0
};
for
(
int
f
=
0
;
f
<
25
;
++
f
)
{
fval
[
0
]
+=
fir_up
[
0
][(
up_clock
+
1
+
f
)
%
25
]
*
fir_rcos_q25
[
f
];
fval
[
1
]
+=
fir_up
[
1
][(
up_clock
+
1
+
f
)
%
25
]
*
fir_rcos_q25
[
f
];
}
++
up_clock
;
cache_win
[
up_clock
%
WINSZx4
][
0
]
=
fval
[
0
];
cache_win
[
up_clock
%
WINSZx4
][
1
]
=
fval
[
1
];
//3. 最佳采样位置跟踪
const
int
curr_offv
=
up_clock
%
16
;
const
double
curr_r
=
sqrt
(
fval
[
0
]
*
fval
[
0
]
+
fval
[
1
]
*
fval
[
1
]);
if
(
clk_offsetLast
[
curr_offv
]
>=
0
)
clk_offset
[
curr_offv
]
+=
fabs
(
curr_r
-
clk_offsetLast
[
curr_offv
]
);
clk_offsetLast
[
curr_offv
]
=
curr_r
;
double
phy
=
0
;
if
(
curr_offv
==
bestOff
)
{
//旋转
static
const
double
beautiful_rt225
[
2
]{
cos
(
c_pi
/
8
),
sin
(
c_pi
/
8
)};
double
rt1
[
2
]{
cos
(
-
curr_dp
),
sin
(
-
curr_dp
)};
double
rt2
[
2
]{
cos
(
-
curr_dp
-
c_pi
/
4
),
sin
(
-
curr_dp
-
c_pi
/
4
)};
double
rt3
[
2
]{
cos
(
-
curr_dp
-
c_pi
/
2
),
sin
(
-
curr_dp
-
c_pi
/
2
)};
double
rt4
[
2
]{
cos
(
-
curr_dp
-
3
*
c_pi
/
4
),
sin
(
-
curr_dp
-
3
*
c_pi
/
4
)};
const
double
out
[
2
]{
cache_win
[(
up_clock
+
16
)
%
WINSZx4
][
0
],
cache_win
[(
up_clock
+
16
)
%
WINSZx4
][
1
]};
double
rp1
[
2
]{
out
[
0
]
*
rt1
[
0
]
-
out
[
1
]
*
rt1
[
1
],
out
[
0
]
*
rt1
[
1
]
+
out
[
1
]
*
rt1
[
0
]
};
double
rp2
[
2
]{
out
[
0
]
*
rt2
[
0
]
-
out
[
1
]
*
rt2
[
1
],
out
[
0
]
*
rt2
[
1
]
+
out
[
1
]
*
rt2
[
0
]
};
double
rp3
[
2
]{
out
[
0
]
*
rt3
[
0
]
-
out
[
1
]
*
rt3
[
1
],
out
[
0
]
*
rt3
[
1
]
+
out
[
1
]
*
rt3
[
0
]
};
double
rp4
[
2
]{
out
[
0
]
*
rt4
[
0
]
-
out
[
1
]
*
rt4
[
1
],
out
[
0
]
*
rt4
[
1
]
+
out
[
1
]
*
rt4
[
0
]
};
double
rpf
[
2
]{
rp1
[
0
]
*
beautiful_rt225
[
0
]
-
rp1
[
1
]
*
beautiful_rt225
[
1
],
rp1
[
0
]
*
beautiful_rt225
[
1
]
+
rp1
[
1
]
*
beautiful_rt225
[
0
]
};
//测角
double
phy1
=
atan_r
(
rp1
[
1
],
rp1
[
0
]);
double
phy2
=
atan_r
(
rp2
[
1
],
rp2
[
0
]);
double
phy3
=
atan_r
(
rp3
[
1
],
rp3
[
0
]);
double
phy4
=
atan_r
(
rp4
[
1
],
rp4
[
0
]);
phy
=
phy1
;
if
(
fabs
(
phy2
)
<
fabs
(
phy
))
phy
=
phy2
;
if
(
fabs
(
phy3
)
<
fabs
(
phy
))
phy
=
phy3
;
if
(
fabs
(
phy4
)
<
fabs
(
phy
))
phy
=
phy4
;
//调整比例以调整跟踪的步进。
curr_dp
+=
phy
/
2
;
while
(
curr_dp
>
2
*
c_pi
)
curr_dp
-=
2
*
c_pi
;
while
(
curr_dp
<-
2
*
c_pi
)
curr_dp
+=
2
*
c_pi
;
dp_iqbuf
[
output_sps
][
0
]
=
rpf
[
0
];
dp_iqbuf
[
output_sps
][
1
]
=
rpf
[
1
];
double
angfinal
=
atan2
(
rpf
[
1
],
rpf
[
0
]);
dp_bitbuf
[
output_sps
]
=
get_sym8psk
(
angfinal
);
++
output_sps
;
}
//错开最佳点进行判断
if
(
last_synclk
+
WINSZx4
<
up_clock
&&
((
up_clock
+
7
)
%
16
)
==
bestOff
)
{
last_synclk
=
up_clock
;
int
mino
=
0
;
double
minv
=
clk_offset
[
0
];
for
(
int
j
=
0
;
j
<
16
;
++
j
)
{
if
(
clk_offset
[
j
]
<
minv
)
{
mino
=
j
;
minv
=
clk_offset
[
j
];
}
clk_offset
[
j
]
=
0
;
clk_offsetLast
[
j
]
=
-
1
;
}
//qDebug() << maxo;
bestOff
=
mino
;
//fprintf(stderr,"BestOffset=%d,clk = %lld, pyherr = %lf, large ang = %lld\n",bestOff,up_clock,phy,bad_angle);
}
}
++
clk
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录