Project problem

Forum for problems or queries regarding other Flowcode Components. Eg LEDs, Switches, LCD, Gfx LCD etc

Moderators: Benj, Mods

erwan
Posts: 5
Joined: Wed Feb 03, 2010 10:09 am
Contact:

Project problem

Postby erwan » Wed Feb 03, 2010 4:28 pm

I am hoping someone will help me on this.

I was asked to do a simple counter. I am using one switch (input), 3 green led (reset output) and 1 red led (warning output). The desired outputs are when I push the switch once, the first led will be on for only three seconds. The same thing will happen again for the second and third led when I push the switch for the second and third time. When I push the switch for the fourth time, I want the red led to turn on permanently as a warning sign and stop the program.

The problem is I can't make the green led to turn off because the loop will repeat itself and the green led will be blinking. I'm using Flowcode 3.2.2.40, 16F88, clock speed 3276800 and one interrupt macro. My calculation is cal= cal + 1 for one cycle of the loop and the program will stop when cal = 4.

I am really desperately need of help on this one.

Please check the file and let me know what's wrong.
Attachments
trial3.fcf
Unsolved problem
(7 KiB) Downloaded 178 times
Last edited by erwan on Wed Feb 03, 2010 4:34 pm, edited 1 time in total.

User avatar
Benj
Matrix Staff
Posts: 14073
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4297 times
Been thanked: 4050 times
Contact:

Re: Project problem

Postby Benj » Wed Feb 03, 2010 4:32 pm

Hello

Sounds like you need some more decision icons in your program.

eg

decision: cal = 1
yes: switch on led 1

decision: cal = 2
yes:switch on led 2 switch off led 1

etc...

erwan
Posts: 5
Joined: Wed Feb 03, 2010 10:09 am
Contact:

Re: Project problem

Postby erwan » Wed Feb 03, 2010 4:37 pm

Thanks for the suggestion.

I already did that part but still I can't figure out how to make it right. Please see the program and see how you can help me.

Thanks

User avatar
Benj
Matrix Staff
Posts: 14073
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4297 times
Been thanked: 4050 times
Contact:

Re: Project problem

Postby Benj » Wed Feb 03, 2010 4:46 pm

Hello

Ok I see the problem.

You are outputting a value to a pin on porta and then straight away afterwards you are writing 0 to all of porta which is clearing the original bit that you set. Maybe swap the port output with the single pin output and that should fix the problem.

You are also outputting the count variable to the porta pin. I would change this to a 1 as the count value is changing during the operation of the program.

erwan
Posts: 5
Joined: Wed Feb 03, 2010 10:09 am
Contact:

Re: Project problem

Postby erwan » Wed Feb 03, 2010 5:08 pm

Thanks, that cleared some of the problem.

However I still face problems with the blinking led. I need the led to be on for only 3 seconds and the next one will on when I pressed the switch. I guess the cause is the endless looping unless I press the switch. Any idea on how to do that?

Here Γ­s what I've done based on what you recommend.
Attachments
trial5.fcf
changed to single bit
(7 KiB) Downloaded 188 times

User avatar
Benj
Matrix Staff
Posts: 14073
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4297 times
Been thanked: 4050 times
Contact:

Re: Project problem

Postby Benj » Wed Feb 03, 2010 5:24 pm

Hello

Ok now you are outputting a 1 and then straight away outputting a 0.

I would instead do this.

count = 1
Yes: 1 -> A0

count = 2
Yes: 0 -> A0
Yes: 1 -> A1

count = 3
Yes: 0 -> A1
Yes: 1 -> A2

etc

This should stop the LEDs from flashing on and off.

erwan
Posts: 5
Joined: Wed Feb 03, 2010 10:09 am
Contact:

Re: Project problem

Postby erwan » Wed Feb 03, 2010 5:40 pm

Hi.

Thanks a lot for your solution. However I still can't turn off the led after three second. Any idea on how to do that? I tried using delay but I can't figure out where to put it. The desired output is green led on for only three second and off automatically and the process is repeated when I press the switch.

I know I look desperate but I just can't get it right. I really appreciate what you did.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8285
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2371 times
Been thanked: 3378 times
Contact:

Re: Project problem

Postby medelec35 » Wed Feb 03, 2010 8:21 pm

Hope this helps.
Each green LED is only on for 3 seconds.
This is how I did it.
When you press the switch, as soon as interrupt is accessed, 1 is added to count then it sets and Time_Out Variable is reset to 0.
Only if Time_Out Variable = 0 the decision branch containing green LED is accessed. Led is lit until delay of 3 seconds has elapsed, then Time_Out Variable is set to 1. This means the Green LED can't be reactivated And all is repeated when button is pressed again.
Attachments
trial5_Modded.fcf
(8.5 KiB) Downloaded 202 times
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

erwan
Posts: 5
Joined: Wed Feb 03, 2010 10:09 am
Contact:

Re: Project problem

Postby erwan » Wed Feb 03, 2010 11:58 pm

Hi.

Wow! Thank you very much. I owe you big time on this one. I'm really glad I join this forum and knowing you guys.

Best regards.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8285
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2371 times
Been thanked: 3378 times
Contact:

Re: Project problem

Postby medelec35 » Thu Feb 04, 2010 6:20 am

Your welcome.
Thank you for letting us know.
Just glad your happy with the end result.
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.