Show Posts
Pages: [1] 2
1  Development / Other Hardware Development / Re: New ATTiny Part (ATTiny841) on: January 22, 2014, 03:15:25 pm
I got 10 of these in for fun  - no bandwidth to get it working with Arduino though..

If anyone wants to add this to the core,  I'll mail you a few !!
2  Development / Other Hardware Development / Re: New ATTiny Part (ATTiny841) on: January 04, 2014, 03:22:04 pm
thanks for the breadcrumb!
3  Development / Other Hardware Development / Re: New ATTiny Part (ATTiny841) on: January 04, 2014, 03:11:57 pm
Has anyone made any progress on a working core for this? This chip looks great, good bang for the buck.



4  Using Arduino / Programming Questions / UDP packet parsing, Ethercard library (ENC28J60) on: June 04, 2013, 11:09:48 am
Hello,
I'm converting some code I've written for the WZ5100 to ENC28J60. Ran into some trouble reading a UDP packet and parsing the data within. In this example, I read the first two bytes of the packet as "S" "0" then the next byte is a value (say a delay time, or pwm value, or something useful).

first example here using WZ5100 works fine:

Code:
Udp.read(packetBuffer,UDP_TX_PACKET_MAX_SIZE);

 if(packetBuffer[0] == 's' && packetBuffer[1] == '0')        
    {
      packetBuffer[0] = ' '; //S
  packetBuffer[1] = ' ';

      int val = (atoi(packetBuffer));
 
  digitalWrite(2, HIGH);
  delay(val);  // the delay time was passed from the UDP packet
  digitalWrite(2, LOW);
    }

But this next code (ethercard) does not work - when I do "atoi" I just get "0"

Code:

setup(){
//some other setup info here...
//...

 ether.udpServerListenOnPort(&udpSerialPrint, 30311);  // callback to function

loop(){
ether.packetLoop(ether.packetReceive()); 

}

void udpSerialPrint(word port, byte ip[4], const char *data, word len) {
  IPAddress src(ip[0], ip[1], ip[2], ip[3]);
  Serial.println(src);
  Serial.println(port);
  Serial.println(data);
  Serial.println(len);

if(data[0] == 's' && data[1] == '0')        
    {
    //  packetBuffer[0] = ' ';
//  packetBuffer[1] = ' ';

  int onTime = atoi(data);  //<----- trying the same atoi here
      Serial.println(onTime);  // added this for debug

  digitalWrite(2, HIGH);
  delay(onTime);
  digitalWrite(2, LOW);

    }

what is being done differently with "packetBuffer"  than with "data"?

thanks in advance
5  Using Arduino / Networking, Protocols, and Devices / Re: Reducing W5100 module Ethernet Timeout when using DHCP? on: January 28, 2013, 10:05:23 am
I would like to bump this, because this is a big problem for me as well now.

For me, it takes between a minute and a minute and a half to timeout.

Essentially my code needs to work either direct connected to PC or through a switch, so I need the timeout to occur around 30 seconds or so to be reasonable.  


Edit: I think I solved it myself. Inside Dhcp.h, there is a response timeout constant of 60,000. I just changed it to 10,000 (10 seconds), and now timeout occurs about 12-13 seconds af
ter a reset.

public:
  IPAddress getLocalIp();
  IPAddress getSubnetMask();
  IPAddress getGatewayIp();
  IPAddress getDhcpServerIp();
  IPAddress getDnsServerIp();

  int beginWithDHCP(uint8_t *, unsigned long timeout = 10000, unsigned long responseTimeout = 4000);
};
6  Products / Arduino Due / Re: Problem with OneWire library on: December 20, 2012, 09:42:29 pm
I'd very much like to get this working as well so I can talk to my 1-wire EEPROM.

I tried the Teensy library and mucked around with some changes, but didn't have much luck. I would think this library would be pretty important.

I tried the modifications to the code as posted here:
http://forum.pjrc.com/threads/252-OneWire-library-for-Teensy-3-(DS18B20)

But still ran into compiler errors after this as well, where: "digital_pin_to_info_PGM[(pin)] was not delared in this scope"

Is there something in the core that needs to be modified?

7  Products / Arduino Due / Re: When is Due is due? on: December 20, 2012, 08:20:13 am
Eagle probably only shows 2 layers on the imported file because you're importing it into Freeware EAGLE, which only allows 2 layers.

They may have released it in this way so that the majority of folks could import it into eagle.

My guess is that it is actually a 4-layer board since the imported files do show many shorting traces on the top layer (which are most likely inner-signal layers imported as top layer).
8  Products / Arduino Due / Re: Due and ethernet processing speed on: December 20, 2012, 07:33:07 am
I could be wrong, but I think there is a general speed limitation overall sending UDP packets. I think more or less the UDP protocol itself will be the limiting factor. Much like how TCP/IP is slower than UDP because of handshaking, etc.. you cannot get around that speed limitation.

SO, I think the limiting factor for UDP speed is the network protocol itself.


what are you doing with UDP? Currently I'm working on fleshing out a UDP protocol for a lighting controller, so I would be curious as to what you're up to.  smiley-mr-green
9  Products / Arduino Due / Re: [Q] How to keep non-volatile parameters with the Arduino Due? on: December 18, 2012, 07:24:04 pm
I'd like very much to see something like this done. I fear I do not have the expertise for creating the libraries to handle such tasks.

Currently I have a project that needs some EEPROM storage, say 1KB.


I'm looking at Dallas DS2431, which is a one-wire EEPROM with 1Kb storage. Maybe it would be easy for someone to re-tool the OneWire library to work with the DUE?

I wouldn't know where to start with something like this...   smiley-roll

-J
10  Using Arduino / Project Guidance / Arduino Bill Of Materials on: March 14, 2012, 07:43:10 am
Anyone have a BOM for Arduino Ethernet? Reference designs are great and all, but the lack of a complete BOM makes it difficult to put all the items in order.

Thanks.

11  Using Arduino / Interfacing w/ Software on the Computer / Re: Interfacing Arduino with PC (2-way communication) on: February 18, 2012, 09:14:36 pm
I have a similar problem to solve. I need an application to be able to do things like check for Arduino connected through ethernet and determine their IP address. I also need to be able to update their IP address from the application.

The next task would be to change some PWM channel values and display some general information to the user about the device (status, etc..).

Serial would be nice, but I may end up going with ethernet only and using UDP (?). One thought is to send UDP packets to update the controller.
12  Using Arduino / Networking, Protocols, and Devices / Re: server/ RGB controller on: February 15, 2012, 12:56:29 pm
Loop

Code:
//***************************************LOOP**********************************************
void loop()
{
  // Serial.println(str);

  //   Serial.print("freeMemory()=");
  //   Serial.println(freeMemory());
  //   delay(2000);


  int bufLength;
  Client client = server.available();
  if (client) {
    boolean current_line_is_blank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        if (inString.length() < maxLength) {
          //inString.append(c);
          inString += c;
        }      

        if (c == '\n' && current_line_is_blank) {
          if (inString.indexOf("?") > -1) {
            int Pos_r = inString.indexOf("r");
            int Pos_g = inString.indexOf("g", Pos_r);
            int Pos_b = inString.indexOf("b", Pos_g);
            int End = inString.indexOf("H", Pos_b);
            if(End < 0){
              End =  inString.length() + 1;
            }
            bufLength = ((Pos_g) - (Pos_r+2));
            if(bufLength > 4){  //dont overflow the buffer
              bufLength = 4;
            }    
            inString.substring((Pos_r+2), (Pos_g-1)).toCharArray(colorBuff, bufLength);  //transfer substring to buffer
            r = atoi(colorBuff);
            bufLength = ((Pos_b) - (Pos_g+2));
            if(bufLength > 4){  //dont overflow the buffer
              bufLength = 4;
            }      
            inString.substring((Pos_g+2), (Pos_b-1)).toCharArray(colorBuff, bufLength);  //transfer substring to buffer
            g = atoi(colorBuff);
            bufLength = ((End) - (Pos_b+2));
            if(bufLength > 4){  //dont overflow the buffer
              bufLength = 4;
            }      
            inString.substring((Pos_b+2), (End-1)).toCharArray(colorBuff, bufLength);  //transfer substring to buffer
            b = atoi(colorBuff);



            /* remnant from having 4 channels
             if (c == '\n' && current_line_is_blank) {
             if (inString.indexOf("?") > -1) {
             int Pos_r = inString.indexOf("r");
             int Pos_g = inString.indexOf("g", Pos_r);
             int Pos_b = inString.indexOf("b", Pos_g);
             int Pos_w = inString.indexOf("w", Pos_b);
             int End = inString.indexOf("H", Pos_w);
             if(End < 0){
             End =  inString.length() + 1;
             }
             bufLength = ((Pos_g) - (Pos_r+2));
             if(bufLength > 5){  //dont overflow the buffer
             bufLength = 5;
             }    
             inString.substring((Pos_r+2), (Pos_g-1)).toCharArray(colorBuff, bufLength);  //transfer substring to buffer
             r = atoi(colorBuff);
             bufLength = ((Pos_b) - (Pos_g+2));
             if(bufLength > 5){  //dont overflow the buffer
             bufLength = 5;
             }      
             inString.substring((Pos_g+2), (Pos_b-1)).toCharArray(colorBuff, bufLength);  //transfer substring to buffer
             g = atoi(colorBuff);
             bufLength = ((Pos_w) - (Pos_b+2));
             if(bufLength > 5){  //dont overflow the buffer
             bufLength = 5;
             }      
            
             inString.substring((Pos_b+2), (Pos_w-1)).toCharArray(colorBuff, bufLength);  //transfer substring to buffer
             b = atoi(colorBuff);
             bufLength = ((End) - (Pos_w+2));
             if(bufLength > 5){  //dont overflow the buffer
             bufLength = 5;
             }  
             inString.substring((Pos_w+2), (End-1)).toCharArray(colorBuff, bufLength);  //transfer substring to buffer
             w = atoi(colorBuff);
             //    if(bufLength > 5){  //dont overflow the buffer
             //      bufLength = 5;
             */


          }

          client.println("<html>");
          client.println("<head>");
          client.print("<title> LEDLink GUI</title>");
          client.println("</head>");

          client.println();
          client.println("<body>");

          //         client.println("<center>");
          client.print("<h2><font face=verdana color=green>LEDLink</font></h2>   ");
          client.println();

          client.print("<font face=verdana>");
          client.print("<h3><a href=\"http://www.advill.com\"<"
            "target=\"_blank\">Advanced Illumination</a></h3>");
          //          client.println("</center>");
          client.println();


          client.println("<fieldset style=width:275>");
          client.println("<legend>Channel Settings</legend>");
          client.println("<table>");
          client.println("<tr></td>Enter Values 0-255<td></tr></td>");

          client.println();
          client.println("<br>");
          client.println("<br>");


          client.println("<tr><td><form method=get>Channel 0: <input type=text size=10 name=r />""</tr></td>");
          client.println("<tr><td><form method=get>Channel 1: <input type=text size=10 name=g />""</tr></td>");
          client.println("<tr><td><form method=get>Channel 2: <input type=text size=10 name=b />""</tr></td>");
          //        client.println("<tr><td><form method=get>Channel 3: <input type=text size=10 name=w/>""</tr></td>");

          client.println("<tr><td>&nbsp;<input name=H type=submit value=Program align=RIGHT></form></tr></table>");

          setChannelPower();

          // TODO: Move this to a function to set channel power
          // function should check for value between 0-255
          // if >255, set value to 255

          client.println("</fieldset>");
          client.println("<br>");
          client.println();


          client.println("<fieldset style=width:275>");
          client.println("<legend>Status/Information</legend>");
          client.println("<br>");
          client.println();


          client.println("Channel 0:    ");
          client.print(r,DEC);
          client.println("<br>");
          client.println();

          client.println("Channel 1:    ");
          client.print(g,DEC);
          client.println("<br>");
          client.println();

          client.println("Channel 2:    ");
          client.print(b,DEC);
          client.println("<br>");
          client.println();
          client.println("<br>");
          client.println();

          /*          
           client.println("Channel 3:    ");
           client.print(w);
           client.println("<br>");
           client.println();
           client.println("<br>");
           client.println();
           */

          client.println(" Software Version: ");
          client.print(swVer);
          client.println("<br>");
          client.println();

          client.println(" Firmware Version: ");
          client.print(fwVer);
          client.println("<br>");
          client.println();


          client.println(" Serial Number: ");
          client.print(serialNum);
          client.println("<br>");
          client.println();


          client.println("</fieldset>");
          client.print("</font>");

          client.println("</body></html>");
          break;
        }
        if (c == '\n') {
          current_line_is_blank = true;
        }
        else if (c != '\r') {
          current_line_is_blank = false;
        }
      }
    }
    delay(1);
    inString = "";
    client.stop();


  }
}
13  Using Arduino / Networking, Protocols, and Devices / Re: server/ RGB controller on: February 15, 2012, 12:55:52 pm
The entire code won't fit in a single message, so here it is in 2 parts:

Includes, Variables, Functions, and Setup:

I'm using the Arduino Ethernet, and v0022 of the compiler

Code:
/* Advanced Illumination
 LEDLink
 */

#include <EEPROM.h>
#include <SPI.h>
#include <Ethernet.h>
#include <Wire.h>
#define maxLength 25
#include <memoryFree.h>


// these values are saved in EEPROM

const byte CH_EEPROM_ID = 0x99;   // used to identify if valid data in EEPROM

byte mac[] = {
  0x00, 0x22, 0xFE, 0x10, 0x00, 0x00 }; //update with factory MAC settings
byte default_ip[] = {
  192, 168, 24, 253};
byte default_gate[] = {
  192,168,24,1};
byte default_subnet[4];


String inString = String(maxLength);
int val;

byte r;               //initial values to hold channel settings
byte g;              
byte b;
//byte w;

char colorBuff[5];
Server server(80);    //server port, HTML

const byte ch0Pin = 5;                // channel0 output PWM pin
const byte ch1Pin = 6;                // channel1 output PWM pin
const byte ch2Pin = 9;                // channel2 output PWM pin

const byte strb0Pin = 4;              // channel0 STRB enable pin
const byte strb1Pin = 7;              // channel1 STRB enable pin
const byte strb2Pin = 8;              // channel2 STRB enable pin

// TODO reserve pins 2 & 3 for hardware interrupts

const char swVer[]="0.02a - Alpha";  //ethernet software version number
const char fwVer[]="010-100";        //controller firmware version number
const char serialNum[]="000001";     //controller serial number


//constants used to identify EEPROM addresses
const int CH_ID_ADDR = 0;            // pointer to the EEPROM address used to store the user channel settings
const int R_PIN_ADDR = 1;            // the EEPROM address used to store the pin
const int G_PIN_ADDR = 2;            // ""
const int B_PIN_ADDR = 3;            // ""
const int CH_INTERVAL_ADDR = 4;      // the EEPROM address used to store the interval

const int IP_ADDR_ID = 5;            //pointer to the EEPROM address used to store the user IP ADDRESS
const int IP_ADDR[] = {
  6,7,8,9};

//FUNCTIONS*********

//------------------------------setChannelPower--------------------------------------
void setChannelPower()
{
  analogWrite(ch0Pin, r);
  analogWrite(ch1Pin, g);
  analogWrite(ch2Pin, b);
  delay(5);
  // analogWrite(ch3Pin, w);       //remnant from 4 channels
  // delay(5);

  EEPROM.write(CH_ID_ADDR, 0x99);
  EEPROM.write(R_PIN_ADDR, r);
  EEPROM.write(G_PIN_ADDR, g);
  EEPROM.write(B_PIN_ADDR, b);
  delay(5);
}

