Hi,
I'm not at all sure if the subject line describes what I'm trying to do but here goes.
I'm using a 12F617 under FCv4.
I have an A/D Channel watching a voltage rail. The program must set one variable called ACTIVE to '1' based on acceptance that the value read on the A/D input, falls between 2 windows of acceptable values.
I have set up in an opening statement,
A....VHiWindowU = 877 (meaning Voltage in the Hi Window...Highest acceptable value)
B....VHiWindowL = 809 (meaning Voltage in the Hi Window...Lowest acceptable value)
C....VLoWindowU = 479 meaning Voltage in the Lo Window...Highest acceptable value)
D....VLoWindowL = 418 (meaning Voltage in the Lo Window...Lowest acceptable value)
So, the circuit reads int value of the voltage (Variable called 'SUPPLY') and must set Variable 'ACTIVE' to '1' if the measured values falls between either A-B or C-D acceptable values and to '0' if outside the windows.........in other words if SUPPLY (int) is <D, >A or in between B & C then ACTIVE is '0'.
Hope this is clearly explained.
What I was trying to do was get the decision calculated within a single calculation icon rather than use multiple decision icons nested.
Is this possible, every form of calculation I try returns syntax error from FC so I've had to cry for help again...
Of course, this functionality must be performed continuously in a loop whilst other functions are called or called up as a macro at regular intervals perhaps once per second or two.
Dave
Change one variable value based on a range of measurements
Moderator: Benj
-
- 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: Change one variable value based on a range of measuremen
Hi Dave, This the easiest way I could think of:
IF: ((Supply>=809) && (Supply<=877)) || ((Supply>=418) && (Supply<=479))
Then Active = 1
Else Active = 0
In English:
IF: ((Supply is greater or equal 809) AND (Supply is less than or equal 877)) OR ((Supply is greater or equal 418) AND (Supply<=479)) Then set active at 1
otherwise Active = 0
Martin
IF: ((Supply>=809) && (Supply<=877)) || ((Supply>=418) && (Supply<=479))
Then Active = 1
Else Active = 0
In English:
IF: ((Supply is greater or equal 809) AND (Supply is less than or equal 877)) OR ((Supply is greater or equal 418) AND (Supply<=479)) Then set active at 1
otherwise Active = 0
Martin
- Attachments
-
- Voltage range1.fcf
- (4.5 KiB) Downloaded 303 times
Martin
-
- Posts: 139
- Joined: Mon Sep 21, 2009 10:17 am
- Location: Leicester
- Has thanked: 35 times
- Been thanked: 12 times
- Contact:
Re: Change one variable value based on a range of measuremen
Hi Martin,
As usual you have the answer.......I am sure you can see what I'm trying to do.....was trying to ease the burden on you working on this water heater code by going solo.....forlorn effort as I spent all day trying to get past this first hurdle.
My theory was that I could have the voltage and temperature measured each within their own macro, then call these macro's during LED off times, this way, the readings couldn't be upset by the small drop in supply caused by the led current draw on vref.
The macro's setting the variable conditions during dead time essentially, then using the combination of variable 1's and 0's to set the led pattern and priorities.....
In trying to help you, I gave you more to do........sorry.
What I was trying to do was combine the entire read and decide into a single calculation cell instead of the decision cell.....(may strange way of simplifying...lol)
Dave
As usual you have the answer.......I am sure you can see what I'm trying to do.....was trying to ease the burden on you working on this water heater code by going solo.....forlorn effort as I spent all day trying to get past this first hurdle.
My theory was that I could have the voltage and temperature measured each within their own macro, then call these macro's during LED off times, this way, the readings couldn't be upset by the small drop in supply caused by the led current draw on vref.
The macro's setting the variable conditions during dead time essentially, then using the combination of variable 1's and 0's to set the led pattern and priorities.....
In trying to help you, I gave you more to do........sorry.
What I was trying to do was combine the entire read and decide into a single calculation cell instead of the decision cell.....(may strange way of simplifying...lol)
Dave
-
- 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: Change one variable value based on a range of measuremen
Hi Dave, don't kick yourself as you are doing the right thing.
By asking questions, and working out your own methods, just means you learn enough to do any type of flowchart.
Like a jigsaw puzzle, It all falls into place in the end. Always best sticking with it.
I will help as much as I can, so ask as many question as you need to as we don't mind at all!
Martin
By asking questions, and working out your own methods, just means you learn enough to do any type of flowchart.
Like a jigsaw puzzle, It all falls into place in the end. Always best sticking with it.
I will help as much as I can, so ask as many question as you need to as we don't mind at all!
Martin
Martin