tutrcos
読み取り中…
検索中…
一致する文字列を見つけられません
tutrcos::module::STS3215 クラス

#include <sts3215.hpp>

tutrcos::module::STS3215 の継承関係図
tutrcos::module::STS3215 連携図

公開型

enum class  Mode { RAD = 0 , PWM = 2 }
 

公開メンバ関数

 STS3215 (peripheral::UART &uart, Mode mode, uint8_t id)
 
bool update ()
 
void set_ref (float value)
 
- 基底クラス tutrcos::module::EncoderBase に属する継承公開メンバ関数
 EncoderBase (int64_t cpr)
 
virtual ~EncoderBase ()
 
int64_t get_cpr ()
 
int64_t get_count ()
 
virtual float get_rotation ()
 
virtual float get_rad ()
 
virtual float get_degree ()
 
virtual float get_rps ()
 
virtual float get_rpm ()
 
virtual float get_radps ()
 
virtual float get_radpm ()
 

その他の継承メンバ

- 基底クラス tutrcos::module::EncoderBase に属する継承限定公開メンバ関数
void set_count (int64_t count)
 

詳解

modeはSTS3215のworkmodeの設定に応じて選択してください。 シリアル通信のbaudrateが1Mbpsだと、オーバーランエラーになる可能性があります(処理能力依存) 500kbps以下を推奨します。

#include <cstdio>
#include <tutrcos.hpp>
extern UART_HandleTypeDef huart2;
extern UART_HandleTypeDef huart4;
extern "C" void main_thread(void *) {
using namespace tutrcos::core;
using namespace tutrcos::peripheral;
using namespace tutrcos::module;
UART uart2(&huart2); // デバッグ出力用
uart2.enable_stdout();
UART uart3(&huart4);
STS3215 sts(uart3, STS3215::Mode::PWM, 10);
while (true) {
if(!sts.update()){ // データ送受信
printf("error\r\n");
}else{
float Kp = 5;
float x_target = 0.5f;
// 現在の角度をrotationで取得
float x_actual = sts.get_rotation();
float error = x_target - x_actual;
// 出力(-1~1)を指定
sts.set_ref(Kp * error);
// STS3215の回転速度と絶対位置を出力
printf("%f %f\r\n", sts.get_rps(), sts.get_rotation());
}
Thread::delay(10);
}
}
Definition sts3215.hpp:64
Definition uart.hpp:51
Definition kernel.hpp:8
Definition amt21.hpp:13
Definition can.hpp:15

列挙型メンバ詳解

◆ Mode

enum class tutrcos::module::STS3215::Mode
strong
列挙値
RAD 
PWM 

構築子と解体子

◆ STS3215()

tutrcos::module::STS3215::STS3215 ( peripheral::UART & uart,
Mode mode,
uint8_t id )
inline

関数詳解

◆ set_ref()

void tutrcos::module::STS3215::set_ref ( float value)
inline

◆ update()

bool tutrcos::module::STS3215::update ( )
inline

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