Show Posts
Pages: 1 ... 23 24 [25] 26
361  Forum 2005-2010 (read only) / Interfacing / SPI and I2C on: September 05, 2010, 04:39:46 pm

I have read multiple posts on SPI and I2C however have a few questions which I hope someone can answer. If I have stated anything incorrectly, can someone please correct me.

I am currently working on a project where I need a few Arduino processors to talk to each other. They are not all the same processors, however that shouldnt matter.

The aim is to have the Master Arduino address up to 8 slave Arduino's or devices on the communications backbone, so whether they are arduino compatible processors or if they are IO Expanders for example.

I have been tossing up whether I should be using SPI or I2C as the 'backbone' for the comms.
From what I understand, SPI isnt fully 'supported' in Arduino yet. It works, but its not really native so to speak, and is done via bingbanging?

I2C is fully supported from what I can tell, however it is slower than SPI, but does only use 2 wires.

Is SPI, in its current form, faster than I2C, given the fact that its not really 'supported', or is I2C actually faster with how its currently implemented in Arduino ?
What determines the speed also, as I see there are a few different speed options when reading wikis about these comms. Are these settable somehow or is it a case of the bus going at the speed of the slowest device?

Also can a number of different devices all go on the same bus if they all talk I2C or SPI, or is there some variation between implementation of these between brands so its not all smooth sailing?

Along with the master Arduino talking to a number of slave Arduino's, I want to be able to talk to other SPI and I2C devices, such as SHT15's and SCH1000's and I2C EEPROM etc. I am just a little unsure what is the best method and if I can also implement hardware and software version of SPI or I2C at the same time.

To break up what I just said:
The SHT15 I have isnt SPI or I2C, so isnt really an issue for this now that I have written it...
The SCH1000 is SPI. If I was to have the hardware pins of the master Arduino go to the SPI backbone, is there a way for me to implement software SPI on different pins for the SCH1000 so it doesnt take up an address on the SPI backbone? Basically so I can have 8 addresses for other devices on the backbone.
The EEPROM I have is I2C. If I was to use an I2C backbone instead of SPI, can I implement a software I2C for the same reasons as above, to provide the 8 addresses on the backbone still without this EEPROM taking up one of the addresses?

From what I have seen, I2C looks easier to implement nicely, however I am just unsure about the speed factor and if SPI is actually the better way to go for being a communications backbone, given the current way these comms are implemented in the Arduino IDE.

Is version 19 of the IDE improving support for SPI by the way?

Thanks in advance

362  Forum 2005-2010 (read only) / Interfacing / Re: Can this Code be Shorter? on: August 31, 2010, 02:34:06 am
What is your aim - more efficient code, less flash required to do the same function, or just shorter so there isnt as much to read...?
Do you want it 'complex' but short, or long and readable...

Just curious on shorter
363  Forum 2005-2010 (read only) / Interfacing / Re: temperature controlled lamp on: August 31, 2010, 02:04:46 am
Hi there

Funnily enough I just built a very similar thing for a friend, not for eggs, but to brew some home brew using the heat source of a light bulb.

Slight different though, not a 12V lamp in our case, but I switch 230VAC 100W lamp, which produces enough heat to warm a cupboard with the home brew 30L or so vessel inside, and comfortable keeps the temp at 20 degrees C. So no PWM in my case, just fairly crude on/off control with hysteresis - which was sufficient as a first pass for him. It has successfully just brewed the first batch, and the beer is now bottled and inside the cupboard again for a week or two as it pressurises.

I am using a SHT15 and the prototype Relay Shield I made.

I am also datalogging every 5 minutes (I think from memory) into the built in EEPROM of the Arduino, and have built a python program which extracts this information to graph the last 24h or so of data. The Arduino also streams data out of the serial port so the laptop can see live data. The laptop can also send commands to change the setpoints, hysteresis etc which is saved in the EEPROM also. Oh it has a 16x2 LCD which displays the current data and setpoint etc too.

Let me know if you want any code.

Quite a fun little project and good for learning about LCD's, EEPROM, logging, crude temperature control, SHT15's, etc.

We will be improving this alot for the next version, and making a dedicated board so I can get my arduino back - lol.

