Go Down

Topic: VirtualWire or String causes arduino to hang (Read 4900 times) previous topic - next topic

dc42


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: [Select]
Sensor1Data = atoi(buf);

Error Message
Code: [Select]
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: [Select]
Sensor1Data = atoi((const char*)buf);
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.

Makkan


Try:

Code: [Select]
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?

AWOL

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.
"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.

Makkan


Try:
Code: [Select]
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.

dc42


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.
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.

Makkan

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.

dc42


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.
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.

Makkan

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.

dc42

What happens if you just comment out the analogWrite calls?
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.

PaulS

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.

Makkan


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.

dc42

OK, try commenting just one or two of the analogWrite calls out, see if it is a particular pin causing the trouble.
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.

Makkan

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?

dc42

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?
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.

Makkan

#29
Dec 14, 2012, 07:14 am Last Edit: Dec 15, 2012, 11:01 pm by Makkan Reason: 1
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.

Go Up