Go Down

Topic: Prototype:  MES v1 (Read 1 time) previous topic - next topic

SpaceBird

MES v1 stands for: Minimal Experiment Shield Version 1

Possible Experiments with the MES V1, could be:

E1-  Digital Counter (Up - Down)
E2 - 1 Nible Counter
E3 - Swaping bits
E4 - Odd - Even Nible
E5 - Nible Vumeter with a Preset
E6 - Controling a MiniServo with a Preset
E7 - Understandig Analog Inputs with a Preset and Display

This is the fisrt version of the MES. What do you think? This could be useful  for worshops.



:-?

florinc

#1
Jun 28, 2009, 03:41 pm Last Edit: Jun 28, 2009, 03:41 pm by florinc Reason: 1
If this is an Arduino shield, don't you want to use the analog pins (A0-A5) of the Arduino (meaning that you would need headers on the bottom right part of the shield)?

Do you have schematics to show?

SpaceBird



MES v1.4 stands for: Minimal Experiment Shield Version 1.4

Possible Experiments with the MES V1.4, could be:

E1-  Digital Counter (Up - Down)
E2 - 1 Nible Counter
E3 - Swaping bits
E4 - Odd - Even Nible
E5 - Nible Vumeter with a Preset
E6 - Controling a MiniServo with a Preset
E7 - Understandig Analog Inputs with a Preset and Display
E8 - Simulating an Interrupt

:-?

Good, here again, I've made the board in one sigle layer. Fig. 1 , now it's working fine. Some pics of the shield. Fig 2 the shield itself. Fig 3 Arduino Duemilanove with the shield.

Fig.1


Fig.2


Fig.3


A small video testing the board with the code show below.



http://www.youtube.com/watch?v=4Tgyu86-BHo

Code: [Select]

#include <Servo.h>

Servo MiServo;

int p0 = 0;
int p1 = 1;
int p2 = 2;
int p3 = 3;

int p4 = 4;
int p5 = 5;
int p6 = 6;
int p7 = 7;

int pm = 9;

int An0 = 0;

int Data;


void setup(){

pinMode (p0,OUTPUT);  
pinMode (p1,OUTPUT);  
pinMode (p2,OUTPUT);
pinMode (p3,OUTPUT);

pinMode (p4,OUTPUT);  
pinMode (p5,OUTPUT);  
pinMode (p6,OUTPUT);
pinMode (p7,OUTPUT);

digitalWrite (p0,0);
digitalWrite (p1,0);
digitalWrite (p2,0);
digitalWrite (p3,0);

digitalWrite (p4,0);
digitalWrite (p5,0);
digitalWrite (p6,0);
digitalWrite (p7,0);

MiServo.attach(pm);

}


void loop(){
 
 Data = analogRead (An0);
 Data = map(Data,0,1024,0,255);

if ((Data >= 0) && (Data <= 64)){

 leds(0);
 disp(0);
 MiServo.write (0);
 delay (1000);
 
}else if ((Data >= 65) && (Data <= 127)){

 leds(1);
 disp(1);
 MiServo.write (45);
 delay (1000);
 
}else if ((Data >= 128) && (Data <= 191)){

 leds(2);
 disp(2);
 MiServo.write (90);
 delay (1000);
 
}else if ((Data >= 192) && (Data <= 255)){

 leds(3);
 disp(3);
 MiServo.write (135);
 delay (1000);
 
}



}


void leds (int i){
 
switch (i){
 
 case 0:

digitalWrite (p0,0);
digitalWrite (p1,0);
digitalWrite (p2,0);
digitalWrite (p3,0);

break;


 case 1:

digitalWrite (p0,1);
digitalWrite (p1,0);
digitalWrite (p2,0);
digitalWrite (p3,0);

break;  
 
 case 2:
 
digitalWrite (p0,0);
digitalWrite (p1,1);
digitalWrite (p2,0);
digitalWrite (p3,0);

break;

 case 3:

digitalWrite (p0,0);
digitalWrite (p1,0);
digitalWrite (p2,1);
digitalWrite (p3,0);

break;

 case 4:

digitalWrite (p0,0);
digitalWrite (p1,0);
digitalWrite (p2,0);
digitalWrite (p3,1);

break;

 }

}

