Show Posts
Pages: 1 2 [3] 4 5
31  Using Arduino / Programming Questions / Re: Problems with Wire.requestFrom (Arduiono Uno v1.0.3) on: January 25, 2013, 04:34:21 pm
Nick-

Please send a link to the Wire library on your site

thanks
32  Using Arduino / Programming Questions / Re: Problems with Wire.requestFrom (Arduiono Uno v1.0.3) on: January 25, 2013, 04:28:19 pm
Thanks Nic-

I just saw your scanner and here is my output

I2C scanner. Scanning ...
Found address: 33 (0x21)
Found address: 34 (0x22)
Found address: 35 (0x23)
Done.
Found 3 device(s).

I will take a llok at your I2C page

thanks
33  Using Arduino / Programming Questions / Re: Problems with Wire.requestFrom (Arduiono Uno v1.0.3) on: January 25, 2013, 04:21:58 pm
There are no links to datasheets for these items as these devices are custom and company
confidential information.

Can someone send me a link to the Wire commands in v1.0.3?

If I could ask the same question in an easier way, it might go like this:

The problem seems to be when I try to write to I2C address 44h with the following code
which shuts the power off to the device that  i am attempting to communicate or get a
status if whether it is connected or not and the data returned from Wire.endTransmission()
(and all the code from that point to the end of my loop closing bracket) is ignored...

Is there some sort of error handling going on behind the scenes that is causing a break
statement (of sorts) in my loop?

I need more information on the v 1.0.3  Wire library I think.
 
Please see comments in the code below


// ------------ turn off ext power ------------------
   Wire.beginTransmission(0x22);              // write to I2c Address 44h to set power condition
//   Wire.beginTransmission(0x44);           // (Use address in line above) because this one DOES NOT WORK
   Wire.write(0xFA);                               //  write command to turn off power
                                                          // ***** power does turn off here with the command in the line above as expected ***********
   timeout = Wire.endTransmission();        // Check status of data sent- did it get there?
   delay(4500);   
   Serial.print(" Power IS OFF- timeout= ");  // This time out is not being displayed in Serial monitor .. Why is that?
   Serial.print(timeout);                  // and all  the code through the end of my loop end bracket is also ignored
34  Using Arduino / Programming Questions / Re: Problems with Wire.requestFrom (Arduiono Uno v1.0.3) on: January 25, 2013, 11:26:01 am
Thanks for the reply...
I tried your suggestion and have posted the code and results for two different scenarios.
1. Reading from the  I2C with the address offsets.
2. Reading from the  I2C per your suggestion.
I had to leave the writing to set the power up as I had it otherwise the power would not switch on and off as I intend for it to do...

1. Reading from the  I2C with the address offsets.
 
Code:
  Serial.flush();  // flush the serial buffer
   delay (300);
   Serial.println("---");
     // ------------ turn on ext power ------------------
   Wire.beginTransmission(0x22);        // write to I2c Address 44h to set power condition
//   Wire.beginTransmission(0x44);      // writing to I2c Address 44h to set power condition - DOES NOT WORK
   Wire.write(0xAF);                    //  write command to turn off ext headbox power
   timeout = Wire.endTransmission();    // Check status of data sent- did it get there?
   delay(4500);
   Serial.print(" Power IS ON- timeout= ");    // Check status of data sent- did it get there?
   Serial.print(timeout); 

   Wire.beginTransmission(0x21);        // write to I2c Address 42h to check if ext device is available
    Wire.write(0x00);                   //  write command to test to see if device exists
   timeout = Wire.endTransmission();    // Check status of data sent- did it get there? 
   
   Serial.print(" check power on- timeout= ");
   Serial.print(timeout); 
   
   v44on= 0;                    // initialize v44off to zero
   Wire.requestFrom(0x21, 1);    // request 1 byte from 0x42h - revision
   
   while(Wire.available())    // slave may send less than requested
   {
        v44on = Wire.read();    // receive a byte as character
   }
   Serial.print(" v44onf= ");
   Serial.println(v44on);
   
     // ------------ turn off ext power ------------------
   Wire.beginTransmission(0x22);        // write to I2c Address 44h to set power condition
//   Wire.beginTransmission(0x44);      // writing to I2c Address 44h to set power condition - DOES NOT WORK
   Wire.write(0xFA);                    //  write command to turn off power
   timeout = Wire.endTransmission();    // Check status of data sent- did it get there?
   delay(4500);   
   Serial.print(" Power IS OFF- timeout= ");
   Serial.print(timeout);

   Wire.beginTransmission(0x21);        // write to I2c Address 42h to check if ext device is available
   Wire.write(0x00);                    //  write command to test to see if device exists
   timeout = Wire.endTransmission();    // Check status of data sent- did it get there?
   
   Serial.print(" check power off- timeout= ");
   Serial.print(timeout);

   v44off= 0;                    // initialize v44off to zero
   Wire.requestFrom(0x21, 1);    // request 1 byte from 0x42h - revision
   
   while(Wire.available())    // slave may send less than requested
   {
        v44off = Wire.read();    // receive a byte as character
   }
   Serial.print(" v44on= ");
   Serial.println(v44on);
   
     // ------------ turn on ext power ------------------
   Wire.beginTransmission(0x22);        // write to I2c Address 44h to set power condition
//   Wire.beginTransmission(0x44);      // writing to I2c Address 44h to set power condition - DOES NOT WORK
   Wire.write(0xAF);                    //  write command to turn off ext headbox power
   timeout = Wire.endTransmission();    // Check status of data sent- did it get there?
   delay(4500);
   Serial.print(" Power IS Turned Back ON- timeout= ");    // Check status of data sent- did it get there?
   Serial.println(timeout); 
   

===============================================================================

With the device connected:
(I2C addr 42h = 1 when power is on
No data is displayed when power is off)
When testing to see if the device is there, Wire.endTransmission returned "0"

I tried writing to 0x44 instead of 0x22 but then my power would not switch on and off.
(the library does not accomodate how the I2C parts are wired on the device that I am communcating with...)

Here is a sample of the output seen (device connected):

 
Quote
ð---
 Power IS ON- timeout= 0 check power on- timeout= 0 v44onf= 1
 ø---
 Power IS ON- timeout= 0 check power on- timeout= 0 v44onf= 1

With the device disconnected:
Quote
(all data is seen- power doesn't matter as device is not connected)


 Power IS ON- timeout= 0 check power on- timeout= 2 v44onf= 0
 Power IS OFF- timeout= 0 check power off- timeout= 2 v44on= 0
 Power IS Turned Back ON- timeout= 0

2. Reading from the  I2C per your suggestion.

 
Code:
  Serial.flush();  // flush the serial buffer
   delay (300);
   Serial.println("---");
     // ------------ turn on ext power ------------------
   Wire.beginTransmission(0x22);        // write to I2c Address 44h to set power condition
//   Wire.beginTransmission(0x44);      // writing to I2c Address 44h to set power condition - DOES NOT WORK
   Wire.write(0xAF);                    //  write command to turn off ext headbox power
   timeout = Wire.endTransmission();    // Check status of data sent- did it get there?
   delay(4500);
   Serial.print(" Power IS ON- timeout= ");    // Check status of data sent- did it get there?
   Serial.print(timeout); 

    Wire.beginTransmission(0x42);       // write to I2c Address 42h to check if ext device is available
    Wire.write(0x00);                   //  write command to test to see if device exists
   timeout = Wire.endTransmission();    // Check status of data sent- did it get there? 
   
   Serial.print(" check power on- timeout= ");
   Serial.print(timeout); 
   
   v44on= 0;                    // initialize v44off to zero
     Wire.requestFrom(0x42, 1);    // request 1 byte from 0x42h - revision
   
   while(Wire.available())    // slave may send less than requested
   {
        v44on = Wire.read();    // receive a byte as character
   }
   Serial.print(" v44onf= ");
   Serial.println(v44on);
   
     // ------------ turn off ext power ------------------
   Wire.beginTransmission(0x22);        // write to I2c Address 44h to set power condition
//   Wire.beginTransmission(0x44);      // writing to I2c Address 44h to set power condition - DOES NOT WORK
   Wire.write(0xFA);                    //  write command to turn off power
   timeout = Wire.endTransmission();    // Check status of data sent- did it get there?
   delay(4500);   
   Serial.print(" Power IS OFF- timeout= ");
   Serial.print(timeout);

   Wire.beginTransmission(0x42);        // write to I2c Address 42h to check if ext device is available
   Wire.write(0x00);                    //  write command to test to see if device exists
   timeout = Wire.endTransmission();    // Check status of data sent- did it get there?
   
   Serial.print(" check power off- timeout= ");
   Serial.print(timeout);

   v44off= 0;                    // initialize v44off to zero
    Wire.requestFrom(0x42, 1);    // request 1 byte from 0x42h - revision
   
   while(Wire.available())    // slave may send less than requested
   {
        v44off = Wire.read();    // receive a byte as character
   }
   Serial.print(" v44on= ");
   Serial.println(v44on);
   
     // ------------ turn on ext power ------------------
   Wire.beginTransmission(0x22);        // write to I2c Address 44h to set power condition
//   Wire.beginTransmission(0x44);      // writing to I2c Address 44h to set power condition - DOES NOT WORK
   Wire.write(0xAF);                    //  write command to turn off ext headbox power
   timeout = Wire.endTransmission();    // Check status of data sent- did it get there?
   delay(4500);
   Serial.print(" Power IS Turned Back ON- timeout= ");    // Check status of data sent- did it get there?
   Serial.println(timeout); 

Per your suggestion, I wrote to and read from 0x42 instead of 0x21-
I tried writing to 0x44 instead of 0x22 but then my power would not switch on and off.
(the library does not accomodate how the I2C parts are wired on the device that I am communcating with...)

With the device connected:
(I2C addr 42h = 0
When testing to see if the device is there, Wire.endTransmission returned "4"
When power is on and no data is displayed when power is off)

Here is a sample of the output seen (device connected):

 
Quote
ð---
 Power IS ON- timeout= 0 check power on- timeout= 4 v44onf= 0
 ð---
 Power IS ON- timeout= 0 check power on- timeout= 4 v44onf= 0

With the device disconnected: (timeout is now 2 but data did not change).
Here is a sample of the output seen (device not connected):

 
Quote
Power IS ON- timeout= 0 check power on- timeout= 2 v44onf= 0
 Power IS OFF- timeout= 0 check power off- timeout= 2 v44on= 0
 Power IS Turned Back ON- timeout= 0
35  Using Arduino / Programming Questions / Re: Problems with Wire.requestFrom (Arduiono Uno v1.0.3) on: January 24, 2013, 03:37:21 pm
Thanks for the reply-

I came up with the following to test the condition of Wire.endTransmission()
but it is coming up with "2" whether the device is there or not...

Am i doing this right?


Code:
  Wire.beginTransmission(0x22);
  Wire.write(0xAF);                //  write command to turn on power
  Wire.endTransmission();
 
   digitalWrite(D8, HIGH);
   digitalWrite(D7, LOW);
   delay(200);

  v44on = 0;

  Wire.beginTransmission(0x21);
  Wire.write(0x00);                //  write command to test if I2c device is there
  timeout = Wire.endTransmission(); 

  Serial.print(" AMP IS ON- timeout= ");
  Serial.print(timeout);
  if (timeout == 2)
  {
     Wire.requestFrom(0x21, 1);    // request 1 byte from 0x42h - revision
     Wire.available();

     while(Wire.available())    // slave may send less than requested
     {
        v44on = Wire.read();    // receive a byte as character
     }

     Serial.print(" v44on= ");
     Serial.print(v44on,HEX);


 // ---------------- turn off ext  power -----------------------

   Wire.beginTransmission(0x22);
   delay(200);

   Wire.write(0xFA);                //  write command to turn off ext headbox power
   Wire.endTransmission();

  Wire.beginTransmission(0x21);
  Wire.write(0x00);                //  write command to turn on ext headbox power
  timeout = Wire.endTransmission(); 
   
Serial.print(" AMP IS OFF- timeout= ");
Serial.print(timeout); 

        while(Wire.available())    // slave may send less than requested
        {
          v44off = Wire.read();    // receive a byte as character
        }
delay(200);
Serial.print(" v44off= ");
Serial.println(v44off,HEX);

===============================
Serial monitor output:
 AMP IS ON- timeout= 2 v44on= 0 AMP IS OFF- timeout= 2 v44off= 0
36  Using Arduino / Programming Questions / Re: Problems with Wire.requestFrom (Arduiono Uno v1.0.3) on: January 24, 2013, 10:55:53 am
Thanks for the response...
The primary device that I am communicating to is a medical amplifier.
The I2C is configured so that I need to offset the lower address bit. This is working just fine
as I am setting other I2C registers without any problems.

In the WirebeginTransmission(0x22); statement I am sending a command to my primary device to set the power on/off to a secondary I2C device that is connected it.

In the WireRequestFrom(0x21, 1); // request 1 byte from 0x42h - revision
statement I am reading an I2C device on the secondary device which is why the address is different
as I want to verify that the power did switch on/off on the secondary device.

It is when the secondary device  is connected is when I notice certain lines of code not being executed by evidence of the output and the serial print statements to the serial monitor. Also, I sometimes get what seems like a stack overflow or something that stops the sketch in its tracks.

When the secondary device  is not connected it seems that all the lines in my code are being executed...

Not sure what is causing this...
37  Using Arduino / Programming Questions / Problems with Wire.requestFrom (Arduiono Uno v1.0.3) on: January 23, 2013, 01:00:06 pm
I am using an Arduino Uno and experiencing some strange things with my code when
reading data from an I2C bus. I recently upgraded to Arduino IDE v1.0.3 but still have
this issue.

A snippet of my code is included below along with the serial monitor data when data is
available and when it is not.

I am seeing different results where a  Wire.requestFrom does not seem to be processed
when data is not available and the code there after also seems to be ignored.

I am also intermittently seeing that when data is available the code locks up. I have been
trying to figure this one out and have been scratching my head.

//???????????? Suspect code here ?????????????

    Wire.requestFrom(0x21, 1);    // request 1 byte from 0x42h
    timeout= Wire.available();

    Serial.print(" Wire.available timeout= ");
    Serial.print(timeout);
 
// ------------ turn on ext power ------------------
//  Serial.print(" Wire.beginTransmission - ");
  Wire.beginTransmission(0x22);
  Wire.write(0xAF);                //  write command to turn on ext headbox power
  Wire.endTransmission();

  Serial.println(" turn on headbox ");

  Wire.requestFrom(0x21, 1);    // request 1 byte from 0x42h - revision
  timeout= Wire.available();

  while(Wire.available())    // slave may send less than requested
  {
     v44on = Wire.read();    // receive a byte as character
  }
}  // end of program loop


Any ideas what I am doing wrong and how to correct this?

Thanks


Code:
byte v44off;

   // ------------ turn on ext  power ------------------
  Wire.beginTransmission(0x22);
  Wire.write(0xAF);                //  write command to turn on ext power
  Wire.endTransmission();
 
   v44on = 0;
   Wire.requestFrom(0x21, 1);    // request 1 byte from 0x42h - revision
   timeout= Wire.available();
   
  while(Wire.available())    // slave may send less than requested
  {
     v44on = Wire.read();    // receive a byte as character
  }
  Serial.print("  ext hdbox read  ");

  Serial.print(" v44on= ");
  Serial.print(v44on,HEX);


 // ---------------- turn off ext power -----------------------

Wire.beginTransmission(0x22);
   Wire.write(0xFA);                //  write command to turn off ext power
   timeout = Wire.endTransmission();

    Serial.print(" timeout= ");
    Serial.print(timeout);

    Serial.print("  Wire.endTransmission timeout= ");
    Serial.print(timeout); 
    Serial.println("   ****   ");

//???????????? Suspect code here ?????????????

    Wire.requestFrom(0x21, 1);    // request 1 byte from 0x42h
    timeout= Wire.available();

    Serial.print(" Wire.available timeout= ");
    Serial.print(timeout);
 
  // ------------ turn on ext power ------------------

//  Serial.print(" Wire.beginTransmission - ");
  Wire.beginTransmission(0x22);
  Wire.write(0xAF);                //  write command to turn on ext headbox power
 Wire.endTransmission();

  Serial.println(" turn on headbox ");

  Wire.requestFrom(0x21, 1);    // request 1 byte from 0x42h - revision
  timeout= Wire.available();


  while(Wire.available())    // slave may send less than requested
  {
     v44on = Wire.read();    // receive a byte as character
  }

}  // end of program loop


