Page 1 of 1

Light pacer

Posted: Sun Apr 20, 2008 7:47 pm
by ziggy1976
I want to construct a flow code that is able to do the following,

Enter a set time between 10-120 seconds. The entered time can be divided into 2-8 parts. The time is then stored in memory. A count down is activated when start button is pressed to decrement by the time set in memory.


A set of lights, 8 in total, come on individually after the time in memory is reached for 2-3 seconds then off again. After a light has come on it stays off. The count is started again and when complete, the next light in the sequence then comes on and so on until all the lights have come on and off. Once all the lights have come on and off the program stops.

I need help on entering/selecting the time for counting down from 10-120 seconds and entering/selecting the divider between 2-8.

Re: Light pacer

Posted: Mon Apr 21, 2008 10:08 am
by Benj
Hello Ziggy

Try looking at the problem logically with a pen and paper. This way you can plan out your functionality without having to start programming.

A good start would be :

Enter a set time - Ok how would you do this. Eg using switches etc.

Re: Light pacer

Posted: Sun May 17, 2009 8:20 pm
by ziggy1976
Benj wrote:Hello Ziggy

Try looking at the problem logically with a pen and paper. This way you can plan out your functionality without having to start programming.

A good start would be :

Enter a set time - Ok how would you do this. Eg using switches etc.
Its a year since I thought about this project. I have returned to it and I'm finding it frustrating to complete. I need help in fact I need solutions to about three very vexing problems I've encountered.

1/ I have worked out...again how to start and stop the stop watch that counts the interval between the lights and displays also the time lapsed. I need a solution for resetting the stop watch. I've tried a solution of my own but when I use that solution, it seems to interfere with the stop button process. The stop button stops or interrupts the TIMER but the display doesn't freeze at the correct time. The stopped time is correct temporarily then shows something like 0.03 sec or a number up to 0.09 sec.

Re: Light pacer

Posted: Sun May 17, 2009 8:38 pm
by ziggy1976
2/ When the stopwatch is paused by the stop button, the reset button doesn't seem to be able to reset the minute unit variable to 0. How do I solve this?

3/ I also still need to know how I can allow a user to change the variable DELAY that determines the time intervals between the lights. I was thinking of using two switches one to scroll up and the other to scroll down. I need a solution.

Re: Light pacer

Posted: Mon May 18, 2009 8:55 am
by Benj
Hello

1. How are you doing the decimal point. Is it juat psudo decimal point?

2. Where are you checking for the reset button press? Simply place a calculation in this part of code setting the count values to 0.

3. Yes two switches to set the delay would work. Simply increment or decrement a variable and pass that variable to your delay function.

Re: Light pacer

Posted: Mon May 18, 2009 9:31 am
by ziggy1976
Benj wrote:Hello

1. How are you doing the decimal point. Is it juat psudo decimal point?

2. Where are you checking for the reset button press? Simply place a calculation in this part of code setting the count values to 0.

3. Yes two switches to set the delay would work. Simply increment or decrement a variable and pass that variable to your delay function.

1. Yes its just a print string decimal point. What is the more efficient way of doing it please?

2. I've sent you the fcf file, I placed it in the stop button section. Its on the file I sent to you (personal message) but feel free to post the image of the flow code. It's also in the image above.

3. Could you provide a flow chart example of how to scroll or is there an example in one of the exemplar programs?

Re: Light pacer

Posted: Mon May 18, 2009 11:07 am
by Benj
Hello Ziggy

1. More efficient way is to use floating point but this can get tricky and uses lots of memory space on the PIC devices so if what you currently have is working then I would stick with it.

2. Sorry but I cannot go through peoples programs fixing problems etc. I am only here to support problems with Flowcode itself or to provide help and useful suggestions. Sorry.

3. To scroll all you have to do is check your switches every time around you main loop. If the switch is pressed then either add 1 or minus 1 from your delay variable. You may want to add limits so the delay variable does not rollover from 0 to 255 and 255 to 0.

Input: RA0 -> UpCount
Input: RA1 -> DownCount

Decision: UpCount && (DelayVar < 255)
Yes: Calc: DelayVar = DelayVar + 1
No:

Decision: DownCount && (DelayVar > 0)
Yes: Calc: DelayVar = DelayVar - 1
No:

Re: Light pacer

Posted: Mon May 18, 2009 11:10 am
by ziggy1976
Benj wrote:Hello Ziggy

1. More efficient way is to use floating point but this can get tricky and uses lots of memory space on the PIC devices so if what you currently have is working then I would stick with it.

2. Sorry but I cannot go through peoples programs fixing problems etc. I am only here to support problems with Flowcode itself or to provide help and useful suggestions. Sorry.

3. To scroll all you have to do is check your switches every time around you main loop. If the switch is pressed then either add 1 or minus 1 from your delay variable. You may want to add limits so the delay variable does not rollover from 0 to 255 and 255 to 0.

Input: RA0 -> UpCount
Input: RA1 -> DownCount

Decision: UpCount && (DelayVar < 255)
Yes: Calc: DelayVar = DelayVar + 1
No:

Decision: DownCount && (DelayVar > 0)
Yes: Calc: DelayVar = DelayVar - 1
No:

Thats a great help. I understand that you can't fix my program. Is there an example in Van Dam's book or a sample program that has a solution that I can adapt for the reset button or is there any entries on the forum that would be appropriate?

Thanks once again for your help.