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.
Project problem
Project problem
- Attachments
-
- trial3.fcf
- Unsolved problem
- (7 KiB) Downloaded 395 times
Last edited by erwan on Wed Feb 03, 2010 4:34 pm, edited 1 time in total.
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Project problem
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...
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...
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: Project problem
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
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
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Project problem
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: Project problem
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.
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 410 times
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Project problem
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: Project problem
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.
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.
-
- 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: Project problem
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.
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 426 times
Martin
Re: Project problem
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.
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.
-
- 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: Project problem
Your welcome.
Thank you for letting us know.
Just glad your happy with the end result.
Thank you for letting us know.
Just glad your happy with the end result.
Martin