Here is what the output looks like on the Serial monitor:
Quote
When data is available:
   ext hdbox read   v44on= 11 timeout= 0   Wire.endTransmission timeout= 0   ****   
   ext hdbox read   v44on= 11 timeout= 0   Wire.endTransmission timeout= 0   ****   
   ext hdbox read   v44on= 11 timeout= 0   Wire.endTransmission timeout= 0   ****   


When no data is available:
ext hdbox read   v44on= 0 timeout= 0   Wire.endTransmission timeout= 0   ****   
 Wire.available timeout= 0 turn on headbox   
ext hdbox read   v44on= 0 timeout= 0   Wire.endTransmission timeout= 0   ****   
 Wire.available timeout= 0 turn on headbox   
ext hdbox read   v44on= 0 timeout= 0   Wire.endTransmission timeout= 0   ****   
 Wire.available timeout= 0 turn on headbox

38  Using Arduino / Programming Questions / Is there another way to do a DigitalWrite? on: November 08, 2012, 12:46:11 pm
I was wondering if instead of doing several digitalWrite commands to set individual output pin levels
on an Arduino (e.g. digitalWrite(D0, HIGH) - digitalWrite(D7, HIGH)) if there is a way to just write a
byte of data to set all output levels at once.

Also, is there a way to set all of the pinModes at once also... (like writing a value to a register for example)

