Show Posts
Pages: [1] 2 3 ... 279
1  Community / Exhibition / Gallery / Re: External EEPROM library for 2k bits - 2M bits on: July 22, 2014, 02:55:49 pm
Thanks Rob!

My assumption regarding the bus speed was that once all I2C devices were initialized, it would not change. Is it possible/advisable to mix different speed devices on the same bus, and then change the speed on the fly to communicate with different devices? For example, a DS1307 that can only do 100kHz and an EEPROM capable of 400kHz. I would think there is some risk of confusing the slower device while the bus is running at the higher speed, even though it's not being addressed. I wonder if it might try to respond which would then result in garbage on the bus.

I do warn in the ReadMe file to place the extEEPROM.begin() call after all other I2C devices are initialized to ensure the desired bus speed is set. But the worst case scenario is just that the bus runs slower, so I didn't feel a need to do anything more.

While running at 400kHz can be a significant improvement, you're probably aware that it's nowhere near even twice as fast with EEPROMs, due to the small block sizes (Wire library 32 byte limit) and the wait times for writes.

Page write times vary between EEPROM part numbers. Datasheets for EEPROMs I have say 3, 5, and 10ms. So I used the polled method as opposed to hardcoding a delay. Still I didn't want to bombard the device with continuous polls so I poll every 0.5ms. I've also observed that page write times are often better than the datasheet specs (no real surprise there). I suppose I could drop my interval to maybe 100┬Ás. I might run some tests and also try your technique.
2  Development / Suggestions for the Arduino Project / Re: Breaking away from a PC on: July 22, 2014, 08:01:49 am
On second thought, it could be made to work, there's plenty of screen space for this:

3  Community / Exhibition / Gallery / Re: Programming DS3231 Alarms and Interupts on: July 22, 2014, 07:50:42 am
I wrote a library, one of these days I'll get back to completing the doc:
https://github.com/JChristensen/DS3232RTC
4  Using Arduino / Motors, Mechanics, and Power / Re: Minimizing power consumption of an Uno? on: July 22, 2014, 07:49:29 am
Hi all.  I can't use a board other than the Uno and I'm on a tight power budget.

That is what I would call between a rock and a hard place. Please describe the power budget.

What is the base power draw with nothing attached with an empty sketch?

http://forum.arduino.cc/index.php?topic=164146.msg1232507#msg1232507
5  Community / Exhibition / Gallery / External EEPROM library for 2k bits - 2M bits on: July 21, 2014, 09:56:49 pm
I updated my external EEPROM library to work with any size EEPROM between 2k bits and 2M bits. Another user on the forum was able to test it with a 1M bit EEPROM. I've tested it with 2kb, 256kb and 2Mb. If anyone has other size EEPROMs and is so inclined, additional testing is always appreciated.

The library will write across block, page and device boundaries, it treats all EEPROMs on the bus as a single address space. I added methods to write and read single bytes and even wrote some documentation (!)

https://github.com/JChristensen/extEEPROM
6  Using Arduino / Storage / Re: Unable to work with 1Mbit EEPROM on: July 21, 2014, 09:12:22 pm
I made final changes to my library and pushed it to GitHub (master branch now), http://github.com/JChristensen/extEEPROM

Added single-byte write and read functions and even added documentation  smiley-surprise

Gave you creds for testing 24FC1026, if you're uncomfortable with that just say the word.
7  Using Arduino / Project Guidance / Re: 3 XBees Communication on: July 21, 2014, 09:03:48 pm
Okay. I will replace the new (S2) XBee with a new Series 1 XBee.

Consider I do that. Do I have to reconfigure all three of them again, even though two of them are configured to communicate already?

Like I said, I have data going from T1 (address 1001) to R3 (address 1000), and also would need data to go from T2 (new one I will be getting) to R3 (address 1000).

I only need R3 to act as a master and send pilot signals to these on when to transmit the data. I have never done API mode. Guide me on the whole thing.

I have a FTDI breakout board to configure the XBees, and a USB A to mini B cable.

I did the AT commands in PuTTY. What should I download and install for configuring in API? I would appreciate it if you could guide me through this.

Insufficient time to "guide you on the whole thing" unless perhaps enormous amounts of money were involved. Else you'll need to see if you can't find some initiative and learn some other way. I work almost exclusively with XBee ZB modules and have never used XBee 802.15.4 modules in API mode. I think it's similar, but there may be differences, I don't know exactly, but that is the tree I would bark up first. The library I linked above is one place to start. The product manual is another. Try things for yourself. You'll make mistakes, but everyone does and that's a good way to learn. If you get stuck, ask good questions on the forum. Best of luck.
8  Using Arduino / Programming Questions / Re: Multi-Function Interrupts on: July 21, 2014, 04:57:08 pm
In this case, the delay function isn't causing the problem. Rather, I realized that because the interrupt returns to where it left off it has to finish all the loops (with included delays) before it will even check to see if it should change.

Well yes it is the problem. While executing the delay() function, nothing else, like checking for a button press, can be done. See the famous BlinkWithoutDelay example which illustrates how to delay without the delay() function, so the code can do something while it's waiting for something else.

Peter_n's suggestion is clever and should work, but like he says I'd only consider it a quick fix. I'd try fixing it that way for now, then go master the BlinkWithoutDelay concept.
9  Development / Suggestions for the Arduino Project / Re: Breaking away from a PC on: July 21, 2014, 04:36:49 pm
Real Programmers don't program on smartphones.  smiley-wink
10  Using Arduino / Programming Questions / Re: Multi-Function Interrupts on: July 21, 2014, 04:34:06 pm
An interrupt always returns to the instruction right after the last one executed when the interrupt occurred.

Would I be correct in guessing that the code for the LED schemes includes the delay() function? That would be the problem, those need to be done away with.

Neither is it necessary to use an interrupt for a button input. So we have two inappropriate techniques here, and they don't play well together either.
11  Using Arduino / Project Guidance / Re: 3 XBees Communication on: July 21, 2014, 04:27:16 pm
You have a problem because XBee 802.15.4 modules (f.k.a. S1) will not communicate with XBee ZB modules (f.k.a. S2).

Even if the three modules were the same type, programming for communication among three or more nodes in AT mode will be very cumbersome. Basically the controller will have to emulate the same "AT" commands as they would be typed in, sending the +++ command sequence, changing the destination address, parsing the output, observing guard times, etc. This is not my idea of fun and is why I strongly recommend API mode.
12  Using Arduino / Storage / Re: Unable to work with 1Mbit EEPROM on: July 21, 2014, 03:24:16 pm
@Gabriele, excellent! Glad it works for you and I very much appreciate the testing. I'll add 24FC1026 to the list of devices tested.

I had a look at the E24C1024 library, and the write code looks OK to me (without doing any testing) but I think the problem is in the read code:

Code:
uint8_t E24C1024::read(unsigned long dataAddress)
{
   uint8_t data = 0x00;
   Wire.beginTransmission((uint8_t)((0x500000 | dataAddress) >> 16)); // B1010xxx
   Wire.send((uint8_t)((dataAddress & WORD_MASK) >> 8)); // MSB
   Wire.send((uint8_t)(dataAddress & 0xFF)); // LSB
   Wire.endTransmission();
   Wire.requestFrom(0x50,1);
   if (Wire.available()) data = Wire.receive();
   return data;
}

Note the statement Wire.requestFrom(0x50,1); will always have the bits A2 = A1 = B0 = 0. Changing it to the same expression as used in Wire.beginTransmission() should fix it.

I did notice the funny addressing for the 24xx1025 when doing research for the library. Not sure why they'd do that, but I decided not to worry about it; my library will not work with that chip.

Thanks again!

PS: I raised an issue with the arduino-at24c1024 library.
13  Using Arduino / Project Guidance / Re: 3 XBees Communication on: July 21, 2014, 11:48:07 am
Anyone else more experienced with multi-XBee networks?

I use XBee ZB modules (f.k.a. Series 2) and communication between three or more is straightforward using API mode. There are many, many types of XBee, so what kind of XBees are we talking about here, exactly? The part number for the one I use most often is XB24-Z7WIT-004. What part number do you have?

Andrew Rapp's XBee-Arduino library makes API mode easy.
14  Using Arduino / Storage / Re: Unable to work with 1Mbit EEPROM on: July 21, 2014, 11:27:07 am
@Gabriele,

I've just wrapped up testing my library with the EEPROMs I have on hand, 2kbits, 256kbits and 2Mbits.

For what it's worth, below is a sketch I used for testing, although I'd still be interested in hearing results from whatever method you are using as well.

Thanks!

Code:
//test updated extEEPROM library
//writes the EEPROM full of 32-bit integers and reads them back to verify
//09Jul2014

#include <Streaming.h>    //http://arduiniana.org/libraries/streaming/
#include <Wire.h>
#include <extEEPROM.h>    //http://github.com/JChristensen/extEEPROM/tree/dev

//24FC1026
const uint32_t totalKBytes = 128;          //for read and write test functions
extEEPROM eep(kbits_1024, 1, 128);         //device size, number of devices, page size

const uint8_t btnStart = 6;                //start button

void setup(void)
{
    pinMode(btnStart, INPUT_PULLUP);
    Serial.begin(57600);
    uint8_t eepStatus = eep.begin(twiClock400kHz);
    Serial << endl << F("EEPROM begin status=") << eepStatus << endl << "TWBR=" << TWBR << endl << F("Press button to start...") << endl;
    while (digitalRead(btnStart) == HIGH) delay(25);    //wait for button push

    uint8_t chunk = 64;
//    eeErase(chunk, 0, totalKBytes * 1024 - 1);
    eeWrite(chunk);
    eeRead(chunk);

    dump(0, 1);
    dump(65520, 1);
    dump(65536, 1);
    dump(131056, 1);
}

void loop(void)
{
}

//write test data (32-bit integers) to eeprom, "chunk" bytes at a time
void eeWrite(uint8_t chunk)
{
    chunk &= 0xFC;                //force chunk to be a multiple of 4
    uint8_t data[chunk];
    uint32_t val = 0;
    Serial << F("Writing...") << endl;
    uint32_t msStart = millis();
    
    for (uint32_t addr = 0; addr < totalKBytes * 1024; addr += chunk) {
        if ( (addr &0xFFF) == 0 ) Serial << addr << endl;
        for (uint8_t c = 0; c < chunk; c += 4) {
            data[c+0] = val >> 24;
            data[c+1] = val >> 16;
            data[c+2] = val >> 8;
            data[c+3] = val;
            ++val;
        }
        eep.write(addr, data, chunk);
    }
    uint32_t msLapse = millis() - msStart;
    Serial << "Write lapse: " << msLapse << " ms" << endl;
}

//read test data (32-bit integers) from eeprom, "chunk" bytes at a time
void eeRead(uint8_t chunk)
{
    chunk &= 0xFC;                //force chunk to be a multiple of 4
    uint8_t data[chunk];
    uint32_t val = 0, testVal;
    Serial << F("Reading...") << endl;
    uint32_t msStart = millis();
    
    for (uint32_t addr = 0; addr < totalKBytes * 1024; addr += chunk) {
        eep.read(addr, data, chunk);
        for (uint8_t c = 0; c < chunk; c += 4) {
            testVal =  ((uint32_t)data[c+0] << 24) + ((uint32_t)data[c+1] << 16) + ((uint32_t)data[c+2] << 8) + (uint32_t)data[c+3];
            if (testVal != val) Serial << F("Error @ addr ") << addr+c << F(" Expected ") << val << F(" Read ") << testVal << F(" 0x") << _HEX(testVal) << endl;
            ++val;
        }
    }
    uint32_t msLapse = millis() - msStart;
    Serial << "Last value: " << --val << " Read lapse: " << msLapse << " ms" << endl;
}

//write 0xFF to eeprom, "chunk" bytes at a time
void eeErase(uint8_t chunk, uint32_t startAddr, uint32_t endAddr)
{
    chunk &= 0xFC;                //force chunk to be a multiple of 4
    uint8_t data[chunk];
    Serial << F("Erasing...") << endl;
    for (int i = 0; i < chunk; i++) data[i] = 0xFF;
    uint32_t msStart = millis();
    
    for (uint32_t a = startAddr; a <= endAddr; a += chunk) {
        eep.write(a, data, chunk);
    }
    uint32_t msLapse = millis() - msStart;
    Serial << "Erase lapse: " << msLapse << " ms" << endl;
}

//dump eeprom contents, 16 bytes at a time.
//always dumps a multiple of 16 bytes.
void dump(uint32_t startAddr, uint32_t nBytes)
{
    Serial << endl << F("EEPROM DUMP 0x") << _HEX(startAddr) << F(" 0x") << _HEX(nBytes) << ' ' << startAddr << ' ' << nBytes << endl << endl;
    uint32_t nRows = (nBytes + 15) >> 4;

    uint8_t d[16];
    for (uint32_t r = 0; r < nRows; r++) {
        uint32_t a = startAddr + 16 * r;
        eep.read(a, d, 16);
        Serial << "0x";
        if ( a < 16 * 16 * 16 ) Serial << '0';
        if ( a < 16 * 16 ) Serial << '0';
        if ( a < 16 ) Serial << '0';
        Serial << _HEX(a) << ' ';
        for ( int c = 0; c < 16; c++ ) {
            if ( d[c] < 16 ) Serial << '0';
            Serial << _HEX( d[c] ) << ( c == 7 ? "  " : " " );
        }
        Serial << endl;
    }
}
15  Using Arduino / Storage / Re: Teensy 3.1 / Data Logging / SD Card / Latency / Non-Blocking SDFAT Library on: July 21, 2014, 11:18:48 am
Quote
This would also be true of any smaller buffer size?

SPI mode performance of the new generation of SD cards varies greatly and is not very predictable.  Manufactures only include SPI mode since the SD spec requires it.  Sometimes larger buffers reduce the frequency of long latency write but not the time.  In other cases the time is reduced.

New cards are optimized for phones and tablets in 4-bit SDIO mode.  There is little correlation between SPI performance with small writes and large writes in SDIO mode. 

I don't think there is a future in optimizing SPI mode performance for fast data logging. 

I am buying  development boards with SDIO mode SD sockets.  The SDIO controller on these boards have CRC and a fast DMA mode.

Thanks for the reply, I sure do appreciate your library and the effort and expertise you've put into it.
Pages: [1] 2 3 ... 279