WIP: snapshot before repo migration
This commit is contained in:
25
jxbeye/lib/FTServo/examples/SCSCL/Broadcast/Broadcast.ino
Normal file
25
jxbeye/lib/FTServo/examples/SCSCL/Broadcast/Broadcast.ino
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
广播写例子在SCS15中测试通过,如果测试其它型号SCS系列舵机请更改合适的位置、速度与延时参数。
|
||||
*/
|
||||
|
||||
#include <SCServo.h>
|
||||
|
||||
SCSCL sc;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial1.begin(1000000);
|
||||
sc.pSerial = &Serial1;
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
//舵机(广播)以最高速度V=1500*0.059=88.5rpm,运行至P1=1000位置
|
||||
sc.WritePos(0xfe, 1000, 0, 1500);
|
||||
delay((1000-20)*1000/(1500) + 100);//[(P1-P0)/(V)]*1000 + 100(误差)
|
||||
|
||||
//舵机(广播)以最高速度V=1500*0.059=88.5rpm,运行至P0=20位置
|
||||
sc.WritePos(0xfe, 20, 0, 1500);
|
||||
delay((1000-20)*1000/(1500) + 100);//[(P1-P0)/(V)]*1000 + 100(误差)
|
||||
}
|
||||
147
jxbeye/lib/FTServo/examples/SCSCL/FeedBack/FeedBack.ino
Normal file
147
jxbeye/lib/FTServo/examples/SCSCL/FeedBack/FeedBack.ino
Normal file
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
回读所有舵机反馈参数:位置、速度、负载、电压、温度、移动状态、电流;
|
||||
FeedBack函数回读舵机参数于缓冲区,Readxxx(-1)函数返回缓冲区中相应的舵机状态;
|
||||
函数Readxxx(ID),ID=-1返回FeedBack缓冲区参数;ID>=0,通过读指令直接返回指定ID舵机状态,
|
||||
无需调用FeedBack函数。
|
||||
*/
|
||||
|
||||
#include <SCServo.h>
|
||||
|
||||
SCSCL sc;
|
||||
int LEDpin = 13;
|
||||
|
||||
void setup()
|
||||
{
|
||||
pinMode(LEDpin,OUTPUT);
|
||||
digitalWrite(LEDpin, HIGH);
|
||||
Serial1.begin(1000000);
|
||||
Serial.begin(115200);
|
||||
sc.pSerial = &Serial1;
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
int Pos;
|
||||
int Speed;
|
||||
int Load;
|
||||
int Voltage;
|
||||
int Temper;
|
||||
int Move;
|
||||
int Current;
|
||||
sc.FeedBack(1);
|
||||
if(!sc.getLastError()){
|
||||
digitalWrite(LEDpin, LOW);
|
||||
Pos = sc.ReadPos(-1);
|
||||
Speed = sc.ReadSpeed(-1);
|
||||
Load = sc.ReadLoad(-1);
|
||||
Voltage = sc.ReadVoltage(-1);
|
||||
Temper = sc.ReadTemper(-1);
|
||||
Move = sc.ReadMove(-1);
|
||||
Current = sc.ReadCurrent(-1);
|
||||
Serial.print("Position:");
|
||||
Serial.println(Pos);
|
||||
Serial.print("Speed:");
|
||||
Serial.println(Speed);
|
||||
Serial.print("Load:");
|
||||
Serial.println(Load);
|
||||
Serial.print("Voltage:");
|
||||
Serial.println(Voltage);
|
||||
Serial.print("Temper:");
|
||||
Serial.println(Temper);
|
||||
Serial.print("Move:");
|
||||
Serial.println(Move);
|
||||
Serial.print("Current:");
|
||||
Serial.println(Current);
|
||||
delay(10);
|
||||
}else{
|
||||
digitalWrite(LEDpin, HIGH);
|
||||
Serial.println("FeedBack err");
|
||||
delay(500);
|
||||
}
|
||||
|
||||
Pos = sc.ReadPos(1);
|
||||
if(!sc.getLastError()){
|
||||
digitalWrite(LEDpin, LOW);
|
||||
Serial.print("Servo position:");
|
||||
Serial.println(Pos, DEC);
|
||||
delay(10);
|
||||
}else{
|
||||
Serial.println("read position err");
|
||||
digitalWrite(LEDpin, HIGH);
|
||||
delay(500);
|
||||
}
|
||||
|
||||
Voltage = sc.ReadVoltage(1);
|
||||
if(!sc.getLastError()){
|
||||
digitalWrite(LEDpin, LOW);
|
||||
Serial.print("Servo Voltage:");
|
||||
Serial.println(Voltage, DEC);
|
||||
delay(10);
|
||||
}else{
|
||||
Serial.println("read Voltage err");
|
||||
digitalWrite(LEDpin, HIGH);
|
||||
delay(500);
|
||||
}
|
||||
|
||||
Temper = sc.ReadTemper(1);
|
||||
if(!sc.getLastError()){
|
||||
digitalWrite(LEDpin, LOW);
|
||||
Serial.print("Servo temperature:");
|
||||
Serial.println(Temper, DEC);
|
||||
delay(10);
|
||||
}else{
|
||||
Serial.println("read temperature err");
|
||||
digitalWrite(LEDpin, HIGH);
|
||||
delay(500);
|
||||
}
|
||||
|
||||
Speed = sc.ReadSpeed(1);
|
||||
if(!sc.getLastError()){
|
||||
digitalWrite(LEDpin, LOW);
|
||||
Serial.print("Servo Speed:");
|
||||
Serial.println(Speed, DEC);
|
||||
delay(10);
|
||||
}else{
|
||||
Serial.println("read Speed err");
|
||||
digitalWrite(LEDpin, HIGH);
|
||||
delay(500);
|
||||
}
|
||||
|
||||
Load = sc.ReadLoad(1);
|
||||
if(!sc.getLastError()){
|
||||
digitalWrite(LEDpin, LOW);
|
||||
Serial.print("Servo Load:");
|
||||
Serial.println(Load, DEC);
|
||||
delay(10);
|
||||
}else{
|
||||
Serial.println("read Load err");
|
||||
digitalWrite(LEDpin, HIGH);
|
||||
delay(500);
|
||||
}
|
||||
|
||||
Current = sc.ReadCurrent(1);
|
||||
if(!sc.getLastError()){
|
||||
digitalWrite(LEDpin, LOW);
|
||||
Serial.print("Servo Current:");
|
||||
Serial.println(Current, DEC);
|
||||
delay(10);
|
||||
}else{
|
||||
Serial.println("read Current err");
|
||||
digitalWrite(LEDpin, HIGH);
|
||||
delay(500);
|
||||
}
|
||||
|
||||
Move = sc.ReadMove(1);
|
||||
if(!sc.getLastError()){
|
||||
digitalWrite(LEDpin, LOW);
|
||||
Serial.print("Servo Move:");
|
||||
Serial.println(Move, DEC);
|
||||
delay(10);
|
||||
}else{
|
||||
Serial.println("read Move err");
|
||||
digitalWrite(LEDpin, HIGH);
|
||||
delay(500);
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
33
jxbeye/lib/FTServo/examples/SCSCL/Ping/Ping.ino
Normal file
33
jxbeye/lib/FTServo/examples/SCSCL/Ping/Ping.ino
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
Ping指令测试,测试总线上相应ID舵机是否就绪,广播指令只适用于总线只有一个舵机情况
|
||||
*/
|
||||
|
||||
#include <SCServo.h>
|
||||
|
||||
SCSCL sc;
|
||||
|
||||
int LEDpin = 13;
|
||||
void setup()
|
||||
{
|
||||
pinMode(LEDpin,OUTPUT);
|
||||
digitalWrite(LEDpin, HIGH);
|
||||
Serial.begin(115200);
|
||||
Serial1.begin(1000000);
|
||||
sc.pSerial = &Serial1;
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
int ID = sc.Ping(1);
|
||||
if(!sc.getLastError()){
|
||||
digitalWrite(LEDpin, LOW);
|
||||
Serial.print("Servo ID:");
|
||||
Serial.println(ID, DEC);
|
||||
delay(100);
|
||||
}else{
|
||||
Serial.println("Ping servo ID error!");
|
||||
digitalWrite(LEDpin, HIGH);
|
||||
delay(2000);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
舵机参数编程
|
||||
*/
|
||||
|
||||
#include <SCServo.h>
|
||||
|
||||
int LEDpin = 13;
|
||||
SCSCL sc;
|
||||
|
||||
void setup()
|
||||
{
|
||||
pinMode(LEDpin, OUTPUT);
|
||||
Serial1.begin(1000000);
|
||||
sc.pSerial = &Serial1;
|
||||
delay(1000);
|
||||
digitalWrite(LEDpin, LOW);
|
||||
sc.unLockEprom(1);//打开EPROM保存功能
|
||||
sc.writeByte(1, SCSCL_ID, 2);//ID
|
||||
sc.writeWord(2, SCSCL_MIN_ANGLE_LIMIT_L, 20);
|
||||
sc.writeWord(2, SCSCL_MAX_ANGLE_LIMIT_L, 1000);
|
||||
sc.LockEprom(2);////关闭EPROM保存功能
|
||||
digitalWrite(LEDpin, HIGH);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
异步写例子在SCS15中测试通过,如果测试其它型号SCS系列舵机请更改合适的位置、速度与延时参数。
|
||||
*/
|
||||
|
||||
#include <SCServo.h>
|
||||
|
||||
SCSCL sc;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial1.begin(1000000);
|
||||
sc.pSerial = &Serial1;
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
//舵机(ID1/ID2)以最高速度V=1500*0.059=88.5rpm,运行至P1=1000位置
|
||||
sc.RegWritePos(1, 1000, 0, 1500);
|
||||
sc.RegWritePos(2, 1000, 0, 1500);
|
||||
sc.RegWriteAction();
|
||||
delay((1000-20)*1000/(1500) + 100);//[(P1-P0)/(V)]*1000 + 100(误差)
|
||||
|
||||
//舵机(ID1/ID2)以最高速度V=1500*0.059=88.5rpm,运行至P0=20位置
|
||||
sc.RegWritePos(1, 20, 0, 1500);
|
||||
sc.RegWritePos(2, 20, 0, 1500);
|
||||
sc.RegWriteAction();
|
||||
delay((1000-20)*1000/(1500) + 100);//[(P1-P0)/(V)]*1000 + 100(误差)
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
同步写例子在SCS15中测试通过,如果测试其它型号SCS系列舵机请更改合适的位置、速度与延时参数。
|
||||
*/
|
||||
|
||||
#include <SCServo.h>
|
||||
|
||||
SCSCL sc;
|
||||
|
||||
byte ID[2];
|
||||
u16 Position[2];
|
||||
u16 Speed[2];
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial1.begin(1000000);
|
||||
sc.pSerial = &Serial1;
|
||||
delay(1000);
|
||||
ID[0] = 1;//舵机ID1
|
||||
ID[1] = 2;//舵机ID2
|
||||
Speed[0] = 1500;//最高速度V=1500*0.059=88.5rpm
|
||||
Speed[1] = 1500;//最高速度V=1500*0.059=88.5rpm
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
//舵机(ID1/ID2)以最高速度V=1500*0.059=88.5rpm,运行至P1=1000位置
|
||||
Position[0] = 1000;
|
||||
Position[1] = 1000;
|
||||
sc.SyncWritePos(ID, 2, Position, 0, Speed);
|
||||
delay((1000-20)*1000/(1500) + 100);//[(P1-P0)/(V)]*1000 + 100(误差)
|
||||
|
||||
//舵机(ID1/ID2)以最高速度V=1500*0.059=88.5rpm,运行至P0=20位置
|
||||
Position[0] = 20;
|
||||
Position[1] = 20;
|
||||
sc.SyncWritePos(ID, 2, Position, 0, Speed);
|
||||
delay((1000-20)*1000/(1500) + 100);//[(P1-P0)/(V)]*1000 + 100(误差)
|
||||
}
|
||||
34
jxbeye/lib/FTServo/examples/SCSCL/WritePWM/WritePWM.ino
Normal file
34
jxbeye/lib/FTServo/examples/SCSCL/WritePWM/WritePWM.ino
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
电机模式例子
|
||||
*/
|
||||
|
||||
#include <SCServo.h>
|
||||
|
||||
SCSCL sc;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial1.begin(1000000);
|
||||
sc.pSerial = &Serial1;
|
||||
delay(1000);
|
||||
sc.PWMMode(1);//舵机切换到PWM开环调速度模式
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
//舵机(ID1)以最大50%扭矩正向旋转
|
||||
sc.WritePWM(1, 500);
|
||||
delay(2000);
|
||||
|
||||
//舵机(ID1)停止旋转
|
||||
sc.WritePWM(1, 0);
|
||||
delay(2000);
|
||||
|
||||
//舵机(ID1)以最大50%扭矩反向旋转
|
||||
sc.WritePWM(1, -500);
|
||||
delay(2000);
|
||||
|
||||
//舵机(ID1)停止旋转
|
||||
sc.WritePWM(1,0);
|
||||
delay(2000);
|
||||
}
|
||||
25
jxbeye/lib/FTServo/examples/SCSCL/WritePos/WritePos.ino
Normal file
25
jxbeye/lib/FTServo/examples/SCSCL/WritePos/WritePos.ino
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
普通写例子在SCS15中测试通过,如果测试其它型号SCS系列舵机请更改合适的位置、速度与延时参数。
|
||||
*/
|
||||
|
||||
#include <SCServo.h>
|
||||
|
||||
SCSCL sc;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial1.begin(1000000);
|
||||
sc.pSerial = &Serial1;
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
//舵机(ID1)以最高速度V=1500*0.059=88.5rpm,运行至P1=1000位置
|
||||
sc.WritePos(1, 1000, 0, 1500);
|
||||
delay((1000-20)*1000/(1500) + 100);//[(P1-P0)/(V)]*1000 + 100(误差)
|
||||
|
||||
//舵机(ID1)以最高速度V=1500*0.059=88.5rpm,运行至P0=20位置
|
||||
sc.WritePos(1, 20, 0, 1500);
|
||||
delay((1000-20)*1000/(1500) + 100);//[(P1-P0)/(V)]*1000 + 100(误差)
|
||||
}
|
||||
Reference in New Issue
Block a user