Funcionamiento Tarjeta Xmotion
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
xmotion KEYWORD1
robotarm KEYWORD1
RobotArmClass KEYWORD1
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);
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);
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);
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);
}
ArcTurn Vuelta de arco void 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);
GetButton2
ServoPin Pin del servo