void disp(int k){
 
 switch (k) {
 
 case 0:

 digitalWrite (p4,0);
 digitalWrite (p5,0);
 digitalWrite (p6,0);
 digitalWrite (p7,0);
 
 break;
 
 
 case 1:

 digitalWrite (p4,0);
 digitalWrite (p5,0);
 digitalWrite (p6,0);
 digitalWrite (p7,1);
 
 break;
   
 case 2:

 digitalWrite (p4,0);
 digitalWrite (p5,0);
 digitalWrite (p6,1);
 digitalWrite (p7,0);
 
 break;
   
 case 3:

 digitalWrite (p4,0);
 digitalWrite (p5,0);
 digitalWrite (p6,1);
 digitalWrite (p7,1);
 
 break;
 
 case 4:

 digitalWrite (p4,0);
 digitalWrite (p5,1);
 digitalWrite (p6,0);
 digitalWrite (p7,0);
 
 break;
 
 case 5:

 digitalWrite (p4,0);
 digitalWrite (p5,1);
 digitalWrite (p6,0);
 digitalWrite (p7,1);
 
 break;
 
 
 case 6:

 digitalWrite (p4,0);
 digitalWrite (p5,1);
 digitalWrite (p6,1);
 digitalWrite (p7,0);
 
 break;
 
 case 7:

 digitalWrite (p4,0);
 digitalWrite (p5,1);
 digitalWrite (p6,1);
 digitalWrite (p7,1);
 
 break;
 
 case 8:

 digitalWrite (p4,1);
 digitalWrite (p5,0);
 digitalWrite (p6,0);
 digitalWrite (p7,0);
 
 break;
 
 
 case 9:

 digitalWrite (p4,1);
 digitalWrite (p5,0);
 digitalWrite (p6,0);
 digitalWrite (p7,1);
 
 break;
 
 }
 
}



Vikas

Nice , A lot of stuff can be experimented using this.
http://www.roboticsindia.com

SpaceBird

#4
Nov 24, 2009, 12:44 am Last Edit: Nov 24, 2009, 12:45 am by spacebird Reason: 1
After testing and analizing the functionality of the Minimal Experimental Shield, I had order pro PCBs. This is the result, in a couple of days I'm going to work on a small manual.



:P

SpaceBird

Just an update.

MES V1.6 with components.



Comments ?

;)

SpaceBird

Assembling finished.


Fig. 1 - MES v1.6


Fig. 2 - MES v1.6 with Arduino Duemilanove

:o

Any comments?

TchnclFl

Looks pretty cool!  I like how it has the 7 digit display integrated :).

SpaceBird

Thanks TchnclFl and Vikas, ep, looks cool now.

Well I was making a program that uses the ADXL3XX, now I post a code and a video. This takes only one axis and obtain positions on the LED and shows a numeric value on the 7 segment display.

Code: [Select]


/* MES-1 V1.6
Sample code to use one axis , from accelerometer ADXL320
Displays numeric and position values using the MES.
spacebird 2009 */


//LEDS
int p0 = 7;
int p1 = 6;
int p2 = 5;
int p3 = 4;

//For decoder
int p4 = 13;
int p5 = 12;
int p6 = 11;
int p7 = 10;

//Analog Input 0
int An0 = 0;

void setup(){

pinMode (p0,OUTPUT);  
pinMode (p1,OUTPUT);  
pinMode (p2,OUTPUT);
pinMode (p3,OUTPUT);

pinMode (p4,OUTPUT);  
pinMode (p5,OUTPUT);  
pinMode (p6,OUTPUT);
pinMode (p7,OUTPUT);

digitalWrite (p0,0);
digitalWrite (p1,0);
digitalWrite (p2,0);
digitalWrite (p3,0);

digitalWrite (p4,0);
digitalWrite (p5,0);
digitalWrite (p6,0);
digitalWrite (p7,0);

}

//Int variables
int a;
int b;
int DataAn0;
int Cent;
int PF;
int Num1;
int Num2;