thanks
39  Using Arduino / Programming Questions / avrdude: stk500_getsync(): not in sync: resp=0x00 on: November 02, 2012, 03:11:07 pm
I recently purchased an Arduino UNO Bootloader chip from DIgikey and am using an FTDI chip TTL-232R-5v cable connected up as follows:

FTDI Cable Pin:
1 - Ground
2 - Ground
3 - +5V (arduino pins 7 & 20)
4 - Arduino D0 (pin 2)
5 - Arduino D1 (pin 3)
6 - open

I also have a 100k pullup on the reset line (pin 1)
and an LED tied high connected to D13 via a 400 ohm resistor.

I am using the arduino 1.0.1 suite and have selected the board type as Arduino Duemilanove w/ ATmega328
and when I compile and upload, the LED on D13 does not flash unless I manually toggle the reset line and it only flashes briefly
not like it would if it was uploading code.

When the upload is complete I get the message:   avrdude: stk500_getsync(): not in sync: resp=0x00

What am I doing wrong and how do I correct this?

thanks
40  Using Arduino / Displays / Interfacing a Samsung SCH-R351 LCD on: March 29, 2012, 07:17:43 am
A friend just gave me an older Samsung SCH-R351 cell phone and I would like to interface the
LCD to an Arduino.

Does anyone know where I can find pin out info on t his LCD and Arduino interfacing information
for the LCD?

thanks
41  Using Arduino / LEDs and Multiplexing / LEDs for a robot costume on: March 15, 2012, 06:31:28 am
My kids are making a robot costume and I was wondering if anyone has any examples of some
simple LED projects that I could put together something quickly to augment their costume with some arduino
driven LED effects that runs off a 9V battery...

any ideas or examples?

thanks
42  Using Arduino / Installation & Troubleshooting / Re: Digital Write D0 & D1 LOW doesn't drive the pin low on: March 08, 2012, 04:10:38 am
Is there a way to turn the Serial functions off and force the atmel part to use pins D0 & D1 exclusively as an input or output instead of  RXD or TXD or snything else for that matter?

Thanks for the tips everyone... this issue has me a little befuddled to say the least...
43  Using Arduino / Installation & Troubleshooting / Re: Digital Write D0 & D1 LOW doesn't drive the pin low on: March 07, 2012, 11:01:22 am
Ooops - I spoke too soon.

If I put these in the loop, once I write the value high, it can not be set low again...

I got tired of measuring it with the meter so I tied a LED & 370 ohm resistor from D0 to ground to monitor it
The LED stays on once a HIGH is written to D0 and does not go off indicating that DO has not been set to a Low state
even though the code performs digitalWrite(D0,LOW)...

What is going on?

Here is my simplified code that produces these results:

void setup ()
{
  Serial.begin (115200);
  
  pinMode (0, OUTPUT);
  
  digitalWrite (0, LOW);

}

void loop () {

 digitalWrite (0, HIGH);
 delay(3000);  // delay 3 secs

 digitalWrite (0, LOW);
 delay(3000);  // delay 3 secs
}
44  Using Arduino / Installation & Troubleshooting / Re: Digital Write D0 & D1 LOW doesn't drive the pin low on: March 07, 2012, 08:11:27 am
Well, that is very peculiar and subtle...

I had the  Serial.begin (115200) statement at the end of my setup function after the pin mode definitions and not before the
pin mode definitions and that made all the difference which now allows D0 & D1 being written to a LOW state.

Is this a recent change with v1.0?

I have been using V 22 for some time and never encountered this phenomenon before...

Thanks for the help!
45  Using Arduino / Installation & Troubleshooting / Digital Write D0 & D1 LOW doesn't drive the pin low on: March 06, 2012, 05:04:15 pm
I have a new Arduino Uno and I have discovered that
DigitalWrite D0 & D1 LOW doesn't drive the pin low.

Did something change or am I doing something wrong?

Pages: 1 2 [3] 4 5