import numpy as np
import matplotlib.pyplot as plt

# accz 
T = 100             # ns
A = 0.8             # 归一化幅度
P = 0.16
omega_d = 100e6     # Hz
theta = 0
a2 = 0.1
phi = 0
sample_rate = 1e9   # Hz

N = int(100 / (1/sample_rate * 1e9))     # 采样点个数
A = A * 2**15

# 包络函数
t = np.linspace(0, N, N+1)
env = A/(np.sqrt(1 + P**2)) * (np.sin(np.pi * t / N) + P * np.sin(3*np.pi * t / N))

# 载波调制
f = env * (np.cos(omega_d * t + theta) + a2 * np.cos(2*omega_d*t + 2*theta + phi))
fint16 = np.int16(f)
#np.savetxt(r'D:\SynologyDrive\SynologyDrive\Work\SQC2.1\gene_wave_on_board\code\acczdata.txt',fint16,'%d')

plt.figure()
plt.plot(t,fint16)
plt.show()