Show Posts
Pages: 1 [2] 3
16  Using Arduino / Project Guidance / How much USABLE memory on UNO? on: July 16, 2013, 06:38:18 pm
I have a Arduino Uno which is acting up once the memory usage, as reported by the compiler, is over about 28,000 bytes. I know is suppose to have 32k but things start acting strange it seems when I use even just a little over 28k.

I have reduce the Serial.print statements and tried to reduce array sizes, etc which help but it would be nice to know what the usable limit is and if the compiler memory usage is really a good guide to go by.

Thanks.

JC
17  Using Arduino / Storage / Re: Can't do subsequent reads from SD card on: July 16, 2013, 05:04:22 pm
I tried the delay but it didn't help.

I replaced the WHILE with a FOR loop, letting it run 4 times and that works. The WHILE doesn't. I thought maybe I was reading beyond EOF but that doesn't seem to be the case but I am not sure. Anyway, the FOR loop with a fix count is working.

JC
18  Using Arduino / Storage / Can't do subsequent reads from SD card on: July 16, 2013, 01:36:58 pm
I am having problems trying to read from my SD card. I have the number 5.0 save in the first 3 bytes of the card. I can read the 3 bytes and convert to a float on the first pass, no problem. But I can't read from the second pass and on. I get a Can't Open File error. Here is the code. I hope it is something simple that I am missing.

Thanks.

JC


Code:

#include <SD.h>

char kwh[4];
int j;
float kwhr;

File myFile;

void setup()
{
  Serial.begin(9600);
  pinMode(10, OUTPUT);
   
  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    return;   }
   Serial.println("initialization done.");
}

void loop()
{
  myFile = SD.open("killog.txt", FILE_READ);
  if (myFile) {
    Serial.println("open killog.txt:");
    j = 0;
      // read from the file until there's nothing else in it:
      while (kwh[j] != '\r') {
      kwh[j] = myFile.read();
      j++;  }
     
      kwhr = atof(&kwh[0]);  //convert read string to float
      Serial.println(kwhr);
      Serial.println("Closing file"); 
      myFile.close(); }
   
      else {
  // if the file didn't open, print an error:
    Serial.println("error opening killog.txt");
   }   
}
19  Using Arduino / Sensors / Re: Would this wind meter idea work? on: May 08, 2013, 09:35:16 am
About the dumbest idea I have ever heard. You can be sure that, it was a good idea, everybody would be doing it and the regular anemometers would all be scrapped.  Why don't you try an ultrasonic gas flow meter? I suspect it's not much smarter, but you might get a result.

I don't believe there are dumb questions, only dumb answers like yours...
20  Using Arduino / Sensors / Would this wind meter idea work? on: May 08, 2013, 08:33:14 am
I want to build a no moving part wind meter for my Arduino. I was wondering if this idea would work:

Have 2 one wire temp sensors, one mounted inside a sealed box and the other out in the open. Then have the Arduino measure the difference in temp to calculate the wind speed. Ideas?

JC
21  Using Arduino / Networking, Protocols, and Devices / SOLVED Re: Web server not responding somtimes on: January 24, 2013, 10:29:30 pm
UPDATE - I added the F() function for all the client print lines and it seems to have cleared up the issue. I was to use all 16 X10 modules via the web page with no issues. So I guess the 2K ram limit was the problem. Thanks.
22  Using Arduino / Networking, Protocols, and Devices / Re: Web server not responding somtimes on: January 23, 2013, 01:16:47 pm
Thank you guys for the quick reply. That must be the problem as it was working until I added all the extra string code and then it started acting strangely.

I will try the F() function, never heard if it before but then again I am learning something new every day with the Arduino. I ALSO ORDERED A NEW ARDUINO MEGA! This isn't the first time I ran into the limits of the Uno. Last week I had a program that exceeded the 32k ram limit. So what the heck, I ordered the Mega 2560. I already have the original Mega in my robot which I don't want to salavge for this X10 project. Plus it gave me an excuse to order more supplies from Sparkfun! 8-)

Will let you know how the code works when I am done.
23  Using Arduino / Networking, Protocols, and Devices / SOLVED - Web server not responding somtimes on: January 23, 2013, 11:51:14 am
I have been working on this program which accepts commands from the web and issues X10 power house commands. Seperately the X10 code works great and seperately the web server code works great. And together they are working until I added coding for all 16 modules. (Was working good with code to decode a few X10 modules).

Most of the code I have gotten off the web. I am using an Uno and the Arduino Ehternet shield. The biggest problem right now is I can't connect from a browser, the Arduino is not sending out the web page. The program is looping through the main loop but the web page is not being sent. It seems to have broken when I added the code for modules 8 - 16.

Could you look at the client code and tell me if you see anything wrong? Thanks.

Code:
//program to accept x10 commands from web site using ehternet shield and pl513
// 1/21/13

#include <SPI.h>
#include <Ethernet.h>
#include <x10.h>
#include <x10constants.h>

#define zcPin 2   //moodule pl513 pin 1 goes to Arduino pin 2
#define dataPin 7 //pl513 pin 4 goes to Arduino pin 7 and 10k pullup resistor

byte mac[] = {
  0x48, 0xC2, 0xA1, 0xF3, 0x8D, 0xB7 };
byte ip[] = {
  192,168,1,66 };   //i am using ip=66, port 8080

// Start the server on port 8080
EthernetServer server(8080);
String readString;  //put data read from web here

// set up a new x10 instance:
x10 myHouse =  x10(zcPin, dataPin);


void setup(){

  Ethernet.begin(mac, ip);
  //Ethernet.begin(mac, ip, gateway, gateway, subnet);
  server.begin();
  Serial.begin(9600);
  
}