//-----------------------------------------------------------------------------------

//------------------------------setMode----------------------------------------------
void setMode()
{
  //TODO: add continuous and strobe modes
  // User will switch between modes using software
  // strobe mode will need to shut off the light and enable
  //the high current sense resistor
}
//-----------------------------------------------------------------------------------

//------------------------------setFactoryDefault------------------------------------
void setFactoryDefault()
{
  //TODO: add code to write all 0x00 to EEPROM
  // When controller first boots, it will set default values when it sees that
  // EEPROM_IDs are 00 and assign default variables accordingly

  for(unsigned int i = 0; i < 512; i++)
  {
    EEPROM.write(i, 0x00);
  }
}  
//----------------------------------------------------------------------------------

//-----------------------------configureDHCP----------------------------------------

/* void configureDHCP()
 {
 // start the Ethernet connection:
 if (Server.begin(mac) == 0) {
 Serial.println("Failed to configure Ethernet using DHCP");
 // no point in carrying on, so do nothing forevermore:
 for(;;)
 ;
 }
 // print your local IP address:
 Serial.print("My IP address: ");
 for (byte thisByte = 0; thisByte < 4; thisByte++) {
 // print the value of each byte of the IP address:
 Serial.print(Ethernet.localIP()[thisByte], DEC);
 Serial.print(".");
 }
 Serial.println();
 */

//-----------------------------displayInfo------------------------------------------

void displayInfo()
{

  Serial.print("\n<Channel Settings>");    
  Serial.println();  
  Serial.print("Channel 0: ");
  Serial.println(r,DEC);
  Serial.print("Channel 1: ");
  Serial.println(g,DEC);
  Serial.print("Channel 2: ");
  Serial.println(b,DEC);


  Serial.print("\n<TCP/IP settings>");    
  Serial.println();
  Serial.print("IP Address: ");
  for (byte i = 0; i <4; i++)
  {
    Serial.print(default_ip[i], DEC);    
    Serial.print(".");
  }

  Serial.println();
  Serial.print("Gateway: ");
  for (byte i = 0; i <4; i++)
  {
    Serial.print(default_gate[i], DEC);    
    Serial.print(".");

  }  
  Serial.println();
  Serial.print("Subnet: ");
  for (byte i = 0; i <4; i++)
  {
    Serial.print(default_subnet[i], DEC);    
    Serial.print(".");

  }
  Serial.println();

  Serial.print("\n<Hardware Information>");
  Serial.println();
  // Serial.println("Software Version: ");
  // Serial.print(swVer);
  Serial.print("Firmware Version: ");
  Serial.println(fwVer);
  Serial.print("Serial Number: ");
  Serial.println(serialNum);



  //TODO-- add more stuff to display here

}
//----------------------------------------------------------------------------------

//*******************************SETUP**********************************************

void setup()
{
  Serial.begin(115200);

  //read EEPROM and determine if channel data and setup data has been written
  //
  byte id = EEPROM.read(CH_ID_ADDR);     // read the first byte from the EEPROM
  if( id == CH_EEPROM_ID)                //looks for 0x99 in ID_ADDR 0
  {
    // here if the id value read matches the value saved when writing eeprom
    Serial.println("Using channel data from EEPROM");

    r = EEPROM.read(R_PIN_ADDR);
    g = EEPROM.read(G_PIN_ADDR);
    b = EEPROM.read(B_PIN_ADDR);

    delay(50);

    analogWrite(ch0Pin, r);    //write EEPROM channel data to output pins
    analogWrite(ch1Pin, g);
    analogWrite(ch2Pin, b);


  }
  else
  {
    // here if the ID is not found,  write the default data
    Serial.println("Writing default channel data to controller");
    analogWrite (ch0Pin, 255);            //default is 255 = 100% output
    analogWrite (ch1Pin, 255);
    analogWrite (ch2Pin, 255);
    // analogWrite (ch3Pin, 255);          //channel 4 remnant

  }

  Ethernet.begin(mac, default_ip);
  server.begin();
  displayInfo();


}
14  Using Arduino / Networking, Protocols, and Devices / server/ RGB controller on: February 15, 2012, 12:53:39 pm
Developing a 3-channel lighting controller to run off a server hosted by the arduino ethernet. I have a server operational and more-or-less functioning.

