IcsClass  2.0.0
公開メンバ関数 | 限定公開メンバ関数 | 限定公開変数類 | 全メンバ一覧
IcsSoftSerialClass クラス

近藤科学のKRSサーボをArduinoのSoftwareSerialからアクセスできるようにしたクラス [詳解]

#include <IcsSoftSerialClass.h>

IcsSoftSerialClass の継承関係図
IcsBaseClass

公開メンバ関数

 IcsSoftSerialClass ()
 コンストラクタ
 
 IcsSoftSerialClass (byte rxPin, byte txPin, byte enpin)
 コンストラクタ [詳解]
 
 IcsSoftSerialClass (byte rxPin, byte txPin, byte enpin, long baudrate, int timeout)
 コンストラクタ [詳解]
 
 IcsSoftSerialClass (KoCustamSoftSerial *koSoftSerial, byte enpin)
 コンストラクタ [詳解]
 
 IcsSoftSerialClass (KoCustamSoftSerial *koSoftSerial, byte enpin, long baudrate, int timeout)
 コンストラクタ [詳解]
 
 ~IcsSoftSerialClass ()
 デストラクタ [詳解]
 
virtual bool begin ()
 通信の初期設定 [詳解]
 
virtual bool begin (long baudrate, int timeout)
 通信の初期設定 [詳解]
 
virtual bool begin (KoCustamSoftSerial *serial, byte enpin, long baudrate, int timeout)
 通信の初期設定 [詳解]
 
virtual bool synchronize (byte *txBuf, byte txLen, byte *rxBuf, byte rxLen)
 ICS通信の送受信 [詳解]
 
- 基底クラス IcsBaseClass に属する継承公開メンバ関数
int setPos (byte id, unsigned int pos)
 サーボモータの角度を変更します [詳解]
 
int setFree (byte id)
 サーボモータをフリー(脱力)状態にします [詳解]
 
int setStrc (byte id, unsigned int strc)
 サーボモータのストレッチ(保持力)の値を書き込みます [詳解]
 
int setSpd (byte id, unsigned int spd)
 サーボモータのスピード(出力)を変更します [詳解]
 
int setCur (byte id, unsigned int curlim)
 サーボモータの電流リミット(電流制限)値を変更します [詳解]
 
int setTmp (byte id, unsigned int tmplim)
 サーボモータの温度リミット(温度制限)値を変更します [詳解]
 
int getStrc (byte id)
 サーボモータのストレッチ(保持力)の値を読み込みます [詳解]
 
int getSpd (byte id)
 サーボモータのスピード(出力)を読み込みます [詳解]
 
int getCur (byte id)
 サーボモータの現在の電流値を読み込みます [詳解]
 
int getTmp (byte id)
 サーボモータの現在の温度値を読み込みます [詳解]
 
int getPos (byte id)
 サーボモータの現在のポジションデータを読み込みます [詳解]
 
unsigned short getKrrButton ()
 KRRが受信しているボタンのデータを取得します [詳解]
 
int getKrrAnalog (int paCh)
 KRRが受信している指定したアナログポート(PA)のデータを取得します [詳解]
 
bool getKrrAllData (unsigned short *button, int adData[4])
 KRRが受信しているボタンデータおよびアナログポート(PA)のデータをすべて取得します [詳解]
 

限定公開メンバ関数

void enHigh ()
 enPinに割り当てられているピンをHにする
 
void enLow ()
 enPinに割り当てられているピンをLにする
 
- 基底クラス IcsBaseClass に属する継承限定公開メンバ関数
byte idMax (byte id)
 サーボIDが範囲内か見る [詳解]
 
bool maxMin (int maxPos, int minPos, int val)
 ポジションデータの最大、最小値の範囲に収める [詳解]
 

限定公開変数類

KoCustamSoftSerial * icsSoftSerial
 arudinoのシリアル型のポインタを格納
 
byte g_enpin
 イネーブルピン(送受信を切り替える)のピン番号を格納しておく変数
 
int g_timeout = 1000
 タイムアウトの設定を格納しておく変数
 
long g_baudrate = 115200
 通信速度の設定を格納しておく変数
 

その他の継承メンバ

- 基底クラス IcsBaseClass に属する継承静的公開メンバ関数
static int degPos (float deg)
 角度データ(float型)をポジションデータに変換 [詳解]
 
static float posDeg (int pos)
 ポジションデータを角度データ(float型)に変換 [詳解]
 
static int degPos100 (int deg)
 角度データx100(int型)をポジションデータに変換 [詳解]
 
static int posDeg100 (int pos)
 ポジションデータを角度データ(int型)に変換 [詳解]
 
- 基底クラス IcsBaseClass に属する継承静的公開変数類
static constexpr int MAX_ID = 31
 サーボIDの最大値
 
static constexpr int MIN_ID = 0
 サーボIDの最小値
 
static constexpr int MAX_POS = 11500
 サーボのポジション最大値
 
static constexpr int MIN_POS = 3500
 サーボのポジション最小値
 