//Float variables
float m;
float P;
float P1;

void loop(){
 
//Calculate m
a = 98;
b = 76;

m = 180 / (float)(a - b);

// Read actual value from accelerometer

DataAn0 = analogRead (An0);
DataAn0 = map(DataAn0,0,1024,0,1024);

//Calculate position
Cent = 87;

P = m*(DataAn0 - Cent) + 90;

P1 = round (P);

PF = abs((int)P1 - 90);

//Display position on LEDS

if ((P1 >= 0) && (P1 <= 30)){

 leds(1);
 delay (255);
 
}else if ((P1 >= 31) && (P1 <= 60)){

 leds(2);
 delay (255);
 
}else if ((P1 >= 61) && (P1 <= 90)){

 leds(5);
 delay (255);
 
}else if ((P1 >= 91) && (P1 <= 120)){

 leds(5);
 delay (255);
 
}else if ((P1 >= 121) && (P1 <= 150)){
 
 leds(3);
 delay (255);
 
}else if((P1 >= 151) && (P1 <= 180)){
 
 leds(4);
 delay (255);
 
}

//Display numeric value on 7 Segment Display

Num1 = PF / 10;
Num2 = PF % 10;

disp (Num1);
delay (250);
disp (Num2);
delay (250);
grad ();
delay (250);

}


void leds (int i){
 
switch (i){
 
 case 0:

digitalWrite (p0,0);
digitalWrite (p1,0);
digitalWrite (p2,0);
digitalWrite (p3,0);

break;


 case 1:

digitalWrite (p0,1);
digitalWrite (p1,0);
digitalWrite (p2,0);
digitalWrite (p3,0);

break;  
 
 case 2:
 
digitalWrite (p0,0);
digitalWrite (p1,1);
digitalWrite (p2,0);
digitalWrite (p3,0);

break;

 case 3:

digitalWrite (p0,0);
digitalWrite (p1,0);
digitalWrite (p2,1);
digitalWrite (p3,0);

break;

 case 4:

digitalWrite (p0,0);
digitalWrite (p1,0);
digitalWrite (p2,0);
digitalWrite (p3,1);

break;

 case 5:
 
digitalWrite (p0,0);
digitalWrite (p1,1);
digitalWrite (p2,1);
digitalWrite (p3,0);

break;
 

 }

}

void disp(int k){
 
 switch (k) {
 
 case 0:

 digitalWrite (p4,0);
 digitalWrite (p5,0);
 digitalWrite (p6,0);
 digitalWrite (p7,0);
 
 break;
 
 
 case 1:

 digitalWrite (p4,0);
 digitalWrite (p5,0);
 digitalWrite (p6,0);
 digitalWrite (p7,1);
 
 break;
   
 case 2:

 digitalWrite (p4,0);
 digitalWrite (p5,0);
 digitalWrite (p6,1);
 digitalWrite (p7,0);
 
 break;
   
 case 3:

 digitalWrite (p4,0);
 digitalWrite (p5,0);
 digitalWrite (p6,1);
 digitalWrite (p7,1);
 
 break;
 
 case 4:

 digitalWrite (p4,0);
 digitalWrite (p5,1);
 digitalWrite (p6,0);
 digitalWrite (p7,0);
 
 break;
 
 case 5:

 digitalWrite (p4,0);
 digitalWrite (p5,1);
 digitalWrite (p6,0);
 digitalWrite (p7,1);
 
 break;
 
 
 case 6:

 digitalWrite (p4,0);
 digitalWrite (p5,1);
 digitalWrite (p6,1);
 digitalWrite (p7,0);
 
 break;
 
 case 7:

 digitalWrite (p4,0);
 digitalWrite (p5,1);
 digitalWrite (p6,1);
 digitalWrite (p7,1);
 
 break;
 
 case 8:

 digitalWrite (p4,1);
 digitalWrite (p5,0);
 digitalWrite (p6,0);
 digitalWrite (p7,0);
 
 break;
 
 
 case 9:

 digitalWrite (p4,1);
 digitalWrite (p5,0);
 digitalWrite (p6,0);
 digitalWrite (p7,1);
 
 break;
 
 }
 
}