One problem I have is that if I enter in invalid data into the URL to pull up the browser-based software, the controller hangs and I must reset the controller.

Examples:

1. I type in the IP address to open the controller interface
http://192.168.24.253/

2. I make setting adjustments to different channels
http://192.168.24.253/?r=255&g=255&b=255&H=Program
sets r, g, & b values. Program button applies the data

Everything works fine in this fashion

3. If erroneous data is sent to the controller like this:
http://192.168.24.253/blahblahblah

the controller hangs.

Is there a way I can safeguard against bad data? Or at least prevent the controller from hanging and needing a reset?

If I have to deal with it hanging, would a watchdog timer work in resetting the controller?

I suspect the problem in the code is within this section, but honestly I'm confused as to how this portion of the code works.

Portion of "Loop"

Code:
void loop()
{
  // Serial.println(str);

  //   Serial.print("freeMemory()=");
  //   Serial.println(freeMemory());
  //   delay(2000);


  int bufLength;
  Client client = server.available();
  if (client) {
    boolean current_line_is_blank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        if (inString.length() < maxLength) {
          //inString.append(c);
          inString += c;
        }     

        if (c == '\n' && current_line_is_blank) {
          if (inString.indexOf("?") > -1) {
            int Pos_r = inString.indexOf("r");
            int Pos_g = inString.indexOf("g", Pos_r);
            int Pos_b = inString.indexOf("b", Pos_g);
            int End = inString.indexOf("H", Pos_b);
            if(End < 0){
              End =  inString.length() + 1;
            }
            bufLength = ((Pos_g) - (Pos_r+2));
            if(bufLength > 4){  //dont overflow the buffer
              bufLength = 4;
            }   
            inString.substring((Pos_r+2), (Pos_g-1)).toCharArray(colorBuff, bufLength);  //transfer substring to buffer
            r = atoi(colorBuff);
            bufLength = ((Pos_b) - (Pos_g+2));
            if(bufLength > 4){  //dont overflow the buffer
              bufLength = 4;
            }     
            inString.substring((Pos_g+2), (Pos_b-1)).toCharArray(colorBuff, bufLength);  //transfer substring to buffer
            g = atoi(colorBuff);
            bufLength = ((End) - (Pos_b+2));
            if(bufLength > 4){  //dont overflow the buffer
              bufLength = 4;
            }     
            inString.substring((Pos_b+2), (End-1)).toCharArray(colorBuff, bufLength);  //transfer substring to buffer
            b = atoi(colorBuff);

This is based off an individuals code here: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1238498454

15  Using Arduino / Project Guidance / Re: Machine Vision LED Controller -- advice requested on: January 28, 2012, 12:57:08 pm
Any suggestions on a better protocol to implement, or should it be something done by scratch?

A software GUI would be needed for users to adjust channel power and apply their settings to the controller -- run from a host PC installed somewhere nearby.

A serial command interface would contain a list of commands and may look  something like this:

Command: Set channel power
Format:
SC###

Where:
C = channel number
### = 0-255

Example:
S0255
S1255
S2255
S3255
etc..


This is geared towards an industrial environment with automation as a focus, where there is potentially numerous machines which are run all together through software. It is common to have software send out serial commands (rather than have a user interface). It is a vision application, so the lighting works in conjunction with camera imaging systems, sensors, etc..

 Typically used in automated inspection (inspecting beer bottles for cracks/imperfections is one example). Beer bottles may be travelling on conveyor where a camera images the bottle with a light flash or continuous lighting. Software algorithms compare defects and reject/accept the bottles as they move along.

This is just one example, but another example may be a system that must adjust intensity levels, or color settings, on the fly due to a changing product that must be inspected. This would all be automated, so a well implemented serial protocol is necessary.

Pages: [1] 2