dmp electronics inc robotics division anthony lu

21
DMP Electronics Inc Robotics Division Anthony Lu

Upload: austin-tate

Post on 17-Jan-2018

220 views

Category:

Documents


0 download

DESCRIPTION

Architecture Portable I/O lib (low level) Portable I/O lib (low level) SPI lib (partially low level) SPI lib (partially low level) PWM lib (low level) PWM lib (low level) A/D lib RC Servo lib User Application Roboard I/O Library

TRANSCRIPT

Page 1: DMP Electronics Inc Robotics Division Anthony Lu

DMP Electronics IncRobotics Division

Anthony Lu

Page 2: DMP Electronics Inc Robotics Division Anthony Lu

OverviewA open-source library for Roboard’s unique I/O functions

PWM with support to RC servo motors (KONDO, HiTEC, …)

GPIOSPIA/D

Supported platformsWindows XP (Visual C++ 2005/2008)Linux (gcc)DOS (DJGPP, Borland C++ 3.0)

Page 3: DMP Electronics Inc Robotics Division Anthony Lu

Architecture

Portable I/O lib(low level)

SPI lib(partially low level)

PWM lib(low level)

A/D lib RC Servo lib

User Application

Roboard I/O Library

Page 4: DMP Electronics Inc Robotics Division Anthony Lu

Usage OverviewInclude roboard.h to

use the following libsRC Servo libSPI libA/D lib

must call io_init() before using all libs’ API

#include <roboard.h>int main() { if (io_init()) { …… //use API of Roboard //I/O library here …… io_close(); } return 0;}

Page 5: DMP Electronics Inc Robotics Division Anthony Lu

SPI lib Usage

clock_mode can be, e.g., SPICLK_21400KHZ (21.4M bps) SPICLK_12500KHZ (12.5M bps) SPICLK_10000KHZ (10M bps) SPICLK_150000KHZ (150M bps)

See spi.h for all available clock modes.

