Show Posts
Pages: 1 2 [3] 4 5
31  Forum 2005-2010 (read only) / Interfacing / Re: Set I2C speed on: March 06, 2008, 02:10:38 am
You can't set I2C speed through the Wire library. If you want to change the speed to something other than 100kHz, you'll need to twiddle with registers. Check the data sheet for these guys.


EDIT:
Oh, bugger. I hate searching for problems and not getting an answer, so I'll post more to help you, and those to come after out. (:

The frequency of the SCL is controlled by two registers: TWI Bit rate Register (TWBR) and the prescaler bits in the TWI Status Register (TWSR). The end frequency of SCL is calculated as follows:

SCL frequency = CPU Clock frequency / (16 + 2 * (TWBR) * (Prescaler)

TWBR is at 0xB8
TWSR is at 0xB9 and the prescaler bits are 0 and 1. The prescaler value is as follows:

TWSR 1TWSR 0Prescaler value
001
014
1016
1164


So. Assuming a 16 MHz clock, if you wanted to have the TWI run at 100kHz, you could use the prescaler value of 4, and a bit rate register value of 18. If you wanted to jack that up to 400kHz, you could quadruple the value of TWBR, or you could use the next prescaler value. Just make sure that whatever you're talking to supports the speed you're wanting to run it at.

... But don't just take this info and run. It's still a very good idea to check the data sheet anyway, in case I've screwed something up.
32  Forum 2005-2010 (read only) / Troubleshooting / Re: infitite loop on: April 10, 2008, 05:54:35 pm
Quote
Assuming you don't have a programmer, you probably can't do anything about it.

You could hack one up though...
33  Forum 2005-2010 (read only) / Troubleshooting / Re: Diecimila - I killed it on: March 05, 2008, 02:25:05 pm
Do you have anything connected to pins 0 and 1?
34  Forum 2005-2010 (read only) / Troubleshooting / Re: Thermistor and Stepper motor on: March 05, 2008, 02:23:13 pm
A transistor is made of silicon, while relays are mechanical devices.

The motor shield can only do 2 steppers, as you've said. If you wanted to do 3 or 4, you probably can with the Arduino since the motor shield has a separate power source AFAIK, but you'd have to do it yourself. You can take a look at ladyada's schematic, and figure out how to get more i/o to accommodate your extra steppers.

And for your thermistor... to "calibrate" it so you can get the temperature in Arduino sketches, you need to get its resistance at at least two known temperatures, and then using those points, you can guesstimate in your code. More points may be helpful, in case the resistance doesn't increase in a linear fashion.

Anyway. Hope that helps. (:
35  Forum 2005-2010 (read only) / Interfacing / Re: Using the I2C PCF8563 Real Time Clock on: February 09, 2008, 11:20:31 pm
I hope I'm not breaking any rules by dredging up this thread (:X) but I've had the same problems, and I think I've found the solution.

When using the Wire library, you only need to pass Wire.beginTransmission and Wire.requestfrom the 7-bit device address, less the read/write bit. Apparently, Wire takes care of the read/write bit for you, so if you pass it the full 8-bit address, your data is gonna get sent to the wrong place. This isn't mentioned anywhere in the documentation, and I had to find out about it from a blog. : |
36  Forum 2005-2010 (read only) / Interfacing / Re: burning bootloader to atmega168 on: May 08, 2008, 05:55:12 pm
Do you have anything currently on any of the arduino pins, and do you have the resistors connected as described here?

Here's a mapping of the pins.
Parallel ProgrammerICSP HeaderATmegaArduino Pins
1111812
-27, 20+5V (Not really nessecary if you have ext. power.)
131913
241711
1651Reset
1868, 22Ground

Note that you do probably need those resistors.
37  Forum 2005-2010 (read only) / Interfacing / Re: Multiple Nunchucks on I2C bus on: April 21, 2008, 02:52:30 pm
I think you could be able to use a relay to switch the SDA lines to the one you wanted to read. It'd take an extra arduino pin, but you'd be able to read two nunchucks all the same. I'm not so sure how it would work with transistors - but you could probably try shutting the SDA line off to one of them.

As for reprogramming I2C addresses, I think the only way you could do that would be to use slave devices with the address pins available and somehow manipulate them with the Arduino, or if the slave was another microcontroller that is able to reassign its address.
38  Forum 2005-2010 (read only) / Interfacing / Re: Triggering sound with input/sensor/button/swit on: April 24, 2008, 01:19:05 pm
Since you won't be doing anything until the button is pressed and the sound starts playing (assuming you want to ignore any subsequent presses until the sound is done), you can do a fairly simple loop, something like this:

Code:
void loop()
{
  if (digitalRead(btn_pin) == LOW)
  {
     playSound();
  }
}

NB: Depending on how you've wired up the button, the low might need to be replaced with high. But that really should be as simple as you can get.
39  Forum 2005-2010 (read only) / Interfacing / Re: Microchip 24xxnnn i2c EEPROM on: April 13, 2008, 03:52:38 am
If the wire library you're using is the same as the one in the Arduino environment, then yes, the Wire library will handle the read/write bit. I don't currently have any code for this EEPROM, but I can show you the idea using code from a sketch that interfaces with a TWI RTC.

Code:
....

#define WIRE_RTC_ADDR 0x51

....

  // Set control registers, and nab the voltage low warning bit out of the seconds register.
  Wire.beginTransmission(WIRE_RTC_ADDR);
  Wire.send(0x00);
  Wire.send(0x00);
  Wire.send(0x1C);
  Wire.endTransmission();
  Wire.requestFrom(WIRE_RTC_ADDR, 4);
  byte temp = Wire.receive();
  cur_time.seconds = temp & 0x7F;
  cur_time.minutes = Wire.receive();
  cur_time.hours = Wire.receive();
  cur_date.days = Wire.receive();
  cur_date.weekday = Wire.receive();

....

Wire.beginTransmission is starting a write, while Wire.requestFrom is starting a read. Notice they still use the same address.
40  Forum 2005-2010 (read only) / Interfacing / Re: Microchip 24xxnnn i2c EEPROM on: April 10, 2008, 06:10:19 pm
There's some undocumented funny business with the Wire library and I2C addresses. The Wire lib will take care of the I2C least significant address bit (the read or write bit) for you, so if you pass in the full 8-bits including read and write, this ends up getting shifted, and your address is invalid. This problem happened a lot to me when I was working with an I/O expander and an RTC. Suffice to say, the answer was nowhere on the Arduino or Wiring sites.

I have the 24C02C version of this chip, and its address is: 1010(A0)(A1)(A2)(W/R). If I had all my A pins tied to ground, the address I would pass the Wire calls would be: 101 0000, or 0x50.
41  Forum 2005-2010 (read only) / Interfacing / Re: Using interrupts and wire library? on: April 17, 2008, 01:32:10 pm
Wire does use interrupts.

Best thing to do is to set a flag in your interrupt service routine, and then call that function from your main loop depending on the value of the flag. This way your ISR runs quick, and you have a better chance of not missing any other interrupts if you're using them.
42  Forum 2005-2010 (read only) / Interfacing / Re: Are LEDs and Resistors Washable? (LilyPad) on: April 12, 2008, 12:09:41 pm
Quote
Why in the world would you want to hand wash electronic components?


He says he's working with an Arduino LilyPad - the variety of board designed to be sewn into clothing. I'd imagine you'd need to wash the clothes eventually!

One thing to note though: You will need to remove the batteries when you do wash. Otherwise, there's an excellent chance the battery's terminals will get shorted, and that's generally a bad thing. As it says on the Sparkfun page: "They're even washable - but be sure to remove the battery!"
(:
43  Forum 2005-2010 (read only) / Interfacing / Re: Arduino Diecimila with Bluetooth on: April 10, 2008, 06:44:47 pm
You don't need to write a new bootloader to make this module work with the Arduino... unless you wanted to be able to program the chip via bluetooth. I think you should be able to connect this chip's RX to Arduino's pin 1, TX to pin 0, and RTS and CTS to ground, unless you want to connect them up to other pins and use them, but you'd have to control them from within your sketch.

Because your chip seems to take 3v power, you might have to add some resistors to your setup... I can't say for sure though. : \
44  Forum 2005-2010 (read only) / Interfacing / Re: Overcurrent on IO pins on: April 06, 2008, 01:56:27 am
I've run LEDs directly off the ATmega168. I'm running LEDs off it now. I'm running an LCD backlight off it too.
I've only fried one thing - a green LED. But that was me being stupid so I deserved it. Wasn't even attached to the ATmega.
45  Forum 2005-2010 (read only) / Interfacing / Re: real time clock on: April 02, 2008, 12:32:05 pm
They have different features, and they're from different manufacturers. The differences are probably not terribly important if you just want it to keep time, but it's still a good idea to check their features and figure out what you need or don't need.

As far as I know, they both use the I2C (Or Two-wire interface) that will use analog pins 4 and 5 on the Arduino. Until you know exactly which chip you're going to get, it's a little difficult to give you sample code, as I'd imagine the memory layout for each chip is different.
Pages: 1 2 [3] 4 5