364  Forum 2005-2010 (read only) / Interfacing / Re: PulseIn() command with Hall Effect Switch on: July 24, 2010, 04:53:25 am
Refer to this post and look at the code at the end:

It helped me as I am also measuring RPM.
PulseIn works but not as accurately as you may want, so the solution in the post above may suit you better. Its more complex but you get the result.
At about 20,000rpm there is an error of about 30rpm or so, so its pretty damn good really.
365  Forum 2005-2010 (read only) / Interfacing / Ambient Pressure Sensor on: August 04, 2010, 01:40:40 am

I have a project where we need to read in Temperature, Humidity and Pressure - basically a little weather station for indoor use. Its just part of a larger project.

I currently have the SHT15 sensor which I have working well with the library found on here, however I now need to find a sensor suitable for pressure and I am not sure what to use.

The SHT15 I have is the Sparkfun breakout version. I am indeally wanting something like for the pressure sensor that is on a little board so I can easily put it on a wire and have it a small distance from the arduino itself.

I noticed sparkfun has two breakout boards with pressure sensors, however I am not sure which one I should use and if one will be ok to use with the SHT15. I am assuming that since the SHT15 isnt using the I2C or SPI bus, then either one of these will be fine - but I just wanted to check.

Is one better than the other, or one better for my application?

I basically just need the hPa reading of the area this machine will be in, as apparently (according to the guy I am building this for), small pressure variations can explain different results of the machine, so knowing what the pressure is at the time will be beneficial. Sorry for being vague however I cannot say exactly what the machine is due to copywrite reasons.

Thanks in advance
366  Forum 2005-2010 (read only) / Interfacing / Re: SHT15 Humidity/Temperature Tutorial on: July 13, 2010, 06:05:48 am
tasasaki - Can you please elaborate on what you found with this? Is this actually a typo? Does the library need to therefore be updated? Can you explain please?

I got the breakout board version from Sparkfun and the temperature is deffinitely not reading what it should. Its about 80% humidity outside at the moment and about 4 degrees C, and mine is reading about 10 degrees C and about 72% humidity.

I am going to leave the breakout board out side under cover overnight as I dont have a humidifier, hopefully the outside humidity will help 'rehydrate' my chip, if this is infact the problem.

See how it goes.
367  Forum 2005-2010 (read only) / Interfacing / Re: ADC - Higher Resolution OR Fast Counting on: July 07, 2010, 07:41:23 pm
Yeah I could do.
Currently I am just generating randoms sine waves and outputting it to serial every loop, at 9600 baud, and the serial is coping fine. The PC is getting every single pass so it seems 9600 is coping no worries.

I put an LCD on the arduino and am printing to that, along with the serial, and also calculating the ms it takes to complete each loop, and its currently sitting at 30ms. So 30ms every serial print, at 9600 baud, and all data is going through...

So 9600 seems fine.
But yes, I can up this to a higher value if needed.
368  Forum 2005-2010 (read only) / Interfacing / Re: ADC - Higher Resolution on: July 07, 2010, 04:07:47 pm
Well if the micro is running at 16,000,000 Hz - which is 16,000,000 a second, then if I get a pulse coming in 333 times a second (once every 0.003 seconds), then the processor would have processed about 48,000 Hz worth of stuff between each pulse ?

Isnt that the case?

16Mhz / 333 = 48Khz

Or am I full of it...
369  Forum 2005-2010 (read only) / Interfacing / Re: ADC - Higher Resolution on: July 07, 2010, 03:56:21 pm
Hi Senso
Thanks - wasnt expecting such a quick reply!

Well that sounds great then. Yes shame about the 2 external interrupts - I should have realised this myself. I am use to using the 644P, but never in anger like this project is demanding.

inductive clamp - just the same sort as you would get on a standard timing light, or inductive pickup on a current sensing multimeter. I dont have one yet, but I know they are available.

So yes, counting 333 pulses per second on 1 interrupt, and counting 150 pulses per second on the 2nd interrupt, along with outputting at 9600 baud to the serial port, and potentially outputting to an LCD (yet to be determined if I need this) all sounds possible then.
I suppose 16Mhz is 16,000,000 Hz, so incrementing a count every 48,000 Hz of the processor (333 a second) etc does sound more possible I suppose.

Thanks for that
370  Forum 2005-2010 (read only) / Interfacing / Re: ADC - Higher Resolution on: July 07, 2010, 03:35:08 pm
Thanks for the replies.

I am aware that this is not the normal method for counting RPM, as yes - they are generally pulses. However my concern was the amount of counting the Arduino would have to do in order to count this signal at the high RPM.
20,000RPM is 333 pulses per second. I wasnt sure if the Arduino is capable of counting at this rate.
I was going to look at some form of frequency to voltage conversion in order to get the signal into an analog reading so it can be simply read at 10 bit (or higher with another chip) by the arduino, as it then wouldnt have to be flat out counting.

To extend the problem, this is one of potentially 4 signals that are going to be like this. My concern was if I have 4 digital input pulses coming in to the arduino at once, is it going to be able to keep up with the counting?

I didnt mention the sensor I am using on purpose, as I dont yet know this. It hasnt been determined yet. It may be an inductive pickup off one of the spark plug leads, it may be from a hall sensor. Regardless, it is irrelevant. It will be a pulse train, but I wasnt sure if I would need to convert this to an analog voltage for the ADC or if the arduino could infact cound the pulses.

I am going to have a 0 - 20,000 pulse count for RPM (333 pulses per second)
I am going to have a 0 - 9,000 pulse count for km/h (150 pulses per second)

The other two are yet to be decided if they will be pulses or voltages, however is the arduino actually capable of doing all this counting?

Sorry if I didnt explain better originally.

371  Forum 2005-2010 (read only) / Interfacing / ADC - Higher Resolution OR Fast Counting on: July 06, 2010, 10:45:59 pm

Hopefully there is a simple solution to this, but I am trying to read in an RPM signal from a motor, which goes from 0 to 20,000 RPM. Ideally I am wanting my Arduino to detect every RPM change, ie have a resolution of 0 to 20,000 - but I know that its only 10 bit..  I really need 15 bit don't I...

What is the simplest solution to this problem? Do I need to get a external ADC chip of some kind, and potentially communicate to it via SPI or I2C, in order to get the required resolution, or can I do something fancy like join two ADC channels together some how?

Some assistance would be most appriciated

I am going to have to get some sort of coverter to change from the output of the motor transducer, to 0-5V also... so hopefully I can find something that has a small enough resolution for that too. I dont yet know the voltage range the motor transducer works at yet, it hasnt arrived yet.

372  Forum 2005-2010 (read only) / Exhibition / Re: Balancing robot for dummies on: September 25, 2010, 09:36:17 pm
This (counterintuitively)

I wouldnt say that... it does make sense. These are inverse pendulum's after all, so when you think about say a clocks pendulum, the weight is at the bottom. Since these are inverse the weight should be at the top. The motors weight is effectively null as its on the axis of rotation about the axle's.
Not debating anything you said obviously, but it does make sense.

Very good writeup - keep it up smiley

I have had all the bits of make one of these for about a year now, but I just havent gotten around to starting - too many other projects on the go sadly.

Good stuff

373  Forum 2005-2010 (read only) / Exhibition / Re: My HCC (Home control center) on: October 14, 2010, 03:51:29 pm
Nice work - your pictures appear to be dead to me - is there an issue?

For that matter, your website doesnt work either.
374  Forum 2005-2010 (read only) / Exhibition / Re: [ch1040][ch1088][ch1076][ch1091][ch1080][ch1085][ch1086] [ch1089] 64 LED [ch1095][ch1088][ch1077][ch1079] 74HC595 [ch1080] ULN2803 on: September 29, 2010, 04:26:58 pm
Bulgarian to English translation:

