Skip to content
Snippets Groups Projects
Commit 760178d9 authored by RicardoEA's avatar RicardoEA
Browse files

Change main to move one wheel forward and backward

parent 152731ca
No related branches found
No related tags found
No related merge requests found
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment