Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ICRE - ESP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
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
Ricardo Andres Ercoli Auersperg
ICRE - ESP
Commits
760178d9
Commit
760178d9
authored
2 years ago
by
RicardoEA
Browse files
Options
Downloads
Patches
Plain Diff
Change main to move one wheel forward and backward
parent
152731ca
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Robotito/src/main.c
+19
-66
19 additions, 66 deletions
Robotito/src/main.c
with
19 additions
and
66 deletions
Robotito/src/main.c
+
19
−
66
View file @
760178d9
...
...
@@ -16,12 +16,15 @@
#include
"motors.h"
#include
"encoders.h"
#include
"hwTimer.h"
#include
"control.h"
#define OMNI_CTRL_TIMER 0.05 // s
#define MAX_OUTPUT 100.0
#define NMOTORS 3
#define OMNI_NRO_TIMER 0
static
void
timer_func
()
{
printf
(
"ECHO TIMER
\n
"
);
}
...
...
@@ -29,85 +32,35 @@ static void timer_func() {
void
app_main
(
void
)
{
//1. mcpwm gpio initialization
//1. mcpwm gpio initialization
motor_h_t
*
mot
;
motor_install
(
27
,
26
,
MCPWM_UNIT_0
,
MCPWM0A
,
MCPWM0B
,
MCPWM_TIMER_0
,
&
mot
);
motor_install
(
26
,
27
,
MCPWM_UNIT_0
,
MCPWM0A
,
MCPWM0B
,
MCPWM_TIMER_0
,
&
mot
);
// pines de los motores
// Motor 0: 26,27 Encoder 0: 37, 39
// Motor 1: 25,33 Encoder 1: 36, 38
// Motor 2: 18,23 Encoder 2: 34, 35
//2. initial mcpwm configuration
printf
(
"Configuring Initial Parameters of mcpwm...
\n
"
);
motor_start
(
mot
);
//Configure PWM0A & PWM0B with above settings
int
inc
=
25
;
while
(
1
)
{
if
(
inc
==
20
){
motor_start
(
mot
);
}
printf
(
"Vel %i
\n
"
,
inc
);
int
inc
=
10
;
while
(
1
)
{
motor_set_speed
(
mot
,
inc
);
vTaskDelay
(
2000
/
portTICK_RATE_MS
);
motor_stop
(
mot
);
vTaskDelay
(
2000
/
portTICK_RATE_MS
);
motor_set_speed
(
mot
,
-
inc
);
vTaskDelay
(
2000
/
portTICK_RATE_MS
);
motor_stop
(
mot
);
vTaskDelay
(
2000
/
portTICK_RATE_MS
);
inc
++
;
if
(
inc
==
30
){
motor_stop
(
mot
);
inc
=
20
;
printf
(
"Reseting vel ...
\n
"
);
}
}
}
/*
static void callback_enc_func(int i_callback, int8_t dir, uint32_t counter) {
printf("motor %i, dir %i, counter %i\n", i_callback, dir, counter);
}
void app_main(void)
{
encoder_h_t *encoder;
encoder_setup(37,39,&encoder);
encoder_register_callback(encoder, callback_enc_func, 0, 1);
int cnt = 0;
while(1) {
printf("cnt: %d\n", cnt++);
vTaskDelay(10000 / portTICK_RATE_MS);
if (!(cnt % 10)){
printf("Minimum free heap size: %d bytes\n", esp_get_minimum_free_heap_size());
inc
=
10
;
}
}
}
static void mcpwm_example_brushed_motor_control(void *arg)
{
//1. mcpwm gpio initialization
motor_h_t *mot;
motor_install(27,26, MCPWM_UNIT_0, MCPWM0A, MCPWM0B, MCPWM_TIMER_0, &mot);
//2. initial mcpwm configuration
printf("Configuring Initial Parameters of mcpwm...\n");
motor_start(mot); //Configure PWM0A & PWM0B with above settings
int inc = 25;
while (1) {
printf("Vel %i\n", inc);
motor_set_speed(mot, inc);
vTaskDelay(2000 / portTICK_RATE_MS);
motor_set_speed(mot, -inc);
vTaskDelay(2000 / portTICK_RATE_MS);
inc++;
if (inc == 10){
inc = 0;
printf("Reseting vel ...\n");
}
}
}
*/
\ No newline at end of file
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