Page 1 of 1

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

Posted: Mon Feb 03, 2014 7:29 am
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

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

Posted: Tue Feb 04, 2014 3:13 pm
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

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

Posted: Sat May 03, 2014 10:50 am
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

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

Posted: Wed May 07, 2014 12:08 am
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

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

Posted: Thu May 08, 2014 7:11 pm
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