Pages: [1]   Go Down
Author Topic: No serial output  (Read 287 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello everyone,
I have an issue Ive never crossed before.  I have code that compiles and uploads fine, but when I open the serial monitor nothing is there.  When I comment out the section checking for the west shop overhead door (lines 222-374) it works fine.  that section was a direct copy and paste with slight alterations to variable names so Im pretty sure the code is good.

It's too long to paste in this window so I've attached it as a txt file.

* code.txt (15.06 KB - downloaded 14 times.)
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12568
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Erratic behaviour and a big sketch are both hints that you may have out-of-memory problems. I haven't looked at your source but I suggest that if you're using the String class you stop doing that. Also add up the number of bytes of global data and the number of bytes of literal values (especially string constants) throughout your code and subtract from the amount of RAM on your Arduino (e.g. 2KB for a UNO) and see whether you're anywhere near close to running out. If this doesn't make it obvious, look on the playground for a code fragment to measure the free memory and make your sketch log that at startup.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You could save a ton of SRAM by using the F() macro in your Serial.print() and client.print() statements. As the code is now, I agree with PeterH that you are most likely out of memory.

Code:
  tcoh = analogRead(2);
  Serial.println ("");
  Serial.print ("Time clock overhead door = ");
  Serial.print (tcoh);
tcoh as a variable name makes no sense to me. I think of a time clock being something that is used to track when employees come and go. I can't see how you can read a time clock using a single analog pin.

Code:
    d1ocount = d1ocount++;
Nonsense. n++ is equivalent to n = n + 1. Your code is equivalent to n = n = n + 1. Which, clearly, looks silly.

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Erratic behaviour and a big sketch are both hints that you may have out-of-memory problems. I haven't looked at your source but I suggest that if you're using the String class you stop doing that. Also add up the number of bytes of global data and the number of bytes of literal values (especially string constants) throughout your code and subtract from the amount of RAM on your Arduino (e.g. 2KB for a UNO) and see whether you're anywhere near close to running out. If this doesn't make it obvious, look on the playground for a code fragment to measure the free memory and make your sketch log that at startup.

Thanks, I don't think I'm using the string class anywhere but finder shows my sketch is 15kb.  Is there a better way to handle large sketches?  I'm sure others have larger sketches than mine.  Is this where I stop using uno and go to the mega?

Thanks for your help!

PaulS: Thanks for the reply! I know that I am a very inefficient coder and appreciate every tip offered to me.  I've never used the F() macro so i'll look into that now.  As far as the "tcoh" that simply refers to a physical location in our plant.  We have an overhead door and a man door entering to a room called " time clock" where employees enter the facility and actually punch a clock. And as for the increment, are you saying all i have to do is simply have d1ocount++; ?  If so I understand how silly, and redundant, my code looks!

Thanks again for the help guys!
Logged

New Jersey
Offline Offline
Faraday Member
**
Karma: 65
Posts: 3638
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The issue is not the size of your source file, it's how much RAM your sketch is consuming at runtime. Judicious use of the F macro, as suggested above, should avoid the necessity to buy a Mega.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The issue is not the size of your source file, it's how much RAM your sketch is consuming at runtime. Judicious use of the F macro, as suggested above, should avoid the necessity to buy a Mega.

Thanks WIldBill, I have rewritten the code using F() and will see how it goes in the morning since i left the arduino on my bench at the office!

I really appreciate all the help form everyone!

Toby
Logged

Pages: [1]   Go Up
Jump to: