Show Posts
Pages: 1 2 3 [4] 5 6 ... 13
46  Forum 2005-2010 (read only) / Interfacing / Re: Using the DS1803 digital pot. on: October 12, 2007, 08:04:41 pm
Got it! Ok so apparently the datasheet gave the address as a 7bit address and I was reading it as an 8bit address. I should have been using 0x28 instead of 0x50... but the fun part is how I figured it out. As someone on IRC suggested I tapped into the twi library and wrote an I2C scanner. Here's the code:

Code:
void scanTWI(void)
{
      Wire.begin();
      
      int ii;
      uint8_t *txBuffer;
      
      for (ii=1;ii<128;ii++)
      {
            twi_writeTo(ii, txBuffer, 0, 1);
            
            if (twi_isFound())
            {
                  Serial.println(ii, HEX);
            }
      }
      Serial.println();
}

I also had to apply the following modification to the twi.c file:
Code:
312a313,324
> int foundDevice = 0;
> int twi_isFound(void)
> {
>       if (foundDevice)
>       {
>               foundDevice = 0;
>               return 1;
>       }
>
>       return 0;
> }
>
325a338,340
>       {
>               foundDevice = 1;
>       }

It's probably terrible code, but as a patch, it works. The question is why isn't something like this in the library? It would be very useful! IMHO at least.

Hope this helps others
47  Forum 2005-2010 (read only) / Interfacing / Using the DS1803 digital pot. on: October 12, 2007, 05:29:00 pm
Hello, I'm trying to interface a DS1803 I2C digital pot without much luck :/
It looks like I'm just writing/reading back the buffer when I communicate with it.
I don't understand why, the address is properly set. And the I2C bus works, I have another device (PCF8574) on it.
If you guys have any idea....

These are the read/write function I'm using. As usual the read address is write+1.
As far as I can see from the datasheet the registers are none looping.
When I write a value and read back, the first is the register address instead of the first byte of data.

Code:
Void DS1803::setValue(uint8_t value)
{
      Wire.beginTransmission(DPOT_ADDRESS_W);
      Wire.send(DPOT_WIPERS); // Send the wiper address
      
      Wire.send(value);
      
      Wire.endTransmission();
}

uint8_t DS1803::getValue()
{
      Wire.requestFrom(DPOT_ADDRESS_R, 2);
      
      while (Wire.available()) {
            Serial.println((uint8_t)Wire.receive(), DEC);
      }
      
      return 0;
}
48  Forum 2005-2010 (read only) / Interfacing / Re: I2C Snoop on: October 12, 2007, 08:06:40 pm
I don't know how far you've got but if you're still stucked, I think this may really help!

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1192228140/0#1

Cheers!
49  Forum 2005-2010 (read only) / Interfacing / Re: I2C Snoop on: September 20, 2007, 04:50:23 pm
I2C addresses are always predefined. Usually by 2 or 3 bits. Look at the datasheet, it should mention the addresses the IC uses, and which pins set the address. After that you could quickly figure out the address of the device. As for a man in the middle type of thing; once you have the address, you could try putting the Arduino on the same I2C bus, set it as a slave and give it the same ID.... I'm not sure if that'll work, but since you'll be connected anyway, it's worth trying!
50  Forum 2005-2010 (read only) / Interfacing / Re: I2C Snoop on: September 07, 2007, 05:34:02 pm
You can connect the Arduino on the same bus. But you'll need to figure out the address and protocol for the tuner and actually read the value. The datasheet should be helpful at that point. Also, I believe the Arduino allows you to choose its address, so if you figure out which address the tuner talks too maybe you could do a man-in-the-middle kind of thing. But reading from the tuner seems far simpler, it just means you'll need to pool the tuner either on request or every so often if you want to keep everything in sync.
51  Forum 2005-2010 (read only) / Interfacing / Re: Using Procyon AVRLib in the Arduino IDE on: September 12, 2007, 06:46:14 pm
That's exactly the approach I was going to take. It would be sufficient for basic debugging at least.

I wrote this but it didn't seem to work:
Code:
char b[2048] = "a";
unsigned int i = 0;
Serial.println();
for (i = 1; 1; i++) {
      Serial.print(i); Serial.print(" "); delay(100);
      b[i] = 255;
}


I looked a little for the sketch and didn't find anything, was it posted on the forum?
52  Forum 2005-2010 (read only) / Interfacing / Re: Using Procyon AVRLib in the Arduino IDE on: September 12, 2007, 04:59:07 pm
GOT IT! I had two functions, one for print and one for println... well the first, called printString, was conflicting with wiring's printString. GCC never complained because wiring.h was not included in the files with the strings functions! FEW :o

Totally out of subject, but is there a way to know the ram specs? Such as how much is free, etc. The mega168 doesn't have JTAG (not that I have the cable), debugWire seems quiet complicated (no 2$ parallel hack) and simulavr doesn't support the mega168 as far as I could see and test. The only option I can see is AVRStudio. But running VMWare all the time seems like a bad idea, not to mention having to replicate the environment under two totally different platforms. And I've seen reviews saying it didn't run under Wine. What does that leave us with for debugging? :/
53  Forum 2005-2010 (read only) / Interfacing / Re: Using Procyon AVRLib in the Arduino IDE on: September 12, 2007, 03:26:35 pm
As far as I can tell, yes it is. There's some really... really... weird stuff. In my regDump function, none of the douzen serial strings are sent... I'll dig deeper I guess :/
54  Forum 2005-2010 (read only) / Interfacing / Re: Using Procyon AVRLib in the Arduino IDE on: September 12, 2007, 12:37:43 am
Well that helped a lot! I moved all of the strings to inline progmem with PSTR. Very neat, albeit it seems a little unreliable... stuff like this happen:

Code:
printString(PSTR("Uptime: ")); delay(2);
Serial.print(millis()); delay(2);
printString(PSTR("ms")); delay(2);
Show as :
Code:
: 1848ask :
and some just don't print.

printString looks like such
Code:
void printString(const char *data)
{
    char ch;

    for (;;) {
        ch = pgm_read_byte( data++ );
        if ( !ch ) return;
            Serial.print(ch);
    }
}

I've tried delaying by 8xNOPs (1/2µS) to no avail.

But hey, at least there is progress hehe smiley
55  Forum 2005-2010 (read only) / Interfacing / Re: Using Procyon AVRLib in the Arduino IDE on: September 11, 2007, 07:30:17 pm
Also, didn't anyone work on an ENC28J60 drivers for the Arduino? If so, is it available anywhere? Maybe it could help?
56  Forum 2005-2010 (read only) / Interfacing / Re: Using Procyon AVRLib in the Arduino IDE on: September 11, 2007, 07:15:21 pm
The Makefile is fine for now, that's what I use normally. Right now I only wished I knew why the program makes the µC crash. As for serial I'm using Wiring's library.

EDIT: Here's the code.
As you can see in the setup there are a few Serial sends which never appears (sometimes just a few char return). Also atm the LED never ends up flashing. Like if the setup failed or the uC crashed when setting up Serial
57  Forum 2005-2010 (read only) / Interfacing / Re: Using Procyon AVRLib in the Arduino IDE on: September 11, 2007, 03:04:21 pm
So I've gotten all the net stuff (and what it relies on) to compile using the "in sketch" method. However only using the Makefile. The IDE seems to try to compile the .cpp's as C instead of c++ (at least it's pretty much the same error I get when I replicate this in the Makefile). Still, it's not perfect, serial seems to be broken, doesn't send/receive anything. Even though I took care of removing all the uart stuff and replacing it by the Serial object). The timer classes are probably going to be an issue. So right now the biggest problem is avoiding wiring and avrlib to conflict; and I only have a small part of avrlib. Any pointers there?
58  Forum 2005-2010 (read only) / Interfacing / Using Procyon AVRLib in the Arduino IDE on: September 11, 2007, 12:38:03 pm
Hello there, I would like to add the Procyoon AVRLib to my IDE. I tried putting the whole thing in lib/targets/ardunio, I tried in the libraries and I tried just putting the files I wanted in my sketch's directory. But to no avail. I'm sure it's something stupid I'm missing. Any pointers?
59  Forum 2005-2010 (read only) / Development / Re: radio frequency broadcasting on: January 13, 2007, 05:40:26 am
I'll sound like a total newb, but what if you wanted to implement other frequencies? This could be useful as a quick frequency generator.
60  Forum 2005-2010 (read only) / Development / Re: Library for DS1307 Real Time Clock on: April 07, 2008, 10:10:47 pm
If you only need a reliable source of 1 seconds delays, why not use millis()? Although you will have to check in loop() or modify the interrupt's code (you'll have to search this forum for more on that) to toggle a boolean value every timerCounter%1000 == 0, you'll then know if you've come across a new second when the variable isn't what it last was. This, however implies that nothing that could happen meanwhile would take more than a second. Otherwise you could add a counter to that conditional statement, make sure you don't overlfow the variable though (see the variable types documentation if you're not familiar with this)!
Pages: 1 2 3 [4] 5 6 ... 13