void loop()
{
  Serial.println("begin loop");
  // Create a client connection
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();

        //read char by char HTTP request
        if (readString.length() < 100) {

          //store characters to string
          readString += c;
          //Serial.print(c);
        }

        //if HTTP request has ended
        if (c == '\n') {

          ////////////////////////////////////////////
          Serial.println(readString); //print to serial monitor for debuging

          client.println("HTTP/1.1 200 OK"); // Standard HTTP response
          client.println("Content-Type: text/html\n");
          //client.println("<html><head><META CONTENT=""15"" HTTP-EQUIV=""Refresh"">\n");
          client.println("<HTML>");
          client.println("<HEAD>");
          client.println("<title>Joe's X10 Remote Control Program</title></head>");
          client.println("<body>\n");
          client.println("<h1>Joe's X10 Remote Control Program</h1>");
          client.println("<h3>Click on device and operation</h3>");
          client.println("<a href='/?C1ON'>C1 ON </a>");
          client.println("<a href='/?C1OFF'>C1 OFF </a>");
          client.println("<br/>");
          client.println("<a href='/?C2ON'>C2 ON </a>");
          client.println("<a href='/?C2OFF'>C2 OFF </a>");
          client.println("<br/>");
          client.println("<a href='/?C3ON'>C3 ON </a>");
          client.println("<a href='/?C3OFF'>C3 OFF </a>");
          client.println("<br/>");
          client.println("<a href='/?C4ON'>C4 ON </a>");
          client.println("<a href='/?C4OFF'>C4 OFF </a>");
          client.println("<br/>");
          client.println("<a href='/?C5ON'>C5 ON </a>");
          client.println("<a href='/?C5OFF'>C5 OFF </a>");
          client.println("<br/>");
          client.println("<a href='/?C6ON'>C6 ON </a>");
          client.println("<a href='/?C6OFF'>C6 OFF </a>");
          client.println("<br/>");
          client.println("<a href='/?C7ON'>C7 ON </a>");
          client.println("<a href='/?C7OFF'>C7 OFF </a>");
          client.println("<br/>");
          client.println("<a href='/?C8ON'>C8 ON </a>");
          client.println("<a href='/?C8OFF'>C8 OFF </a>");
          client.println("<br/>");
          client.println("<a href='/?C9ON'>C9 ON </a>");
          client.println("<a href='/?C9OFF'>C9 OFF </a>");
          client.println("<br/>");
          client.println("<a href='/?C10ON'>C10 ON </a>");
          client.println("<a href='/?C10OFF'>C10 OFF </a>");
          client.println("<br/>");
          client.println("<a href='/?C11ON'>C11 ON </a>");
          client.println("<a href='/?C11OFF'>C11 OFF </a>");
          client.println("<br/>");
          client.println("<a href='/?C12ON'>C12 ON </a>");
          client.println("<a href='/?C12OFF'>C12 OFF </a>");
          client.println("<br/>");
          client.println("<a href='/?C13ON'>C13 ON </a>");
          client.println("<a href='/?C13OFF'>C13 OFF </a>");
          client.println("<br/>");
          client.println("<a href='/?C14ON'>C14 ON </a>");
          client.println("<a href='/?C14OFF'>C14 OFF </a>");
          client.println("<br/>");
          client.println("<a href='/?C15ON'>C15 ON </a>");
          client.println("<a href='/?C15OFF'>C15 OFF </a>");
          client.println("<br/>");
          client.println("<a href='/?C16ON'>C16 ON </a>");
          client.println("<a href='/?C16OFF'>C16 OFF </a>");
          client.println("<br/>");
          client.println("<a href='/?ALLOFF'>ALL UNITS OFF </a>");
          client.println("<br/>");
          client.println("<a href='/?ALLLIGHTSON'>ALL LIGHTS ON </a>");
          client.println("<br/>");
          client.println("<a href='/?ALLLIGHTSOFF'>ALL LIGHTS OFF </a>");
          client.println("</BODY>");
          client.println("</HTML>");
          delay(1);
          //stopping client
          client.stop();

          ///////////////////// decode x10 commands
          if(readString.indexOf("ALLOFF") >0)//checks for on
          {
            myHouse.write(HOUSE_C, ALL_UNITS_OFF,3);
            delay(500);
            myHouse.write(HOUSE_C, ON,3);
            delay(500);
          }

          /////////////////////////////////////////////////////
          if(readString.indexOf("ALLLIGHTSON") >0)//checks for on
          {
            myHouse.write(HOUSE_C, ALL_LIGHTS_ON,3);
            delay(500);
            myHouse.write(HOUSE_C, ON,3);
            delay(500);
          }

          /////////////////////////////////////////////////////
          if(readString.indexOf("ALLLIGHTSOFF") >0)//checks for on
          {
            myHouse.write(HOUSE_C, ALL_LIGHTS_OFF,3);
            delay(500);
            myHouse.write(HOUSE_C, ON,3);
            delay(500);
          }

          /////////////////////////////////////////////////////
          if(readString.indexOf("C1ON") >0)//checks for on
          {
            myHouse.write(HOUSE_C, UNIT_1,3);
            delay(500);
            myHouse.write(HOUSE_C, ON,3);
            delay(500);
          }

              
other x10 decoding goes here, removed from this post as it was too  long...


               if(readString.indexOf("C16OFF") >0)//checks for off
          {
            myHouse.write(HOUSE_C, UNIT_16,3);
            delay(500);
            myHouse.write(HOUSE_C, OFF,3);
            delay(500);  
          }

          /////////////////////////////////////////////////////
          //clearing string for next read
          readString="";

        }  //end of IF C==\N..
      }  //end if IF CLIENT.AVAILABLE...
    }  // end of WHILE CLIENT...
  } // end of IF CLIENT....
}
24  Topics / Home Automation and Networked Objects / Re: Need info on X10.h library on: January 22, 2013, 09:43:08 am
Yea, Doug's library worked and I would like to see a reference to it on the Arduino X10 page for people like me who couldn't get it Tom's original library to work and who don't know enough C++ and library coding to troubleshoot it.

