Author |
Message |
Topic: Hysteresis for two thresholds |
MDM1985
Replies: 32
Views: 33935
|
Forum: General CCS C Discussion Posted: Sun Oct 26, 2014 11:03 am Subject: Hysteresis for two thresholds |
myAdc = reading of adc
myState is remembered variable for the current condition (only three values)
myPins is pic pins to change to set the current condition
(ps. be sure you have diodes across the ... |
Topic: Hysteresis for two thresholds |
MDM1985
Replies: 32
Views: 33935
|
Forum: General CCS C Discussion Posted: Sun Oct 26, 2014 3:37 am Subject: Hysteresis for two thresholds |
No. It's time for you to do some real testing (I mean really serious rigorous testing).
You've not cleared the error in this section of code.
case 2: //in the middle
output_low(RELAY_ ... |
Topic: Hysteresis for two thresholds |
MDM1985
Replies: 32
Views: 33935
|
Forum: General CCS C Discussion Posted: Sat Oct 25, 2014 7:04 am Subject: Hysteresis for two thresholds |
As I said before I only did a quick check.
I thought you had missed a test, but on more careful examination they do all seem to be there.
There are, however, some glaring errors which testing in the ... |
Topic: Hysteresis for two thresholds |
MDM1985
Replies: 32
Views: 33935
|
Forum: General CCS C Discussion Posted: Fri Oct 24, 2014 12:16 pm Subject: Hysteresis for two thresholds |
OK. I've had a quick look at your code.
It's quite cumbersome but should, in principle, work.
You're now:-
Getting into a known state at start-up. OK
Then depending on latest state deciding on ... |
Topic: Hysteresis for two thresholds |
MDM1985
Replies: 32
Views: 33935
|
Forum: General CCS C Discussion Posted: Fri Oct 24, 2014 10:58 am Subject: Hysteresis for two thresholds |
I think that this code could solve my problem:
v = read_adc();
switch (state)
{
case 0: //IDLE STATE; only the first time.
if (v < th_low)
{
st ... |
Topic: Hysteresis for two thresholds |
MDM1985
Replies: 32
Views: 33935
|
Forum: General CCS C Discussion Posted: Thu Oct 23, 2014 10:33 am Subject: Hysteresis for two thresholds |
That will work fine as long as the variable changes continuously. If there can be jumps between trips through the test then you could go from State = 0 to the deadband between State 1 and State 2. T ... |
Topic: Hysteresis for two thresholds |
MDM1985
Replies: 32
Views: 33935
|
Forum: General CCS C Discussion Posted: Thu Oct 23, 2014 12:06 am Subject: Hysteresis for two thresholds |
I think that this is a threshold comparator with two hysteresis, one for the upper dead band and one for the lower.
Any advice? I think that a switch with five case could resolve the problem. :con ... |
Topic: Hysteresis for two thresholds |
MDM1985
Replies: 32
Views: 33935
|
Forum: General CCS C Discussion Posted: Wed Oct 22, 2014 11:30 am Subject: Hysteresis for two thresholds |
Here my code:
if (v < th_low - k) // k is a value to set
{
state = 0;
}
else
if ((v > th_low + k) && (v < th_high - k))
{
... |
Topic: Hysteresis for two thresholds |
MDM1985
Replies: 32
Views: 33935
|
Forum: General CCS C Discussion Posted: Wed Oct 22, 2014 5:07 am Subject: Hysteresis for two thresholds |
What you now have is a system with five states, as shown below:-
Max. ADC reading
Upper region. Set required relays state here
---------------------------------------
TH2 Do NOTHING in t ... |
Topic: Hysteresis for two thresholds |
MDM1985
Replies: 32
Views: 33935
|
Forum: General CCS C Discussion Posted: Tue Oct 21, 2014 2:13 pm Subject: Hysteresis for two thresholds |
Sorry, but I don't understand.
When volt > RELAY_2_ON, we have also the condition volt > RELAY_1_ON thus relay 1 and relay 2 are ON? Is this correct?
I asked several post ago for an EXACT ... |
Topic: Hysteresis for two thresholds |
MDM1985
Replies: 32
Views: 33935
|
Forum: General CCS C Discussion Posted: Mon Oct 20, 2014 12:51 pm Subject: Hysteresis for two thresholds |
This is a classic 'state' problem:
#define RELAY_1_ON (130)
#define RELAY_2_ON (160) //Set where you want
#define THRESHOLD (5) //threshold to turn off
#define OFF 0
#de ... |
Topic: Hysteresis for two thresholds |
MDM1985
Replies: 32
Views: 33935
|
Forum: General CCS C Discussion Posted: Mon Oct 20, 2014 12:01 am Subject: Hysteresis for two thresholds |
Yes,when the adc_value is changing close to the threshold, for example the low threshold, I would have a stable output. For example, when the adc_value is 101 relay is on but, when the adc_value step ... |
Topic: Hysteresis for two thresholds |
MDM1985
Replies: 32
Views: 33935
|
Forum: General CCS C Discussion Posted: Sun Oct 19, 2014 1:25 pm Subject: Hysteresis for two thresholds |
Here the code:
#define blind 0
...
int state;
adc_val = read_adc();
threshold_low = 100;
threshold_high = 400;
hysteresis_low = abs(adc_val - threshold_low);
hysteresis_ ... |
Topic: Hysteresis for two thresholds |
MDM1985
Replies: 32
Views: 33935
|
Forum: General CCS C Discussion Posted: Sun Oct 19, 2014 7:55 am Subject: Hysteresis for two thresholds |
Hi. First of all very nice and useful forum. I am an electronic engineer and I need to add hysteresis for two thresholds in order to avoid the relay chattering. Here the pseudo code without hysteresis ... |
|