Pages: 1 [2]   Go Down
Author Topic: VirtualWire or String causes arduino to hang  (Read 4459 times)
0 Members and 2 Guests are viewing this topic.
United Kingdom
Offline Offline
Tesla Member
***
Karma: 227
Posts: 6639
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I tried this but that didn't work. Allthough I doubt I did it right. Am I looking for a char to integer converter or something else?
Code:
Sensor1Data = atoi(buf);

Error Message
Code:
conversion from 'uint8_t*' to 'const char*'
rgb_mixer_RF_controlled_pulse_makkan_v4_ino:115: error: initializing argument 1 of 'int atoi(const char*)'

Try:

Code:
Sensor1Data = atoi((const char*)buf);
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Gothenburg, Sweden
Offline Offline
Jr. Member
**
Karma: 0
Posts: 94
Excellent!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Try:

Code:
Sensor1Data = atoi((const char*)buf);

That compiled, as I suspect you already knew. Unfortunately I will have to wait a couple of hours before I can try it live. However as I do like to know what I'm coding could you please tell me or point me in a good direction to find reading material as to what actually is done in that line. Am I just stating that buf is a const char* or does (const char*)buf perform some sort of change?
Logged

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

Quote
Am I just stating that buf is a const char* or does (const char*)buf perform some sort of change?
You're just telling the compiler that you want the pointer to "buf" to be treated as though it were a "const char*", even though you know it is a pointer to a different type.
Because it is a pointer to a datatype with the same size, this is normally perfectly OK, particularly as in this case, where the buffer simply contains ASCII data.
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.

Gothenburg, Sweden
Offline Offline
Jr. Member
**
Karma: 0
Posts: 94
Excellent!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Try:
Code:
Sensor1Data = atoi((const char*)buf);

Sorry to say I got the same problem as before. A couple of lines fly by in the Serial Monitor before it hangs. Commenting out the Serial.print lines does not help either.

Again if I don't include the colorControl(); function everything seems to work just fine.
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 227
Posts: 6639
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Again if I don't include the colorControl(); function everything seems to work just fine.

Ah, I missed that bit. The version of VirtualWire I am looking at (1.9) uses timer 1. That means that you can't use PWM on pins 9 and 10.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Gothenburg, Sweden
Offline Offline
Jr. Member
**
Karma: 0
Posts: 94
Excellent!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, so I've changed the ledpins to use pin 3, 5 and 6.
This actually stops Serial Monitor output from hanging. But it still seems to hang after a while when the Sensor1Data gets stuck with the same number.
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 227
Posts: 6639
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

But it still seems to hang after a while when the Sensor1Data gets stuck with the same number.

Perhaps the device is no longer receiving data over VirtualWire then? In which case, either receiving has stopped, or the other device has stopped sending data. You need to determine which.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Gothenburg, Sweden
Offline Offline
Jr. Member
**
Karma: 0
Posts: 94
Excellent!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It's the receiver that stops receiving.
And it seems it is colorControl() that somehow mixes things up. If I just comment that one out, I can go on for ages.
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 227
Posts: 6639
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What happens if you just comment out the analogWrite calls?
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

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

You appear to still have your LEDs connected to pins 9 and 10, which the VirtualWire class uses, unless you tell it to use other pins. Which you don't.

So, it's hardly surprising that as soon as you write to those pins VirtualWire quits working.
Logged

Gothenburg, Sweden
Offline Offline
Jr. Member
**
Karma: 0
Posts: 94
Excellent!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You appear to still have your LEDs connected to pins 9 and 10, which the VirtualWire class uses, unless you tell it to use other pins. Which you don't.

So, it's hardly surprising that as soon as you write to those pins VirtualWire quits working.

Nope, dc42 noted this a while back so I've changed to pins 3,5 and 6.

What happens if you just comment out the analogWrite calls?

That works, it's up and running hand still works after five minutes of continous running. So it seems to be analogWrite that causes trouble.
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 227
Posts: 6639
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, try commenting just one or two of the analogWrite calls out, see if it is a particular pin causing the trouble.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Gothenburg, Sweden
Offline Offline
Jr. Member
**
Karma: 0
Posts: 94
Excellent!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That didn't do much but I noticed that if I disconnected the led everything worked. Could it be that the led disturbs the transmission?
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 227
Posts: 6639
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Post a photo and schematic of your setup. Maybe the ground wiring needs attention. What value resistors do you have in series with the LEDs?
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Gothenburg, Sweden
Offline Offline
Jr. Member
**
Karma: 0
Posts: 94
Excellent!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Took a while but here we go:

Circuit diagram
Breadboarded Circuit 1
Breadboarded Circuit 2
Breadboarded Circuit 3

Since it looks a bit messy I might aswell say, NO! There are no crossed leads touching.

EDIT: Moving this to the General Electronics part forum.
« Last Edit: December 15, 2012, 05:01:10 pm by Makkan » Logged

Pages: 1 [2]   Go Up
Jump to: