Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MicroCART
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Distributed Autonomous Networked Control Lab
MicroCART
Commits
b0218782
Commit
b0218782
authored
6 years ago
by
James Talbert
Browse files
Options
Downloads
Patches
Plain Diff
Add frequency scanning to PWM loop tests
parent
7ac753e9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
quad/vivado_workspace/PWM_Combined_Tests/PWM_Combined_Tests.sdk/Loopback_Error_Check/src/helloworld.c
+33
-22
33 additions, 22 deletions
..._Combined_Tests.sdk/Loopback_Error_Check/src/helloworld.c
with
33 additions
and
22 deletions
quad/vivado_workspace/PWM_Combined_Tests/PWM_Combined_Tests.sdk/Loopback_Error_Check/src/helloworld.c
+
33
−
22
View file @
b0218782
...
@@ -51,6 +51,7 @@
...
@@ -51,6 +51,7 @@
#include
"xparameters.h"
#include
"xparameters.h"
#include
"xuartps.h"
#include
"xuartps.h"
#include
"sleep.h"
#include
"sleep.h"
#include
"math.h"
int
main
()
{
int
main
()
{
init_platform
();
init_platform
();
...
@@ -61,33 +62,43 @@ int main() {
...
@@ -61,33 +62,43 @@ int main() {
(
volatile
uint32_t
*
)
(
XPAR_PWM_RECORDER_0_S_AXI_BASEADDR
);
(
volatile
uint32_t
*
)
(
XPAR_PWM_RECORDER_0_S_AXI_BASEADDR
);
volatile
uint32_t
*
pwmGenerate
=
volatile
uint32_t
*
pwmGenerate
=
(
volatile
uint32_t
*
)
(
XPAR_PWM_SIGNAL_OUT_0_S_AXI_BASEADDR
);
(
volatile
uint32_t
*
)
(
XPAR_PWM_SIGNAL_OUT_0_S_AXI_BASEADDR
);
while
(
1
)
{
print
(
"Please connect JB0 and JB1 with an external jumper.
\r\n
When ready, press any button.
\n\r
"
);
while
(
buttonsGPIO
[
0
]
==
0
)
;
print
(
"Thank You :)
\r\n
"
);
print
(
const
int
min_period
=
1000
;
"Please connect JB0 and JB1 with an external jumper.
\r\n
When ready, press any button.
\n\r
"
);
const
int
max_period
=
5
*
1000
*
1000
;
while
(
buttonsGPIO
[
0
]
==
0
)
const
float
period_step_factor
=
1
.
5
;
;
int
period
;
print
(
"Thank You :)
\r\n
"
);
for
(
period
=
min_period
;
period
<
max_period
;
period
*=
period_step_factor
)
{
pwmGenerate
[
0
]
=
50
*
1000
;
pwmGenerate
[
1
]
=
period
/
2
;
pwmGenerate
[
1
]
=
25
*
1000
;
pwmGenerate
[
0
]
=
period
;
int
iteration
;
int
duty_iteration
;
const
int
num_iterations
=
100
;
const
int
num_duty_iterations
=
100
;
for
(
iteration
=
0
;
iteration
<
num_iterations
;
iteration
++
)
{
for
(
duty_iteration
=
0
;
duty_iteration
<
num_duty_iterations
;
pwmGenerate
[
1
]
=
(
iteration
*
pwmGenerate
[
0
])
/
num_iterations
;
duty_iteration
++
)
{
usleep
(
10000
);
pwmGenerate
[
1
]
=
((
duty_iteration
+
1
)
*
pwmGenerate
[
0
])
/
(
num_duty_iterations
+
1
);
int
error
=
pwmRecord
[
0
]
-
pwmGenerate
[
1
];
usleep
(
period
/
25
);
int
abserror
=
error
;
if
(
abserror
<
0
)
{
int
error
=
pwmRecord
[
0
]
-
pwmGenerate
[
1
];
abserror
=
-
error
;
int
abserror
=
(
error
<
0
)
?
-
error
:
error
;
if
(
abserror
>
pwmGenerate
[
0
]
/
1000
)
{
xil_printf
(
"%5d Hz, %3d%% Duty Cycle: %d cycle error
\r\n
"
,
(
50
*
1000
*
1000
/
pwmGenerate
[
0
]),
(
100
*
pwmGenerate
[
1
])
/
pwmGenerate
[
0
],
error
);
}
}
usleep
(
period
/
5
);
}
}
xil_printf
(
"%3d%% Duty Cycle: %c%3d.%08d%% error
\r\n
"
,
(
100
*
pwmGenerate
[
1
])
/
pwmGenerate
[
0
],
(
error
<
0
)
?
'-'
:
' '
,
(
100
*
abserror
)
/
((
int
)
pwmGenerate
[
0
]),
((
10000000000
*
abserror
)
/
((
int
)
pwmGenerate
[
0
]))
%
100000000
);
}
}
cleanup_platform
();
cleanup_platform
();
return
0
;
return
0
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment