View previous topic :: View next topic |
Author |
Message |
filjoa
Joined: 04 May 2008 Posts: 260
|
Problem with crash |
Posted: Fri Jul 31, 2009 2:25 pm |
|
|
Hi
I make a program for controller lights of my car but it crash many times, and I need turn off power for it restart...
This is my circuit:
This is my program:
Code: |
#include <12F683.h>
#use delay(clock=4000000)
#fuses NOWDT,INTRC_IO, NOCPD, NOPROTECT, MCLR, NOPUT, BROWNOUT, IESO, FCMEN
#define LEDS PIN_A4
#define ALARMON PIN_A1
#define ALARMOFF PIN_A0
#define DOORS PIN_A2
#define IGN PIN_A5
void main()
{
int16 i;
int8 aux=0;
output_low(LEDS);
while(TRUE)
{
if (input(ALARMON)==0) output_low(LEDS);
if (input(ALARMOFF)==0) output_low(LEDS);
if (input(DOORS)==1) output_low(LEDS);
if ((input(ALARMON)==1) && (input(IGN)==0))
{
output_high(LEDS);
for (i=0;i<=40;i++)
{
delay_ms(500);
if (input(IGN)==1) break;
if (input(ALARMOFF)==1) break;
}
}
if (input(DOORS)==0)
{
output_high(LEDS);
while(DOORS!=1);
for (i=0;i<=40;i++)
{
delay_ms(500);
if (input(IGN)==1) break;
if (input(ALARMOFF)==1) break;
}
}
}
}
|
Someone have an idea how make this crashes?
kind regards |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jul 31, 2009 3:06 pm |
|
|
Quote: | #define DOORS PIN_A2
if (input(DOORS)==0)
{
output_high(LEDS);
while(DOORS!=1);
for (i=0;i<=40;i++)
{
delay_ms(500);
if (input(IGN)==1) break;
if (input(ALARMOFF)==1) break;
}
}
} |
The line in bold is wrong. Can you see the error ? |
|
|
filjoa
Joined: 04 May 2008 Posts: 260
|
|
Posted: Fri Jul 31, 2009 5:03 pm |
|
|
Hi
why this line is wrong?
on PIN "DOORS" it stay at 5V when I close the doors and go to 0V when I open.
on PIN "Signal Doors Open" I have one pulse of 12V for central loock
on PIN "Signal Doors Close" I have one pulse of 12V for central loock
on PIN "IGN" I have 12V when I put key ON
is possible I need put pull-down on "Signal Doors Open", "Signal Doors Close" and "IGN"?
You think which program stay wrong? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jul 31, 2009 5:18 pm |
|
|
Look at it closely. Compare that line to all the other lines that have
'DOORS' in them. What is missing ? There is one thing. |
|
|
filjoa
Joined: 04 May 2008 Posts: 260
|
|
Posted: Fri Jul 31, 2009 6:14 pm |
|
|
Hi
I write "while(DOORS!=1); " for program wait there at I close the doors...
don't stay correct my thought? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jul 31, 2009 6:43 pm |
|
|
What is 'DOORS' ? It's this:
Quote: | #define DOORS PIN_A2 |
What is 'PIN_A2' ? Look in 12F683.h to find this:
So 'DOORS' is the number 42.
With that knowledge, look at your test:
Then substitute the value for 'DOORS' in that statement:
That's your code. That's what it's doing. I ask you, is that correct ?
What should you do to fix it ? Look at your other statements that use
the 'DOORS' value. |
|
|
filjoa
Joined: 04 May 2008 Posts: 260
|
|
Posted: Sat Aug 01, 2009 8:17 am |
|
|
Hi
I don't see the bug... problem is because I need have
while(input(DOORS)!=1);
I can see that when post my problem.. thanks for help |
|
|
Ttelmah Guest
|
|
Posted: Sat Aug 01, 2009 2:02 pm |
|
|
The point is that 'DOORS', is not the value of the input pin. It is a numeric value, which allows specific functions to access the pin. Your test, does not use these functions....
Best Wishes |
|
|
|