Offline
Newbie
Karma: 0
Posts: 13
|
 |
« on: December 08, 2012, 06:27:45 am » |
Hello, Sorry for my bad English, I'm French and new arduino user. In my program, I have this :
void DeclenchePyro () { Serial.println ("Relais ON"); digitalWrite( relaisPin, HIGH ); } ---> It's write to pc terminal : Re`ais ON
If I put in a char, it's ok :
char stringFin [] = "Relais ON"; void DeclenchePyro () { Serial.println (stringFin); digitalWrite( relaisPin, HIGH ); } It's write correct to terminal : Relais ON
I don't know why first function doens't work ????
Thanks
Thierry
|
|
|
|
|
Logged
|
|
|
|
|
New Jersey
Offline
Edison Member
Karma: 24
Posts: 2353
|
 |
« Reply #1 on: December 08, 2012, 06:32:20 am » |
Looks fine from that snippet. Is the issue repeatable? If so, post the whole sketch.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 13
|
 |
« Reply #2 on: December 08, 2012, 06:57:02 am » |
It was repeatable. But I changed timing to call that function (20 sec instead of 60 sec) and the error didn't occur. So I rechanged to 60 sec and no more error. I don't understand pfffffffffffffff
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 138
Posts: 19067
I don't think you connected the grounds, Dave.
|
 |
« Reply #3 on: December 08, 2012, 07:00:04 am » |
Impossible to say for sure from a snippet, but it could be a memory overflow error so where, or a simple pointer write stomping on memory it shouldn't. Post your code.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
0
Offline
God Member
Karma: 37
Posts: 974
Get Bitlash: http://bitlash.net
|
 |
« Reply #4 on: December 08, 2012, 07:24:19 am » |
The problem is the serial output glitch, right?
I wonder if turning on the relay is glitching the power supply and causing the serial output to take a hit.
-br
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 13
|
 |
« Reply #5 on: December 08, 2012, 07:28:08 am » |
I have the same idea, so I put "Serial.print" before "digital.Write" but it didn't change anything
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 138
Posts: 19067
I don't think you connected the grounds, Dave.
|
 |
« Reply #6 on: December 08, 2012, 07:47:48 am » |
I put "Serial.print" before "digital.Write" But did you put a flush after the print?
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
0
Offline
God Member
Karma: 37
Posts: 974
Get Bitlash: http://bitlash.net
|
 |
« Reply #7 on: December 08, 2012, 07:49:01 am » |
Putting Serial.write first won't matter -- because the output you send to Serial.write is buffered. When you Serial.write, it buffers your output (presuming there's room) and starts up an interrupt-driven activity to print your output from the buffer, then returns to you immediately.
So the hypothess is that your relay is firing during the printing, in the error case, causing the glitch. The fact that it's just a few characters (=milliseconds) into the string is the giveaway.
You could use Serial.flush() to force all the characters to be transmitted before you turn the relay on, but the glitch is telling you your power suppy is not adequate or not adequately decoupled, and you should fix it properly or you will just be facing it in another form shortly down the road.
This is probably a good time to ask if you have the relay connected directly to the Arduino output pin, which is not usually a good idea because relays use too much power and cause glitches like this or worse (like frying your board).
-br
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 13
|
 |
« Reply #8 on: December 08, 2012, 10:21:03 am » |
Thank you for help. It's a mini-kit relais. Pin 31 command the relais. But relais seems to pose problems. Another one : 2 temperature sensors are connected : BMP085 (BOSH) and DS18B20 (DALLAS) Dallas sensor is plug into Pin 02 (Arduino Mega) If this command is excecuted (float temperatureExt = sensors.getTempCByIndex(0)  Pin 31 becomes HIGH It is very dissapointing. I search what's wrong in my code.. Just 3 days I use arduino language :-) Code for Dallas sensor comes directly from manufacturer. Regards, Thierry
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
God Member
Karma: 37
Posts: 974
Get Bitlash: http://bitlash.net
|
 |
« Reply #9 on: December 08, 2012, 10:35:00 am » |
If you have 31 pins, you must have a Mega. The library may need adjustment for use on Mega - look in the library files for documentation, or search the forum here.
-br
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 13
|
 |
« Reply #10 on: December 08, 2012, 11:04:50 am » |
Thanks, I will take a look
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 219
Posts: 13896
Lua rocks!
|
 |
« Reply #11 on: December 08, 2012, 02:59:19 pm » |
It's a mini-kit relais. Pin 31 command the relais. But relais seems to pose problems.
What relay? Post a link please. Are you using a transistor to turn it on? It is very dissapointing. I search what's wrong in my code.. Just 3 days I use arduino language :-) Code for Dallas sensor comes directly from manufacturer.
Please post all your code, not just tiny snippets. Read this before posting a programming question
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 13
|
 |
« Reply #12 on: December 08, 2012, 04:31:54 pm » |
I found my error.
int ledRougePin[] = {0, 52}; // LEDs rouges ... void InitialisationCapteurOK (byte numeroCapteur) { // allumer Vert digitalWrite( ledRougePin[numeroCapteur], HIGH ); digitalWrite( ledVertPin[numeroCapteur], LOW ); digitalWrite( ledBleuPin[numeroCapteur], HIGH ); } ....
if (temperatureExt != 0) InitialisationCapteurOK(2); // Led état passe au vert
Error was InitialisationCapteurOK(2) no permit (just 0 or 1). This error triggered relay pin 31. I don't know why but it does.
Thanks everybody
Thierry
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 138
Posts: 19067
I don't think you connected the grounds, Dave.
|
 |
« Reply #13 on: December 08, 2012, 04:50:59 pm » |
See reply #3. If you don't post code, don't expect answers.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 13
|
 |
« Reply #14 on: December 08, 2012, 04:58:55 pm » |
code is long, so I don't want "polluate"
thank you for time took to respond to me :-)
|
|
|
|
|
Logged
|
|
|
|
|
|