Motorbank / MAS001

MAS001 Arduino Library
7 stars 5 forks source link

set_id 부분 문의 드립니다. #2

Open chldndus12 opened 3 years ago

chldndus12 commented 3 years ago

(BLC-400R4E 센서타입BLDC모터 엔코더장착형 서보모터 드라이버 RS485통신규격 400W) 드라이버 2개와 (Nema17 엔코더장착BLDC모터 BL4241E1K 24V 26W 분해능 1000CPR) 모터2개를 mas-001를 사용하여 구동하고 있습니다. xy 액츄에이터를 구동시켜야해서 모터 2개를 다축 개별 제어해야 하는데 코딩과정에서 모터 2개를 제어하려면 두개의 device_id를 기존의 모터 1은 0으로 설정되있어서 지장이 없고 모터 2는 device_id를 1로 설정해줘야 하는데 코딩 명령어 에서 //void set_ID(); // 6. ID 설정 (송신) 이부분을 주석 처리해서 사용하지 못하는 명령어 인지 아직 개발중인지 문의드립니다. 다축제어의 기본인 모터 개별적으로 제어해야하는데 처음에

define DEVICE_ID1 0

define DEVICE_ID2 1

이런식으로 정의를 해도 모터는 동시에 구동되고 있습니다. 저희가 사용하는 코딩입니다. 명령어를 막아놓은 이유가 있으신건지, 혹은 다른 방법이 있나요?

include "mas001.h"

include "blc200.h"

define DEVICE_ID1 0

define DEVICE_ID2 1

MAS001 myShield; BLC200 myDevice(9600, 100); // Baudrate = 9600, Serial timeout = 100ms

uint16_t pos_input; uint16_t pos_output; uint16_t cnt; uint16_t sub_cnt;

void setup() { Serial.begin(115200); }

void loop() {

for(cnt=0;cnt<400;cnt++){

pos_input = myShield.getPot() * 35; myDevice.set_ReductionRatio(DEVICE_ID1,40); myDevice.set_ReductionRatio(DEVICE_ID2,40);

if(myShield.button1Clicked()){ if(cnt<100){ myDevice.set_PositionWithSpeed(DEVICE_ID1, 0, 45000, 2500); //myDevice.set_PositionWithSpeed(DEVICE_ID2, 0, 45000, 7500); }else if(cnt<400){ // ID = 0, CW, POS = (pos_input/100)DEGREE, SPD = 100RPM // myDevice.set_PositionWithSpeed(DEVICE_ID1, 1, 45000, 7500); myDevice.set_PositionWithSpeed(DEVICE_ID2, 1, 45000, 2500); }else{ cnt=0; sub_cnt=0; pos_input=0; } }

// Get Current position // if(myDevice.get_Feedback(DEVICE_ID1, 0xA1)){ // pos_output = (uint16_t)myDevice.blcData[2] << 8 | (uint16_t)myDevice.blcData[3]; // Serial.println(pos_output); // } if(myDevice.get_Feedback(DEVICE_ID2, 0xA1)){ // pos_output = (uint16_t)myDevice.blcData[2] << 8 | (uint16_t)myDevice.blcData[3]; //Serial.println(pos_output); // }

delay(10);

} }