Page 1 of 1

timed loops

Posted: Sun Oct 09, 2011 4:56 am
by brandonb
is it possible to have a program that runs 50hz 80% duty output that is timed with a loop for 3 minutes to run then go to another loop that does 189hz at 34% duty for 1 minute.... im trying to create a fuel injection ultrasonic routine for cleaning and backflushing but not have a hundred 255 counts to obtain the result, (not with count+1)

Re: timed loops

Posted: Sun Oct 09, 2011 9:29 am
by allpicproject
How accurate you want it?

If not too accurate, you can use delay and loop.

Re: timed loops

Posted: Sun Oct 09, 2011 9:31 am
by allpicproject
Please post your flowcode file, let other see where is the problem.

Re: timed loops

Posted: Sun Oct 09, 2011 9:41 am
by medelec35
brandonb wrote: but not have a hundred 255 counts to obtain the result, (not with count+1)
If you select Edit, Variables then select to highlight the count variable (which is a byte ie. 0 to 255) and select rename variable you can then change from a byte to an integer which goes up to 32767.
Don't forget to reset count2 when it reaches the highest desired value otherwise when it rolls over, if integer then it becomes a negative number!

Alternately if thats not high enough you can add an additional count e.g count2
Then you can can have a decision branch:
If count = 255 then count = 0: count2 = count2 + 1



If you left both count and count 2 as a byte variable then maximum counts of 255 is 255. so you will have 255 x 255 = 63025.

However if this is not enough then if change count2 to int and leave count as byte then maximum counts = 255 x 32767 = 8355585
That should be high enough?

Martin

Re: timed loops

Posted: Sun Oct 09, 2011 8:28 pm
by brandonb
martin- i tried to get the loop to count in integers prior to help request and couldnt do it, can you show me how this is done? also i have only 36 presets and i ran out of memory words, i have a hardtime with the microchip page, is there another pic chip that my version of flowcode supports that has alot more memory words, it would be great if i had 4x what i have with the 16f690.... thanks

Re: timed loops

Posted: Sun Oct 09, 2011 11:10 pm
by medelec35
brandonb wrote:is there another pic chip that my version of flowcode supports that has alot more memory words, it would be great if i had 4x what i have with the 16f690.... thanks
Hi, Brandon
This will help you find the best chip for your application:
http://www.microchip.com/maps/microcontroller.aspx
Just untick the 16 and 32 bit, then choose PIC16F for prefix.
Then all you do is move the sliders.
If nothing found for PIC16F, then you could try PIC18F
brandonb wrote:i tried to get the loop to count in integers prior to help request and couldnt do it, can you show me how this is done?
I have posted the general idea, not had too much time to work out number of counts and time delay durations.
Hopefully there is enough in the flowchart to help you.
Another possibility is using a timer interrupt, I will look into this when I get a chance.

Martin

Re: timed loops

Posted: Mon Oct 10, 2011 12:35 am
by brandonb
hey martin thanks for the promp help on this, i modified it- named variable to (int) int=0 then int=int+1 the with loop i changed it to check at end of loop (loop until) using variable int="the number count" this works amazing!! thank you for showing me the magic...

Re: timed loops

Posted: Mon Oct 10, 2011 7:36 am
by medelec35
Your welcome Brandon.
I'm just gald the flowchart helped you.
Thanks for the update :)

Martin