Show Posts
Pages: [1] 2 3 ... 24
1  Using Arduino / Programming Questions / Re: Code freezes if dsl line is down on: April 23, 2014, 02:09:15 pm
Thanks SurferTim. Appreciate the pointers.

I came across this site http://biskandar.com/2012/10/10/make-your-arduino-talks-to-the-world/ and used the code to add a ping check to my sketch.

So whenever I want to upload the log data, I first run the ping ( all 2 lines of code ) and if the ping returns "Request Timed Out" then I skip the log upload for 1 minute and then try again.

The ping appears really fast ( compared to trying to 'connect' to a web server ) so it has little effect on the execution of the rest of the code.

Thanks to all for the help.
2  Using Arduino / Programming Questions / Re: Code freezes if dsl line is down on: April 23, 2014, 09:07:15 am
If your code uses dns to resolve the domain name of the server, the dns server is not localnet, and the dsl is down, that code will never connect. If the internet part is down, the length of the delay will not matter. If your code can't connect, it can't connect.

Thanks SurferTim

The setup in my code contains :
Code:
char serverName[] = "http://www.abc.com";
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
IPAddress ip(192,168,1,101); // ip in lan
IPAddress gateway(192,168,1,254); // internet access via router
IPAddress subnet(255,255,255,0); //subnet mask
IPAddress myserver(11,11,18,70); //my web server ip
EthernetServer server(82); //server port
EthernetClient client;
String readString;

Ethernet.begin(mac, ip, subnet, gateway);
server.begin();

but I think maybe I have not made my question clear.

So here it is re-worded : is there any way to check if a dsl connection exists, that is not subject to any time delays / timeouts, or any way to ping a server with a set maximum timeout ? That way I could ping my web server first, and if that does not respond within, for example, 100ms, then assume that the dsl line is down ( or the web server is down ) and move on with the rest of the sketch without wasting time ( and delaying sketch code execution ) waiting for the connection to time-out ?
3  Using Arduino / Programming Questions / Re: Code freezes if dsl line is down on: April 23, 2014, 06:30:04 am
Hi Paul

Why is it not valid ?

The data being passed to the php script is assembled in the 'for' loop, and it is definitely working with this code.
4  Using Arduino / Programming Questions / Code freezes if dsl line is down on: April 23, 2014, 03:26:56 am
I am finding that sometimes our DSL line is down ( ethernet shield connected to dsl router and router operating OK ) and my code is freezing.

I assume that this is caused by the ethernet library retrying until some timeout occurs, or more likely by incorrect code in my sketch that is not managing the retries.

Would the follow 2 extracts produce the same result, or would one be better at ignoring a DSL line fault than the other ?

The data I am sending out to my web site php script is only log data and is not critical. It is more important for the other code in my sketch to be able to run without interruptions / delays.

code 1 :

Code:
      if (client.connect(myserver, 80)) {
        client.print("GET http://www.abc.com/myscript.php?data=");
        // make a string of all the codes to upload 
        for(int i = 0;i < 30;i++){
          if(LogData[i] != 0){
              client.print(LogData[i]);
              client.print("-");
          }
        }
        client.println(" HTTP/1.1");
        client.println("Host: www.abc.com");
        client.println();
        delay(1);
        client.stop();
      }

code 2 :    
    
Code:
  EthernetClient WWWclient = server.available();
  if (WWWclient) {
    while (WWWclient.connected()) {
      if (WWWclient.available()) {

        client.print("GET http://www.abc.com/myscript.php?data=");
        // make a string of all the codes to upload 
        for(int i = 0;i < 30;i++){
          if(LogData[i] != 0){
              client.print(LogData[i]);
              client.print("-");
          }
        }
        client.println(" HTTP/1.1");
        client.println("Host: www.abc.com");
        client.println();

delay(1);
WWWclient.stop();
      }
    }
  }
5  Using Arduino / General Electronics / Re: Power Supply voltage dropping - faulty supply ? on: April 11, 2014, 03:16:09 pm
Update :

OK. I have another similar power supply ( 12V 3A with 17Ah battery ) in another room for a non-critical function.

Have re-routed that to the problem system.

Before power-on, the supply is 13.19V
After switching on all components of the home system, dropped to 12.91V and registering 1.2A
Has remained constant for 30 minutes now.

So I guess that if it remains stable for the next hour, I can safely assume my old power supply was faulty.

Thanks to all for the input. Really appreciated.

Update : 2 hours and no change at all smiley
6  Using Arduino / General Electronics / Re: Power Supply voltage dropping - faulty supply ? on: April 11, 2014, 01:49:36 pm
If it worked before that and doesn't work afterwards then I think we found the problem.

