Show Posts
Pages: 1 ... 5 6 [7] 8 9 ... 19
91  Community / Bar Sport / Re: I just got the fastest delivery from China :) on: September 12, 2013, 05:27:17 pm
seller ebay name is hkshanhai_shop

granted I am located by left coast port of entry. I usually receive packages between 8-10 days.
ymmv
92  Community / Bar Sport / I just got the fastest delivery from China :) on: September 12, 2013, 01:21:51 pm
shipped on 9/9, delivered 9/12. This is for a mega2560 board for $11.50 with free shipping.

93  Using Arduino / Storage / Re: sdfat + ethernet + spi issue (ethernet dropping connection) on: September 11, 2013, 05:02:50 pm
yes, I did suggest it may be a software/hardware issue.

the relays are powered by 12v, arduino is isolated from the relay. relay control input use opto isolator.
I don't think it is an issue of under powered power supply (though I'm not ruling that out yet), but may be a spike or surge as you suggested. I can try delaying the sd write, say 2 seconds after the relay switches.

Tim, I like your logic, just because you do not see a problem, you conclude there is no problem. lol. 
As fat16lib said, the overhead is minimal to add the SPI initialization code. It will take 2-3 clock cycles to do it (refer to AVR datasheet, SBR and CBR instructions take 1 clock cycle each).  Don't get too hung up on code performance where it does not matter. smiley

As to my source code, it is a very large project so I do not want to waste anyone's time perusing it.  I will eventually put it in github as an open source project.
94  Using Arduino / Storage / Re: sdfat + ethernet + spi issue (ethernet dropping connection) on: September 11, 2013, 01:41:16 pm
I'll try that.

Note that there is no Ethernet activity (other than testing) at all during this time.
Say for example overnight last night, from 12midnight to 6 am, there is no network activity (web request) to the arduino, there were about 100 relay switch changes, and the corresponding sd writes. After each write I do a  client.connect to port 80 of the router. I got 13 failures out of 100 (I call ethernet.begin if connect failed). I know if I do not add the client.connect (so absolutely no network activity), and I just monitor the attached devices on my router, after several outlet relay switch activity,  I will see the arduino drop out of the list, after which I am unable to connect to it anymore.
95  Using Arduino / Storage / Re: sdfat + ethernet + spi issue (ethernet dropping connection) on: September 11, 2013, 11:19:55 am
Quote
I think sdfat code can be a good SPI bus citizen if it stores the SPCR bits 0 and 1 and SPSR bit 0 on chipSelectLow() and restores it in Sd2Card::chipSelectHigh().

I considered restoring SPI settings in SdFat but this is not the correct solution.   I soon encountered a user with an LCD, ADC and SD on the SPI bus.  It is not uncommon for three or more devices to be on the SPI bus.  The only correct solution is for each library to set its SPI settings.


Ok. Thanks for that info. I understand what you are saying. I tried looking for an SPI protocol document but did not find one, but wikipedia did mention

To begin a communication, the bus master first configures the clock, using a frequency less than or equal to the maximum frequency the slave device supports. Such frequencies are commonly in the range of 10 kHz–100 MHz.

I suppose that could be interpreted as on SPI initialization and not before each transmission (just like how it is done in Ethernet library). It mentioned there is a lack of SPI protocol standard. I looked at a couple SPI chip datasheet and I did not find any mention of initializing SPI bus before each transmission as a protocol requirement.

Anyway, I took your suggestion and added initialization code to the ethernet library. I am still testing it.
in setSS(), I added one of these (tried several clock setting)
//full speed
SPCR &= 0xFC;SPSR |= 0x01;
//half speed, since Ethernet library uses this speed, I think this should be part of the code
SPCR &= 0xFC;SPSR &=0xFE;
//qtr  speed
SPCR = ((SPCR&0xFC) | 0x01);SPSR |= 0x01;
I still see the problem, so now I am thinking if it is a hardware (or hardware/software) issue.

What the program does is, I have an 8 channel relay that switches on and off, and I log the switching event to SD card. It appears like after the SD card write, the network connection drops (no problem on the SD card write). I can comment out the SD card write and the network does not drop. It does not happen all the time, maybe 10% of the time. For now, right after the SD card write, I make a network connection test, and if it fails, I call Ethernet.begin which brings up the ethernet again. I prefer to find the cause of this problem and fix it rather than use a workaround.
96  Using Arduino / Storage / Re: sdfat + ethernet + spi issue (ethernet dropping connection) on: September 10, 2013, 04:23:21 pm
^^^^ lol


I checked the W5100 datasheet, and it can handle 70ns SCK speed (about 14.28mhz), so it should work at spi_full_speed just fine, in theory.
97  Using Arduino / Storage / Re: sdfat + ethernet + spi issue (ethernet dropping connection) on: September 10, 2013, 04:06:49 pm
I just went through the spi, ethernet and sdfat libraries and atmega datasheet.

