Dynamixel dx-series – Robotis Dynamixel DX-117 User Manual

Page 35

Advertising
background image

34

DYNAMIXEL

DX-Series

C Language Example : Dinamixel access with Am188ER CPU




#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <dos.h>
#include <mem.h>

#define MCS80
#include "..\..\base.h"
#include "..\lib188es.c"

#define RS485_DIRECTION_BIT 0x2000
#define RS485_TXD (SET_PORT1(RS485_DIRECTION_BIT))
#define RS485_RXD (RESET_PORT1(RS485_DIRECTION_BIT))

#define BROADCASTING_ID 0xfe
#define MEMORY_SPARE 10

#define ADDRESS_TORQUE_ENABLE 20
#define ADDRESS_OPERATING_MODE 19
#define ADDRESS_ID 3
#define ADDRESS_GOAL_POSITION 26

#define INST_PING 0x01
#define INST_READ 0x02
#define INST_WRITE 0x03
#define INST_SET_SCHEDULE 0x04
#define INST_DO_SCHEDULE 0x05
#define INST_RESET 0x06

#define DIGITAL_MODE 0

//Gloval variable number
byte gbpInterruptRxBuffer[256+MEMORY_SPARE]; //485 RxD Data Buffer
byte gbRxBufferReadPointer,gbRxBufferWritePointer; //Pointers for access the gbpInterruptRxBuffer

void static interrupt far Serial0Interrupt(void);
void PrintBuffer(byte *bpPrintBuffer, byte bLength);
byte TxPacket(byte *bpTxBuffer, byte bID, byte bInstruction, byte *bpParameter, byte bParameterLength);
byte RxPacket(byte *bpRxBuffer);

void main(void)
{
byte bID,bPacketLength;
byte bpTxBuffer[20+MEMORY_SPARE];
byte bpRxBuffer[256+MEMORY_SPARE];
byte bpParameter[256+MEMORY_SPARE];

CLI; //Disable Interrupt
//PortInitialize();
InitPort(OUT, PDATA1, 0xe000); //Set Out(Port30,31:LED,Port29:485Direction)
InitPort(IN, PDATA1, 0x0004); //Set In(Port2:Push SW)
InitPort(NORMAL_USE, PDATA1, 0x00c0); //
RS485_RXD; //Set 485 Direction Select Port to 0

//UartInitialize();
outpw(SP0BAUD,5); //.2MBPS = 16MHz/16/5
outpw(SP1BAUD,17); //57600
outpw(SP0STS,0);
outpw(SP1STS,0);

//InterruptInitialize();

Definition area

Major

Function

CPU dependent Initialize

Advertising
This manual is related to the following products: