Show Posts
Pages: 1 [2] 3 4 ... 33
16  Development / Other Software Development / Re: Arduino on Xcode Project — Official Thread on: March 05, 2014, 08:10:09 am
Were the variables you created global or local?

They were local
17  Development / Other Software Development / Re: Arduino on Xcode Project — Official Thread on: March 04, 2014, 09:55:57 pm
I'm having problems getting the warnings feature to work.  I just installed ver 136 (I have plus).  I opened an existing project and told embedxcode to upgrade when asked.  I went into the Makefile and noticed the upgrade process did not add WARNING_OPTIONS.  So I added:
Code:
WARNING_OPTIONS = unused-variable unused-function unused-label unused-value
I put it right after the #SERIAL_BAUDRATE = 19200 line.
I created some variables that are not used and ran Build, but I didn't get any warnings.
18  Using Arduino / General Electronics / Re: Level shift FTDI pins on: February 26, 2014, 08:11:04 am
Exactly. You don't want the control signals exceeding the supply voltage by more than 0.5V. That can damage the IO pins.
Didn't know that either.  Thanks.  In my project I have a 3.3 volt LCD on the Vcc line, so I don't want to put 5 volts on that line with the FTDI cable. So, I think I'll need to keep the FTDI volts connected to the Vraw pin and level shift Tx, Rx and DTR to 3.3 volts so they match 3.3 volts on Vcc.   
19  Using Arduino / General Electronics / Re: Level shift FTDI pins on: February 25, 2014, 11:51:58 pm
So you don't go thru the regulator.

Why don't you want to go through the regulator?
20  Using Arduino / General Electronics / Re: Level shift FTDI pins on: February 25, 2014, 09:29:02 pm
A 3.3V promini with 8 MHz oscillator can be powered & programmed from a 5V FTDI. It's the same chip. It's the same IO lines.  Connect the 5V line to VCC instead of Raw and bypass the regulator. No level shifting needed.

Well that makes life easier.  So the Atmega 328P I/O is 5 volt tolerant.  Good to know.
What's the reason you suggest connecting 5v to Vcc instead of Raw?
21  Using Arduino / General Electronics / Re: Level shift FTDI pins on: February 25, 2014, 08:33:25 pm
What else is connected to the promini when it is being programmed?

I'm only connecting FTDI cable.  I know if I'm using a 3.3 volt FTDI cable, I can go straight to the pro-mini.  I want to also use a 5 volt FTDI, so I need to level shift.  I've got the FTDI Vcc going to the raw pin on the pro-mini which can handle 12 volts, so I'm not worried about that.  it's just Tx, Rx and DTR.
22  Using Arduino / General Electronics / Level shift FTDI pins on: February 25, 2014, 01:42:21 pm
I'm building a circuit for my  3.3 volt Arduino pro-mini.  The Pro-mini is programmed with an FTDI cable.  I'd like the project to work with either a 5 volt or 3.3 volt FTDI cable.   I'll need to level shift the Tx and Rx pins which  I'm planning on doing with a BSS138 MOSFET (see attached circuit).  What I want to know is should I use another MOSFET on the Reset pin or should I do it a different way?

23  Using Arduino / Networking, Protocols, and Devices / Re: Change SS pin on Ethernet Shield on: February 23, 2014, 10:45:40 am
If you do not want to replace the files in the ethernet library with my files, then you are dead in the water.

I recommend renaming your original w5100 and Ethernet files before replacing them. That is what I did.
I renamed:
w5100.h to w5100.h.orig
w5100.cpp to w5100.cpp.orig
Ethernet.h to Ethernet.h.orig
Ethernet.cpp to Ethernet.cpp.orig

Then I moved my files into those directories. If all goes bad, remove my files and rename those .orig files back to the original filenames.
Okay, I'll try it that way.  I was hoping to avoid doing that because I use several computers to program my Arduinos.  So I have to change it everywhere.  Also, when I upgrade the IDE, I have to remember to change the files again.  How come the header guards don't solve the multiple definition problem?
  #ifndef ethernet_h
  #define ethernet_h
24  Using Arduino / Networking, Protocols, and Devices / Re: Change SS pin on Ethernet Shield on: February 23, 2014, 09:59:07 am
SurferTim,
I'm trying your modified files, but I'm having some trouble getting it to compile.  I put the 4 files (Ethernet.h/cpp, w5100.h/cpp) in the same directory as my INO file; so in the Arduino IDE (1.05 on Mac) they show up as tabs.  When I use the sketch you posted, I get this error:
error: 'class EthernetClass' has no member named 'select'
I'm including the library with <> like this:
#include <Ethernet.h>
So I assume the sketch us using the built-in Ethernet.h library and not the modified one in my INO directory . So I changed the syntax to:
#include "Ethernet.h"
So now I think it's using your version that's in my sketch directory, but I'm getting tons of multiple definition errors. 
I'd prefer to leave the original Ethernet.h and w5100.h files alone.  What's the right way to do this?
25  Using Arduino / Networking, Protocols, and Devices / Re: Change SS pin on Ethernet Shield on: February 20, 2014, 05:36:41 pm
Thanks!   I'll let you know how it works out.  I'm not using the SD card.
26  Using Arduino / Networking, Protocols, and Devices / Re: Change SS pin on Ethernet Shield on: February 20, 2014, 01:46:35 pm
I have since modified that to select the slave select through an Ethernet library call so I can access two ethernet shields in the same sketch code.

Would you mind sharing your modified libraries?
27  Using Arduino / Networking, Protocols, and Devices / Re: Change SS pin on Ethernet Shield on: February 13, 2014, 09:27:02 pm
I used this in w5100.h. I commented out all the old code and used digitalWrite() instead. Worked great on my Mega. Give it a try.

I tried digitalWrite() but it didn't work for me.  If I used pin 10 with digitalWrite() it would work.  When i changed to pin 8 it didn't work.  I also tried pin 9 and 7, they didn't work either.  When I change the pin number, I moved the wire on the Arduino to that pin.  So when I tried digitalWrite with pin 8, the jumper was connected from Arduino pin 8 to Ethernet shield pin 10,

BTW - I'm using Arduino IDE ver 1.05 on a Mac.  My Arduino is a Duemilanove with Adafrut's adaboot boot loader. 
28  Using Arduino / Networking, Protocols, and Devices / Re: Change SS pin on Ethernet Shield on: February 13, 2014, 08:36:07 am
Does your ethernet shield have a 6 pin (2x3) connector centered on the bottom of the circuit board?

No it doesn't have the2x3 connector.  I'm using an old rev 01 shield.   MISO, MOSI and CLK pins are not the problem since my setup does work when using pin 10 as SS.  Put I want to use Pin 8 (or any pin between from 2-8) as SS. 

29  Using Arduino / Networking, Protocols, and Devices / Change SS pin on Ethernet Shield on: February 12, 2014, 09:15:01 pm
I'm trying to change the SS pin from 10 to 8 with the Ethernet shield.  As a test I have a Duemilanove and an Ethernet shield ver 01.  I don't have them stacked, instead I have jumper wires connecting the following pins.
11, 12, 13, Reset, Gnd, 5V. 

I have w5100.h file in the same directory as my .ino sketch file.  In the w5100.h I commented out the lines that make pin 10 the SS pin and changed it so it should be pin 8.  But this doesn't seem to do anything.  If I have pin 10 on the Arduino connected to pin 10 on the Ethernet shield, it works.  But it shouldn't.  If I change it so pin 8 on the Arduino is connected to pin 10 on the Ethernet shield it doesn't work.  But that's the configuration that I want to work.

Here is the modification to w5100.h
Code:
private:
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
  inline static void initSS()    { DDRB  |=  _BV(4); };
  inline static void setSS()     { PORTB &= ~_BV(4); };
  inline static void resetSS()   { PORTB |=  _BV(4); };
#elif defined(__AVR_ATmega32U4__)
  inline static void initSS()    { DDRB  |=  _BV(6); };
  inline static void setSS()     { PORTB &= ~_BV(6); };
  inline static void resetSS()   { PORTB |=  _BV(6); };
#elif defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB162__)
  inline static void initSS()    { DDRB  |=  _BV(0); };
  inline static void setSS()     { PORTB &= ~_BV(0); };
  inline static void resetSS()   { PORTB |=  _BV(0); };
#else
//  inline static void initSS()    { DDRB  |=  _BV(2); };  // SS Pin 10
//  inline static void setSS()     { PORTB &= ~_BV(2); };
//  inline static void resetSS()   { PORTB |=  _BV(2); };
  inline static void initSS()    { DDRB  |=  _BV(0); };  // SS Pin 8
  inline static void setSS()     { PORTB &= ~_BV(0); };
  inline static void resetSS()   { PORTB |=  _BV(0); };
#endif

Here is my sketch
Code:
#include <SPI.h>
#include "Ethernet.h"
#include "w5100.h"

byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x18, 0x45 };  // MAC address from Ethernet shield sticker under board
IPAddress ip(192,168,216,48);
EthernetServer server(80);  // create a server at port 80

String HTTP_req;            // stores the HTTP request

void setup()
{
 pinMode(10, OUTPUT);
 pinMode(8, OUTPUT);
 digitalWrite(10, HIGH);
 digitalWrite(8, HIGH);
 
  Ethernet.begin(mac, ip);  // initialize Ethernet device
  server.begin();           // start to listen for clients
  Serial.begin(9600);       // for diagnostics
  pinMode(7, INPUT_PULLUP );        // switch is attached to Arduino pin 7
 
  Serial.println("Setup()");
 
} // setup()

void loop()
{
  EthernetClient client = server.available();  // try to get client

  if (client)
  {  // got client?
   
    boolean currentLineIsBlank = true;
    while (client.connected())
    {
      if (client.available())
      {   // client data available to read
        char c = client.read(); // read 1 byte (character) from client
        HTTP_req += c;  // save the HTTP request 1 char at a time
        // last line of client request is blank and ends with \n
        // respond to client only after last line received
       if (c == '\n' && currentLineIsBlank)
        {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: keep-alive");
          client.println();
          // AJAX request for switch state
          if (HTTP_req.indexOf("ajax_switch") > -1)
          {
            // read switch state and analog input
            GetAjaxData(client);
          }
          else // HTTP request for web page
          { 
              // send web page - contains JavaScript with AJAX calls
              client.println("<!DOCTYPE html>");
              client.println("<html>");
              client.println("<head>");
              client.println("<title>Arduino Web Page</title>");
              client.println("<script>");
              client.println("function GetSwitchAnalogData() {");
              client.println("nocache = \"&nocache=\" + Math.random() * 1000000;");
              client.println("var request = new XMLHttpRequest();");
              client.println("request.onreadystatechange = function() {");
              client.println("if (this.readyState == 4) {");
              client.println("if (this.status == 200) {");
              client.println("if (this.responseText != null) {");
              client.println("document.getElementById(\"sw_an_data\").innerHTML = this.responseText;");
              client.println("}}}}");
              client.println("request.open(\"GET\", \"ajax_switch\" + nocache, true);");
              client.println("request.send(null);");
              client.println("setTimeout('GetSwitchAnalogData()', 1000);");
              client.println("}");
              client.println("</script>");
              client.println("</head>");
              client.println("<body onload=\"GetSwitchAnalogData()\">");
              client.println("<h1>Arduino AJAX Input</h1>");
              client.println("<div id=\"sw_an_data\">");
              client.println("</div>");
              client.println("</body>");
              client.println("</html>");
            }
            // display received HTTP request on serial port
            Serial.print(HTTP_req);
            HTTP_req = "";            // finished with request, empty string
            break;
          }  // end if currentLineIsBlank
         
          // every line of text received from the client ends with \r\n
          if (c == '\n')
          {
              // last character on line of received text
              // starting new line with next character read
              currentLineIsBlank = true;
          }
          else if (c != '\r')
          {
              // a text character was received from client
              currentLineIsBlank = false;
          }
      } // end if (client.available())
    } // end while (client.connected())
    delay(1);      // give the web browser time to receive the data
    client.stop(); // close the connection
  } // end if (client)
}

// send the state of the switch to the web browser
void GetAjaxData(EthernetClient cl)
{
    int analog_val;
   
    if (digitalRead(7)) {
        cl.println("<p>Switch 7 state: ON</p>");
    }
    else {
        cl.println("<p>Switch 7 state: OFF</p>");
    }
    if (digitalRead(6)) {
        cl.println("<p>Switch 6 state: ON</p>");
    }
    else {
        cl.println("<p>Switch 6 state: OFF</p>");
    }
   
    // read analog pin A2
    analog_val = analogRead(2);
    cl.print("<p>Analog A2: ");
    cl.print(analog_val);
    cl.println("</p>");

    // Print seconds on
    cl.print("<p>On Time: ");
    cl.print(millis()/1000);
    cl.println(" seconds</p>");
}
30  Using Arduino / Programming Questions / Re: Static function for interrupts in a class on: January 29, 2014, 10:59:53 am
I'm not really familiar with a singleton, but I just did a little research and it seems like I should use this technique for the hot tub project. 

I like your example for multiple instances scenario. 
Pages: 1 [2] 3 4 ... 33