It has not been easy getting X10 to work. Besides the coupler capacitor I needed to install X10 filters for all my computers as they all tend to kill the X10 signals. And I still have a stray outlet that does not work. I know it is not the best system and of course it is like 30 years old now. But like I said I have almost every kind of X10 module every made. It would cost me way to much to replace. And since I have not really done anything with X10 in a long time, I am not even sure what has replaced it. All I know is most places don't sell it anymore and the modules are getting harder to fine. Maybe I will be force to upgrade sometime in the future. Thanks for your post.
25  Topics / Home Automation and Networked Objects / Re: Need info on X10.h library on: January 21, 2013, 07:34:03 pm
SUCCESS!!!!!!!!!!!!!!!!

Thanks Tom!!!!! I did a search on Doug's library and downloaded it. I did not get the compile error. But it still didn't work. As a last resort I switch the zc and data pins around and it worked. I know I had the plug wired correctly between the PL513 and the Arduino. All I can think of is inside the phone cable I am using they switch 2 wires around. Anyway I am very happy now.

Regarding what you said about the X10, I have been using X10 for 25 years and my whole house is using it. I got alot of spare modules around and it works good for me. Many years ago I installed the X10 capactior which coupled both phases of my 220 in my house so I have no problem sending a signal from one socket to any other in ther house.

My next step is my ultimate goal, to control the X10 from the net using the Arduino. That is a piece of cake compared to getting the X10 to be controled by the Arduino. 8-)

Joe
26  Topics / Home Automation and Networked Objects / Re: Need info on X10.h library on: January 21, 2013, 05:46:42 pm
Thanks Tom for your reply. But unfortunately, that was not the problem. I completely deleted all the Arduino software and downloaded and installed 1.0.3 and re-downloaded the X10h zip file and re-installed it. But I still get the same error as before. Running your X10Blink programs compiles OK but does not run. It hangs on the x10.write command. I am about to give up on the x10 library.

27  Topics / Home Automation and Networked Objects / Re: Need info on X10.h library on: January 20, 2013, 11:05:26 pm
Cant get the x10ex library to work, maybe because I am using the PL513. So I sent an email to Tom I. who wrote the x10.h lib to see what he says about the error with x10.h.
28  Topics / Home Automation and Networked Objects / Re: Need info on X10.h library on: January 19, 2013, 06:56:39 pm
Thanks, that is the one I found. I will try it when I get home. Not sure if it works the same as x10.h or if it works with my PL513. We'll see.
29  Topics / Home Automation and Networked Objects / Re: Need info on X10.h library on: January 19, 2013, 05:09:41 pm
This link may shed some light on this. All the examples I have found are old. Seems like in 2012 when 1.0.1 came out it broke the x10 library. Still looking into this. I found an x10ex library, maybe I can use that.


http://arduino.cc/forum/index.php?topic=108325.0
30  Topics / Home Automation and Networked Objects / Re: Need info on X10.h library on: January 19, 2013, 02:38:59 pm
I got the X10 library from here...    http://arduino.cc/en/Tutorial/x10

Here is another example code I found on this site and supposedly works. But I get the same error - "X10' does not name a type". Could it be something wrong with my PC? I am using the 1.0.2 ver of the IDE.

Code:
#include <x10constants.h>
#include <x10.h>

#define ZCROSS_PIN        2        // BLK or Yel pin 1 of TW523
#define RCVE_PIN        4       // GRN or RED  pin 3 of TW523
#define TRANS_PIN        5       // YEL or BLK pin 4 of TW523
#define LED_PIN        13       // state pin for testing

x10 SX10= x10(ZCROSS_PIN,TRANS_PIN,RCVE_PIN,LED_PIN);//error flagged here

void setup(){
  Serial.begin(9600);
}

void loop(){
 
  myHouse.write(A, UNIT_1, 3);
  myHouse.write(A, OFF, 3);
  myHouse.write(B, UNIT_1, 3);
  myHouse.write(B, OFF, 3);
  myHouse.write(C, UNIT_1, 3);
  myHouse.write(C, OFF, 3);
     
}
Pages: 1 [2] 3