Show Posts
Pages: 1 ... 166 167 [168] 169 170 ... 404
2506  Using Arduino / Programming Questions / Re: Not Opening the SD file to upload to FTP on: June 18, 2013, 04:59:35 pm
It isn't really a matter of clearing it, but freeing it. That is why the F() function is prevalent in that code. It keeps those static strings in program memory instead of copying them to SRAM to use them.

Try the freeRam() function. Call it at the end of your setup() function to check how much you have remaining there, then again just before the SD file open. It is possible this is not the problem, but until you check...

edit: Some of the SRAM is used by the "operating system", and the Ethernet and SD libraries take their toll on it too. Then when it runs that FTP function, you have a file and two sockets open, all at the same time.
2507  Using Arduino / Programming Questions / Re: Not Opening the SD file to upload to FTP on: June 18, 2013, 04:33:45 pm
The FTP code only includes one function or the other in the compile. It compiles either the SD-to-FTP code, or the FTP-to-SD code, depending on the FTPWRITE define. That is so it will fit easier into an Uno.

And there is a difference between program memory and SRAM. You have 32K of program memory, but only 2K SRAM.

Here is a short sketch that has a SRAM checking function. It doesn't show zero when out of SRAM, but a very large or negative number. You can add it to your sketch and call it just before the SD open fail to see how much SRAM you have before the SD file open.
Code:
int freeRam() {
  extern int __heap_start,*__brkval;
  int v;
  return (int)&v - (__brkval == 0 ? (int)&__heap_start : (int) __brkval);  
}

void setup() {
  Serial.begin(9600);
  // all your setup stuff, then

  Serial.print(F("SRAM = "));
  Serial.println(freeRam());
}

void loop() {
}
2508  Using Arduino / Programming Questions / Re: Not Opening the SD file to upload to FTP on: June 18, 2013, 04:02:27 pm
What device are you using? If it is an Uno, you are close to using up all your SRAM with the FTP code. An SD file open fail is one symptom.
2509  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet shield + arduino as a CLIENT, please help! on: June 18, 2013, 11:18:32 am
What page do you want me to check? I was downloading your home page. Indirectly this:
Code:
client.println("GET / HTTP/1.1");

edit: If you are using an Uno, try reducing the size of outBuf. Maybe you are getting close to running out of SRAM.
Code:
  char outBuf[64];
2510  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet shield + arduino as a CLIENT, please help! on: June 18, 2013, 10:19:59 am
Not impossible. Are you required to use a proxy by your ISP? Sometimes that will interfere with the connect/send/receive unless you adjust your ethernet shield settings for a proxy.

edit: Insure you are not using an ip that is already being used by another device. That will cause connection problems.
2511  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet shield + arduino as a CLIENT, please help! on: June 18, 2013, 09:42:20 am
I downloaded the sketch for the new GET client code from the playground link above. Those are my localnet settings, so I changed only these
Code:
char serverName[] = "www.valerioantonangeli.it";
IPAddress server(46,4,96,70);
I'm now on pass 10 and doing fine.
2512  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet shield + arduino as a CLIENT, please help! on: June 18, 2013, 07:10:32 am
I changed the ethernet client GET code in the playground to send the Host and Connection parameters.

Feel free to change it any way that fits your requirements. That code fits mine, because I can use it to access multiple servers at different ports and different pages, or the same page with different parameters. You can hard code those values into your getPage() function if your code requires only one server and page.

It is a demo of how to contact a server with the client code using a basic trigger (30 seconds in my demo) and the ability to pass parameters to the server.
2513  Using Arduino / Networking, Protocols, and Devices / Re: Linking 2 Arduinos over ethernet on: June 17, 2013, 02:18:14 pm
Have you considered UDP? That is about as simple as it gets. No connection or error checking at all. Just send the packet. It isn't bulletproof. You never know if the packet got there or not unless the destination device sends a response packet back to you.

