Show Posts
Pages: [1]
1  Using Arduino / Networking, Protocols, and Devices / Re: Mistery: I2C not working, blink working on: December 01, 2012, 12:29:04 pm
Quote
As I understand I2C is digital protocol, but why we can use ony 2 pins for it?

Because the AVR chip uses special internal hardware to support the I2C function and it only wires that function to those two specific pins. Just like the hardware serial function on a standard Uno is only available on pins 0 and 1, same thing going on there. analogWrite (pwm outputs) only works on specific pins because it uses internal chip hardware timers that only wire up to specific pins. All I/O pins can be used as simple digital input or output pins, but most of the special functions of the chip are only supported by specific pins. The AVR datasheet is the best source of information on this topic.

Lefty

Can this special internal hardware be damaged?
2  Using Arduino / Networking, Protocols, and Devices / Re: Mistery: I2C not working, blink working on: December 01, 2012, 01:48:20 am
Code:
    analogWrite(21, 0);   
Does pin 21 have a little squiggly next to it to indicate that it is a PWM pin? If not analogWrite isn't going to do anything.   

Oh, my fault, you are right. But it not explains why does not I2C working.

As I understand I2C is digital protocol, but why we can use ony 2 pins for it?
3  Using Arduino / Networking, Protocols, and Devices / Re: Mistery: I2C not working, blink working on: November 30, 2012, 12:41:09 pm
Hello again. I bought oscilloscope today and tried to measure what's going on.

Same programm on arduino uno and arduino mega. Right connection to both.

This is oscillogramm from uno(it's good):
On mega no impulses appear.

I also made an experiment. I wrote this code to mega and use oscilloscpe with it:
Code:
void setup()  {
  // nothing happens in setup
}

void loop()  {
 while(true){
    analogWrite(21, 0);        
    delay(1000);
    analogWrite(21, 100);        
    delay(1000);
    analogWrite(21, 255);        
    delay(1000);    
  }
}
But i saw only one impulse at 5V with 1sec duration and then 2sec 0V.

My theory is that DAC is broken, but I still don't know why I2C isn't working.

Anyway powering from battery doesn't give any results.
4  Using Arduino / Networking, Protocols, and Devices / Re: Mistery: I2C not working, blink working on: November 19, 2012, 09:11:39 am
I don't have oscilloscope yet.  smiley-confuse
5  Using Arduino / Networking, Protocols, and Devices / Re: Mistery: I2C not working, blink working on: November 19, 2012, 12:30:20 am
Quote
Can it be something with ic atmega2560?
I would not have thought so.

So, what is your diagnosis?
6  Using Arduino / Networking, Protocols, and Devices / Re: Mistery: I2C not working, blink working on: November 18, 2012, 02:38:09 pm
Blink working on each pin. Swaping is not helpful, but i admit that circuit is right. I used this mega for i2c month ago. Can it be something with ic atmega2560?
7  Using Arduino / Networking, Protocols, and Devices / Re: Mistery: I2C not working, blink working on: November 18, 2012, 06:19:58 am
As requested:
Uno connection:


Mega connection:


Main code:
Code:
#include <Wire.h>
#include <L3G.h>

L3G gyro;

void setup() {
  Serial.begin(9600);
  Wire.begin();
 
  if (!gyro.init())
  {
    Serial.println("Failed to autodetect gyro type!");
    while (1);
  }

  gyro.enableDefault();
}

void loop() {
  gyro.read();

  Serial.print("G ");
  Serial.print("X: ");
  Serial.print((int)gyro.g.x);
  Serial.print(" Y: ");
  Serial.print((int)gyro.g.y);
  Serial.print(" Z: ");
  Serial.println((int)gyro.g.z);

  delay(100);
}

Library: https://github.com/pololu/L3G
8  Using Arduino / Networking, Protocols, and Devices / Re: Mistery: I2C not working, blink working on: November 17, 2012, 10:34:20 am
I also noticed that my imu already have pullup resistors
9  Using Arduino / Networking, Protocols, and Devices / Re: Mistery: I2C not working, blink working on: November 17, 2012, 01:52:53 am
And how can be explained that same circuit and same code works on arduino with 328p and hangs on arduino with 2560?
As I said before, I used different pins on uno and mega. And different voltages too.

L3G library uses wire library.

I wonder if mega I2C circuit is different to uno circuit(except I2C pins placement).
10  Using Arduino / Networking, Protocols, and Devices / Re: Mistery: I2C not working, blink working on: November 16, 2012, 04:33:06 pm
Ok, code is from examples for L3G, it works on uno, but don't work on mega. Don't think it need to be checked.
Addresses are default, that proved by uno run.
Using this imu: http://www.pololu.com/catalog/product/1265

I don't use any resistors. Tried to use 3.3V and 5V, imu board uses vin voltage for I2C voltage.
11  Using Arduino / Networking, Protocols, and Devices / Mistery: I2C not working, blink working on: November 16, 2012, 02:28:04 pm
Hello, I have strange trouble with my arduino mega.

I'm trying to connect I2C gyroscope and I2C IMU to it, but wire.transmit() hangs. I connected same gyro to my arduino uno and run same programm and gyro worked.

Yes I connected right: 21-SCL;20-SDA.

What it can be?
12  Forum 2005-2010 (read only) / Interfacing / Re: IR distanse sensor connect and communicate on: November 12, 2010, 11:41:57 am
And I forget, I found sensor's datasheet in http://lib.chipdip.ru/204/DOC000204804.pdf
13  Forum 2005-2010 (read only) / Interfacing / IR distanse sensor connect and communicate on: November 12, 2010, 11:41:16 am
Hi there,
I'm new at electronics and new in arduino code. I bought IR distance sensor HLC1395. I don't know how connect it to my arduino Duemilanove. I guess I need some resistors between sensor and platform, but I don't know how many Ohm do i need.
I also need code or advise how get distanse form it. I guess i must count milliseconds between LED blink and transistor response and divide it on light speed, am i right?

Please help me
Pages: [1]