05-29-2012 05:35 PM
Hi,
I'm working a a program to integrate two motion sensors near the entrance of a small tunnel for mice. I wanted to design a simple program to count how many time the mice is entering and leaving the tunnel. My logic is if the mice trigger sensor 1(channel 0) then sensor 2(channel 1), then we consider it +1 for the count for entering. We will count +1 for leaving the tunnel if the mice trigger sensor 2 then sensor 1. If the mice trigger the same sensor againg, that won't count as anything. To me, I have a hard time figuring out how to write this logic for the programming. The program below is just how I think they should structure with two case structures for the counting of entering and leaving. I'm struggling on how to write the logic to relate the data coming from the two sensors in order to connect to the case structure.
I'm thinking of creating a dummy variable that stay true if sensor 2 is trigger true and stay false if sensor 1 is trigger false. I don't know if this is a right approach, but I have trouble creating the logic for this dummy variable as well.
Thank you so much. Any suggestion is appreaciated.
05-29-2012 09:27 PM
The logic is more complex than you have considered. Mice do a lot of exploratory behavior - nose in, nose out. Get half way in then back out. And of course you need to detect the mouse going the other way. Do you want to keep a separate count for each direction?
How far apart are the sensors? Can the mouse activate both sensors simultaneously or only one at at time? Can the bedding or food or other material (mice do leave other material behind) activate a sensor? Is there a time limit? What if the mouse goes to sleep at a sensor? Are there ever two or more mice in the enclosure at one time? how will you handle the case where two mice meet in the tunnel? Can they pass each other in the tunnel? What if four or five go through as a tightly packed group? Are there multiple tunnels?
When I have worked on animal tracking devices, I have found that a carefully drawn flow chart showing every possibility is very useful. You may be surprised at how complicated it can be with just two sensors. It is similar to the logic for interpretting a quadrature encoder for rotary motion.
Also your VI should have some kind of timing. The loop runs as fast as possible, limited primarily by the DAQ Reads. How fast do you expect things to happen? You could read the port and get the data as an integer rather than using two separate Reads. This would be more expandable when you decide to add more sensor pairs. Once you get this working, someone will want more sensors. They always do.
Lynn