Possible (Cheap) Expansion Board for the Arduino Uno?

For a few months, many in the Arduino community have heard rumors about Iteadstudio’s release of a very low priced Arduino development board ($US 7-8).  While there are clones of many varieties available, it is always interesting to know what is out there and to at least characterize it.

One of the Arduino Community active contributors, John Boxall of tronixstuff, received his Iteaduino Lite and wrote a review of the development board.  Summary is that the microcontroller (LogicGreen LGT8F88) is a Chinese clone of the ATmega88A (with some extra things), which means 8k of Flash memory.  Of course, I have no qualms with “green-tech”, but cutting back on Flash?  It appears the reaction in the community is, “Wah?!”

They seem to have an answer to this on the simple spec page:

LGT8F88A based on LGT8XM, a deeply optimized 8bit RISC core. In order to maximize performance and parallelism, LGT8XM uses Harvard architecture – with separate memories and buses for program and data. Instructions are executed inside a 2-stage pipeline. 2-stage pipeline reduces useless fetch-stage, so decrease power consumption caused by flash memory. LGT8XM introduce a smart instruction cache, which can fetch more instructions one time, effectively decrease memory accessing operations. Based on our test, LGT8XM decrease about 40% power consumption caused by program memory compare to other 8bit architectures.

So, it might be interesting to compare the current consumption, but I am thinking the vast majority of the current consumption will be in the shield stack, so not very high on the concerns list.  There has got to be something interesting.

What I did see in that specification?  32MHz @ 1.8 ~ 5V?  There might be something here… I wonder if you could easily mount the Iteaduino Lite on the Uno?

One of the more features that can be found on a lot of Asian Arduino hardware is the two sets of offset header holes for allowing the boards to stack.  For the development boards, I suspect it was for putting standard 0.1″ perf boards on Arduino derivatives.

Okay, the hardware to hardware interface is available, what about the software?  The only real options are TWI/I2C (maybe One-

Wire) or the SPI interface.  I am not sure if I am done stacking, so I will pick the Two Wire interface.

I2C Lite

The board to board connections are simple with soldering only a pair of male pins for the 5V/Gnd and A4/A5 from the bottom of the Iteaduino Lite board.

Alright, now a good sketch is in order and I am not going to re-invent the wheel.  From my search of the net, Nick Gammon (Another Arduino Community mainstay) has the most complete exploration study of Two-Wire or I2C for the Arduino that I can find.  There is more TWI/I2C functionality that can be found on his site, but I liked these for the basic concept.

For the Uno (Master) (Pastebin here):

// Written by Nick Gammon
// Date: 18th February 2011
// Modified by Synthetic Physical Computing
// Date: 1st Febuary 2014

#include <Wire.h>

const int SLAVE_ADDRESS = 0x42;

// various commands we might send
enum {
CMD_ID = 1,
CMD_READ_A0 = 2,
CMD_READ_A1 = 3,
CMD_READ_A2 = 4,
CMD_READ_A3 = 5,
CMD_READ_D2 = 6,
CMD_READ_D3 = 7,
CMD_READ_D4 = 8,
CMD_READ_D5 = 9,
};

void sendCommand (const byte cmd, const int responseSize)
{
Wire.beginTransmission (SLAVE_ADDRESS);
Wire.write (cmd);
Wire.endTransmission ();

Wire.requestFrom (SLAVE_ADDRESS, responseSize);
} // end of sendCommand

void setup ()
{
Wire.begin ();
//TWBR = 12; //Uncomment for 400k
Serial.begin (9600); // start serial for output

sendCommand (CMD_ID, 1);

if (Wire.available ())
{
Serial.print (“Slave is ID: “);
Serial.println (Wire.read (), HEX);
}
else
Serial.println (“No response to ID request”);

} // end of setup