My problem with that statement is that it would also be correct to say : If "the complete system as a whole" worked before that and doesn't work afterwards then I think we found the problem. - we still can't say for certain that it is the power supply - although suspicion and logic says it is the most likely candidate.

The Amp sensor is not detecting any real change in the current draw by the system, so is it reasonable to assume that, once any load, no matter how large or small ( like the brand new un-used Mega ) is connected, the transformer or circuitry of the power supply could start it's gradual loss ?
7  Using Arduino / General Electronics / Re: Power Supply voltage dropping - faulty supply ? on: April 11, 2014, 01:43:29 pm
That's bad, a power surge and PC destroyed.
You don't know what else is damaged.
I suggest to use a multimeter and check everything step by step.

I have done all the steps that I can think of :

disconnected each part of the system from the 12V supply when the reading was down to 9V, one at a time. In each case, there was no noticible change to the 9V reading.

At the end, I was left with a totally disconnected Mega 2560 ( all wires are on male header pins, so were physically removed ) and still no change.

So I suspected the Arduino and ethernet shield.

Removed the shield - no change.

Disconnected the Mega and connected a spare, brand new, Mega - same reading - so unlikely that the Mega was damaged and causing the drain.
8  Using Arduino / General Electronics / Re: Power Supply voltage dropping - faulty supply ? on: April 11, 2014, 01:38:40 pm
Does it get hot?


Yes, the casing that the power supply and battery are in, is warm, but not too warm that I can't keep my hand on it.
9  Using Arduino / General Electronics / Re: Power Supply voltage dropping - faulty supply ? on: April 11, 2014, 01:37:23 pm
Hi Mike

Quote
and that their effect on the system voltage should be almost instant after power is applied ?
Not too sure what that means.

Quote
that I have a faulty power unit
Yes that would be my guess as well. Just remove all the load to check but it sounds lie a faulty supply.
Of all the parts in a system the power supply is nearly always the most unreliable.

I am assuming that any effect that any components of the system could possibly have, should be reasonably constant and should exist from shortly after power is applied, and not degrade the power like this over a period of time.

I have removed ( switched off with toggle switch ) the load and the power supply is now reading 11.5V
10  Using Arduino / General Electronics / Power Supply voltage dropping - faulty supply ? on: April 11, 2014, 12:53:41 pm
I have a home automation and security system running on a mega 2560. All been working well for over 6 months with no changes.

Nothing changed recently on the components list of things attached to the Arduino.

Power is from a 220V Power supply that is rated output 12VDC 5A with a 12V 9Ah battery in the power supply box ( battery was changed this morning to rule it out of the equation ).

When I power up the Arduino, relay boards, sensors, etc, the voltage from the supply is 11.47V

Over a period of 2 hours, nothing is used on the system. No relays activated, no sensors triggered, no inputs change.

My Hall sensor on the main power line is reading 1.03A and remains reasonably constant ( between 1.00 an 1.05A )

But the voltage measured from the power supply drops to around 9.3V over a 2 hour period.

Would it be correct to assume that the components in the system, pullup resistors, etc should hold a steady 'state' and their drain / effect should remain reasonably constant, and that their effect on the system voltage should be almost instant after power is applied ?

My last guess is that I have a faulty power unit - we did have a power surge a few weeks back after a power outage, and that destroyed my PC, and that was on the same circuit as the power unit in question.

Any other ideas ?
11  Using Arduino / Programming Questions / Re: Remove delay from inside function on: April 07, 2014, 03:56:14 am
Thanks Paul

Sorry, my error when I tried to extract the text relevant to the question.

The LogItWeb function is in fact outside the main loop.

So the following should work ?

Code:

long ClientStopMillis = 0;

void setup(void) {

}

void loop(void){
unsigned long currentMillis = millis();

if(ClientStopMillis != 0 && ClientStopMillis <= currentMillis){
client.stop();
ClientStopMillis = 0;
}

LogItWeb(1,tempC2); // tempC2 contains a float value from a sensor reading

} // end of main loop

