KRS ICSサーボモータ用ライブラリ

初期化 KRS name(tx,rx);

位置指定 void SetPosition(id, position); [position : 0 3500 ~ 11500]

速度設定 void SetSpeed(id, speed); [speed : 0 ~ 127]

ストレッチ設定 void SetStretch(id, stretch); [stretch : 0 ~ 127]

電流制限設定 void SetCurrent(id, rotate, value : 0 ~ 127); [rotate : KRS::F KRS::R KRS::COM, current : 0 ~ 64]

ID書き込み void WriteAddress(id);

id : 0x00 ~ 0x1F

Files at this revision

API Documentation at this revision

Comitter:
koki_konishi
Date:
Sun Jul 03 05:11:26 2022 +0000
Parent:
1:50d0eb774b0d
Commit message:
Kondo-servo

Changed in this revision

KRS.cpp Show annotated file Show diff for this revision Revisions of this file
KRS.h Show annotated file Show diff for this revision Revisions of this file
diff -r 50d0eb774b0d -r 431a802d01e2 KRS.cpp
--- a/KRS.cpp	Sun Jul 03 04:35:46 2022 +0000
+++ b/KRS.cpp	Sun Jul 03 05:11:26 2022 +0000
@@ -6,6 +6,22 @@
     _serial.format(8,Serial::Even,1);
 }
 
+void KRS::WriteAddress(uint8_t address){
+    uint8_t ins = 0b11100000;
+    if(address <= 0x1F){
+        ins |= address;
+    }else{
+        ins |= 0x1F;
+    }
+    
+    _serial.putc(ins);
+    _serial.putc(0x01);
+    _serial.putc(0x01);
+    _serial.putc(0x01);
+    
+    wait_ms(10);
+}
+
 void KRS::SetStretch(uint8_t address, uint8_t value){
     uint8_t ins = 0b11000000;
     if(address <= 0x1F){
diff -r 50d0eb774b0d -r 431a802d01e2 KRS.h
--- a/KRS.h	Sun Jul 03 04:35:46 2022 +0000
+++ b/KRS.h	Sun Jul 03 05:11:26 2022 +0000
@@ -13,6 +13,8 @@
     
     KRS(PinName tx,PinName rx);
     
+    void KRS::WriteAddress(uint8_t address);
+    
     void KRS::SetStretch(uint8_t address, uint8_t value);
     
     void KRS::SetSpeed(uint8_t address, uint8_t value);