Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

osno's Content

There have been 17 items by osno (Search limited from 29-March 23)


By content type

See this member's

Sort by                Order  

#6976 Help needed with I2C EEPROM

Posted by osno on 04 January 2011 - 12:37 PM in General Discussion

One thing that bugs me, though, is the amount of repeated code in the xx16 and xx256 classes. If it where me, I'll make all the addresses an int, and then have an AddressByteCount property or something that will be 1 for the xx16 and 2 for the xx256, and have the base class handle the conversion (which is simply a loop making a >> 8 & 0xFF). All the Read and Write methods would be on the base class. Using that and the max address you can easily throw an exception if the address is wrong (which you already do anyway). Also, you can have all the overloads in the derived classes, but they'll look like this: public int WriteString(byte writeAddress, string value) { return WriteString((int)writeAddress, value); } You can even make the base class methods protected if you don't want users of the code to have the liability of an exception (except for the high byte of the xx256, where it will happen anyway). Anyway, thanks again!



#6941 Help needed with I2C EEPROM

Posted by osno on 03 January 2011 - 11:00 PM in General Discussion

It took me quite a while to get back to my Netduino... and I must say that EEPROM code works amazingly well!! Thanks for that.



#5833 Help needed with I2C EEPROM

Posted by osno on 07 December 2010 - 12:05 AM in General Discussion

So here is the class, fritzing diagram, and example output for the I2C EEPROM classes. There is also some extraneous code in the project for some MCP23008 and MCP23016 Digital I/O expander chips that I'm working on, so ignore those for now (they are a work-in-progress).

The example program should be relatively self-explanatory. Let me know if you've got questions or suggestions.


Very cool. It's actually similar to my first try. I'll have to try it in a week or so when I get home. Thanks!!



#5817 Help needed with I2C EEPROM

Posted by osno on 06 December 2010 - 06:18 PM in General Discussion

Not sure if you all are still interested, but I did get a class working for both a 24LC16B and a 24LC256 that uses the standard 4.1.0.5 firmware. It's only regular reads / writes, but I've had it write and read 10 consecutive bytes at a time without problem. I haven't tried (nor have a need for) random / sequential reads, so you're on your own for that.

If you are interested, I could post code and a fritzing diagram.

I'm interested :). I'm away from home for a few days so I won't be able to provide feedback, but I sure would love to try when I get back.



#5422 Help needed with I2C EEPROM

Posted by osno on 27 November 2010 - 07:01 PM in General Discussion

Chris, any time frame on 4.1.1? CW2, is the version that's working with the EEPROMs the one that I have? Thanks, J



#5309 Help needed with I2C EEPROM

Posted by osno on 26 November 2010 - 02:23 AM in General Discussion

I think it has the exact same problem (Device Address -> Write needed memory address -> device address repeat). Some of the guys here can confirm. The problem is that the stock firmware doesn't repeat the device address (that is, you can't request device -> write -> device -> read in a single instruction). Check the sequence in page 11 here: http://www.sparkfun....IC/24LC256.pdf. One calls it control byte and the other device address, but the sequence is basically identical.



#5243 Help needed with I2C EEPROM

Posted by osno on 24 November 2010 - 11:42 AM in General Discussion

I got completely sidetracked on other things and couldn't test this appropriately, sorry for that. I'd love to see that code in the official firmware, though!



#4696 I2CDevice extension

Posted by osno on 08 November 2010 - 11:51 PM in Beta Firmware and Drivers

Ok, known issue. I'm using 2-byte addresses, the driver supports 1 byte. Working on it, sorry for the troubles to users reading the conversation.



#4695 Help needed with I2C EEPROM

Posted by osno on 08 November 2010 - 11:49 PM in General Discussion

I had tested before I read your message. PMing you now. Thanks!! I plan on writing a big-ass blog post if this works, if you don't mind.



#4693 I2CDevice extension

Posted by osno on 08 November 2010 - 11:47 PM in Beta Firmware and Drivers

I'm testing with an 24LC256 EEPROM and I'm getting an ArgumentException using: int bytesTransfered = eeprom.WriteRead(addressBuffer, 0, 2, data, 0, data.Length, timeout, I2COptions.RepeatStart); (where addressBuffer is a byte[2] and data is a byte[] I get from a parameter). I also tried the short version. Am I doing anything wrong? Thanks, J



#4684 Help needed with I2C EEPROM

Posted by osno on 08 November 2010 - 11:07 PM in General Discussion

That may be the issue. Here's the protocol:
protocol.png

I think that after the Write, I should be sending the start again. Can I do that by doing this?
            byte[] data = new byte[length];

            using (I2CDevice eeprom = new I2CDevice(new I2CDevice.Configuration(0x50, 400))) //0x50 is 1010 000, 400 is 400khz
            {
                // Create a new Transaction 
                I2CDevice.I2CTransaction[] transaction = new I2CDevice.I2CTransaction[]{
                    I2CDevice.CreateWriteTransaction(new byte[] { (byte)((address >> 8) & 0x7F), (byte)(address & 0xFF) }),
                };
                eeprom.Execute(transaction, 1500);
            }

            using (I2CDevice eeprom = new I2CDevice(new I2CDevice.Configuration(0x50, 400))) //0x50 is 1010 000, 400 is 400khz
            {
                // Create a new Transaction 
                I2CDevice.I2CTransaction[] transaction = new I2CDevice.I2CTransaction[]{
                    I2CDevice.CreateReadTransaction(data)
                };
                int bytesTransfered = eeprom.Execute(transaction, 1500);

                if (bytesTransfered == length + 2)
                    return data;
                else
                    return null;
            }

Because I tried it, but it didn't work either...

