...
POST No. 2407612
Code doesn't start after power down
2019-10-02 09:30:14 RyanWork

Hi guys, I am using an openCM and a robotis board. When I upload say the Dxl_Speed sketch it works as expected but if I pull out the power and then replace it, the code doesn't start again. I have to Press the "reset" button on the board before the code with start again (but don't re upload it). How do I get it so that If it has power, then it executes the code? 


Cheers guys, 

Ryan. 

2019-10-02 09:30:14
RyanWork
2019-10-02 11:56:06 Will Son

Hi,


If you are still using OpenCM IDE, please use Arduino IDE as OpenCM IDE is not supported anymore.

In order to keep running the code while the power is on, you need to program it accordingly so the program in the loop can be executed.

Thank you.

2019-10-02 11:56:06
willson
2019-10-15 06:08:44 KKK

Hi


Are there any example sketches which show program in loop?


Thanks

2019-10-15 06:08:44
kkk123
2019-10-16 15:27:57 Will Son

Hi,


Below is an example from Dynamixel2Arduino > basic > position_mode.

https://github.com/ROBOTIS-GIT/Dynamixel2Arduino/blob/master/examples/basic/position_mode/position_mode.ino 


You can find the example after installing Dynamixel2Arduino library from Arduino IDE.

Thank you.

comment
2019-10-17 02:26:04 kkk123
Thanks for pointer. However the position_mode example didn't rotate the motor.

I am using Arduino IDE + OpenCM 9.04 + EXP Board + XL 430.



Because of EXP board one change i performed in code: #define DXL_SERIAL Serial3



I am not sure if any other change is needed to accommodate Arduino2Dynamixel lib. Also not sure what is DXL_DIR_PIN

Same Dynamixel is moving if I use example under OpenCM 9.04 in Arduino IDE



here is my code:



/*******************************************************************************

* Copyright 2016 ROBOTIS CO., LTD.

*

* Licensed under the Apache License, Version 2.0 (the "License");

* you may not use this file except in compliance with the License.

* You may obtain a copy of the License at

*

* http://www.apache.org/licenses/LICENSE-2.0

*

* Unless required by applicable law or agreed to in writing, software

* distributed under the License is distributed on an "AS IS" BASIS,

* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and

* limitations under the License.

*******************************************************************************/



#include



#if defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_MEGA2560)

#include

SoftwareSerial soft_serial(7, 8); // DYNAMIXELShield UART RX/TX

#define DXL_SERIAL Serial

#define DEBUG_SERIAL soft_serial

const uint8_t DXL_DIR_PIN = 2; // DYNAMIXEL Shield DIR PIN

#else

#define DXL_SERIAL Serial3

#define DEBUG_SERIAL Serial

const uint8_t DXL_DIR_PIN = 2; // DYNAMIXEL Shield DIR PIN

#endif



const uint8_t DXL_ID = 1;

const float DXL_PROTOCOL_VERSION = 2.0;



Dynamixel2Arduino dxl(DXL_SERIAL, DXL_DIR_PIN);



void setup() {

// put your setup code here, to run once:



// Use UART port of DYNAMIXEL Shield to debug.

DEBUG_SERIAL.begin(115200);



// Set Port baudrate to 57600bps. This has to match with DYNAMIXEL baudrate.

dxl.begin(57600);

// Set Port Protocol Version. This has to match with DYNAMIXEL protocol version.

dxl.setPortProtocolVersion(DXL_PROTOCOL_VERSION);

// Get DYNAMIXEL information

dxl.ping(DXL_ID);



// Turn off torque when configuring items in EEPROM area

dxl.torqueOff(DXL_ID);

dxl.setOperatingMode(DXL_ID, OP_POSITION);

dxl.torqueOn(DXL_ID);

}



void loop() {

// put your main code here, to run repeatedly:



// Please refer to e-Manual(http://emanual.robotis.com/docs/en/parts/interface/dynamixel_shield/) for available range of value.

// Set Goal Position in RAW value

dxl.setGoalPosition(DXL_ID, 512);

delay(1000);

// Print present position in raw value

DEBUG_SERIAL.print("Present Position(raw) : ");

DEBUG_SERIAL.println(dxl.getPresentPosition(DXL_ID));

delay(1000);



// Set Goal Position in DEGREE value

dxl.setGoalPosition(DXL_ID, 5.7, UNIT_DEGREE);

delay(1000);

// Print present position in degree value

DEBUG_SERIAL.print("Present Position(degree) : ");

DEBUG_SERIAL.println(dxl.getPresentPosition(DXL_ID, UNIT_DEGREE));

delay(1000);

}



The output



Present Position(raw) : 0.00

Present Position(degree) : 0.00

Present Position(raw) : 0.00

Present Position(degree) : 0.00
2019-10-17 02:26:04
kkk123
2019-10-16 15:27:57
willson
Reply
웹에디터 시작 웹 에디터 끝