CONROLIB

advertisement
CONROLIB
Objective of presentation

CONRO Developer should be able to
program a fully functional CONRO after
this presentation
Outline of Presentation











The Basics: What is the new CONRO Hardware?
What is the new development environment?
Where can I get this software environment?
What is CONROLIB?
Discussion of all APIs
Writing your first program …very easy
Modifying the Makefile
How do I add my contribution to CONROLIB?
Why use static libaries?
Future Work on CONROLIB
Demo
The Basics: What is the new CONRO
Hardware?

Atmega128 Low power MCU


All peripherals on chip (ADC, Timers, UART)
4Mhz , 128Kb Program Flash, 4KB RAM

MICA2DOT = MCU + Wireless Chip +
Serial Flash For Data Logging

Board under DOT -> IR LEDs / Transistor

Battery Powered
Main Functionalities of CONRO’s
Hardware
Communicate using
Software UART and Infrared
Control Each ports TX LED and
Read Digital from Rx
Control 2 Servo Motors
Send Debug Info to a PC Host
Measure Infrared Intensity
at each port
Wireless Communication
What is the new development environment?
Serial
Programmer
PC Host with
Cross Compiler
CONRO
Atmega128
What is the new development
environment?...contd.
Cross Compiler is avr-gcc + avr-linker +
avr-binutils
 Both *nix & Windows environments
available.

C Code
Avr-gcc
Bin-Utils converts
assembly to Intel hex file
UISP/Avrdude
CONRO
Where can I get this software environment?

Unix/Linux :
http://www.isi.edu/~weiye/system/guide/
avrtools.html


Windows



Note: instructions are old download latest
versions of gcc, avr-libc, binutils, uisp.
http://sourceforge.net/projects/winavr
Instructions are available with s/w
NOTE! : Must have permissions for
accessing /dev/ttyS0 (unix) or COM1 in
Windows
What is CONROLIB?



A precompiled static library with host of standard
C APIS.
CONROLIB = libconro_lib.a + header files. That's
all you need to program CONRO!
The library has API's for :






Reading Sensor from each port
Debug through printf to a host pc running
hyperterminal(9600 8N1) in
Software UART for inter CONRO communication
Individual control of each port TX and reading the digital
value of
Each port RX.
Controlling pitch and yaw servo
Discussion of all APIs

1 Header file for each oval functionality





adc.h
debugPrintf.h
portControl.h
servo.h
uartsw.h
Discussion of all APIs

Uartsw (For Infrared Communication)

#include “uartsw.h”

int sendByte(uint8_t u08)

int receiveByte(void)

#define UARTSW_RX_BUFFER_SIZE
0x20
Discussion of all APIs

Servos
#include “servo.h”
 initializeServos();
 void controlServoNorth(uint16_t angle);
 void controlServoSouth(uint16_t angle);

Discussion of all APIs

Controlling PORT LEDS(TX) and reading a
digital value from RX

#include “portControl.h”

initializePorts();

void northPortTx(uint8_t status); //status =1 TX
=> ON status = 0 =>OFF.

uint8_t readNorthRx(void); //returns a HIGH or
LOW
Discussion of all APIs

Reading ADC sensor: intensity of
received IR on any RX port

#include “adc.h”

initializeAdc();

uint16_t readSensorNorth(void);
Discussion of all APIs
Using printf to send data to PC:
Hyperterminal
 #include “debugPrintf.h”


initializeDebug();
Printf(“Howdy CONRO\n\r”);
OR
 Printf(“value of angle is %d\n\r”,angle);

Writing your first program

Example :you want to move the servo

Make any directory say.. testConro
mkdir testConcro
cd testConro
tar xvzf CONRO.tar.gz
Vi/emacs demo.c




Writing your first program
#include “servo.h”
Int main(void)
{
initializeServos();//initiallize servo
controlServoNorth(300);//servo middle
return 1;//make sure u write return
}
Writing your first program
To clean
testConro>$ make clean
To compile
testConro>$ make
Switch on CONRO ,Connect the programming cable
testConro>$ make flash
You’re done!
Modifying the Makefile
Currently
SRCS = demo.c
OBJS = demo.o

Change to
SRCS = cfile1.c cfile2.c
OBJS = cfile1.o cfile2.o

How do I add my contribution to
CONROLIB?

U just made a cool *.o u want to add to
libconro_lib.a

USE CVS! Do not overwrite the old library

Compile ure code to obj(-c option) do NOT link




avr-gcc –mmcu=atmega128 –c blah.c
ar qv libconro_lib.a blah.o
ranlib libconro_lib.a
Make a header file with ure API in it. Put header
file in includes dir and update libconro_lib.a
Why use static libaries?

Precompiled: Saves time

If a bug fix is found you only have to
update 1 file !

Insulates you from hardware. Don’t worry
about hardware dependant C code

Note: only relevant object code is linked
Future Work on CONROLIB

Modify APIs?

Wireless API

API code is stable according to me but
bugs could still be lurking around. Report
anything unusual to me

Fixed point Math Library :Speed and
Accuracy
Demo

How To install Winavr?

How To use it?

Installing CONROLIB

Running a Program
HAVE FUN !
Download