Hello folks, attached is my flow chart of a automatic light switch. The current knob represents the light level detected by a LDR. Once the set threshold is reached, the led turn on.
Could somebody show me please how to adjust the threshold level before the LED turns on.
Thanks very much everyone............John
Adjustable Threshold Level
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: Adjustable Threshold Level
Hi John,
You have got:
So what about using another ADC and setting it to ReadAsByte.
The ADC read variable you can name Threshold for example.
Then change your flowchart to:
You can also add hysteresis
e.g
Martin
You have got:
Code: Select all
if lightlevel < 150 then LED = On
The ADC read variable you can name Threshold for example.
Then change your flowchart to:
Code: Select all
if lightlevel < Threshold then LED = On
e.g
Code: Select all
if lightlevel > Threshold+5 then LED = Off
Martin
-
- Posts: 271
- Joined: Tue Mar 05, 2013 10:49 pm
- Has thanked: 111 times
- Been thanked: 13 times
- Contact:
Re: Adjustable Threshold Level
Hello Martin, I got close to it (attached)
Would you be kind enough to explain to me what Readbyte Uint etc means.
How do I actually add the hysterisis, do I need to include another calculation symbol or can it be included in one of the calculation symbols I already have??
Many thanks again......John
Would you be kind enough to explain to me what Readbyte Uint etc means.
How do I actually add the hysterisis, do I need to include another calculation symbol or can it be included in one of the calculation symbols I already have??
Many thanks again......John
- Attachments
-
- Auto Light.fcf
- (9 KiB) Downloaded 243 times
-
- 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: Adjustable Threshold Level
Hi john.
Its just the resolution or sensitivity.
E.g if you ReadAsByte then the full range from 0V to 5V will be 0 to 255 (256 steps).
Resolution (minimum voltage change to cause change of 1) = 5/256 = 19.5mV
So the type of variable should be byte to save ROM space. You can use UInt or Int but maimum will be 255.
ReadAsInt then the full range from 0V to 5V will be 0 to 1023 (1024 steps)
Resolution = 5/1024 = 4.88mv
The Hysteresis is just a set difference between of and on.
if on = 100 and off = 99 then there is no hysteresis.
So what I have done is modified flowchart so on = threshold +5
Off must be less or equal to threshold.
There for there has to be a change of 5 or greater between on and off = hysteresis.
So see the rage of different variable types when you go to add variable you will get to see all the ranges.
Martin
Its just the resolution or sensitivity.
E.g if you ReadAsByte then the full range from 0V to 5V will be 0 to 255 (256 steps).
Resolution (minimum voltage change to cause change of 1) = 5/256 = 19.5mV
So the type of variable should be byte to save ROM space. You can use UInt or Int but maimum will be 255.
ReadAsInt then the full range from 0V to 5V will be 0 to 1023 (1024 steps)
Resolution = 5/1024 = 4.88mv
The Hysteresis is just a set difference between of and on.
if on = 100 and off = 99 then there is no hysteresis.
So what I have done is modified flowchart so on = threshold +5
Off must be less or equal to threshold.
There for there has to be a change of 5 or greater between on and off = hysteresis.
So see the rage of different variable types when you go to add variable you will get to see all the ranges.
Martin
- Attachments
-
- Auto Light 1.1.fcf
- (9.5 KiB) Downloaded 304 times
Martin