the default is as you stated (by virtue of SPCR and SPSR registers being initially 0), so ethernet runs at spi_half_speed (by sdfat terminology).

So it seems that if I use spi_half_speed on sdfat, then everything should be fine, but it is not the case. I will try one more step lower, since ethernet does not bother setting the SCK frequency, I'll see if it still works at the lower clock speed.

regarding the registers being read only or read write. according to the datasheet, SPCR is read/write, and SPSR bit SPI2X is read/write. I think sdfat code can be a good SPI bus citizen if it stores the SPCR bits 0 and 1 and SPSR bit 0 on chipSelectLow() and restores it in Sd2Card::chipSelectHigh().  That will be no different than saying SPI library must initialize SPI bus before each access, we are just moving that "initialize" up to sdfat code.

this is all about low level code working together correctly and has nothing to do with application level code.
98  Using Arduino / Storage / Re: sdfat + ethernet + spi issue (ethernet dropping connection) on: September 10, 2013, 03:01:28 pm
I do not see anywhere in Ethernet library where it initializes the SPI mode.
Ethernet begin only contains a line W5100 init, which does a writeMR(1<<RST). But that is more setting the W5100 mode, and not the SPI. So it seems ethernet simply uses whatever is the spi default provided by the cpu.

I do see sdfat uses

void Sd2Card::chipSelectLow() {
  spiInit(spiRate_);
  digitalWrite(chipSelectPin_, LOW);
}

Is that register write only such that sdfat cannot read the state, store it, and then restore it back to the original state after it is done using the spi bus?

99  Using Arduino / Storage / Re: sdfat + ethernet + spi issue (ethernet dropping connection) on: September 10, 2013, 02:31:38 pm
I suppose this

The Ethernet driver doesn't seem reinitialize the SPI bus for the mode it uses before each access.

Maybe that is why Ethernet.begin workaround fixes the issue.

is it because ethernet does not initialize the spi bus before each access or is it because sdfat does not restore the mode after using spi bus?
100  Using Arduino / Storage / sdfat + ethernet + spi issue (ethernet dropping connection) on: September 10, 2013, 02:19:09 pm
I am using the latest sdfat (with use arduino spi library enabled) + ethernet + arduino spi.

from time to time (usually after an sd write), the ethernet will drop its connection (I can see it disappear on my router attached device list).
I currently work around this by calling Ethernet.begin(..) and all is well.

I remember reading somewhere about this incompatibility (perhaps due to sdfat using a different spi speed?).
I tried both full and half speed and still see the problem.

what is exactly causing this problem? (I think sdfat author may have more knowledge about this)
what is the best way to resolve this? (besides my calling Ethernet.begin).

Will setting SS, pins 4 and 10 high be enough? (instead of going through the whole Ethernet.begin).

this is on a mega2560 board.

Thanks
101  Using Arduino / General Electronics / Re: where can i buy triple row right angle pin headers? on: September 08, 2013, 02:50:10 am
I had not seen these before, but found some at adafruit, fairly reasonable price compared to the uaviation guys.
http://www.adafruit.com/products/816

thanks. good to know. I searched sparkfun and did not find any. I should have remembered to search adafruit.
102  Using Arduino / General Electronics / Re: where can i buy triple row right angle pin headers? on: September 07, 2013, 01:24:06 pm

wow good find! I search ebay first and did not get any hit

yes, I already passed the test of patience humanly possible, so I can handle this  smiley

I get most orders in 5-7 working days (usually from "top rated sellers" which this seller is). never past the delivery date listed (which is like 45 days).

$4.99 for 5pcs, that's more than I'll ever need in my lifetime.


thanks!
103  Using Arduino / General Electronics / Re: where can i buy triple row right angle pin headers? on: September 07, 2013, 12:18:15 am
I found a few sellers.

I just need to change my search to right angle servo connector. turns out most RC stores sell them.

this one sells 3x40 for $4.50+ $3.00 shipping

http://uaviation.net/openpilot/19-3x40-right-angle-header.html
104  Using Arduino / General Electronics / where can i buy triple row right angle pin headers? on: September 07, 2013, 12:00:25 am
I need triple row pin headers (right angle) for servo connections but can't seem to find any place that sells them. any suggestions?

thanks.
105  Using Arduino / Displays / Re: How long will 1602 LCD on 24x7 last? on: August 30, 2013, 12:23:59 pm
forever it is then!!

I use an I2C module with it, so the backlight driver is in that I2C module (it has a transistor+resistor). It can't be too much current, as I power it from +5v pin of mega board.  The I2C module chip is rated for 100khz, but I run it at 400khz using a custom i2c library I got from my quadcopter project and its been running for at least a couple weeks i2c error free. At 400khz, I timed the lcd update takes approximately 1/3 the time using the Wire library.
Pages: 1 ... 5 6 [7] 8 9 ... 19