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
Can't figure out how to break in/out of loop
Moderator: Benj
Can't figure out how to break in/out of loop
- Attachments
-
- ChemCon_C.fcf
- (77.75 KiB) Downloaded 365 times
-
- 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
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
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
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Can't figure out how to break in/out of loop
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
Was wondering how you got on with the information provided and the flowchart called SPA_MASTER a.fcf you wanted via PM?
Martin
Martin
Re: Can't figure out how to break in/out of loop
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
I am working a construction job in the daytime and a lot of times it cuts into my electronic work.
Thanks,
Scott
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Can't figure out how to break in/out of loop
Hi Scott.
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: 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
The switch icon is just like from 1 to 10 yes decision branches and 1 no decision branch: Note: You don't have to use all 10 YES branches if you don't want to.ionize wrote:and elaborate on the switch icon functions
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: 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