Roboard RB-100
PWM pin 24, connect sin, GND. ( without red wire )
Align ESC BL15X
Align Brushless Motor BL250
Motor :
Stop pulse 1000
restart 1300
slow 1200
full speed ?????
!!! figure out pulse range and Throttle power range ...~!!!!!!
讀取 Futaba 2.4G 接收機 Channel 信號..
Channel 4 (Rudder) "美國手"
Code:
unsigned long TransmitterThrottle=0;
unsigned long TransmitterCH4=0;
void setup()
{
Serial.begin(9600);
pinMode ( 9, INPUT);
pinMode (10, INPUT);
clearLCD();
}
void CheckTransmitter()
{
TransmitterThrottle = (pulseIn (9, HIGH, 200000))/10;
TransmitterCH4 = (pulseIn (10, HIGH, 200000));
}
void loop()
{
CheckTransmitter();
clearLCD (); // 清除 LCD 畫面
Serial.print ("pulse= ");
Serial.print (TransmitterThrottle, DEC);
Serial.print (" CH4: ");
Serial.print (TransmitterCH4, DEC );
delay(100);
}
// ===== clear the LCD =====
void clearLCD()
{
Serial.print(12, BYTE);
}
輸出數值:
中立: 1509 ~ 1514
至左: 1381 ~ 1388
至右: 1633 ~ 1639
要先搞清楚這些數值的 跳動 原因 ...
~ 待續 ~
Code:
unsigned long TransmitterThrottle=0;
unsigned long TransmitterCH4=0;
void setup()
{
Serial.begin(9600);
pinMode ( 9, INPUT);
pinMode (10, INPUT);
clearLCD();
}
void CheckTransmitter()
{
TransmitterThrottle = (pulseIn (9, HIGH, 200000))/10;
TransmitterCH4 = (pulseIn (10, HIGH, 200000));
}
void loop()
{
CheckTransmitter();
clearLCD (); // 清除 LCD 畫面
Serial.print ("pulse= ");
Serial.print (TransmitterThrottle, DEC);
Serial.print (" CH4: ");
Serial.print (TransmitterCH4, DEC );
delay(100);
}
// ===== clear the LCD =====
void clearLCD()
{
Serial.print(12, BYTE);
}
輸出數值:
中立: 1509 ~ 1514
至左: 1381 ~ 1388
至右: 1633 ~ 1639
要先搞清楚這些數值的 跳動 原因 ...
~ 待續 ~
讀取 Futaba 2.4G 接收機油門信號..
配件:
Futaba FF9 2.4G 發射器
Futaba R617FS 2.4G 接收器
Arduino Pin 9 連接 接收器 pin 3 信號
11.1V 鋰電 和 Arduino 共地 (GND)
執行結果:顯示數值
油門最低點 110
油門最高點 191
Code:
unsigned long TransmitterThrottle=0;
void setup()
{
pinMode (9, INPUT);
Serial.begin(57600);
Serial.println("System Ready~");
}
void CheckTransmitter()
{
TransmitterThrottle = (pulseIn (9, HIGH, 200000))/10;
}
void loop()
{
CheckTransmitter();
Serial.print ("pulse: ");
Serial.println (TransmitterThrottle);
delay (200);
}
Futaba FF9 2.4G 發射器
Futaba R617FS 2.4G 接收器
Arduino Pin 9 連接 接收器 pin 3 信號
11.1V 鋰電 和 Arduino 共地 (GND)
執行結果:顯示數值
油門最低點 110
油門最高點 191
Code:
unsigned long TransmitterThrottle=0;
void setup()
{
pinMode (9, INPUT);
Serial.begin(57600);
Serial.println("System Ready~");
}
void CheckTransmitter()
{
TransmitterThrottle = (pulseIn (9, HIGH, 200000))/10;
}
void loop()
{
CheckTransmitter();
Serial.print ("pulse: ");
Serial.println (TransmitterThrottle);
delay (200);
}
Stepper motor 步進馬達的控制:
步進馬達的控制:
把老舊的 彩色印表機拆了,
發現裡面有一顆步進馬達,
使用 Arduino 接上馬達的4條線,
我使用了 pin 9~12,
輕易控制馬達前進後退和速度..
Code:
#include
const int stepsPerRevolution = 100;
Stepper myStepper(stepsPerRevolution, 9,10,11,12);
void setup() {
myStepper.setSpeed(100);
Serial.begin(9600);
}
void loop() {
Serial.println("clockwise");
myStepper.step(stepsPerRevolution * 10);
delay(500);
Serial.println("counterclockwise");
myStepper.step(-stepsPerRevolution * 10 );
delay(500);
}
影片:
把老舊的 彩色印表機拆了,
發現裡面有一顆步進馬達,
使用 Arduino 接上馬達的4條線,
我使用了 pin 9~12,
輕易控制馬達前進後退和速度..
Code:
#include
const int stepsPerRevolution = 100;
Stepper myStepper(stepsPerRevolution, 9,10,11,12);
void setup() {
myStepper.setSpeed(100);
Serial.begin(9600);
}
void loop() {
Serial.println("clockwise");
myStepper.step(stepsPerRevolution * 10);
delay(500);
Serial.println("counterclockwise");
myStepper.step(-stepsPerRevolution * 10 );
delay(500);
}
影片:
無刷馬達的控制..
在這個學習中使用了搖控直升機的 無刷馬達和電子變速器(ESC)
使用材料:
Align ESC BL15X
Align BL250 Brushless motor
動作說明:
提升馬達速度, 降低馬達速度, 暫停..
Code:
#include
Servo myservo;
void setSpeed(int speed)
{
int val = map(speed, 0, 100, 0, 180);
myservo.write(val);
}
void setup()
{
Serial.begin(115200);
myservo.attach(9);
}
void loop()
{
Serial.println("System Ready !!! Hit the 1 ");
do{ if ( Serial.read() == '1' ) break; } while(1);
int speed;
Serial.println("Throttle up");
for(speed = 37; speed <= 90; speed += 1) { setSpeed(speed); Serial.println(speed); delay(100); } setSpeed(30); delay(1000); Serial.println("Throttle down"); for(speed = 90; speed > 37; speed -= 1) {
setSpeed(speed);
Serial.println(speed);
delay(100);
}
Serial.println("waiting for 5 sec...");
setSpeed(30);
delay(5000);
}
//=============================
另外也可以用程式..取代使用遙控器油門設定電變(ESC)的方式
例如電變的 緩啟動, 煞車模式, 截止電壓...等..
依照不同廠商生產不同的電變而有所差異..
Code:
// 程式設定ESC 狀態
void AdjustESC ()
{
//plug ESC Battery first, when ESC start music ready, enter "1" in serial window
Serial.println("Enter Setup Mode");
do{ if ( Serial.read() == '1' ) break;
setSpeed(90);
} while(1);
delay ( 2000 );
setSpeed(30);
// waiting for ESC edit mode music and into brake edit mode,
// then enter "1" in serial window
Serial.println("Break Mode - soft Brake");
do{ if ( Serial.read() == '1' ) break; } while(1);
setSpeed(50);
Serial.println("Electronic Timing -Mid timing");
do{ if ( Serial.read() == '1' ) break; } while(1);
setSpeed(50);
Serial.println("Battery Protection - High cut off voltage protection");
do{ if ( Serial.read() == '1' ) break; } while(1);
setSpeed(30);
Serial.println("Aircraft Mode - normal airplane");
do{ if ( Serial.read() == '1' ) break; } while(1);
setSpeed(30);
Serial.println("Throttle response speed - Quick speed");
do{ if ( Serial.read() == '1' ) break; } while(1);
setSpeed(90);
Serial.println("BEC output voltage - 5.5V");
do{ if ( Serial.read() == '1' ) break; } while(1);
setSpeed(50);
}
影片:
使用材料:
Align ESC BL15X
Align BL250 Brushless motor
動作說明:
提升馬達速度, 降低馬達速度, 暫停..
Code:
#include
Servo myservo;
void setSpeed(int speed)
{
int val = map(speed, 0, 100, 0, 180);
myservo.write(val);
}
void setup()
{
Serial.begin(115200);
myservo.attach(9);
}
void loop()
{
Serial.println("System Ready !!! Hit the 1 ");
do{ if ( Serial.read() == '1' ) break; } while(1);
int speed;
Serial.println("Throttle up");
for(speed = 37; speed <= 90; speed += 1) { setSpeed(speed); Serial.println(speed); delay(100); } setSpeed(30); delay(1000); Serial.println("Throttle down"); for(speed = 90; speed > 37; speed -= 1) {
setSpeed(speed);
Serial.println(speed);
delay(100);
}
Serial.println("waiting for 5 sec...");
setSpeed(30);
delay(5000);
}
//=============================
另外也可以用程式..取代使用遙控器油門設定電變(ESC)的方式
例如電變的 緩啟動, 煞車模式, 截止電壓...等..
依照不同廠商生產不同的電變而有所差異..
Code:
// 程式設定ESC 狀態
void AdjustESC ()
{
//plug ESC Battery first, when ESC start music ready, enter "1" in serial window
Serial.println("Enter Setup Mode");
do{ if ( Serial.read() == '1' ) break;
setSpeed(90);
} while(1);
delay ( 2000 );
setSpeed(30);
// waiting for ESC edit mode music and into brake edit mode,
// then enter "1" in serial window
Serial.println("Break Mode - soft Brake");
do{ if ( Serial.read() == '1' ) break; } while(1);
setSpeed(50);
Serial.println("Electronic Timing -Mid timing");
do{ if ( Serial.read() == '1' ) break; } while(1);
setSpeed(50);
Serial.println("Battery Protection - High cut off voltage protection");
do{ if ( Serial.read() == '1' ) break; } while(1);
setSpeed(30);
Serial.println("Aircraft Mode - normal airplane");
do{ if ( Serial.read() == '1' ) break; } while(1);
setSpeed(30);
Serial.println("Throttle response speed - Quick speed");
do{ if ( Serial.read() == '1' ) break; } while(1);
setSpeed(90);
Serial.println("BEC output voltage - 5.5V");
do{ if ( Serial.read() == '1' ) break; } while(1);
setSpeed(50);
}
影片:
訂閱:
文章 (Atom)