Author Topic: Help with L298 + Axon I  (Read 1702 times)

0 Members and 1 Guest are viewing this topic.

Offline HenriqueTopic starter

  • Jr. Member
  • **
  • Posts: 10
  • Helpful? 0
Help with L298 + Axon I
« on: October 14, 2010, 03:57:56 PM »
Hi folks!  ;D
Here is my problem, so if anyone can help I would be glad

I have two motors which will be controlled by my L298,
and i want control them with a variable speed.
But  when i set my new speed to the actuators the motors just
don't make a movement ( and if make is just a little movement),
here is the code:
PS: with or without the "n" the problem persists.

main code:
Code: [Select]
#include "hardware.h" //iopin ,actuators , axon... are included here
// and 2 motors (right and left)  are initilized here too.
#include "movements.h"
#include "controlManual.h"
#include "l298.h" //
//define the type of control
#define manual

void appInitHardware(void){

pin_make_output( E2, false );
pin_make_output( A4, false );
pin_make_output( H2, false );
pin_make_output( A5, false );

uartInit(UART1, 115200);
solarL298Init(&bank1);
rprintfInit(&uart1SendByte);

rprintfProgStrM("System Warmed UP. .Initialization Complete\n");

}
TICK_COUNT appInitSoftware(TICK_COUNT loopStart){

turnOnL298(); // this method turn on the pins of L298
act_setSpeed(&left,DRIVE_SPEED_MAX*0.5);
act_setSpeed(&right,DRIVE_SPEED_MAX*0.5);
return 0;
}
TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart){



    act_setSpeed(&left,DRIVE_SPEED_MAX * n);
    act_setSpeed(&right,DRIVE_SPEED_MAX * n);
// this "n" is like a control of the speed , i want control the speed of
//each motor. and HERE IS THE PROBLEM (i think)!
//*0<=n<=1

    #ifdef manual
 controlManual();
    #endif



    return 1000000;
}

controlManual

Code: [Select]
void controlManual(){ // Get an key from keyboard.then the methods move , back , turn left ,turn
//right ,top , set the PINs true or false, to make the motor spin the way i want.
// Like if i press w, he will move forward then, i set values to my pin
char cByte = GET_DATA_USB;
switch ( cByte ){
case 'w':
move();
front();
break;
case 's':
move();
back();

break;
case 'd':
move();
turnRight();

break;
case 'a':
move();
       turnLeft();

break;
default:
   stop();
}

}

the methods, back , move, turnRight...
Code: [Select]
void front(){

pin_set( E2, false );
pin_set( H2, true );
}
void back(){

pin_set( E2, true );
pin_set( H2, false );
}
void turnRight(){
pin_set( E2, false);
pin_set( H2, false );
}
void turnLeft(){
pin_set( E2, true );
pin_set( H2, true );
}
void stop(){
pin_low( A4 );
pin_low( A5 );
}
void move(){
pin_high( A4 );
pin_high( A5 );
}

sorry my english  :-X
« Last Edit: October 14, 2010, 04:01:39 PM by Henrique »

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Help with L298 + Axon I
« Reply #1 on: October 14, 2010, 04:04:34 PM »
Instead of defining turn right/left/forward, etc by changing pins, do it by using act_setSpeed();

Offline HenriqueTopic starter

  • Jr. Member
  • **
  • Posts: 10
  • Helpful? 0
Re: Help with L298 + Axon I
« Reply #2 on: October 14, 2010, 08:26:54 PM »
hey thanks dude!, another question:
after doing this , i only can go forward with my two motors, how can I go back?

the only comands i can give are like

act_setSpeed(&left,DRIVE_SPEED_MAX);

then he goes forward with the left wheel

but when i use de command

act_setSpeed(&left,DRIVE_SPEED_MIN);

nothing happens.


Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Help with L298 + Axon I
« Reply #3 on: October 14, 2010, 08:40:01 PM »
The command act_setSpeed(&left,DRIVE_SPEED_MIN); *should* make the motor go full speed in reverse . . .

Are you sure you got all the pins matching your wiring?

Offline HenriqueTopic starter

  • Jr. Member
  • **
  • Posts: 10
  • Helpful? 0
Re: Help with L298 + Axon I
« Reply #4 on: October 14, 2010, 09:59:09 PM »
SOLAR_L298_MOTOR left = MAKE_SOLAR_L288_MOTOR(TRUE , E3,E2,A4);

Im using like this:
E3 = L1
E2 = L2
A4 = enable

SOLAR_L298_MOTOR right = MAKE_SOLAR_L298_MOTOR(FALSE, H3, H2,A5 );

H3 = L3
H2 = L4
A5 = ENABLE

based on the datasheet of L298:
http://www.solarbotics.com/assets/datasheets/solarbotics_l298_compact_motor_driver_kit.pdf
page 12
« Last Edit: October 15, 2010, 06:10:41 PM by Henrique »

Offline HenriqueTopic starter

  • Jr. Member
  • **
  • Posts: 10
  • Helpful? 0
Re: Help with L298 + Axon I
« Reply #5 on: October 15, 2010, 08:40:37 PM »
Oh damn you were right !
Now I set point pins as PWM E3 and H3, and A4, A5, C4 and C5 as I / O
the problem was the pin order in time to create the motor also.
anyway Thanks man!! you were helpfull.