Read 2 Sensors at the same time

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
JDR04
Posts: 271
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Read 2 Sensors at the same time

Post by JDR04 »

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
Attachments
2 Beam Program.fcf
(10.5 KiB) Downloaded 441 times

User avatar
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

Post by Benj »

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.

Code: Select all

(LIGHTLEVEL1 < THRESHOLD1) && (LIGHTLEVEL2 < THRESHOLD1)

medelec35
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

Post by medelec35 »

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:
Light levels.png
(100.62 KiB) Downloaded 2926 times
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

Post Reply