Pages: 1 2 [3]   Go Down
Author Topic: Simple assignment operator not working! [SOLVED]  (Read 2501 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Offline Offline
Brattain Member
*****
Karma: 496
Posts: 19047
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

However something very strange happens when i take the //comment from the line '//heading = heading + temp4'. 'heading' seems to become a null variable or something, and the 'if' comparisons that check the heading against the RC angle stop working entirely.

Yeah, it's like it's Not A Number any more. <grin>
Logged


Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26485
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I can't believe it's Not A Number tm    smiley-yell
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 209
Posts: 13024
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Somebody's feeling his oats.
Logged

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

SOLVED!!! Step by step I backed through my math, setting variables as simple numbers, until I came across the TRUE trouble code. 'enctickL' becomes 0 when the robot isn't moving, and i was doing 1/0 which becomes NaN! I didn't think anything of it at first because it was reporting regular numbers. This was then filtering down through the math and eventually showing itself at 'heading = heading + angleinc'. I added two if statements to change them from 0 to 999999 to my main code and it worked! Thank you guys so much for the help! I'm feeling much better about bringing my robot in to class today!

Code:
enctickL = pulseIn(encpinL, HIGH, 40000);
enctickR = pulseIn(encpinR, HIGH, 40000);

temp1 = 1.0 / (float)enctickL;//temp1 = ticks per millisecond
temp2 = 1.0 / (float)enctickR;

Logged

0
Offline Offline
God Member
*****
Karma: 2
Posts: 596
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you feel the problem is solved, please consider adding [SOLVED] to the topic title. :-)
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 496
Posts: 19047
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It would be nice. And you could change it.

Now fixed in the next release:

http://code.google.com/p/arduino/issues/detail?id=946
Logged


Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 209
Posts: 13024
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


No F?

Code:
  if (isnan (number))
    return print ( F( "nan" ) );
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 496
Posts: 19047
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

They may not want the overhead of the progmem library, if a sketch was not otherwise using it.

But you could always comment on the Google Code board.
Logged


Global Moderator
Offline Offline
Brattain Member
*****
Karma: 496
Posts: 19047
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What about this, a few lines down:

Code:
// Print the decimal point, but only if there are digits beyond
  if (digits > 0) {
    n += print(".");

That could be:

Code:
// Print the decimal point, but only if there are digits beyond
  if (digits > 0) {
    n += print(F("."));

Or perhaps better:

Code:
// Print the decimal point, but only if there are digits beyond
  if (digits > 0) {
    n += print('.');
Logged


Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 209
Posts: 13024
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

But you could always comment on the Google Code board.

Naw.  Seems like rather low hanging fruit (especially the print(".") in your post) and was curious.
Logged

Pages: 1 2 [3]   Go Up
Jump to: