Flashing/Pulsing Problem 16F690

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
jbs4wd
Posts: 46
Joined: Thu Dec 03, 2009 7:29 am
Has thanked: 4 times
Contact:

Flashing/Pulsing Problem 16F690

Post by jbs4wd »

Would anyone know why when I have a simple compasrison program that works well on PC but when put into real life (onto board) it flashes its outputs?
I have checked the board and everything there is fine.


Cheers
JOHN
Attachments
airbag front.fcf
(16.5 KiB) Downloaded 296 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Flashing/Pulsing Problem 16F690

Post by medelec35 »

Hello jbs4wd.
Can you be more specific please. Does LED flash constantly? Or as I suspect, flash only when pot is set near point of where LED should go from off to on? I know of two things (there is probably more) that can cause outputs to change when they should be steady.

1) when reading ADC voltage, the ADC value can change, very slightly. even if voltage sampled is constant. If using EB006 you could used LDC display to see how much ADC reading changes if pot is not touched. Then instead of if < +70
you add hysteresis. So if between 65 and 70 ( or what ever the change is) do nothing, if < + 65 led on, if > +70 LED off.

2)A used input input is left floating. In one of my projects I Wanted to have an ADC i/p with either a pot connected or no pot connected, with out changing software. PSU current Available was limited,so in the end, I used a 1M resistor across ADC i/p. but that did not work as I thought as o/p kept changing every so often, but did not want a lower resistance connected. As soon as I decoupled i/p with 100nF cap it worked great.
Martin

jbs4wd
Posts: 46
Joined: Thu Dec 03, 2009 7:29 am
Has thanked: 4 times
Contact:

Re: Flashing/Pulsing Problem 16F690

Post by jbs4wd »

Thanks for the reply.

To answer your questions;
When it 'flashes' all outputs flash at a 1/2 sec rate.
I have checked the adc i/p when this happens and all is stable and no where near the comparison point. ie: PS (airbag) = 2.5v and initialset is at 1.5v.
I have tried adding resistors and capacitors to no avail.
I have also tried macros to keep the o/p stage in a loop until i/p changes. Does the same.
Wierd!!!!

Cheers

JOHN

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Flashing/Pulsing Problem 16F690

Post by medelec35 »

I believe I have worked out what the problem is. You have not taken into account rollover of variables. E.g you have got PS<(initialset-60)
What if initialset = 0 to 59?
With micros if you have a 8 bit variable = 0 and you take 1 away, it will roll over to 255.

So if initialset = 0 then if initialset-60, then the decision will be if PS<(0-60) = PS<256-60 = PS<196

So in reality, with initialset set to 0 and PS set to < 76 the first routine will always be true. This means at two routines will be true, so every 500ms, the same port will keep toggling...Hence flashing LED.
So there is no bugs in the flowcode. you just need to change the way the decisions are done. If you get stuck in changing your formula, I would be able to help you.
I am not sure why flowcode simulator can not simulate correctly, so you could of seen what was happening (that is if I am correct of course :P )?
Hope this helps.
Martin

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Flashing/Pulsing Problem 16F690

Post by medelec35 »

Anyone at Maxtix can verify if I am correct or not please?
If i am correct why it does not show up on the simulator i.e why does -60 not get taken into account like it would on real hardware?
Martin

User avatar
Dan81
Valued Contributor
Valued Contributor
Posts: 268
Joined: Sun Jan 15, 2006 4:07 pm
Location: Albi France
Been thanked: 60 times
Contact:

Re: Flashing/Pulsing Problem 16F690

Post by Dan81 »

Hello John

I think Medelec is correct.

You can "rename" variable (initialset and PS) from byte to integer.

Daniel

jbs4wd
Posts: 46
Joined: Thu Dec 03, 2009 7:29 am
Has thanked: 4 times
Contact:

Re: Flashing/Pulsing Problem 16F690

Post by jbs4wd »

DAN & MADELEC
THANKS FOR YOUR HELP.
MAD, I HAVEN'T TRIED YOUR SUGESTION YET BUT DAN, IT WORKED!!!!!!
EVERYTHING IS STABLE AND WORKING BRILLIANTLY.
MAD, WHEN I GET TIME I WILL COME BACK AND ASK YOU HOW TO DO YOUR CALCULATIONS IF YOU DONT MIND
THANKS HEAPS
JOHN

Post Reply