FUNCIONAMIENTO TARJETA XMOTION
Este directorio de archivos principal debe estar dentro de Documentos / Arduino / bibliotecas.
Paginas de Interes
https://www.jsumo.com/xmotion-all-in-one-controller
https://www.jsumo.com/xmotion
https://blog.jsumo.com/xmotion-basics-xmotion-101/
http://blog.jsumo.com/how-to-make-mini-sumo-robot-with-xmotion/
SINTAXIS PARA TARJETA XMOTION
#define RM_DIR 13
#define RM_PWM 11
#define LM_DIR 12
#define LM_PWM 3
#define TP A3 //Trimpot
#define VI A0 //Trimpot
#define UL1 8 //User Led1
#define UL2 9 //User Led2
Tipo de dato (KEYWORD1) PALABRA CLAVE1
xmotion KEYWORD1
robotarm KEYWORD1
RobotArmClass KEYWORD1
Methods and Functions // Metodos y funciones(KEYWORD2)
Instruccion Significado Explicación Codigo
Forward Avanzar void Forward(byte speed, int time);
void XMotionClass::Forward(byte speed, int Time){
speed = constrain(speed,0,100);
speed = map(speed,0,100,0,255);
digitalWrite(RM_DIR,HIGH);
digitalWrite(LM_DIR,HIGH);
analogWrite(RM_PWM, speed);
analogWrite(LM_PWM, speed);
delay(Time);
}
Backward Retroceder void Backward(byte speed, int time);
void XMotionClass::Backward(byte speed, int Time){
speed = constrain(speed,0,100);
speed = map(speed,0,100,0,255);
digitalWrite(RM_DIR,LOW);
digitalWrite(LM_DIR,LOW);
analogWrite(LM_PWM, speed);
analogWrite(RM_PWM, speed);
delay(Time);
}
Right0 Derecha void Right0(byte speed, int time);
void XMotionClass::Right0(byte speed, int Time){
speed = constrain(speed,0,100);
speed = map(speed,0,100,0,255);
digitalWrite(RM_DIR,LOW);
digitalWrite(LM_DIR,HIGH);
analogWrite(RM_PWM, speed);
analogWrite(LM_PWM, speed);
delay(Time);
}
Left0 Izquierda void Left0(byte speed, int time);
void XMotionClass::Left0(byte speed, int Time){
speed = constrain(speed,0,100);
speed = map(speed,0,100,0,255);
digitalWrite(RM_DIR,HIGH);
digitalWrite(LM_DIR,LOW);
analogWrite(RM_PWM, speed);
analogWrite(LM_PWM, speed);
delay(Time);
}
MotorControl Control del Motor void MotorControl(int LeftSpeed, int RightSpeed);
void XMotionClass::MotorControl(int RightMotorPwm, int
LeftMotorPwm) {
if (RightMotorPwm <= 0) {
RightMotorPwm = abs(RightMotorPwm);
digitalWrite(RM_DIR, LOW);
analogWrite(RM_PWM, RightMotorPwm);
}
else {
digitalWrite(RM_DIR, HIGH);
analogWrite(RM_PWM, RightMotorPwm);
}
if (LeftMotorPwm <= 0) {
LeftMotorPwm = abs(LeftMotorPwm);
digitalWrite(LM_DIR, LOW);
analogWrite(LM_PWM, LeftMotorPwm);
}
else {
digitalWrite(LM_DIR, HIGH);
analogWrite(LM_PWM, LeftMotorPwm);
}
}
StopMotors Detener motores void StopMotors(int time);
void XMotionClass::StopMotors(int Time){
analogWrite(RM_PWM, 0);
analogWrite(LM_PWM, 0);
delay(Time);
}
ArcTurn Vuelta de arco void ArcTurn(byte LeftSpeed, byte RightSpeed, int Time);
void XMotionClass::ArcTurn(byte LeftSpeed, byte
RightSpeed, int Time){
LeftSpeed = constrain(LeftSpeed,0,100);
LeftSpeed = map(LeftSpeed,0,100,0,255);
RightSpeed = constrain(RightSpeed,0,100);
RightSpeed = map(RightSpeed,0,100,0,255);
digitalWrite(RM_DIR,HIGH);
digitalWrite(LM_DIR,HIGH);
analogWrite(RM_PWM, RightSpeed);
analogWrite(LM_PWM, LeftSpeed);
delay(Time);
}
VoltageIn Voltaje de Entrada float VoltageIn();
float XMotionClass::VoltageIn(){
int Total=0;
for (int x = 0; x <10; x=x+1){
int sensorValue = analogRead(A0);
Total=Total+sensorValue;
delay(1);
}
return Total * 0.8021* (5.0 / 1023.0);
}
LipoCutOff Corte de Energia de void LipoCutOff(int Cell);
Bateria
void XMotionClass::LipoCutOff(int Cell){
Serial.begin(9600);
delay(300);
float CellVoltage = xmotion.VoltageIn() / Cell;
if (CellVoltage < 3.6) {
while (1) {
xmotion.ToggleLeds(80);
}
Serial.print("Low Battery");
Serial.print(CellVoltage);
} else {
Serial.print("OK");
}
}
Trimpot Potenciometro Un pequeño potenciómetro int Trimpot();
utilizado para hacer pequeños
ajustes al valor de resistencia o int XMotionClass::Trimpot(){
voltaje en un circuito electrónico. return analogRead(TP);
}
ToggleLeds Encender y apaar Se especifica el tiempo que va a void ToggleLeds(int Time);
ambos leds estar encendido los leds, el tiempo
de la línea de código es dos veces void XMotionClass::ToggleLeds(int Time){
el tiempo asignado. digitalWrite(UL1,HIGH);
digitalWrite(UL2,LOW);
delay(Time);
digitalWrite(UL2,HIGH);
digitalWrite(UL1,LOW);
delay(Time);
digitalWrite(UL1,LOW);
digitalWrite(UL2,LOW);
}
CounterLeds Contador void CounterLeds(int Time, int countx);
void XMotionClass::CounterLeds(int Time, int countx){
for (int i=0; i < countx; i++){ //
xmotion.ToggleLeds(Time/2); //
}
}
Receive Recibir
UserLed1 Led 1 void UserLed1(int Time);
void XMotionClass::UserLed1(int Time){
digitalWrite(UL1,HIGH);
delay(Time);
digitalWrite(UL1,LOW);
delay(Time);
}
UserLed2 Led 2 void UserLed2(int Time);
void XMotionClass::UserLed2(int Time){
digitalWrite(UL2,HIGH);
delay(Time);
digitalWrite(UL2,LOW);
delay(Time);
}
SaveToMemor Guardar en memoria
y
RepeatMemory Repetir memoria
GetPot1 Recibe puerto 1
GetPot2
GetPot3
Move Mover byte mode();
ReadServo1 Leer servo 1
ReadServo2
ReadServo3
ReadServo4
MoveServo1 Mover servo 1
MoveServo2
MoveServo3
MoveServo4
GetPot1Angle
GetPot2Angle
GetPot3Angle
GetButton bool GetButton();
GetButton2
ServoPin Pin del servo