The UDP "server" sends packets to its "clients", and the "client" send a response packet to the server.
edit: Or the other way around if you wish. Client initiates a packet, server responds.
2514  Using Arduino / Networking, Protocols, and Devices / Re: Linking 2 Arduinos over ethernet on: June 17, 2013, 01:48:37 pm
You will need a server. It does not have to stick to strict format data. The client can send what you want. The server can return what you want.

If you want http format and fault tolerance, then what you see there is the minimum for continued operation. Otherwise it would be what I refer to as "perfect world" code. It works as long as nothing goes wrong. The bad news is that things go wrong often, so if not written with built-in fault tolerance, your code will lock up often.
2515  Using Arduino / Project Guidance / Re: Having trouble setting a static IP Address on wifi shield on: June 17, 2013, 01:13:02 pm
Are you certain the router is not blocking the traffic? My routers (MikroTik), and most others, have a wireless forwarding setting. MikroTik calls it default-forwarding. If that is set to yes, the wireless devices on the localnet can communicate with each other. If set to no, then they can't.

edit: Insure the server code has the correct port. It should be port 80 for a web browser.
2516  Using Arduino / Networking, Protocols, and Devices / Re: Linking 2 Arduinos over ethernet on: June 17, 2013, 12:52:27 pm
This client and server code should work together.
http://playground.arduino.cc/Code/WebClient
http://playground.arduino.cc/Code/WebServerST
Use the GET request on the client code. Note the warnings about the mac addresses of each device. They must all be unique.

That would have been one of the problems with the sketches  zoomkat suggested on the other topic. My code in the playground had the same problem, but you will notice the mac addresses are not identical on my client and server code.
2517  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet shield + arduino as a CLIENT, please help! on: June 17, 2013, 05:58:31 am
could i marry u?
Not without dinner and several drinks first.  smiley

edit: I changed the GET code to HTTP/1.1. Set the global char[] serverName to your domain name, and it will send the Host and Connection:close for you.
2518  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet shield + arduino as a CLIENT, please help! on: June 17, 2013, 04:49:19 am
You should be able to use your website. Use the code in reply #9. Your web hosting company server requires the Host parameter, or it will load your web hosting company's page.

This is the code I use. You will need to modify the GET code to use the Host parameter.
http://playground.arduino.cc/Code/WebClient
It has all the bug fixes I know to prevent lockups. The good part about that code is if you have a question or problem, ask me.
2519  Using Arduino / Networking, Protocols, and Devices / Re: Hardware SPI: how to shift out less than 1 byte? on: June 17, 2013, 02:57:11 am
Solved. Changing SPI to MODE3 instead of MODE0 helped.
However, it seems to me that MODE0 is the right mode, according to datasheet.
Not the way I see it. Page 4 of the datasheet says clock is HIGH with LOW pulses (CPOL=1) and captures on the rising edge and propagates on the falling edge (CPHA=1).
That is mode 3.
http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus

edit: Here is how to compute mode. The phase (CPHA) isn't based on rising or falling edge as I might have implied above, but first or second edge after the slave select is activated (LOW).

If clock is LOW with HIGH pulses, then CPOL = 0.
If clock is HIGH with LOW pulses, then CPOL = 1.

If it captures on the first edge (rising or falling) after SS goes LOW, then CPHA=0
If it captures on the second edge (rising or falling) after SS goes LOW, then CPHA=1

MODE = 2CPOL + CPHA
2520  Using Arduino / Programming Questions / Re: Funny readings when trying to read PWM fan RPM on: June 16, 2013, 12:52:59 pm
Take a look at this page and it might help you understand what is happening.
http://www.bearblain.com/fan_speed_control.htm

The 3-wire fan (quarter way down the page) uses the "+" input as the power supply for the tach output through resistor R1. If you use PWM on the "+" input, the tach output will also go high and low at the PWM frequency.

The 4-wire fan (halfway down the page) has a separate input for the PWM pulses, and the power supply is used for the hall effect transistor and tach output.
Pages: 1 ... 166 167 [168] 169 170 ... 404