步骤1:附件
所需的附件是:
框架
Arduino UNO R3主板
扩展板
电机驱动模块
PS2无线控制器SONY(模型遥控器或枪支遥控器)
锂聚合物电池(Li-Po 2S)
步骤2:转向杯和变速箱轴
每个附件是2套,可以组装2套,然后在底盘上安装。
黑色转向杯x 2
旋转轴x 2
轴承x 4(内侧4外侧8mm,内侧8外侧12mm)
销x 2
六角形x 2
车轮x 2
M4防松螺母x 2
65mm车轮x 2
步骤3:安装伺服配件
将L形支架固定在伺服系统上,注意到括号的长度(红色圆圈)。在转向器上安装转向角之前,请先将其对准90°(1500μs),以方便后续安装和调试。
M2.5 x 10mm螺钉x 1
M3 x 6mm螺丝x 1
M3 x 8mm螺丝x 4
M2.5防松螺母x 1
M3螺母x 4
MG996R伺服x 1
球头操纵杆(短)x 1
舵角x 1
L型支架x 1
名称:MG996R
电压:4.8-7.2V
电流:400-800MA
转向器扭矩:10kg.cm
极端角度:180°
电线长度:30CM
齿轮材料:金属
控制系统:更改脉冲宽度
伺服接线:数字端口I/O4
步骤4:连接2个侧面转向杯
长连杆在上孔中,连接两个侧转向杯;短连杆位于下孔中,方向盘连接在一侧,舵角连接在另一侧,长连杆和短连杆不在同一孔位置。
长连杆孔间距65mm,短连杆孔间距46mm,如有偏差,可进行微调。
M2.5 x 10mm螺钉x 3
长短连杆x 2
步骤5:扁平前部
之前安装时,请确保底盘正反,向上弯曲并将先前装备的转向器和转向杯固定到底盘上。转向盘通过铜柱支撑固定在两侧,塑料缸放置在转向盘下方(前后高度一致),不能拧紧转向盘固定螺钉,以确保转向灵活。
机箱x 1
M3 x 26毫米铜柱x 4
M2.5 x 8毫米螺钉x 2(向上)
M2.5 x 12mm螺丝x 2(向下)
M3 x 8mm螺丝x 12
M3螺母x 4
黑色圆柱x 2(红色框)
步骤6:后轮差速器部分
最后需要固定后轮座。首先将驱动轴固定在输出轴上。后轮的安装方式与前轮类似;后轮座椅安装在左右两侧, *顶部R安装在左侧,标准L安装在右侧。
下支架是Z形结构。安装时要注意方向,靠近差速器箱宽度,并且轮距很窄。如果不清楚,则可以与图中的视角保持一致。上支架固定需要卸下螺钉才能安装。
差x 1
传动轴x 2
三角支架x 4
Z型支架x 4
后轮座x 2
轴承x 4
六角适配器x 2
销钉x 2
铝制圆柱体x 2(固定在上支架(三角形)和后轮座之间)
65mm车轮x 2
M2 x 12mm螺丝x 2
M2防松螺母x 2
M2.5 x 16mm螺丝x 4
M2.5 x 25mm螺丝x 2
M2.5 x 30mm螺丝x 2
M2.5防松螺母x 8
M4 Locknut x 2
步骤7:将差速器箱固定到机箱上
将铜齿轮安装到输入轴上减速齿轮箱,将锁紧螺钉固定在D型平面上,用L型扳手将其紧固,然后将差速器箱固定在底盘上
M2.5 x 8mm螺钉x 4
齿轮圈0.5模数54齿x 1
步骤8:电机固定
首先将电动机固定到大支架,然后再固定到机架。支架用M3螺钉固定。电动机固定在支架上,可以调节电动机的左右位置以设置齿轮的紧度。
M2.5 x 5mm螺钉x 2(平头螺钉)
M3 x 6mm螺钉x 3(带垫圈)
L型电动机支架
RS380直流电动机
参数:
工作电压范围:3.0-9.0V
额定电压:7.2V
空载速度:16200rpm
空载电流:0.50A
额定速度:14000rpm
最大电流:3.29A
额定扭矩:110g.cm
额定功率:15.8W
启动扭矩:840g.cm
电极的红点为正。
步骤9:上部机箱安装(丙烯酸)
上部机箱由丙烯酸材料制成,并集成了Arduino UNO和Raspberry Pi孔,并安装了Rocker开关在矩形孔中
M3 x 8mm螺钉x 9
M3 x 35mm铜柱x 5
Rocker Switch x 1
丙烯酸x 1
步骤10:防撞棉
红色圆圈是铜柱固定孔,保险杠棉被垫圈压住了
M3 x 8mm螺钉x 8
M3垫片x 4
M3 x 16mm铜柱x 4
防碰撞棉x 1
步骤11:电动机驱动模块
MD01电机驱动器由单个H桥驱动器IC和四个外部N沟道MOS晶体管组成。其体积小巧(长*宽:3.3 * 2cm),主板支持5.9V至30V宽电压输入,连续电流可达到17A,支持100%脉宽调制。该模块通过方向DIR引脚和速度控制PWM引脚实现电动机的正向,反向和速度控制。
控制端子支持1.8V-5V逻辑输入,驱动器IC集成了PWM电流调节功能,限制了电机浪涌电流。 SLP引脚的低电平允许MD01驱动器模块进入低功耗模式,从而导致大约9uA的低静态电流消耗。
注:SLP低功耗模式下,默认为低电平,使用时需要保持SLP引脚为高电平,如果不需要使用低功耗模式,则可以直接连接+ 5V。
工作电压:5.9-13V
工作电流:17A
逻辑输入:1.8V,3.3V,5V(max)
PWM频率:100kHz
电流检测:50mV/A(仅在正向或反向时有效)
反射电压保护:无(VM和GND不得反向)
步骤12:遥控器(2.4Ghz)
2.4Ghz遥控器我们使用Sony的PS2也可以使用RC模型控制器;如果您有电子调速器,可能不需要Arduino UNO即可加入,但我们正在学习使用Arduino。
手柄配有适配器板,以方便接线和反向连接保护。该接口从最下面开始: GND VCC DAT CMD CS CLK
/****************************************************************************
* The program controls the forward and backward
* movement of the motor through the Y-axis of the left joystick,
* the X-axis of the right joystick controls the left and right of the servo,
* the button part also writes forward and backward,
* and the right button controls the left and right.
*****************************************************************************/
#include
#include
//for v1.6
PS2X ps2x;
Servo myservo;
#define PS2_DAT A0
#define PS2_CMD A1 //PS2
#define PS2_SEL A2
#define PS2_CLK A3
#define PWM 5 //Motor A‘s pin
#define DIR 6 //Motor A’s pin
#define SERVOPIN 4 //servo‘s pin
#define SERVOMIN 40 //the angle of servo
#define SERVOMID 90
#define SERVOMAX 130
#define TURNLEFT myservo.write(SERVOMIN) //turn left
#define TURNMID myservo.write(SERVOMID) //turn middle
#define TURNRIGHT myservo.write(SERVOMAX) //turn right
#define MOTORFOWARD setMotor(100) //motor forward PWM
#define MOTORBACK setMotor(-100) //motor back PWM
#define MOTORSTOP setMotor(0) //motor stop PWM
bool EnableRockerR = 1;
bool EnableRockerL = 1;
int RMid = 0 ;
int LStop = 0 ;
#define pressures false
#define rumble false
int error = 0;
byte type = 0;
byte vibrate = 0;
void(* resetFunc) (void) = 0;
void setup() {
Serial.begin(57600);
pinMode(PWM, OUTPUT);
pinMode(DIR, OUTPUT);
myservo.attach(SERVOPIN);
SERVOMID;
delay(300);
error = ps2x.config_gamepad(PS2_CLK, PS2_CMD, PS2_SEL, PS2_DAT, pressures, rumble);
if (error == 0) {
Serial.print(“Found Controller, configured successful ”);
Serial.print(“pressures = ”);
if (pressures)
Serial.println(“true ”);
else
Serial.println(“false”);
Serial.print(“rumble = ”);
if (rumble)
Serial.println(“true)”);
else
Serial.println(“false”);
Serial.println(“Try out all the buttons, X will vibrate the controller, faster as you press harder;”);
Serial.println(“holding L1 or R1 will print out the analog stick values.”);
Serial.println(“Note: Go to www.billporter.info for updates and to report bugs.”);
}
else if (error == 1)
Serial.println(“No controller found, check wiring, see readme.txt to enable debug. visit www.billporter.info for troubleshooting tips”);
else if (error == 2)
Serial.println(“Controller found but not accepting commands. see readme.txt to enable debug. Visit www.billporter.info for troubleshooting tips”);
else if (error == 3)
Serial.println(“Controller refusing to enter Pressures mode, may not support it. ”);
type = ps2x.readType();
switch (type) {
case 0:
Serial.print(“Unknown Controller type found ”);
break;
case 1:
Serial.print(“DualShock Controller found ”);
break;
case 2:
Serial.print(“GuitarHero Controller found ”);
break;
case 3:
Serial.print(“Wireless Sony DualShock Controller found ”);
break;
}
}
void loop() {
if (error == 1) //skip loop if no controller found
resetFunc();
ps2x.read_gamepad(false, vibrate); //read controller and set large motor to spin at ’vibrate‘ speed
if (ps2x.Button(PSB_START)) //will be TRUE as long as button is pressed
Serial.println(“Start is being held”);
if (ps2x.Button(PSB_SELECT))
Serial.println(“Select is being held”);
if (ps2x.ButtonPressed(PSB_PAD_UP)) {
Serial.println(“PAD_UP just pressed”);
MOTORFOWARD;
EnableRockerL = 0;
}else if(ps2x.ButtonReleased(PSB_PAD_UP)) {
Serial.println(“ PAD_UP just released”);
MOTORSTOP;
EnableRockerL = 1;
LStop = 0;
}
if (ps2x.ButtonPressed(PSB_PAD_DOWN)) {
Serial.println(“PAD_DOWN just pressed”);
MOTORBACK;
EnableRockerL = 0;
}else if(ps2x.ButtonReleased(PSB_PAD_DOWN)) {
Serial.println(“ PAD_DOWN just released”);
MOTORSTOP;
EnableRockerL = 1;
LStop = 0;
}
if (EnableRockerL) { //Forward and Back
if (0 《= ps2x.Analog(PSS_LY) && ps2x.Analog(PSS_LY) 《= 110) {
digitalWrite(DIR, HIGH);
analogWrite(PWM, map(ps2x.Analog(PSS_LY), 0, 110, 255,0));
LStop = 0;
} else if (255 》= ps2x.Analog(PSS_LY) && ps2x.Analog(PSS_LY) 》= 140) {
digitalWrite(DIR, LOW);
analogWrite(PWM, map(ps2x.Analog(PSS_LY), 140, 255, 0,255));
LStop = 0;
} else {
if(LStop == 0){
MOTORSTOP;
LStop ++;
}
}
}
if (ps2x.ButtonPressed(PSB_CIRCLE)) { //will be TRUE if button was JUST pressed
Serial.println(“Circle just pressed”);
TURNRIGHT;
EnableRockerR = 0;
} else if (ps2x.ButtonReleased(PSB_CIRCLE)) {
Serial.println(“Circle just released”);
TURNMID;
EnableRockerR = 1;
RMid = 0;
}
if (ps2x.ButtonPressed(PSB_SQUARE)) { //will be TRUE if button was JUST released
Serial.println(“Square just pressed”);
TURNLEFT;
EnableRockerR = 0;
} else if (ps2x.ButtonReleased(PSB_SQUARE)) { //will be TRUE if button was JUST released
Serial.println(“Square just released”);
TURNMID;
EnableRockerR = 1;
RMid = 0;
}
if (EnableRockerR) { //Left and Right
if (0 《= ps2x.Analog(PSS_RX) && ps2x.Analog(PSS_RX) 《= 110) {
myservo.write(map(ps2x.Analog(PSS_RX), 0, 110, 40,90));
RMid = 0;
} else if (255 》= ps2x.Analog(PSS_RX) && ps2x.Analog(PSS_RX) 》= 140) {
myservo.write(map(ps2x.Analog(PSS_RX), 140, 255, 90,130));
RMid = 0;
}else {
if(RMid == 0){
TURNMID;
RMid ++;
}
}
}
if (ps2x.NewButtonState(PSB_CROSS)) { //will be TRUE if button was JUST pressed OR released
Serial.println(“X just changed”);
MOTORSTOP;
}
delay(50);
}
void setMotor(int Speed) //Motor drive function
{
if (Speed 》 0)
{
digitalWrite(DIR, HIGH);
analogWrite(PWM, Speed);
}
else if(Speed 《 0){
digitalWrite(DIR, LOW);
analogWrite(PWM, -Speed);
}else{
digitalWrite(PWM, LOW);
digitalWrite(DIR, LOW);
}
}
步骤13:RC接收器(FS-TH9X)
如果使用模型遥控器,则可以按以下方式控制机器人。我只是用中断编写了一些代码,如果需要,您可以对其进行改进并使其更好。我正在使用FS-TH9X。我正在使用左右油门。为了返回,我使用右操纵杆来控制机器人的前进和后退运动。当我居中时,我停下来。左操纵杆控制左右转向。对我来说,它可能会被使用。不习惯,如果您需要FS-TH9X信息,请Google。
我使用CH3(油门)和CH4(方向)。接线时易于使用。可以为接收器提供5v和GND。使用Arduino UNO上的5V引脚。也许UNO可能提供的不足。该电流用于维持接收器和伺服器的正常运行。此时,您需要一个外部电源为伺服器或接收器供电。当然,您需要接地。
布线:
CH3 》》 Arduino I/O2
CH4 》》 Arduino I/O3
//The two channels of the receiver are connected to the
//digital port 2 and 3 of the arduino respectively.
int ppm1 = 2;
int ppm2 = 3;
unsigned long rc1_PulseStartTicks,rc2_PulseStartTicks;
volatile int rc1_val, rc2_val;
void setup() {
Serial.begin(9600);
pinMode(ppm1, INPUT); //PPM inputs from RC receiver
pinMode(ppm2, INPUT);
attachInterrupt(0, rc1, CHANGE); // Level change trigger interrupt
attachInterrupt(1, rc2, CHANGE);
}
void rc1(){
// did the pin change to high or low?
if (digitalRead( ppm1 ) == HIGH)
rc1_PulseStartTicks = micros(); // store the current micros() value
else
rc1_val = micros() - rc1_PulseStartTicks;
}
void rc2(){
// did the pin change to high or low?
if (digitalRead( ppm2 ) == HIGH)
rc2_PulseStartTicks = micros();
else
rc2_val = micros() - rc2_PulseStartTicks;
}
void loop() {
Serial.print(“CH1: ”);Serial.print(rc1_val); Serial.print(“ ”);//print values
Serial.print(“CH2: ”);Serial.println(rc2_val);
delay(200);
}
记住在控制时先打开发射机
#include
Servo myservo;
//The two channels of the receiver are connected to the digital port 2 and 3 of the arduino respectively.
int ppm1 = 2;
int ppm2 = 3;
int servo = 4; //Servo pin
int PWM = 5; //Motor pin
int DIR = 6; //Motor pin
unsigned long rc1_PulseStartTicks,rc2_PulseStartTicks;
volatile int rc1_val, rc2_val;
void setup() {
Serial.begin(9600);
pinMode(DIR ,OUTPUT);
pinMode(PWM ,OUTPUT);
myservo.attach(servo);
pinMode(ppm1, INPUT); //PPM inputs from RC receiver
pinMode(ppm2, INPUT);
attachInterrupt(0, rc1, CHANGE); // Level change trigger interrupt
attachInterrupt(1, rc2, CHANGE);
}
void rc1(){
// did the pin change to high or low?
if (digitalRead( ppm1 ) == HIGH)
rc1_PulseStartTicks = micros(); // store the current micros() value
else
rc1_val = micros() - rc1_PulseStartTicks;
}
void rc2(){
// did the pin change to high or low?
if (digitalRead( ppm2 ) == HIGH)
rc2_PulseStartTicks = micros();
else
rc2_val = micros() - rc2_PulseStartTicks;
}
void loop() {
if(rc1_val 《 1100){ rc1_val = 1100; }
if(rc1_val 》 1900){ rc1_val = 1900; }
if(rc2_val 《 1100){ rc2_val = 1100; }
if(rc2_val 》 1850){ rc2_val = 1850; }
if(rc1_val 》= 1100 && rc1_val 《= 1490)
{
digitalWrite(DIR ,LOW);
analogWrite(PWM,map(rc1_val,1100,1490,255,0));
}
else if(rc1_val 》= 1510 && rc1_val 《= 1900)
{
digitalWrite(DIR ,HIGH);
analogWrite(PWM,map(rc1_val,1510,1900,0,255));
}else{
digitalWrite(PWM, LOW);
digitalWrite(DIR, LOW);
}
if(rc2_val 》= 1100 && rc2_val 《= 1490)
{
myservo.write(map(rc2_val,1100,1490,40,89));
}
else if(rc2_val 》= 1510 && rc2_val 《= 1850)
{
myservo.write(map(rc2_val,1510,1850,91,130));
}
delay(15);
}
责任编辑:wv
-
遥控车
+关注
关注
9文章
81浏览量
23713 -
Arduino
+关注
关注
188文章
6469浏览量
186969
发布评论请先 登录
相关推荐
评论