if (spi_Initialize(clock_mode)) { …… spi_Write(0x55); //write a byte (0x55) to SPI bus unsigned val = spi_Read(); //read a byte from SPI bus …… spi_Close();}

Page 6: DMP Electronics Inc Robotics Division Anthony Lu

A/D lib Usage

To use the 8-channel A/D, we must set SPI clock to 21.4M bps.

The SPICS pin is used by A/D, and should not be used for other SPI devices.

A/D lib only provides usual AD7918 functions.

if (spi_Initialize(SPICLK_21400KHZ)) { …… int val = ad7918_ReadChannel(channel, //channel = 0 ~ 7 AD7918MODE_RANGE_2VREF, AD7918MODE_CODING_1023); …… spi_Close();}

Page 7: DMP Electronics Inc Robotics Division Anthony Lu

A/D lib Usage (cont.)Input-voltage range:

AD7918MODE_RANGE_2VREF: 0V ~ 5V

AD7918MODE_RANGE_VREF: 2.5V ~ 2.5V

A/D value range:AD7918MODE_CODING_1023: 0 ~ 1023

AD7918MODE_CODING_511: 512 ~ 511

minimum value lowest voltage, maximum value highest voltage

Page 8: DMP Electronics Inc Robotics Division Anthony Lu

RC Servo lib Usage

RCSERVO_USECHANNEL0 ~ RCSERVO_USECHANNEL23 are available

Three operation modes Capture mode (for reading RC servo’s position feedback) Action playing mode (for playing user-defined motions) PWM mode (send PWM pulses for individual channels)

if (rcservo_Initialize(RCSERVO_USECHANNEL0 | RCSERVO_USECHANNEL1 | ……)) { //use API of RC Servo lib here rcservo_Close();}

Page 9: DMP Electronics Inc Robotics Division Anthony Lu

RC Servo lib Usage (cont.)Capture mode

Call rcservo_EnterCaptureMode() to enter this modeThe initial mode after rcservo_Initialize()

Available API in Capture modercservo_ReadPosition(): read position feedback of an RC

servo motorrcservo_ReadPositions(): read feedback of multiple RC

servo motorsrcservo_ReadPositionDN()/rcservo_ReadPositionsDN(): multiprogramming OS version of the above functions

Page 10: DMP Electronics Inc Robotics Division Anthony Lu

RC Servo lib Usage (cont.)

The second argument is servo feedback command, and is uaually 0. if fail to read, return 0xFFFFFFFFL

rcservo_EnterCaptureMode();……unsigned long pos = rcservo_ReadPosition(channel, 0);……unsigned long motion[32];rcservo_ReadPositions(RCSERVO_USECHANNEL0 | RCSERVO_USECHANNEL1 | ……, 0, motion);

Page 11: DMP Electronics Inc Robotics Division Anthony Lu

RC Servo lib Usage (cont.)Action playing mode

Call rcservo_EnterPlayMode() to enter this modeUsed to replay motions captured by rcservo_ReadPositions()

Available API in Action playing modercservo_SetAction(): set the motion that is ready to playrcservo_PlayAction(): rotate all servo motors to the motion

set by rcservo_SetAction()Must call rcservo_PlayAction() repeatedly until it returns RCSERVO_PLAYEND

Page 12: DMP Electronics Inc Robotics Division Anthony Lu

RC Servo lib Usage (cont.)unsigned long motion[32];……//set motion for playing……rcservo_EnterPlayMode();……rcservo_SetAction(motion, 500); //play motion in 500mswhile (rcservo_PlayAction() != RCSERVO_PLAYEND) { // //can do something here when playing motion //}

Page 13: DMP Electronics Inc Robotics Division Anthony Lu

RC Servo lib Usage (cont.)PWM mode

Call rcservo_EnterPWMMode() to enter this mode In this mode, all used PWM channels remain to be low if no pulse

is sent.

Available API in PWM modercservo_SendPWMPulses(): send a given number of pulses

with specific duty and periodrcservo_IsPWMCompleted(): return true when all PWM

pulses have been sent out

Page 14: DMP Electronics Inc Robotics Division Anthony Lu

RC Servo lib Usage (cont.)rcservo_EnterPWMMode();……unsigned long PWM_period = 10000; //10000usunsigned long PWM_duty = 1500; //1500usunsigned long count = 100;rcservo_SendPWMPulses(channel, PWM_period, PWM_duty, count);while (!rcservo_IsPWMCompleted(channel)) { // //can do something here when sending PWM pulses //}

Page 15: DMP Electronics Inc Robotics Division Anthony Lu

RC Servo lib Usage (cont.)Non-used PWM channels can be treated as GPIO

The user decides used channels when calling rcservo_Initialize().

Available GPIO API:

Invalid if channel is used

rcservo_Outp(channel, out_value); //out_value = 0 or 1

int in_value = rcservo_Inp(channel);

Page 16: DMP Electronics Inc Robotics Division Anthony Lu

PWM lib UsageAllow users to employ complete Roboard’s PWM

featuresControl PWM output waveformControl PWM resolution (minimum PWM duty = 20ns)Enable PWM interrupt……

Do not use PWM lib when RC Servo lib is in useSee pwm.h and pwmdx.h for available API

Page 17: DMP Electronics Inc Robotics Division Anthony Lu

Use Roboard I/O Library in VC2005Decompose the zip file to, e.g., C:\Roboard

Docs: datasheets for Roboard’s unique I/O Include: include files for Roboard I/O libraryLib: binary of Roboard I/O libraryWinio: needed when using Roboard I/O library under XP

Page 18: DMP Electronics Inc Robotics Division Anthony Lu

Use Roboard I/O Library in VC2005 (cont.)Setting the library in your VC2005 project

Page 19: DMP Electronics Inc Robotics Division Anthony Lu

Use Roboard I/O Library in VC2005 (cont.)If you use .NET

To run your application, copy all files in Roboard\Winio to your application directoryNote: only run it on Roboard, not on your PC

Page 20: DMP Electronics Inc Robotics Division Anthony Lu

COM & I2CCOM ports

All Roboard’s COM can be used as standard COM in XP, DOS, and Linux.

Can customize IRQ and I/O base in BIOS

I2CMaximum speed is 3.3M bps.We will add I2C support in the next version of Roboard

I/O library.

Page 21: DMP Electronics Inc Robotics Division Anthony Lu

Anthony [email protected]