int grad(){
 
 digitalWrite (p4,1);
 digitalWrite (p5,1);
 digitalWrite (p6,0);
 digitalWrite (p7,0);

}






Fig. 1 - Video testing of MES-1 v1.6

http://www.youtube.com/watch?v=_3Q7ozhvzrA

8-)

SpaceBird

Code update

Code: [Select]


/* MES-1 V1.6
Sample code to use one axis , from accelerometer ADXL320
Displays numeric and position values using the MES.
spacebird 2009

v0.1 - nov 2009
v0.2 - dic 2009
*/


//LEDS
int pLED[] = {7,6,5,4};

//For decoder
int pDEC[] = {13,12,11,10};

//Analog Input 0
int An0 = 0;

int i;

void setup(){

for (i = 4; i <= 7; i++ ){

 pinMode (pLED[i], OUTPUT);
 pinMode (pDEC[i+6],OUTPUT);

}  

for (i = 4; i <= 7; i++){
 
 digitalWrite(pLED[i],0);
 digitalWrite(pDEC[i+6],0);  
 
}

}

//Int variables
int a;
int b;
int DataAn0;
int Cent;
int PF;
int Num1;
int Num2;

//Float variables
float m;
float P;
float P1;

void loop(){
 
//Calculate m
a = 98;
b = 76;

m = 180 / (float)(a - b);

// Read actual value from accelerometer

DataAn0 = analogRead (An0);
DataAn0 = map(DataAn0,0,1024,0,1024);

//Calculate position
Cent = 87;

P = m*(DataAn0 - Cent) + 90;

P1 = round (P);

PF = abs((int)P1 - 90);

//Display position on LEDS

if ((P1 >= 0) && (P1 <= 30)){

 leds(1);
 delay (255);
 
}else if ((P1 >= 31) && (P1 <= 60)){

 leds(2);
 delay (255);
 
}else if ((P1 >= 61) && (P1 <= 90)){

 leds(5);
 delay (255);
 
}else if ((P1 >= 91) && (P1 <= 120)){

 leds(5);
 delay (255);
 
}else if ((P1 >= 121) && (P1 <= 150)){
 
 leds(3);
 delay (255);
 
}else if((P1 >= 151) && (P1 <= 180)){
 
 leds(4);
 delay (255);
 
}

//Display numeric value on 7 Segment Display

Num1 = PF / 10;
Num2 = PF % 10;

disp (Num1);
delay (250);
disp (Num2);
delay (250);
grad ();
delay (250);

}


void leds (int i){
 
switch (i){
 
 case 0:

for (i = 4; i <= 7; i++){
 digitalWrite(pLED[i],0);
}

break;


 case 1:

digitalWrite (pLED[7],1);

for (i = 4; i <= 6; i++){
 digitalWrite(pLED[i],0);
 
}

break;  
 
 case 2:
 
for (i = 4; i <= 7; i++){

 if (i == 6){
  digitalWrite(pLED[6],1);

 }else{

  digitalWrite(pLED[i],0);

 }
 
}

break;

 case 3:

for (i = 4; i <= 7; i++){

 if (i == 5){

  digitalWrite(pLED[5],1);

 }else{

  digitalWrite(pLED[i],0);

 }
 
}

break;

 case 4:
 
digitalWrite (pLED[4],1);

for (i = 5; i <= 7; i++){

 digitalWrite(pLED[i],0);
 
}

break;

 case 5:

digitalWrite (pLED[7],0);
digitalWrite (pLED[6],1);
digitalWrite (pLED[5],1);
digitalWrite (pLED[4],0);

break;
 

 }

}