Rather than deal with Arduino and because the council listened to write an explanation for the realization of my project I decided to open a topic on the matter. Pisanitsa in Bulgarian section 'Combine' a title they 'Arduino drive 64 LEDs using a 74HC595 and ULN2803'. If there is something to discuss it here is the place.
375  Forum 2005-2010 (read only) / Exhibition / Re: Morse decoder and password checker on: September 23, 2010, 03:11:32 pm
Nice work
I just wrapped your code up in the forum friendly code displayer (the little # button above when you post)
Just so its easier to read.

Top job smiley

* Morse Code Decoder and door opener
* Josh Myer <>
* 20090103 rev 0 -- ugly and unfortunate, but mostly functional (my first arduino code)
* Hook a debounced switch up to digital pin 2, like you would for the Button demo.
* This code reads morse code from digital02, turning it into ASCII characters.
* If you key in "SOS" (... --- ...), it will turn on the LED on digital13.
* The intended application is to let me key in a password at my apartment's
* front gate and have it automatically let me into the building, instead of
* fumbling around for keys.
* There's still lots of stuff to do and clean up, but I wanted to share the idea
* and the current implementation to help spur people on.

#include <avr/pgmspace.h>
#include <string.h>

int ledPin = 13;                // choose the pin for the LED
int inputPin = 2;               // choose the input pin (for a pushbutton)
int val = 0;                    // variable for reading the pin status

#define THRESHOLD 3
#define DELAY_TIME 10 // ms

int n_since_zero = 0;
int n_in_zero = 0;

#define NCHARS 26+10+3

char morse_chars[NCHARS]  = {


char* morse_strings[NCHARS] = {

#define PAUSE 0
#define DIT 1
#define DAH 2
#define DDLEN 5

char passwd[] = "SOS";

char chars_rx[10];
int char_cursor= 0;

int ditsdahs[DDLEN];
int dd_cursor = 0;

void setup() {
 pinMode(ledPin, OUTPUT);      // declare LED as output
 pinMode(inputPin, INPUT);     // declare pushbutton as input

 for (int i = 0; i < DDLEN; i++) {
   ditsdahs[i] = 0;
 dd_cursor = 0;

 for (int i = 0; i < 10; i++) {
   chars_rx[i] = 0;
 char_cursor = 0;


void dd_print() {
 Serial.print("  > DD BUF: ");
 for(int i = 0; i < DDLEN; i++) {
   Serial.print(", ");

boolean dd_eq(char*buf) {
 if(ditsdahs[0] == PAUSE) return false;

 int i;

 for(i = 0; ditsdahs[i] != PAUSE && i < DDLEN; i++) {
   if (ditsdahs[i] == DIT && buf[i] == '-') {
     return false;
   if (ditsdahs[i] == DAH && buf[i] == '.') {
     return false;

 Serial.print("Got to the end of ");
  Serial.print("; checking strlen=");
  Serial.print(" == i=");
 if (i != strlen(buf)) return false;

 return true;

void dd_decode() {
 for(int i = 0; i < NCHARS; i++) {
   Serial.print("dd_decode: check i=");
    Serial.print(" , string=\"");
    Serial.print("\", c=");
   if (dd_eq(morse_strings[i])) {

     char c = morse_chars[i];



 for (int i = 0; i < DDLEN; i++) {
   ditsdahs[i] = 0;
 dd_cursor = 0;

void check_passwd() {

 Serial.print("Check password: ");

 if (0 != strstr(chars_rx, passwd)) {
   digitalWrite(ledPin, HIGH);

 for (int i = 0; i < 10; i++) {
  chars_rx[i] = 0;
  char_cursor = 0;

void char_emit(char c) {
 Serial.print("Got a char: c=");


 chars_rx[char_cursor] = c;

 if (char_cursor >= strlen(passwd)) {

void dd_emit(int v) {
 ditsdahs[dd_cursor] = v;


 if (v == PAUSE)

void dit()   {
void dah()   {
void pause() {

void loop(){
 val = digitalRead(inputPin);  // read input value

 if (val == LOW) {
   if (n_since_zero > 5) {
     /*  Serial.print("CROSS LOW AFTER ");
     if (n_since_zero > 16) {
     else {


   n_since_zero = 0;
 else {

 if (n_in_zero == 20) {

 if (n_since_zero > THRESHOLD) {
   if (n_in_zero > 0) {
     // Serial.print("CROSS HIGH AFTER ");
     //Serial.print(" > ");
     // Serial.println(n_in_zero);

     //      Serial.println("**************************");

   n_in_zero = 0;
   // digitalWrite(ledPin, HIGH);
 else {
   // digitalWrite(ledPin, LOW);

Pages: 1 ... 23 24 [25] 26