Pages: 1 [2] 3   Go Down
Author Topic: Arduino crashes after 15-20 hours or running  (Read 2372 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 0
Posts: 144
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Same thing happened - looks like after it receives the first error it never recovers.
Logged

Dallas, Texas
Offline Offline
Sr. Member
****
Karma: 3
Posts: 267
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Same thing happened - looks like after it receives the first error it never recovers.

That's certainly disappointing. I expected we were done.

I quickly eyed the code one more time this morning. I'm not seeing anything jump out at me. With the addition of checking for a message in the latest code, my concerns for behavioral ambiguity have been addressed. I'm inclined to say its either a bug in the VirtualWire library or you have a component which is taking things out into left field. Given the board seems to continue running and not really crashing, and all we know is you're getting short reads. I would first look there.

Unless you can readily rule out RF module failure (one to swap out?), I'd start exploring the software route. First of all, add debugging code on your TX side to verify you are, in fact, ALWAYS transmitting at least two bytes per frame. A short TX (one byte) would absolutely cause a false positive on the RX side. So make absolutely sure the TX code isn't the core problem. If after you're absolutely sure its not a false positive on the RX side because of a bug on the TX side, dig into the virtual wire library.

As a side note, I reviewed some of the VirtualWire code. Contrary to the comment, vw_have_message is absolutely not required. So it makes sense it changed nothing. If you look in vw_get_message, the first thing it does is check the status of the same variable the vw_have_message function does. So NOT calling vw_have_message, as you originally had it, is in fact, ideal. Not calling it was not a bug. That explains why, reportedly, the example code doesn't use it.

Furthermore, the message will be copied regardless of CRC failure. That means technically, any number of bytes will be available on a bad CRC. But, I don't see a mechanism which allows you to discern a receive with bad CRC versus no receive. The implementation details of the vw_get_message are sorta odd, but not likely to be causing your issue.

So in a nut shell, if you'd like, post your TX code. And if you have another RF module to swap out, please do so. Please add a debugging line which reports the size which has been received. Please add debugging lines which report the size which has been transmitted. What is the reported length of the short rx and tx?
« Last Edit: June 15, 2011, 08:16:00 am by gerg » Logged


Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 200
Posts: 12779
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
"buflen" should have the array's maximum size upon input

Would you like me to show you were to put the one line code?
« Last Edit: June 15, 2011, 03:21:23 pm by Coding Badly » Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 144
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Coding Badly - I don't follow? It would be helpful if you showed me the one liner.
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 200
Posts: 12779
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

void loop()
{
    buflen = VW_MAX_MESSAGE_LEN;
    if (vw_have_message() &&
        vw_get_message(buf, &buflen)) // check to see if anything has been received
    {


This is probably a better structure...

void loop()
{
    if (vw_have_message() )
    {
        buflen = VW_MAX_MESSAGE_LEN;

        if ( vw_get_message(buf, &buflen) ) // check to see if anything has been received
        {
            // process buf here
        }
    }

« Last Edit: June 15, 2011, 03:24:34 pm by Coding Badly » Logged

Dallas, Texas
Offline Offline
Sr. Member
****
Karma: 3
Posts: 267
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Good eye there!

And structure doesn't need to change. The comment is library comment is wrong. The extra call is not required. Both functions check the same state. Yes, it may mean future library updates may cause breakage, but it looks like its being used as an optimization anyways. Besides, when the examples change to reflect the code comment, then you should be concerned. Until then, monkey see, monkey do. It can look like this:

Code:
void loop()
{
    buflen = VW_MAX_MESSAGE_LEN ;
    if (vw_get_message(buf, &buflen)) // check to see if anything has been received
    {
blinkLed(redLedPin,1,250);

if( buflen >= 2 ) {
   power = word(buf[1],buf[0]);
   power = power / 100;
   count++;
   Serial.print(power,1);
   Serial.print("kwh : count:");
   Serial.print(count);
   Serial.print( "errors: " ) ;
   Serial.print( error ) ;
   Serial.println("");
   power = 0;
} else {
   error++ ;
   Serial.print( "did not receive enough data; error: " ) ;
   Serial.print( error ) ;
}
    }
}


« Last Edit: June 15, 2011, 03:29:33 pm by gerg » Logged


0
Offline Offline
Full Member
***
Karma: 0
Posts: 144
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ahh ok. I see what you've done.

Thanks for all the help guys - lets hope this solves the problem.

Code compiled and uploaded. Holding thumbs.
Logged

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1217
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@Greg,   have you had any luck yet, I have a similar problem , but the receiver/decoder hangs without my sending any transmission.

see thread http://arduino.cc/forum/index.php/topic,63995.msg466411.html#msg466411

I am wondering if its getting hung up an an outside transmission at the same bitrate ( I am testing in my house with all the neighbours having a different brand of garage door opener, a lot of them on 433 mHz the same as mine ....???

It looks like you have the same hassle with knowing how long to test a change before you know if its fixed or not.

I think I might slow the bitrate right down both ends to get away from the garage door stuff for testing..

I slowed it to 1100 but it hung up within a couple of minutes ...???
« Last Edit: June 15, 2011, 05:05:52 pm by Boffin1 » Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

0
Offline Offline
Full Member
***
Karma: 0
Posts: 144
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Boffin1 - a fellow Cape Townian smiley

I think I might have the problem solved - will know after a day or two of running.
Logged

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1217
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Greg

Its that bl***y great flat topped mountain doing it !!!!

but give me a clue and I can test at the same time ..
Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

0
Offline Offline
Full Member
***
Karma: 0
Posts: 144
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Boffin1 - I"m transmitting at 1200 and so far so good. The problem I was having is I need to include this in the main loop:

buflen = VW_MAX_MESSAGE_LEN ;

Logged

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1217
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Greg

I have that in my code, unfortunately  smiley-sad

I am using a cheap switch mode power supply, I am going to try another type this morning, and I have even tried moving my celphone away from the unit under test, really clutching at straws now..

I have just noticed that neither of us have the
if (vw_have_message() )   
that codingbadly suggested .  I think I will study the VW pdf again ( RTFM )

I know for instance that I will be receiving 20 bytes every message, so perhaps I can get it to check buflen is 20, but then again  thats what VW is doing when it sends buflen anyway....

As I only need the loop to do anything after getting a message ( my displays are latched, not multiplexed ) I am trying the instruction

vw_wait_rx()

which is blocking, the trouble is I might only know by tonight really if its working ...
« Last Edit: June 16, 2011, 04:14:49 am by Boffin1 » Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1217
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@Greg

Is your problem unit an arduino board powered by the usb?
Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1217
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


I think my problem must have been a noisy power supply !  ( I was using a JUS mains adaptor that the supermarkets sell )

Its been working 20 hours OK now since I changed the PSU   (and made the loop wait for a new message wit the blocking VirtualWire wait instruction.)

Good luck with yours
Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

Dallas, Texas
Offline Offline
Sr. Member
****
Karma: 3
Posts: 267
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


I think my problem must have been a noisy power supply !  ( I was using a JUS mains adaptor that the supermarkets sell )

Its been working 20 hours OK now since I changed the PSU   (and made the loop wait for a new message wit the blocking VirtualWire wait instruction.)

Good luck with yours

Congrats!

But in fairness, you did have multiple issues with the code and you can now react to various unexpected conditions which the previous code just glossed over. So its a win-win!

Again, congrats!
Logged


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