Thursday, November 1, 2012

Firmware for uC | Introduction

   This post marks the beginning of a new article series discussing the development of the firmware, we coded for the atmega16 micro-controller(we call it the, ORGAN) used in the project.

   The firmware will not do anything unless the android(we call it the, BRAIN) asks it to do so. After lot of thinking, and experiments interrupt driven method is chosen  for implementation. When it receives a command usually one the predefined set of values defined through these directives.

file: athena.h
/************************************************************
 * Actual operations                                        *
 * they are used as indices for                             *
 * <category>_<operation>_<direction> function pointer array  *
 ************************************************************/

/*  LOCOMOTION OPERATIONS */
#define LOCO_FORWARD      LOCO_CONT_BEGIN +  01
#define LOCO_BACKWARD     LOCO_CONT_BEGIN +  02
#define LOCO_TURN_RIGHT   LOCO_CONT_BEGIN +  03
#define LOCO_TURN_LEFT    LOCO_CONT_BEGIN +  04
#define LOCO_TURN_AROUND  LOCO_CONT_BEGIN +  05
/*  CAMERA HANDLING */
#define CAM_LOOK_UP       CAM_CONT_BEGIN + 01
#define CAM_LOOK_DOWN     CAM_CONT_BEGIN + 02
#define CAM_LOOK_RIGHT    CAM_CONT_BEGIN + 03
#define CAM_LOOK_LEFT     CAM_CONT_BEGIN + 04
/* ARM CONTROL */
#define ARM_CONTRACT      ARM_CONT_BEGIN + 01
#define ARM_DILATE        ARM_CONT_BEGIN + 02
#define ARM_UP            ARM_CONT_BEGIN + 03
#define ARM_DOWN          ARM_CONT_BEGIN + 04
where the values of <category>_CONT_BEGIN are,
#define LOCO_CONT_BEGIN 00                               /* 00 */
#define LOCO_CONT_LEN   10
#define LOCO_CONT_END   LOCO_CONT_BEGIN + LOCO_CONT_LEN  /* 10 */

#define CAM_CONT_BEGIN  LOCO_CONT_END                    /* 10 */
#define CAM_CONT_LEN    10
#define CAM_CONT_END    CAM_CONT_BEGIN + CAM_CONT_LEN    /* 20 */

#define ARM_CONT_BEGIN  CAM_CONT_END                     /* 20 */
#define ARM_CONT_LEN    10
#define ARM_CONT_END    ARM_CONT_BEGIN + ARM_CONT_LEN    /* 30 */
So when the brain send one of these commands to the organ, the organ do the job for a fixed time frame and stop. (do not worry about the communication interface b/w brain & organ. we will come to that in next post.) What is now important is, firmware does the job for a fixed time duration when it is asked to do.


0 comments:

Post a Comment

 

Copyright © Project Athena Design by O Pregador | Blogger Theme by Blogger Template de luxo | Powered by Blogger