void disp(int k){
 
 switch (k) {
 
 case 0:

for (i = 10; i <= 13; i++){
 
 digitalWrite(pDEC[i],0);
 
}
 
 break;
 
 
 case 1:

 digitalWrite(pDEC[10],1);

 for (i = 11; i <= 13; i++){
 
   digitalWrite(pDEC[i],0);
 
 }

 break;
   
 case 2:

for (i = 10; i <= 13; i++){

 if (i == 11 ){
 
   digitalWrite(pDEC[11],1);
 
 }else{
   
   digitalWrite(pDEC[i],0);
 }
 
}

 break;
   
 case 3:

 digitalWrite (pDEC[13],0);
 digitalWrite (pDEC[12],0);
 digitalWrite (pDEC[11],1);
 digitalWrite (pDEC[10],1);
 
 break;
 
 case 4:

for (i = 10; i <= 13; i++){
 
 if (i == 12){
   
   digitalWrite(pDEC[12],1);
 
 }else{
   
 digitalWrite(pDEC[i],0);
   
 }
 
}

 break;
 
 case 5:

 digitalWrite (pDEC[13],0);
 digitalWrite (pDEC[12],1);
 digitalWrite (pDEC[11],0);
 digitalWrite (pDEC[10],1);
 
 break;
 
 
 case 6:

 digitalWrite (pDEC[13],0);
 digitalWrite (pDEC[12],1);
 digitalWrite (pDEC[11],1);
 digitalWrite (pDEC[10],0);
 
 break;
 
 case 7:

 for (i = 10; i <= 13; i++){
   
   if (i == 13){
     
     digitalWrite(pDEC[13],0);
     
   }else{
     
    digitalWrite(pDEC[i],1);
   
   }
   
 }

 break;
 
 case 8:

 for (i = 10; i <= 13; i++){
   
   if (i == 13){
     
     digitalWrite(pDEC[13],1);
     
   }else{
     
    digitalWrite(pDEC[i],0);
   
   }
   
 }
 
 break;
 
   case 9:

 digitalWrite (pDEC[13],1);
 digitalWrite (pDEC[12],0);
 digitalWrite (pDEC[11],0);
 digitalWrite (pDEC[10],1);
 
 break;
 
 }
 
}


int grad(){
 
 digitalWrite (pDEC[13],1);
 digitalWrite (pDEC[12],1);
 digitalWrite (pDEC[11],0);
 digitalWrite (pDEC[10],0);

}




:o

SpaceBird

Ok, well now MES-1 has a library, easy :o to use.

Librar

Code: [Select]

/*
   Mes1dlc.h

     MES-1 Lib  for Disp and LEDs
   v 0.1 12 dec 2009
   Created > sgbzona
*/

#ifndef Mes1dlc_h
#define Mes1dlc_h

#include "WProgram.h"

class Mes1dlc{

     public:
      Mes1dlc(uint8_t d3, uint8_t d2, uint8_t d1, uint8_t d0);
      // pins used by Display or LEDs
      void init(uint8_t d3, uint8_t d2, uint8_t d1, uint8_t d0);
      void disp(int k);
      void ledsC(int k);
      void ledsE(int k);

      private:
            uint8_t _pPIN[4];
            
};

#endif



Code: [Select]

/*
   Mes1dlc.cpp

     MES-1 code  for Disp and LEDs
   v 0.1 12 dec 2009
   Created > sgbzona
*/

#include "WProgram.h"
#include "Mes1dlc.h"

int Num [][16] = {{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1},{0,1,0,0},{0,1,0,1},{0,1,1,0},{0,1,1,1},{1,0,0,0},{1,0,0,1},{1,0,1,0},{1,0,1,1},{1,1,0,0},{1,1,0,1},{1,1,1,0},{1,1,1,1}};

int NumE [][19] = {{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,1,0,0},{1,0,0,0},{1,0,0,1},{0,1,1,0},{0,0,0,0},{0,0,0,1},{0,0,1,1},{0,1,1,1},{1,1,1,1},{0,1,1,0},{1,1,0,0},{0,0,1,1},{1,0,1,0},{0,1,0,1},{0,0,0,0},{1,1,1,1}};


Mes1dlc::Mes1dlc(uint8_t d3, uint8_t d2, uint8_t d1, uint8_t d0){

     init (d3, d2, d1, d0);

}

     
void Mes1dlc::init(uint8_t d3, uint8_t d2, uint8_t d1, uint8_t d0){

int i;
           
           _pPIN[0] = d3;      
           _pPIN[1] = d2;      
           _pPIN[2] = d1;      
           _pPIN[3] = d0;      

     
     for (i = 0; i <= 3; i++){
           
           pinMode(_pPIN[i],OUTPUT);
           digitalWrite(_pPIN[i],0);
     
     }      
     
     
}