static constexpr int ICS_FALSE = -1
 ICS通信等々で失敗したときの値
 
- 基底クラス IcsBaseClass に属する継承静的限定公開変数類
static constexpr float ANGLE_F_FALSE = 9999.9
 角度計算時、範囲内に入ってない場合は999.9にする(負側の場合はマイナスをつける)
 
static constexpr int ANGLE_I_FALSE = 0x7FFF
 角度計算時、範囲内に入ってない場合は0x7FFFにする(負側の場合はマイナスをつける)
 
static constexpr int MAX_127 = 127
 パラメータの最大値
 
static constexpr int MAX_63 = 63
 パラメータの最大値(電流値)
 
static constexpr int MIN_1 = 1
 パラメータの最小値
 
static constexpr float MAX_DEG = 180.0
 角度の最大値
 
static constexpr float MIN_DEG = -180.0
 角度の最大値
 
static constexpr int MAX_100DEG = 18000
 角度(x100)の最大値
 
static constexpr int MIN_100DEG = -18000
 角度(x100)の最小値
 

詳解

近藤科学のKRSサーボをArduinoのSoftwareSerialからアクセスできるようにしたクラス

IcsBaseClassからの派生して作られている SoftwareSerialは高速通信は難しいためKoCustamSoftSerialを使用する

構築子と解体子

§ IcsSoftSerialClass() [1/4]

IcsSoftSerialClass::IcsSoftSerialClass ( byte  rxPin,
byte  txPin,
byte  enpin 
)

コンストラクタ

引数
[in]rxPinSoftSerialのRXに割り当てるピン番号
[in]txPinSoftSerialのTXに割り当てるピン番号
[in]enpin送受信切替えピンのピン番号

§ IcsSoftSerialClass() [2/4]

IcsSoftSerialClass::IcsSoftSerialClass ( byte  rxPin,
byte  txPin,
byte  enpin,
long  baudrate,
int  timeout 
)

コンストラクタ

引数
[in]rxPinSoftSerialのRXに割り当てるピン番号
[in]txPinSoftSerialのTXに割り当てるピン番号
[in]enpin送受信切替えピンのピン番号
[in]bandrateサーボの通信速度
[in]timeout受信タイムアウト(ms)

§ IcsSoftSerialClass() [3/4]

IcsSoftSerialClass::IcsSoftSerialClass ( KoCustamSoftSerial *  softSerial,
byte  enpin 
)

コンストラクタ

引数
[in]*serialICSに設定するUART(KoCustamSoftSerial型のポインタ)
[in]enpin送受信切替えピンのピン番号

§ IcsSoftSerialClass() [4/4]

IcsSoftSerialClass::IcsSoftSerialClass ( KoCustamSoftSerial *  softSerial,
byte  enpin,
long  baudrate,
int  timeout 
)

コンストラクタ

引数
[in]*serialICSに設定するUART(KoCustamSoftSerial型のポインタ)
[in]enpin送受信切替えピンのピン番号
[in]bandrateサーボの通信速度
[in]timeout受信タイムアウト(ms)

§ ~IcsSoftSerialClass()

IcsSoftSerialClass::~IcsSoftSerialClass ( )

デストラクタ

事後条件
使用していたのicsSoftSerialを開放します

関数詳解

§ begin() [1/3]

bool IcsSoftSerialClass::begin ( )
virtual

通信の初期設定

戻り値
true通信設定完了
false通信設定失敗
注意
ピンの割り当て、通信速度、タイムアウトは事前に設定してある事

§ begin() [2/3]

bool IcsSoftSerialClass::begin ( long  baudrate,
int  timeout 
)
virtual

通信の初期設定

引数
[in]baudrateICSの通信速度(115200,625000,1250000(1.25M)bps)
[in]timeout受信タイムアウト(ms)
戻り値
true通信設定完了
false通信設定失敗
注意
UARTピンおよび送受信切替えピンは設定してある事

§ begin() [3/3]

bool IcsSoftSerialClass::begin ( KoCustamSoftSerial *  serial,
byte  enpin,
long  baudrate,
int  timeout 
)
virtual

通信の初期設定

引数
[in]*serialICSに設定するUART(KoCustamSoftSerial型のポインタ)
[in]enpin送受信切替えピンのピン番号
[in]baudrateICSの通信速度(115200,625000,1250000(1.25M)bps)
[in]timeout受信タイムアウト(ms)
戻り値
true通信設定完了
false通信設定失敗

§ synchronize()

bool IcsSoftSerialClass::synchronize ( byte *  txBuf,
byte  txLen,
byte *  rxBuf,
byte  rxLen 
)
virtual

ICS通信の送受信

引数
[in,out]*txBuf
[in]txLen
[out]*rxBuf受信格納バッファ
[in]rxLen受信データ数
戻り値
true通信成功
false通信失敗
注意
送信データ数、受信データ数はコマンドによって違うので注意する

IcsBaseClassを再実装しています。


このクラス詳解は次のファイルから抽出されました: