timed loops
Moderator: Benj
-
- Posts: 438
- Joined: Mon Aug 29, 2011 12:26 am
- Location: arizona
- Has thanked: 175 times
- Been thanked: 173 times
- Contact:
timed loops
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)
-
- Flowcode V4 User
- Posts: 36
- Joined: Thu Sep 01, 2011 11:10 am
- Has thanked: 17 times
- Been thanked: 1 time
- Contact:
-
- Flowcode V4 User
- Posts: 36
- Joined: Thu Sep 01, 2011 11:10 am
- Has thanked: 17 times
- Been thanked: 1 time
- Contact:
-
- 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: timed loops
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.brandonb wrote: but not have a hundred 255 counts to obtain the result, (not with count+1)
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
Martin
-
- Posts: 438
- Joined: Mon Aug 29, 2011 12:26 am
- Location: arizona
- Has thanked: 175 times
- Been thanked: 173 times
- Contact:
Re: timed loops
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
- Attachments
-
- martian loop.fcf
- (6.5 KiB) Downloaded 288 times
-
- 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: timed loops
Hi, Brandonbrandonb 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
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
I have posted the general idea, not had too much time to work out number of counts and time delay durations.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?
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
- Attachments
-
- martian loop1.fcf
- (7 KiB) Downloaded 275 times
Martin
-
- Posts: 438
- Joined: Mon Aug 29, 2011 12:26 am
- Location: arizona
- Has thanked: 175 times
- Been thanked: 173 times
- Contact:
Re: timed loops
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...
-
- 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: timed loops
Your welcome Brandon.
I'm just gald the flowchart helped you.
Thanks for the update
Martin
I'm just gald the flowchart helped you.
Thanks for the update
Martin
Martin