Can't figure out how to break in/out of loop

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
User avatar
ionize
Posts: 25
Joined: Fri Aug 05, 2011 8:01 pm
Has thanked: 29 times
Been thanked: 11 times
Contact:

Can't figure out how to break in/out of loop

Post by ionize »

I've been reading about interrupts and have been trying to make this chart work for awhile now but I can't get a handle on interrupts and get stuck in a loop. Can someone show me how to do this with this chart? or re-arrange it. The 16F1938 chip has port B available for pin change interrupts but I am using port A for the switches. TMR0? Thanks
Scott
Attachments
ChemCon_C.fcf
(77.75 KiB) Downloaded 328 times

Bobw
Posts: 157
Joined: Sat Jan 22, 2011 10:39 pm
Location: Michigan
Has thanked: 6 times
Been thanked: 27 times
Contact:

Re: Can't figure out how to break in/out of loop

Post by Bobw »

Ionize,

I think you have too many loops, or loops that lead you no where:
In your get_mesurments Macro you have several loops set as Loop While, these leave you trapped in the loops. You should either have them set to only loop a set number of times, or provide a way to go elsewhere in your program once the conditions are met.
Sorry I do not know how to paste flow code here:
You have:
Loop:
While 1
<LOOP>
Output:
1 -> C3
Delay:
500 ms
Output:
0 -> C3
Delay:
500 ms
</LOOP>

You need to add a way out such as:
Loop:
While 1
<LOOP>
Output:
1 -> C3
Delay:
500 ms
Output:
0 -> C3
Delay:
500 ms
IF A=B Yes (Jump to connection Main)
No

</LOOP>

This is a poor example but the way you have it set up once you call the get measurements macro you are stuck there.
Hope that helps

medelec35
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: Can't figure out how to break in/out of loop

Post by medelec35 »

Hi Scott,
Was wondering how you got on with the information provided and the flowchart called SPA_MASTER a.fcf you wanted via PM?

Martin
Martin

User avatar
ionize
Posts: 25
Joined: Fri Aug 05, 2011 8:01 pm
Has thanked: 29 times
Been thanked: 11 times
Contact:

Re: Can't figure out how to break in/out of loop

Post by ionize »

Hi Martin, I've been working with the version you sent and successfully added EEPROM to hold the values I wanted to it and I've been trying to add a requested additional feature- an ammeter, but have not made that work yet. If you'd like to take a look at it, and elaborate on the switch icon functions that would be wonderful!!
I am working a construction job in the daytime and a lot of times it cuts into my electronic work.
Thanks,
Scott

medelec35
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: Can't figure out how to break in/out of loop

Post by medelec35 »

Hi Scott.
ionize wrote:and elaborate on the switch icon functions
The switch icon is just like from 1 to 10 yes decision branches and 1 no decision branch:
switch component 1.png
(257.07 KiB) Downloaded 1050 times
Note: You don't have to use all 10 YES branches if you don't want to.
when a variable is equal to value entered within the properties e.g 2
then the YES branch that matches the value of 2 will be accessed:
switch component 2.png
(42.58 KiB) Downloaded 1050 times
If the value of variable within the switch component dos not match any of the YES branches, then only the NO branch is accessed.

As for the ammeter, one way is have a low value resistor in series with the load, then use ADC component to measure the voltage across the resistor.
Current is then measured voltage/resistance value.


Martin
Martin

Post Reply