I've done a flowchart with the objective of reading two LDR's at the same time.(Represented by LIGHTLEVEL1 and LIGHTLEVEL2)
I can get the light to flash on and off by manipulating LIGHTLEVEL1 but LIGHTLEVEL2 seems to have no effect.
The idea is both sensors need to detect two lights switching off at exactly the same time. If only one light switches off then the LED stays off.
Any help on this one will be appreciated. John
Read 2 Sensors at the same time
Moderator: Benj
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Read 2 Sensors at the same time
Hello John,
Are your components marked correctly? Could this be the cause of the problems your seeing.
Pot ADC(3) is marked LIGHTLEVEL1 and connected to pin AN0, however in your flow chart LIGHTLEVEL1 reads component ADC(0)
Pot ADC(0) is marked THRESHOLD1 and connected to pin AN2, however in your flow chart THRESHOLD1 reads component ADC(3)
LIGHTLEVEL2 references seems correct.
You shouldn't need the delays in between ADC reads if you want to sample multiple channels one after another at high speed.
If you want to check both ADC readings are below the threshold then you can use this in your decision icon.
Are your components marked correctly? Could this be the cause of the problems your seeing.
Pot ADC(3) is marked LIGHTLEVEL1 and connected to pin AN0, however in your flow chart LIGHTLEVEL1 reads component ADC(0)
Pot ADC(0) is marked THRESHOLD1 and connected to pin AN2, however in your flow chart THRESHOLD1 reads component ADC(3)
LIGHTLEVEL2 references seems correct.
You shouldn't need the delays in between ADC reads if you want to sample multiple channels one after another at high speed.
If you want to check both ADC readings are below the threshold then you can use this in your decision icon.
Code: Select all
(LIGHTLEVEL1 < THRESHOLD1) && (LIGHTLEVEL2 < THRESHOLD1)
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- 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: Read 2 Sensors at the same time
Hi John, in addition to Ben's comments,
If you press single step (F8) then within Variable window add all the variables by right click & select Add variable: You will see that the values are wrong when you turn pots confirming what Ben is stating.
During simulation, adding variables to watch is useful practice.
If you press single step (F8) then within Variable window add all the variables by right click & select Add variable: You will see that the values are wrong when you turn pots confirming what Ben is stating.
During simulation, adding variables to watch is useful practice.
Martin