void loop()
{
int val;

sendCommand (CMD_READ_A0, 2);
val = Wire.read ();
val <<= 8;
val |= Wire.read ();
Serial.print (“Value of A0: “);
Serial.println (val, DEC);

sendCommand (CMD_READ_A1, 2);
val = Wire.read ();
val <<= 8;
val |= Wire.read ();
Serial.print (“Value of A1: “);
Serial.println (val, DEC);

sendCommand (CMD_READ_A2, 2);
val = Wire.read ();
val <<= 8;
val |= Wire.read ();
Serial.print (“Value of A2: “);
Serial.println (val, DEC);

sendCommand (CMD_READ_A3, 2);
val = Wire.read ();
val <<= 8;
val |= Wire.read ();
Serial.print (“Value of A3: “);
Serial.println (val, DEC);

sendCommand (CMD_READ_D2, 1);
val = Wire.read ();
Serial.print (“Value of D2: “);
Serial.println (val, DEC);

sendCommand (CMD_READ_D3, 1);
val = Wire.read ();
Serial.print (“Value of D3: “);
Serial.println (val, DEC);

sendCommand (CMD_READ_D4, 1);
val = Wire.read ();
Serial.print (“Value of D4: “);
Serial.println (val, DEC);

sendCommand (CMD_READ_D5, 1);
val = Wire.read ();
Serial.print (“Value of D5: “);
Serial.println (val, DEC);

delay (500);
} // end of loop

For the Iteaduino Lite (Slave) (Pastebin here):

// Written by Nick Gammon
// Date: 18th February 2011
// Modified by Synthetic Physical Computing
// Date: 1st Febuary 2014

#include <Wire.h>

const byte MY_ADDRESS = 0x42;

// various commands we might get

enum {
CMD_ID = 1,
CMD_READ_A0 = 2,
CMD_READ_A1 = 3,
CMD_READ_A2 = 4,
CMD_READ_A3 = 5,
CMD_READ_D2 = 6,
CMD_READ_D3 = 7,
CMD_READ_D4 = 8,
CMD_READ_D5 = 9,
};

char command;

void setup()
{
command = 0;

pinMode (2, INPUT);
digitalWrite (2, HIGH); // enable pull-up
pinMode (3, INPUT);
digitalWrite (3, HIGH); // enable pull-up
pinMode (4, INPUT);
digitalWrite (4, HIGH); // enable pull-up
pinMode (5, INPUT);
digitalWrite (5, HIGH); // enable pull-up

pinMode (A0, INPUT);
digitalWrite (A0, LOW); // disable pull-up
pinMode (A1, INPUT);
digitalWrite (A1, LOW); // disable pull-up
pinMode (A2, INPUT);
digitalWrite (A2, LOW); // disable pull-up
pinMode (A3, INPUT);
digitalWrite (A3, LOW); // disable pull-up

Wire.begin (MY_ADDRESS);
Wire.onReceive (receiveEvent); // interrupt handler for incoming messages
Wire.onRequest (requestEvent); // interrupt handler for when data is wanted

} // end of setup

void loop()
{
// all done by interrupts
} // end of loop

void receiveEvent (int howMany)
{
command = Wire.read (); // remember command for when we get request
} // end of receiveEvent

void sendSensor (const byte which)
{
int val = analogRead (which);
byte buf [2];

buf [0] = val >> 8;
buf [1] = val & 0xFF;
Wire.write (buf, 2);
} // end of sendSensor

void requestEvent ()
{
switch (command)
{
case CMD_ID: Wire.write (MY_ADDRESS); break; // send our ID
case CMD_READ_A0: sendSensor (A0); break; // send A0 value
case CMD_READ_A1: sendSensor (A1); break; // send A0 value
case CMD_READ_A2: sendSensor (A2); break; // send A0 value
case CMD_READ_A3: sendSensor (A3); break; // send A0 value

case CMD_READ_D2: Wire.write (digitalRead (2)); break; // send D2 value
case CMD_READ_D3: Wire.write (digitalRead (3)); break; // send D3 value
case CMD_READ_D4: Wire.write (digitalRead (4)); break; // send D4 value
case CMD_READ_D5: Wire.write (digitalRead (5)); break; // send D5 value

} // end of switch

} // end of requestEvent

Output looks like this:

I2C Terminal

I must confess that is just two Arduinos attach via TWI/I2C, but when I do receive my Iteaduino Lite I am curious of the ADC performance running at 32 MHz above my Uno.  Until then.

About these ads

Posted on February 1, 2014, in Two Wire - I2C. Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: