Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
42 lines (30 loc) · 1.06 KB

File metadata and controls

42 lines (30 loc) · 1.06 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import numpy as np
import matplotlib.pyplot as plt
# Calculate velocity control value exponential mapping to [0, MAX_TIME] seconds.
SAMPLE_RATE = 48_000
MAX_TIME = 2**2
BASE = 20 # Base for exponential function.
BRAM_SIZE_LOG2 = 10
ctrl_exp = np.zeros(2**16)
velocity = np.zeros(2**16)
length = np.zeros(2**16)
for i in range(0, 2**16):
# Map control value range to range in [0, 1]
ctrl_exp[i] = (BASE**((i + 1) / 2**16) - 1) / (BASE - 1)
# Calculate corresponding velocity values.
velocity[i] = 2**31 / (MAX_TIME * SAMPLE_RATE * ctrl_exp[i])
# Check by calculating resulting envelope times for control range.
length[i] = 2**31 / (velocity[i] * SAMPLE_RATE)
velocity = np.minimum(velocity, 2**31 - 1)
# print(ctrl_exp)
# print([int(x) for x in velocity][:5])
# print(length)
with open('log.hex', 'w') as f:
for v in velocity[::2**(16 - BRAM_SIZE_LOG2)]:
f.write(f"{np.uint32(v):08X}\n")
fig = plt.figure()
axes = fig.subplots(3)
axes[0].plot(ctrl_exp)
axes[1].semilogy(velocity)
axes[2].plot(length - MAX_TIME * ctrl_exp)
plt.show()
Morty Proxy This is a proxified and sanitized view of the page, visit original site.