void Mes1dlc::disp(int k){

int i;
int j;

             i = k;
             
                 for (j = 0; j <= 3; j++){
                       
                 digitalWrite(_pPIN[j],Num[i][j]);
                 
                 }
     
}

void Mes1dlc::ledsC(int k){

int i;
int j;
     
          i = k;
             
                 for (j = 0; j <= 3; j++){
                       
                 digitalWrite(_pPIN[j],Num[i][j]);
                 
                 }
     
}

void Mes1dlc::ledsE(int k){

int i;
int j;
     
          i = k;
             
                 for (j = 0; j <= 3; j++){
                       
                 digitalWrite(_pPIN[j],NumE[i][j]);
                 
                 }
     
}
     


New Sample code.

Code: [Select]

/* MES-1 V1.6
Sample code to use one axis , from accelerometer ADXL320
Displays numeric and position values using the MES.
spacebird 2009

v0.1 - nov 2009 // Basic CONFIG
v0.2 - dic 2009 // Using Basic CONFIG w/Cycles
v0.3 - dic 2009 // Using a Library

*/

#include <Mes1dlc.h>


//LEDS
Mes1dlc mes1PLEDS (7,6,5,4);

//For decoder
Mes1dlc mes1PDISP (13,12,11,10);

//Analog Input 0
int An0 = 0;

int i;

//Int variables
int a;
int b;
int DataAn0;
int Cent;
int PF;
int Num1;
int Num2;

//Float variables
float m;
float P;
float P1;

void setup(){

}


void loop(){
 
//Calculate m
a = 98;
b = 76;

m = 180 / (float)(a - b);

// Read actual value from accelerometer

DataAn0 = analogRead (An0);
DataAn0 = map(DataAn0,0,1024,0,1024);

//Calculate position
Cent = 87;

P = m*(DataAn0 - Cent) + 90;

P1 = round (P);

PF = abs((int)P1 - 90);

//Display position on LEDS

if ((P1 >= 0) && (P1 <= 30)){

 mes1PLEDS.ledsE(4);
 delay (255);
 
}else if ((P1 >= 31) && (P1 <= 60)){

 mes1PLEDS.ledsE(3);
 delay (255);
 
}else if ((P1 >= 61) && (P1 <= 90)){

 mes1PLEDS.ledsE(6);
 delay (255);
 
}else if ((P1 >= 91) && (P1 <= 120)){

 mes1PLEDS.ledsE(6);
 delay (255);
 
}else if ((P1 >= 121) && (P1 <= 150)){
 
 mes1PLEDS.ledsE(2);
 delay (255);
 
}else if((P1 >= 151) && (P1 <= 180)){
 
 mes1PLEDS.ledsE(1);
 delay (255);
 
}

//Display numeric value on 7 Segment Display

Num1 = PF / 10;
Num2 = PF % 10;

mes1PDISP.disp(Num1);
delay (250);
mes1PDISP.disp(Num2);
delay (250);
mes1PDISP.disp(12);
delay (250);

}


AlphaBeta

Like it!

Just a tip: You can cut down RAM usage to 6,25%

Code: [Select]
Num [][16] = {{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1},{0,1,0,0},{0,1,0,1},{0,1,1,0},{0,1,1,1},{1,0,0,0},{1,0,0,1},{1,0,1,0},{1,0,1,1},{1,1,0,0},{1,1,0,1},{1,1,1,0},{1,1,1,1}};

Use:
Code: [Select]

byte Num[8] = {
     B00000001,
     B00100011
     B01000101,
     B01100111,
     B10001001,
     B10101011,
     B11001101,
     B11101111
};


You need to change the way you access the data, but arduino provides with some bitRead/bitWrite functions (plus some more). Look at the reference section :)

Gool luck!

SpaceBird

Cool... looking to improve it... nice tip, working on vectors now...

;)

Go Up