步驟1:附件
所需的附件是:
框架
Arduino UNO R3主板
擴展板
電機驅動模塊
PS2無線控制器SONY(模型遙控器或槍支遙控器)
鋰聚合物電池(Li-Po 2S)
步驟2:轉向杯和變速箱軸
每個附件是2套,可以組裝2套,然后在底盤上安裝。
黑色轉向杯x 2
旋轉軸x 2
軸承x 4(內(nèi)側4外側8mm,內(nèi)側8外側12mm)
銷x 2
六角形x 2
車輪x 2
M4防松螺母x 2
65mm車輪x 2
步驟3:安裝伺服配件
將L形支架固定在伺服系統(tǒng)上,注意到括號的長度(紅色圓圈)。在轉向器上安裝轉向角之前,請先將其對準90°(1500μs),以方便后續(xù)安裝和調試。
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
齒輪材料:金屬
控制系統(tǒng):更改脈沖寬度
伺服接線:數(shù)字端口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模數(shù)54齒x 1
步驟8:電機固定
首先將電動機固定到大支架,然后再固定到機架。支架用M3螺釘固定。電動機固定在支架上,可以調節(jié)電動機的左右位置以設置齒輪的緊度。
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寬電壓輸入,連續(xù)電流可達到17A,支持100%脈寬調制。該模塊通過方向DIR引腳和速度控制PWM引腳實現(xiàn)電動機的正向,反向和速度控制。
控制端子支持1.8V-5V邏輯輸入,驅動器IC集成了PWM電流調節(jié)功能,限制了電機浪涌電流。 SLP引腳的低電平允許MD01驅動器模塊進入低功耗模式,從而導致大約9uA的低靜態(tài)電流消耗。
注: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);
}
記住在控制時先打開發(fā)射機
#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瀏覽量
23778 -
Arduino
+關注
關注
188文章
6474瀏覽量
187424
發(fā)布評論請先 登錄
相關推薦
評論