I may be forced to reflash. I didn't want to brick my netduino :(.

Anyway, my problem. Thanks! I'll try that...



#4681 Help needed with I2C EEPROM

Posted by osno on 08 November 2010 - 10:26 PM in General Discussion

I've been trying for a few days to get an 24LC256 EEPROM working. I'm in a point where the bytesTransferred I receive from the I2CTransaction is correct for both Write and Read, but when I inspect the buffer for the read operation, it's all 255's (every byte is maxed out). I think it has something to do with the resistors I'm using. I tried 2k connected to 5V and 3.3V and 10k connected to 5V and 3.3V and I get the same in all combinations. If I remove the pull-up's completely, the read operation reports 2 bytes transferred (the address I'm writing, I'm assuming). If anybody can help, I'll be more than grateful.

This is how I'm wiring everything. The digital pins are connected to a 74HC238 to show me some output from what I'm saving. I only drew a few leds... there's more. That part seems to work, though. The graphic:
EEPROM.png

And the code for the memory driver is:
        public byte[] ReadBytes(ushort address, int length)
        {
            byte[] data = new byte[length];

            using (I2CDevice eeprom = new I2CDevice(new I2CDevice.Configuration(0x50, 400))) //0x50 is 1010 000, 400 is 400khz
            {
                // Create a new Transaction 
                I2CDevice.I2CTransaction[] transaction = new I2CDevice.I2CTransaction[]{
                    I2CDevice.CreateWriteTransaction(new byte[] { (byte)((address >> 8) & 0x7F), (byte)(address & 0xFF) }),
                    I2CDevice.CreateReadTransaction(data)
                };
    
                int bytesTransfered = eeprom.Execute(transaction, 1500);

                if (bytesTransfered == length + 2)
                    return data;
                else
                    return null;
            }
        }

        public void WriteBytes(ushort address, byte[] data)
        {
            using (I2CDevice eeprom = new I2CDevice(new I2CDevice.Configuration(0x50, 400))) //0x50 is 1010 000, 400 is 400khz
            {
                // Create a new Transaction 
                I2CDevice.I2CTransaction[] transaction = new I2CDevice.I2CTransaction[]{
                    I2CDevice.CreateWriteTransaction(new byte[] { (byte)((address >> 8) & 0x7F), (byte)(address & 0xFF) }),
                    I2CDevice.CreateWriteTransaction(data)};

                // Execute the WriteBytes transaction, check if it was succesfull.
                int bytesTransfered = eeprom.Execute(transaction, 1500);
            }
        }
    }

The program does:

            byte[] sequence = new byte[]{ 2, 1, 2, 3, 2, 1, 0, 3, 1, 2, 0 };
            byte[] data = new byte[11];

            board.Memory.WriteBytes(100, sequence);
            data = board.Memory.ReadBytes(100, 11);

And then loops flashing the leds.

Thanks in advance to any kind soul who can take a look and give me some advice. I have tried 2 different EEPROM chips (same type) to the same result. Many resistor/voltage combinations. Even reversing the SDA and SCL (that didn't help :)). I don't know what to try at this point.

Thanks again,
J

(formatting tips are also appreciated... other people's posts look way better than mine!!)



#4554 Native code implementation

Posted by osno on 07 November 2010 - 01:11 AM in Netduino 2 (and Netduino 1)

SAM-BA sounds scary right now, so I think I'll skip it. What I can do is: var secondLoopThread = new Thread(SecondLoop); secondLoopThread.Start(); where SecondLoop is an infinite loop in an extern method. Will that work? My goal is to have a DEMUX looping through several outputs every 100-200ns, so I can provide the illusion of a single output driving many outputs at the same time. For instance, have 16 LEDs and be able to turn on any combination of them with just 4 GPIO pins in the Netduino. So the logic for which LEDs to turn on will be in .Net, and the loop for turning them on and off will be in native. .Net is too slow to reliably provide this illusion. Regards, j



#4549 Native code implementation

Posted by osno on 07 November 2010 - 12:49 AM in Netduino 2 (and Netduino 1)

It sounds incredibly difficult so I'll have to try it! Is it possible (theoretically) to modify the bootloader so you can deploy native code? If it is, I'll love to help integrating it to Visual Studio. And btw, will this solve the main issue with .Net MF, which is speed? Meaning, can I do speed-sensitive stuff in native code and complex logic in managed code and expect it to work? Thanks, J



#4546 Arduino and Netduino pros and cons

Posted by osno on 06 November 2010 - 10:13 PM in General Discussion

...
You can also look into using the bitbanger driver:
http://forums.netdui...tbanger-driver/

Does that give you a good start?
...


Looking into that right now. It looks promising! And thanks for the welcome and the response.



#4545 Native code implementation

Posted by osno on 06 November 2010 - 10:08 PM in Netduino 2 (and Netduino 1)

It would be amazing if we could do the following: Have a solution with a C native project that compiles ARM and a Netduino MF project. Deploy both to the device. In the netduino code, use p/invoke (the DLLImportAttribute) to call methods in the C native project. Is this even a possibility? I'd love to help implement that in Visual Studio if it's possible. Regards, J



#4541 Arduino and Netduino pros and cons

Posted by osno on 06 November 2010 - 09:41 PM in General Discussion

I was trying to drive several leds from a 74HCT238 at the same time, but I can't sleep a thread for less than 1 milliseconds. The effect is blinking leds all over the place. If I could sleep for, say, 500ns it will look way better. It's not possible to do that because of what's being discussed here, right? I may be able to code that in an UNO and use the chip as a LED driver (or I can learn how to use a PIC, maybe), and use the Netduino for the actual high level program.




home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.