void LogItWeb(int Location, float LogTxt){
if (DSLcount > 0){  // if there was a previous failure, then wait 10 loops before trying again
DSLcount++;
if (DSLcount > 10) DSLcount = 0; // now try again

if (DSLcount == 0){ 
DSLcount = 1;  // if the following connect fails, then DSLcount will be 1 and activate the 10 loop delay.
if (client.connect(myserver, 80)) {
DSLcount = 0;  // if the connect succeeds, then set the DSLcount to 0, so no delay loop next time
client.print("GET http://www.xxx.com/xxx.php?data=");
client.print(Location);
client.print("--");
client.print(LogTxt);
client.println(" HTTP/1.1");
client.println("Host: www.xxx.com");
client.println();
// set the Stop time as the current millis + 250 ms
ClientStopMillis = currentMillis + 250;
// delay(250);
// client.stop();
}
}
}
12  Using Arduino / Programming Questions / Remove delay from inside function on: April 07, 2014, 02:31:46 am
I am wanting to eliminate all Delays in my code.
I have a function in my main loop that accepts some data, uploads it to my web site ( php page that adds data to an online log file ), and then closes the connection.

From experience, I have found that I have to add a short delay ( in this example, a delay of 250 ms ) before client.stop so that the preceding code completes fully to the web based php page. The code at present is working as required.

Code:
void loop(void){
unsigned long currentMillis = millis();
void LogItWeb(int Location, float LogTxt){
if (DSLcount > 0){  // if there was a previous failure, then wait 10 loops before trying again
DSLcount++;
if (DSLcount > 10) DSLcount = 0; // now try again

if (DSLcount == 0){ 
DSLcount = 1;  // if the following connect fails, then DSLcount will be 1 and activate the 10 loop delay.
if (client.connect(myserver, 80)) {
DSLcount = 0;  // if the connect succeeds, then set the DSLcount to 0, so no delay loop next time
client.print("GET http://www.xxx.com/xxx.php?data=");
client.print(Location);
client.print("--");
client.print(LogTxt);
client.println(" HTTP/1.1");
client.println("Host: www.xxx.com");
client.println();
delay(250);
client.stop();
}
}
}
LogItWeb(1,tempC2); // tempC2 contains a float value from a sensor reading
} // end of loop

Would it work to remove the client.stop to outside the function like this ? :
Is the function LogItWeb able to change the value of variable ClientStopMillis for use outside the function ?

Code:
void loop(void){
unsigned long currentMillis = millis();
// add a new variable
long ClientStopMillis = 0;
void LogItWeb(int Location, float LogTxt){
if (DSLcount > 0){  // if there was a previous failure, then wait 10 loops before trying again
DSLcount++;
if (DSLcount > 10) DSLcount = 0; // now try again

if (DSLcount == 0){ 
DSLcount = 1;  // if the following connect fails, then DSLcount will be 1 and activate the 10 loop delay.
if (client.connect(myserver, 80)) {
DSLcount = 0;  // if the connect succeeds, then set the DSLcount to 0, so no delay loop next time
client.print("GET http://www.xxx.com/xxx.php?data=");
client.print(Location);
client.print("--");
client.print(LogTxt);
client.println(" HTTP/1.1");
client.println("Host: www.xxx.com");
client.println();
// set the Stop time as the current millis + 250 ms
ClientStopMillis = currentMillis + 250;
// delay(250);
// client.stop();
}
}
}
// add this code to the general section of the Main loop
if(ClientStopMillis != 0 && ClientStopMillis <= currentMillis){
client.stop();
ClientStopMillis = 0;
}
LogItWeb(1,tempC2); // tempC2 contains a float value from a sensor reading
} // end of loop

13  Using Arduino / General Electronics / Re: SN754410 Quadruple Half H Driver - what signal to activate ? on: March 27, 2014, 11:24:10 pm
now noW nOW NOW !!
damn autotype.
At least I wasn't trying to say ExpertS EXchange smiley

I hear your logic on the pull-up / pull-down resistors. So better to use a transistor to sink the opposite pin to ground only when required.

I have learnt so much from such a small project.

Thanks again for your help.
14  Using Arduino / General Electronics / Re: SN754410 Quadruple Half H Driver - what signal to activate ? on: March 27, 2014, 01:35:04 pm
to MarkT

Many Thanks for the input and guidance.

Feedback is that the transistors worked perfectly and the H-Bridge is not operating exactly as it should.

Now that I think that I grasp the idea of having the pins high and low ( as opposed to simply making one High ), I wonder if it would not be easier to simply have a pull down resistor connected to both pins 2 and 7, so they are Low by default, and each only requires a positive signal to activate ?

Regards
15  Using Arduino / General Electronics / Re: SN754410 Quadruple Half H Driver - what signal to activate ? on: March 22, 2014, 03:49:19 pm
Thanks for the reply MarkT

The RC receiver is a very cheap unit from a kid's toy. I have checked the output and am seeing a constant 4.7V+ on the line being driven, and 0V on the other line. ( switched around when RC controller changes direction ).

I suspect that the 0V that I am seeing is not 0V ( as in Ground ), but just no voltage, no ground, not connected to anything.

So I think the only options that I would have ( with my limited supplies and parts available ) would be to pull down the line that is at 0V with a resistor, or with a transistor which is activated by the high line.

Any advice welcome.
Pages: [1] 2 3 ... 24