2015-08-04 11:11 PM
Hello, I am a college student and a beginner programmer, I got a project to make a library using STM32F4 Discovery to move a Dynamixel motor type XL-320. I already studied the basic communication for commanding Dynamixel XL-320 (http://support.robotis.com/en/product/dynamixel_pro/communication/instruction_status_packet.htm) and I already made some of the program list, but it doesn't work, can somebody help me? Thank you very much.
I use some of the program from HelloSpoon, to get the CRC value (https://github.com/HelloSpoon/HelloSpoon-Spark/blob/master/firmware/dxl_pro.cpp) Here is some of the program list I made : void Dyna_move(unsigned char ID, int Position) { //length XL_LENGTH_L = L_Byte(XL_GOAL_P_LENGTH); XL_LENGTH_H = H_Byte(XL_GOAL_P_LENGTH); Packet_Length = XL_GOAL_P_LENGTH; //address XL_ADDRESS_L = L_Byte(XL_GOAL_POSITION); XL_ADDRESS_H = H_Byte(XL_GOAL_POSITION); //position POS_L = L_Byte(Position); POS_H = H_Byte(Position); //txpacket unsigned char DataSend[] = { XL_START1, XL_START1, XL_START2, XL_RESERVED, ID, XL_LENGTH_L, XL_LENGTH_H, XL_WRITE_DATA, XL_ADDRESS_L, XL_ADDRESS_H, POS_L, POS_H, CRC_L, CRC_H }; for(count=0;count<(XL_GOAL_P_LENGTH+7);count++) { TxPacket[count]=DataSend[count]; } //CRC CRC_X = update_crc (CRC_ACCUM, TxPacket , (5+Packet_Length) ) ; CRC_L = L_Byte(CRC_X); CRC_H = H_Byte(CRC_X); UART_SendByte(DYNAMIXEL, XL_START1); UART_SendByte(DYNAMIXEL, XL_START1); UART_SendByte(DYNAMIXEL, XL_START2); UART_SendByte(DYNAMIXEL, XL_RESERVED); UART_SendByte(DYNAMIXEL, ID); UART_SendByte(DYNAMIXEL, XL_LENGTH_L); UART_SendByte(DYNAMIXEL, XL_LENGTH_H); UART_SendByte(DYNAMIXEL, XL_WRITE_DATA); UART_SendByte(DYNAMIXEL, XL_ADDRESS_L); UART_SendByte(DYNAMIXEL, XL_ADDRESS_H); UART_SendByte(DYNAMIXEL, POS_L); UART_SendByte(DYNAMIXEL, POS_H); UART_SendByte(DYNAMIXEL, CRC_L); UART_SendByte(DYNAMIXEL, CRC_H); Delayus(100); } #stm32 #stm32f4 #discovery #usart2015-08-05 05:06 AM
Does the UART_SendByte() wait for TXE to assert before sending each data byte?
Perhaps you can provide a number of example packets that you are sending? ie the stream of hex bytes. The code you provided doesn't really make it easy to do remotely.I'd suggest to write equivalent code you can run on a PC that just computes and prints packets, and make sure that's valid. Look if there are example packets provided for the motor documentation which would allow you to cross check the values computed by your code.2015-08-05 10:53 PM
ÿ, sometimes it appeared twice, or three times or once then vanished, and reappeared again in a quick pace. But sometimes the symbols change when I change the parameter like ID or position. There was even a time when I sent a data, it didn't match with the ASCII table. I am confused, Sir, maybe there is something wrong in the way I did it? Can you give me some advice?