Go to Post It really is up to us to stand up for these principles so when we sell it to the general public we're not just feeding them some line because if we don't believe it, why should they? - Koko Ed [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rating: Thread Rating: 8 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 08-01-2013, 03:42 PM
techhelpbb's Avatar
techhelpbb techhelpbb is offline
Registered User
FRC #0011 (MORT - Team 11)
Team Role: Mentor
 
Join Date: Nov 2010
Rookie Year: 1997
Location: New Jersey
Posts: 1,620
techhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond repute
Re: Arduino + Ethernet Shield Help

I only get the 'favicon.i' if the serial monitor is open when the board first connects. Other than that just "HTTP" out of the serial monitor.

It did not appear on my DMM that either pin 7 or 8 was toggling with the webpage button presses (not sure if it's one or zero oriented).

Will look into it more later.

What I suspect is wrong here is that:

1. If you look there is only one call to serial to output from this code.
2. What you should see is what is in the buffer.
3. When you alter the form it fires a POST event.
4. That should cause the page to reload (with the same content).
5. During that post event parameters follow.
6. We both only see "HTTP".
7. However this is a POST so look at this link:
http://www.jmarshall.com/easy/http/#postmethod
(Link altered to something more related and friendly)
8. Therefore when the code reloads and tries to parse these parameters...it can not find what is not in the buffer.
9. Therefore the page simply reloads but does not change the pins (it thinks it's the first time you loaded it).
10. This *might* have worked for someone at some point but this is likely time sensitive.
11. The browser is doing all the work to display the HTML form.
12. When the browser toggles something it's just a silly drawing to the browser.
13. Even if this was a slider (it's a button) it would likely slide as you might expect.
14. Even if the browser does not successfully communicate the change it will tend to draw the changes.
15. HTTP is stateless so unless you put something more intelligent like Javascript in there you can't ask the browser after the fact what happened without another HTML form submission.
16. If your HTML forms never send valid data you are trapped in a vicious loop where things *appear* to be happening.

This is a typical problem for web applications of any sort.
Often form submissions recall the same code and that code needs to get parameters (either GET or POST).
If that code does not get parameters HTTP is stateless so it thinks you were *never there before*.

So since I am not the student here
Put a serial print statement *inside* the conditional that toggles the pin.
See if it ever prints.
You sort of did this already above just put *only* the print statement not any additional conditionals.

Then we can go from there.

BTW when was this book you have written? Look at the copyright date.
It's this book right: http://shop.oreilly.com/product/9780596802486.do

Whistles innocently:
https://bugzilla.mozilla.org/show_bug.cgi?id=260500

Last edited by techhelpbb : 08-02-2013 at 12:54 AM.
  #2   Spotlight this post!  
Unread 08-01-2013, 05:53 PM
jwallace15's Avatar
jwallace15 jwallace15 is offline
What am I going to do with my life?
AKA: Wally
FRC #0068 (Truck Town Thunder)
Team Role: College Student
 
Join Date: Aug 2012
Rookie Year: 2013
Location: Michigan
Posts: 435
jwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud of
Re: Arduino + Ethernet Shield Help

Quote:
Originally Posted by techhelpbb View Post
BTW when was this book you have written? Look at the copyright date.
It's this book right: http://shop.oreilly.com/product/9780596802486.do
No, it is the second edition; http://shop.oreilly.com/product/0636920022244.do
__________________
J Wallace IV
Truck Town Thunder
Just a college student now.
  #3   Spotlight this post!  
Unread 08-01-2013, 05:58 PM
techhelpbb's Avatar
techhelpbb techhelpbb is offline
Registered User
FRC #0011 (MORT - Team 11)
Team Role: Mentor
 
Join Date: Nov 2010
Rookie Year: 1997
Location: New Jersey
Posts: 1,620
techhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond repute
Re: Arduino + Ethernet Shield Help

Quote:
Originally Posted by jwallace15 View Post
No, it is the second edition
Try my suggestion above.

In the conditional already in the example code just try to print anything out the serial port.

Things change and when someone writes a *tiny* webserver they sometimes forget that they control the part they write. They do not control the browser part that is written by someone to whom they have no immediate contact.

So let's think about this:
What happens when the browser part does something different then it did before? How does the example written in a hard copy book evolve when the authors and editors of the book can't predict the future? It doesn't.

This code is obsolete (for people with current browsers) but it's actually not terribly hard to fix it.

So let's do this step by step. Start with my request above. Tell us if you ever see that line print.

Last edited by techhelpbb : 08-01-2013 at 06:01 PM.
  #4   Spotlight this post!  
Unread 08-01-2013, 06:27 PM
jwallace15's Avatar
jwallace15 jwallace15 is offline
What am I going to do with my life?
AKA: Wally
FRC #0068 (Truck Town Thunder)
Team Role: College Student
 
Join Date: Aug 2012
Rookie Year: 2013
Location: Michigan
Posts: 435
jwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud of
Re: Arduino + Ethernet Shield Help

So in the code line...

Code:
while(client.findUntil("PinD", "\n\r"))
{
 int val = client.parseInt();
pinMode(8, OUTPUT);
digitalWrite(8, val);  
}
Add...

Code:
while(client.findUntil("PinD", "\n\r"))
{
int val = client.parseInt();
pinMode(8, OUTPUT);
digitalWrite(8, val);
if(val == 1)
{
Serial.print("The LED is on")
}
else
{
Serial.print("The LED is off")
}
}
?
__________________
J Wallace IV
Truck Town Thunder
Just a college student now.
  #5   Spotlight this post!  
Unread 08-01-2013, 06:42 PM
techhelpbb's Avatar
techhelpbb techhelpbb is offline
Registered User
FRC #0011 (MORT - Team 11)
Team Role: Mentor
 
Join Date: Nov 2010
Rookie Year: 1997
Location: New Jersey
Posts: 1,620
techhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond repute
Re: Arduino + Ethernet Shield Help

Somewhere you've lost a line...I highlighted it red.
The line you want to add is shown in green.

Code:
            if(strcmp(buffer,"POST ") == 0)
            {
              client.find("\n\r");
              while(client.findUntil("PinD", "\n\r"))
              {
                int pin = client.parseInt();
                int val = client.parseInt();
                pinMode(pin, OUTPUT);
                digitalWrite(pin, val);
                Serial.println("I saw the POST and toggled the pin!")
              }
            }
Also I noticed you statically assigned the pin I think it best you start with the original unmodified code for this.
Just add the one green line to the original code.

Be back in 2 or so hours....gotta go to a MORT thing.....

Last edited by techhelpbb : 08-01-2013 at 06:50 PM.
  #6   Spotlight this post!  
Unread 08-01-2013, 07:37 PM
jwallace15's Avatar
jwallace15 jwallace15 is offline
What am I going to do with my life?
AKA: Wally
FRC #0068 (Truck Town Thunder)
Team Role: College Student
 
Join Date: Aug 2012
Rookie Year: 2013
Location: Michigan
Posts: 435
jwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud of
Re: Arduino + Ethernet Shield Help

Quote:
Originally Posted by techhelpbb View Post
Somewhere you've lost a line...I highlighted it red.
The line you want to add is shown in green.

Code:
            if(strcmp(buffer,"POST ") == 0)
            {
              client.find("\n\r");
              while(client.findUntil("PinD", "\n\r"))
              {
                int pin = client.parseInt();
                int val = client.parseInt();
                pinMode(pin, OUTPUT);
                digitalWrite(pin, val);
                Serial.println("I saw the POST and toggled the pin!")
              }
            }
Also I noticed you statically assigned the pin I think it best you start with the original unmodified code for this.
Just add the one green line to the original code.

Be back in 2 or so hours....gotta go to a MORT thing.....
Yeah, my bad. I modified the code either yesterday or the day before. I just hardcoded it so that it would digital write on pin 8 no matter what, so that if that was the problem.

Will do, and will post results.
__________________
J Wallace IV
Truck Town Thunder
Just a college student now.
  #7   Spotlight this post!  
Unread 08-02-2013, 12:05 AM
techhelpbb's Avatar
techhelpbb techhelpbb is offline
Registered User
FRC #0011 (MORT - Team 11)
Team Role: Mentor
 
Join Date: Nov 2010
Rookie Year: 1997
Location: New Jersey
Posts: 1,620
techhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond repute
Re: Arduino + Ethernet Shield Help

Make sure to put the semicolon at the end of the line I suggested you add.
Guess I nicked it off when I edited the color tags on my phone.

Something to think about as you work this out:

Code:
Press OFF button:

FireFox 19.02 Internet browser sends:
  POST / HTTP/1.1
  Host: 192.168.1.130
  User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:19.0) Gecko/20100101 Firefox/19.0
  Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  Accept-Language: en-US,en;q=0.5
  Accept-Encoding: gzip, deflate
  Referer: http://192.168.1.130/
  Connection: keep-alive
  Content-Type: application/x-www-form-urlencoded
  Content-Length: 7
  pinD8=0

Arduino Replies:
  HTTP/1.1 200 OK
  Content-Type: text/html
HTML of web page follows.

Press ON button:

FireFox 19.02 Internet browser sends:
  POST / HTTP/1.1
  Host: 192.168.1.130
  User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:19.0) Gecko/20100101 Firefox/19.0
  Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  Accept-Language: en-US,en;q=0.5
  Accept-Encoding: gzip, deflate
  Referer: http://192.168.1.130/
  Connection: keep-alive
  Content-Type: application/x-www-form-urlencoded
  Content-Length: 7
  pinD8=1

Arduino Replies:
  HTTP/1.1 200 OK
  Content-Type: text/html
HTML of webpage follows.
Captured with LiveHTTPHeaders Add-on for FireFox.
No sense in posting what the HTML looks like here.
It's in the code and major browsers will let you view that as source.

Take a good look at the code as supplied and picture what will happen when it reads that.

As of last night around midnight I had this code fixed and working as it was intended.
I just don't want to deprive anyone of the learning experience
If time is pressing let me know and I'll just send the fixed code to look at.


I wanted to address another statement previously made:

15 LEDs at 20mA each DC current limit.
Driven at 50% duty cycle PWM so you can 'dim' them.
Consume something like an average of 10mA.
If the PWM is sychronized to all 15 LEDs on actual outputs (so this assumes your Arduino has enough digital I/O for this).
Then that's 150mA.
If the PWM signals are 'out of phase' with each other then it's possible this could be as low as 75mA.
Let us assume the likely chance that it's 15 LEDs on 15 digial I/O at 75% duty cycle.
That would, at least to your eye, look like they are almost fully powered on.
So 15 LEDs are probably drawing close to 200mA out of the maximum typical drive of an Atmel AVR of 200mA.
Since R/C hobby servos are usually connected to another circuit or shield.
Since R/C hobby servos are often 6VDC for the motor which is a good reason for the additional circuit.
It's likely the R/C hobby servo control presents a simple 5V CMOS input to the Arduino.
Such an input draws a tiny current.
Usually around 0.1mA or even less.

So that means that you were hovering somewhere between 150mA and 201mA of total drive from the Atmel AVR with that setup.

So previously when it was suggested that an Arduino was able to power 15 LEDs and servos off the same board from a USB port that wasn't entirely a fair assesment of the actual total drive power being demanded of the Atmel AVR on the Arduino itself.

It seems unlikely that the servo power came from the USB port since they typically limit to 1A or even 500mA.

So again be very careful with this.

I can stack CMOS input shift registers on Arduino digital outputs.
Heck I can stack I2C/SPI port expanders and other Arduinos on the digital ouputs of a single Arduino.
So it is possible to have an enormous number of things controlled by a single Arduino.
*However* always consider just how much current as a whole that will demand of the Atmel AVR on the Arduino.
Device count alone can fool you easily.
It is the context that actually matters.

Also seeing as you've driven LEDs with PWM and know how to do that.
Did you know you can drive the opto-isolator LED with PWM?
The relay coil is really slow to respond.
So you can save digital I/O current by driving the LED in the opto-isolators with PWM.
Depends on how you do that.
You could drive half of the relays low.
Then the other half.
So you could reduce 160mA to drive that 8 relay board you have to something like 80mA.

Last edited by techhelpbb : 08-02-2013 at 12:10 PM.
  #8   Spotlight this post!  
Unread 08-06-2013, 02:41 PM
jwallace15's Avatar
jwallace15 jwallace15 is offline
What am I going to do with my life?
AKA: Wally
FRC #0068 (Truck Town Thunder)
Team Role: College Student
 
Join Date: Aug 2012
Rookie Year: 2013
Location: Michigan
Posts: 435
jwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud of
Re: Arduino + Ethernet Shield Help

Sorry it took so long, I've been too busy to toy with this issue.

I added the Serial.print function where you indicated
Code:
(if(strcmp(buffer,"POST ") == 0)
            {
              client.find("\n\r");
              while(client.findUntil("PinD", "\n\r"))
              {
                int pin = client.parseInt();
                int val = client.parseInt();
                pinMode(pin, OUTPUT);
                digitalWrite(pin, val);
                Serial.println("I saw the POST and toggled the pin!")
              }
            }
It does not print "I saw the POST and toggled the pin!", it still prints the HTTP and favicon.i

Except it added one character;
Code:
 HTTP
favicon.i¨
__________________
J Wallace IV
Truck Town Thunder
Just a college student now.
  #9   Spotlight this post!  
Unread 08-06-2013, 02:47 PM
techhelpbb's Avatar
techhelpbb techhelpbb is offline
Registered User
FRC #0011 (MORT - Team 11)
Team Role: Mentor
 
Join Date: Nov 2010
Rookie Year: 1997
Location: New Jersey
Posts: 1,620
techhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond repute
Re: Arduino + Ethernet Shield Help

Quote:
Originally Posted by jwallace15 View Post
It does not print "I saw the POST and toggled the pin!", it still prints the HTTP and favicon.i

Except it added one character;
Code:
 HTTP
favicon.i¨
You would have gotten the extra character eventually it's a bit of junk from the fact that this code is parsing wrong.

You did not get the message because you never get to that part of the loop.

Look up at my last post.
It shows what my FireFox browser sends to the board.
Then look at the code you have.

Specifically look at the inner conditionals that mention POST.
Look before and look after that.

There are several things wrong there.
  #10   Spotlight this post!  
Unread 08-06-2013, 03:06 PM
jwallace15's Avatar
jwallace15 jwallace15 is offline
What am I going to do with my life?
AKA: Wally
FRC #0068 (Truck Town Thunder)
Team Role: College Student
 
Join Date: Aug 2012
Rookie Year: 2013
Location: Michigan
Posts: 435
jwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud of
Re: Arduino + Ethernet Shield Help

Quote:
Originally Posted by techhelpbb View Post
Look up at my last post.
It shows what my FireFox browser sends to the board.
Then look at the code you have.

Specifically look at the inner conditionals that mention POST.
Look before and look after that.

There are several things wrong there.
I'm not exactly sure what I'm looking for... Does it have to do with the way I used a " in the line
Code:
if(client.find("/"))
And in the next I used ' ?
Or how I added a space after POST in
Code:
if(strcmp(buffer,"POST ") == 0)
In that line should I change the 0 to a 1?
__________________
J Wallace IV
Truck Town Thunder
Just a college student now.
  #11   Spotlight this post!  
Unread 08-06-2013, 03:10 PM
techhelpbb's Avatar
techhelpbb techhelpbb is offline
Registered User
FRC #0011 (MORT - Team 11)
Team Role: Mentor
 
Join Date: Nov 2010
Rookie Year: 1997
Location: New Jersey
Posts: 1,620
techhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond repute
Re: Arduino + Ethernet Shield Help

Nope it's not a single versus double quotation issue.

The first thing a browser will send you after you click the button is the following text:
POST / HTTP/1.1

So remember the original code is trying to read what the browser sends and then act on that information. Plus the original code is obsolete.

So if you look for "/" first what will you find?
Now look at what it looks for next...

Remember each time the Atmel AVR MCU takes a character from the ethernet chip's buffer that character is no longer available in the ethernet chip to read again. So if you look for the "/" first. Will you ever find "POST"?

Last edited by techhelpbb : 08-06-2013 at 03:12 PM.
  #12   Spotlight this post!  
Unread 08-06-2013, 03:19 PM
jwallace15's Avatar
jwallace15 jwallace15 is offline
What am I going to do with my life?
AKA: Wally
FRC #0068 (Truck Town Thunder)
Team Role: College Student
 
Join Date: Aug 2012
Rookie Year: 2013
Location: Michigan
Posts: 435
jwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud ofjwallace15 has much to be proud of
Re: Arduino + Ethernet Shield Help

Wait, I think I'm understanding now. Are you saying change the order of the if statements? Take this one
Code:
if(client.find("/"))
And put it in the spot of this (and vice versa)?

Code:
if(strcmp(buffer,"POST ") == 0)
?
That way it looks for POST instead of the "/"?
Or add a new if statement for if(client.find"POST")?
__________________
J Wallace IV
Truck Town Thunder
Just a college student now.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 12:44 PM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi