-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bee counter that is based on state transition instead of elapsed time #17
Comments
Hey, I don't have an active hive right now either...
That's a great idea of sharing unfiltered data. I did capture some on
another laptop for just that purpose. I'll see if I can dig it up.
…On Mon, Apr 12, 2021, 4:02 AM svavassori ***@***.***> wrote:
First of all I'd like to thank you to put freely available the design of
the board and the code to run it.
Looking at the Arduino code I saw that your counter is based on time
threshold (200 ms and 600-650 ms) to avoid some bouncing in the reading.
This gave me the idea to try to detect the entering or the exiting pattern
in a way that is robust with respect to the bouncing of a *single* sensor
of the gate at a time. This gist (
https://gist.github.com/svavassori/431e78c2d9f1ff55adb63623408eb033 )
implements a state machine that detects the entering or exiting of a bee
for a gate, the extension to multiple gate can be easily done be extending
the State current[] array to the side desired.
Unfortunately I have no access to a beehive until some months, so I was
wondering about these two possibilities:
- if you could test it on your board (the integration shouldn't be
difficult) to see if it actually works, or
- if you could share some unfiltered captures of a single-gate sensors
(in-out) in order to have real sequences, so I can test it by myself and
see if it works.
Regards,
SV
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#17>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA3MOPGSXOUT6SIB3A3W6PTTIKSKJANCNFSM42YX36LA>
.
|
If you could find those, it would be awesome because it will also validate (or invalidate) the assumption of a single sensor change per gate. Let's hope for the best! |
Do you have any news about the raw capture of the gate? |
Hi, I am interested in the variant of the project, I have the system available on a hive from which I detect the data as a protocol created by hydronics2 ( very beautifull), you can check the data is as follows link : |
@rodece I saw you have almost 20k bees as difference between out and in count over a 24h period, that's really strange. Usually out count should be a little higher than in because bees are dying outside and are born inside, so you have a net flux from inside to outside, but what you got is way too big for a single day. Moreover it seems that the temperature sensor could be exposed to direct sunlight since it peaks at 11:00 instead of at 16:00-17:00 I don't have an Arduino here because I'm using an ESP32, but before plugging in the state machine, I would like to ask if you can run this sketch to get some raw data: https://gist.github.com/svavassori/37b6db89e4ab47f45748939dbb8f16b2, its output should be like:
It's a stripped down version of @hydronics2 one that prints to the serial line only the raw values of sensors at Gate 0 for each loop. In this way we can see how much debouncing (spurious state transition of the sensor) there are and if the precondition on which my solution is built is met (singe sensor transition at a time). If that condition isn't met, the current implementation will go in an error state and so wouldn't be of any use. The idea is to record what it is read from the sensor (a dozen of bees entering and exiting should be enough) in order to understand the timings and the cases that we face and then to find a solution to properly count the bees (or at least reduce the false counts to a number so small that it doesn't impact on the final result. Since gate 0 is the first one, probably it won't be so frequently used by the bees, so closing some other gates with a stick of wood for a couple of minutes can help in getting the results in a shorter time. :-) |
Yes, you are right, however in these days there was a high import, today the values are more correct.
The sensor is installed behind the hive, but the apiary is installed in a wood and the sun only comes around 12 o'clock I have two bee counters with feather M0, on the second I made the modification you requested and the data can be found in: |
@rodece, thanks for your files, they have been very helpful to do an offline analysis. As first I tried to run the state-machine as it is but it got stuck too many times to be happy with, so I changed its behavior to reset itself when the gate comes empty again: in this way it doesn't block and just skip the problematic parts. Unfortunately, by doing some stats, it came out that it counted:
This means a 41% of sequences aren't handled properly, and that is not a good number, so probably my assumption of a single-change isn't that right. Then, I calculate the time it took for each detected bee to pass through the gate, in order to have an idea of the time it needs and the results are interesting, I plotted them in this simple frequency chart: As it can be seen, filtering below 650 ms it would cut out more than 20% of the counted bees (13 over 56), so at least the idea of being time-independent does make sense, because of the variance of the distribution. Another interesting thing of the raw data is that it can be seen there are some bees on the inside that check the gate (starts from the inside but then go back) while the bees that are coming in are pretty resolved and traverse the gate without too many doubts. About tightening the gate, in order to let the drone pass you could tighten just the first and leave some others open. Of course this will imply we aren't counting all the bees, but just to test if it reduces the errors it could be enough. I saw you uploaded the videos (thanks a lot!), I'll take a closer look later on, but at least they validate that it was mainly an incoming traffic. At first sight, in one of them it seems there are two bees entering at the same time, would that be possible or it's just the point of view of the camera? |
I had a look at the size of the gate on the PCB schema and compared with other references: I think the gate is definitely too big and bees could probably pass on the sides without being detected by the sensors. From the schema, the gate should be 9.85x15.3x8.4 mm (WxLxH) while the two sensors are around 2 mm wide, this means there is 4 mm on each side that can be used by the bee. Could you please check those measure (9.85x8.4) matches the build one? Looking at this image, it can be seen how much space there is. As reference, the classical metallic entrance has gates of 7.8x7 mm (WxH) and the grid of the queen excluder is spaced 4.1 mm, so if the above measures are correct, it means the gate should be shrunk by 1.1 mm on each side; some black tape should be enough for testing. It could be that also the bottom would benefit of 1 mm lift, in order to avoid two bees passing on top-bottom, but first I would prefer to see how the counter behaves only with shrinking. This top-bottom dual-passing can be observed in the video @hydronics2 shared at second 13: in the center of image, in the gate right under the yellow capacitor, a bee with pollen on her legs is entering and while she is still in the gate, another bee exits from the top |
@svavassori |
In In In When you will do your next Saturday test, I would also ask if you can change in the Arduino code the last |
I make a tests, find the results on |
I saw from the videos that with the tube it seems they slips and it is problematic for them to enter upside down.
Sure, with less traffic should perform much better. Thanks for the new dataset, here is the relative frequency chart: This confirms two things:
A gate traversal in 50 ms is very unlikely to be a real bee (walking 20cm/s is too fast), so anything below 100 ms would be suspicious, and probably is due to two bees at each side of the gate that accidentally trigger a sequence that matches an inbound (but it could be an outbound as well). Nonetheless this is not a big problem since it can be easily filtered by doing some stats and see what is a reasonable minimum time to get through the gate. On the other hand, that false positive made me think about the impossibility to guarantee a false positive free counter with a two sensor gate: two bees could just stay there for the right amount of time to be in the "likely" range and there will be no way to distinguish it from a real arrival or departure. It shouldn't impact a lot on the big numbers because I suppose it would average to zero between false arrivals and false departures and it will mostly happen when there is "traffic jam", but it is an intrinsic limit of this solution. That led me think about using 3 or 4 sensors (inline) per gate: it should resolve this problem and probably, by using 4, it will also be able to differentiate:
It is possible that (2) could be exposed to a false positive in case two bees exits one after the other; hopefully in the majority of cases there will be a space between the two bees big enough to trigger an empty state in one of the inner sensors (at 10cm/s, 10ms is 1mm). Unfortunately adding more sensors requires a new design and fabrication, so I looked around and it seems that nobody implemented it in that way. I don't know if @hydronics2 had any experience with that or if adding more sensors per gate simply increases complexity and cost without giving any major benefits. |
Beautiful analysis !!!!
To check the speed I built a gate with the millimeter band, the videos can be found on:
If you want I built a gate prototype with 4 sensors, see video, I could connect the first two on port 1, as originally, and the second pair on port 2 of the bee_counter. |
Thanks for the videos, I'll calculate bee's speed during this weekend. It will take me a while but at least we will have some real data about bee's speed. A thing I noticed by having a quick look at them is that a longer tunnel increases the chance two bees enter in different directions and one "wins" by pushing the other back :-) By the way, I don't know if it's something that is depending on my VLC or other, but all the videos you uploaded start only with audio, then the video appears after 7-8s.
That would be really nice to try out! About the 4 sensor prototype, if you are able to connect those sensors to gate 0 and 1, we can read all 4 and it will cover the 3 sensor variant (by simply ignoring one of the outermost). If I got it right the mapping will be something like this, please let me know if it's different: inner -> inner gate 0 This is the modified gist that reads from gate 0 and 1: https://gist.github.com/svavassori/7fc9af576663dc35193071d04cc8e4cf Can you please measure the length of the 4 sensors? This is to double-check the queen case and if two bees can trigger it. |
@svavassori really nice analysis. I went down a similar rabbit holes (design thinking) about the bee counter. You've done a great job articulating the design thinking. @rodece thanks for providing all the data and work! Uneven Bees count IN vs OUT
Bee Speed Through The Gates
Size of gates
More sensors in the gates
@svavassori / @rodece it was great to hear you work through some of the problems/fixes/prototyping I was working on over the years. great job! |
@svavassori ; tested the prototype with 4 sensors, the videos and logs can be found on:
I had used VLC for the conversion and saw that it was losing the first few seconds of the video, now I have used another converter and it works.
The distance between the sensors is 5 mm. The size of the gate are 8 x 8 mm.
I confirm that the sequence is correct @hydronics2 |
I'm sorry for all these days of silence but the analysis took me more time than expected. @hydronics2 it's nice to hear you again!
Actually I was referring to the whole length of the 4-sensor row. :-) About the analysis, first I mangled a little the video (crop, rotate, enlarge and extract frames) in order to read more easily the different positions for each bees and I collect a total of 58 sequences with various length. As it can be seen, the top speed is about 12 cm/s but it cannot be sustained through all the length of the gate, so it cannot be used as maximum average speed. My initial idea was to integrate the speed for each bee to find the space as a function of time and then invert that function to calculate how much time would have been needed to traverse a gate of a given size according to the possible initial positions.
According to these data, it seems that in the best case (small bee and small gate) the minimum time to pass through the gate is 200 ms, but looking at the frequency chart I find a little odd that 100 and 150 ms are false positive and 200ms are good since they have the same frequency. In addition I had a look at the new 4-sensors gate data to see if that would make sense and I found this sequence that shouldn't happen: inner sensors are occupied without having passed through outer sensors.
At first I thought of a possible light leak from the other sensors of the board, but as it can be seen here, the board doesn't have any sensor attached to it, so they cannot leak. That made me think that maybe the @hydronics2 schema is correct from the receiver point of view, but not for the emitter+receiver system. With that I mean that since each sensor is composed by the emitter and the receiver, the IR light reflection point should be in the middle of the two, and under normal condition, it doesn't leak in the other receiver, so it could be that the actual sensing area is smaller than I though. For this reason, in order to estimate the actual sensing area of the 2-sensor and 4-sensor gate and to shed some light on the possible causes of that strange behavior, I would ask if @rodece could you do this test (it doesn't need the hive):
With this we can control what is happening at each moment when a bee is entering and hopefully understand better what is going on. |
Great analysis again !!! :-)
The measurement between the beginning of the first sensor and the end of the last is 16 mm. I made the tests you requested, the results on: The activation distance of the first sensor is 1 mm. |
Thanks for the quick response and videos! About the bees' logged data, they are exactly the same file and it seems they refer to the first one (1 bee "slow"), maybe it has been a copy/paste problem from output of the serial port. Nonetheless it has been useful to find out that the two gates aren't working the same way.
I observed that also in the some previous captures, so it isn't by chance, and it is kind of problematic because if the bee can trigger up to 3 sensors, it should always trigger two, unless they are spaced unevenly. This makes me think that the leftmost sensor could be oriented slightly different from the others (looking outward). The aim of the test is to understand at which distance each sensor is triggered (1 or 0), so the timing is of second importance. The following diagram should help to better explain the setup: The millimeter paper should be put under the device and aligned with the gate and the moving strip to minimize errors when reading the distance. Once the bee is at the gate entrance, so before the first sensor is triggered, you can mark on the mm paper that point as reference for zero distance and then, with a 1 mm step (or less if possible) push the strip inside the gate and mark each time there is a change in the sensors ( The result of the test should be a table like this:
With that table and knowing the length of the bee and the sensors' length, it possible to understand the actual sensing area of the sensors. Extra points if you want also to repeat the test with a 1 mm thick white strip (like the one at the bottom of the image) instead of the bee to increase the resolution :-) |
I've seen it too, unfortunately github only accepts files no larger than 20 Mb, so I had to convert them with youtube.
I did the tests you requested and these are the results: with 15 mm long bee
with 1mm white line
If you need other tests, I'm available ;-) |
That is a limitation of the GitHub web interface, with the command line the limit is 100 MiB per file. About the tests, it has been useful to have both and with this information it can be deduced the length of the bee as seen by the sensors, the detection area for each sensor and if they overlaps or have blind spots. This is the first table shown in a graphical way: Each row generates a set of constraints on the bee size:
It turns out that:
If the bee is detected by the sensors with a length of 8-9 m while it should be 15 mm this can be explained by two possible reasons:
@rodece could you please tell us in which case are we? Another thing that I noticed is that in this test, we didn't observe the single-triggered sensor ( |
As always great analysis ..... ;-)
Correct is the n.2, I have measured the bee and the value is 15mm.
No, I have not made any changes but I noticed that sometimes the log stopped, I restarted the pc and now it seems to work regularly I have made a new tests you can find in I also uploaded the photo of the test bees. |
Thanks for the files, what it puzzles me is why do we have a single triggered sensor when there are two bees, it seems it's related to the length (from the photo the second one is shorter than the first) but not always and it seems to happen more frequently on the rightmost gate. Here below is the image @rodece uploaded with marks of 8.5 mm length, that is what are detecting the sensors and this impacts also the estimation of the minimum time to traverse the 2-sensors gate, that for a 8 mm "bee" is around 140 ms. This made me wonder if is only the slope of the abdomen that is scattering out the IR light or is also the color. If the color has a role, I would expect the head shouldn't be detected, especially for the leftmost one. So, if I may @rodece ask you another tests: could you please with a single bee do again the distance/sensors table and without moving the bee cutting its head and redo again the test starting from the same mark (such that the body starts at the same position in each round)? The leftmost one is better because it has a darker head and thus will give a stronger proof. The second test is similar but using the rightmost bee and cutting its abdomen, so in the end there should be 4 tables:
In this way we can check what are the parts of the bee that are seen best by the sensors and verify if they aren't triggered only because of the slope or also because of the color. @hydronics2 have you thought to use some sensors similar to SX1070 (i.e. transmissive instead of reflective)? I don't know if it would give better results but its sensing should be independent of the shape and color of the bee. |
|
Unfortunately, I no longer have the bees from the previous tests available, I still added new bees as you requested, the photos can be found on: https://github.com/rodece58/contavoli/tree/main/test_28_07 test results:
as you can see the test 1 bee with and without head the result is the same, clearly changes completely with bee without abdomen.
A further problem is that according to the breed of bees the color also varies, for example the "ligustica" bee has a light color, while the "Carnic" bee has an almost black color. I live in the north east of Italy where both breeds are present and above all hybrids that have, in most cases, color as shown in the photo.
I used a 120 cm cable to connect the test sensors. , could it affect the results?
If you want I can see to provide 4 sensors to do the test, I check the characteristics to make the changes. |
Thanks @rodece for the quick testing.
I think we all agree looking at the test results, the head isn't detected at all, since there is no difference in the first two tables. In the second case, the abdomen is partially detected because it does show some differences, even if it's noisier than the first, so color and shape does have an impact on the sensor's ability to detect the bee.
From my understanding, if it has any effect, it will be the same on both gates, so the sensors will work under the same conditions.
You are right but fortunately it will mostly happen when there is high traffic, so in general I would expect it to be negligible when all gates are open and we are at least counting one of the two. Probably it will get worse with the 4-sensor gate.
I just have basic knowledge of electronics, so I don't know if the SX1070 is the best the market can offer for this job: any other options are welcomed. I found it on this short article: their approach is more hardware-based (FPGA) than software-based (as ours) and there is no in-field validation since it has been left as future task. However I wasn't able to find the following paper. |
That's interesting feedback. I wonder if there's a difference if the bees crawl across the sensor up-side-down. I know this happens quite often but I've never tried to measure the difference.
There's a 560uF capacitor on the board but even with this extra energy source.... I saw a definite difference in the IR LED strength between gate 1 and gate 24. Gate 1 triggered slightly easier than Gate 24 because the LED was pulse was greater as it was closer to the triggering mosfet and apparently less voltage drop from signal trace resistance.
I like the idea of trying a 'gate' type sensor but I'm not so motivated to do a redesign at this point. Usually FPGAs are used when you require super fast sensor response so it's curious that was their choice. As we've seen with this project, honey bees aren't super quick :) |
I have to admit I haven't thought about that even if we saw it, that is an interesting observation. My take is that it should give a stronger signal with respect to the "classical" crawl because the bee is closer to the sensor and there aren't big differences in color on both sides. Moreover the bottom is mostly flat.
I could be wrong, but I remember the original board to be empty, so the only voltage drop should be the ohmic one of the cable (0.02 V maybe)?
I prefer to write software, so don't worry, I won't ask any FPGA redesign: it was only to show where the sensor came from :-) |
I ordered some sx1070 sensors, I saw the electrical characteristics and they are similar to the ones installed now, apart from the different connections, as soon as they arrive I try to install 3 or 4, I would say at a distance between the first and third of 17 mm. ?? |
SX1070 arrived. |
Good job with the new sensor's type! I will have a deeper look at it this weekend, but by the quick look, it seems some sequences are chopped:
It may depend on height of the bee. Have you tried, or do you see it as feasible, to put the sensor vertically? Just to understand if it will improve detection or if that doesn't depend on the orientation. |
Hello all, I looked again to the data and unfortunately all the sequences are incomplete or broken in the middle. In addition, this is a confirmation that the longer the gate, the stronger the tunnel effect is (two bees entering the gate at the same time and colliding). What puzzles me most is the spurious reading on the outer gate, there are a lot of transition @rodece How hard would be to put all the 4 sensors one next to the other without any space in between in order to reduce the total length of the gate from 32 mm to 24 mm and the sensed one from 26 mm to 18 mm? A second test would be to build one gate with just two sensors to evaluate how much is the actual improvement with respect to the reflective one. In that case, the distance between the two beams would be 6 mm and the total gate length would be 12 mm, so a little shorter than the original from @hydronics2 |
This weekend I found this interesting article from the 90s: Microprocessor-controlled monitoring of honeybee flight activity at the hive entrance by Marc Struye. It seems one of the most accurate articles that talks about the accuracy and the parameters that affect bee counting. What caught my attention is that:
It was covered by a patent BE1011050A6 that I think it is expired now, so there shouldn't be any problem about intellectual property. In Abeilles & Cie nº 68 - 1/1999 at page 8 and 9, it reports a 1.76% mortality on July, 3rd and the table has an average of 3% in the first part of August with good weather, then it increases up to 9% with bad and cold weather (also going to the end of September). Another partial reference that I found from the same author is Possibilities and limitation of monitoring the flight activity of honeybees by means of BeeSCAN bee counters, extracted from Hazards of Pesticides to Bees: Avignon (France), September 07-09, 1999 that shows the following table: Here are the result of the so called robbers test: in that test an empty beehive containing some honey is monitored with the counter. Obviously bees that entered will exit or have died inside, so by inspecting the empty beehive at the end of the day to count the died bees (d), the counter error can be assessed. I think those numbers are sound even if it's it's hard to draw the precise line between real mortality and counter error. All this, together with the tunnel effect we are seeing by adding more sensors, made me think that the shorted the gate, the better it is.
@rodece if you are willing, we could test before season ends the two-sensors per gate board with all gates opened, using the state-machine enabled and the minimum time-traversal cutoff to check how performs compared with the standard one and the one of the article. |
Hi, I contacted a company that builds electronic boards and I asked if they can find the dualir to do the tests. The season is now over, but there are still bees coming out on hot days, so I would have no problem testing the new software, if you want I can load it on the couter that I currently have in service in the apiary. |
Hey, also apologize for missing your email.
Wow... that is a great paper. Probably the best paper I've read discussing
some of the issues with bee counting.
- They are using an IR break type sensor (emitter and receiver on opposite
sides)...specifically they're using one emitter LED and two sensors spaced
slightly apart.....
- That sensor was more widely used just 10 years ago...where as this
counter uses an IR reflective type.
- IR reflective is easier to build on a PCB... whereas break type sensors
require placement of emitter/receiver on opposing surfaces (perhaps two
circuit boards facing each other) increasing cost/complexity
- Regardless of sensor type.... having the sensors close together is a good
technique to count quick moving bees or bees lined up in quick succession..!
- As an aside, the reflective IR requires the IR light to reflect back into
the sensor and because the bee is not a perfect reflector (the bee is not
white) the IR sensor creates a bit more noise that has to be dealt with.
Hole size and queue-break (what a great word!)
- decreasing hole size is with a queue-break makes a lot of sense and
forces bees one at a time through the sensor(s)
- decreasing hole size also increases blockages with dead bees as they
mention in the article
- requires more frequent checks and cleaning
- if we used a queue-break, the bee-counter could alert you to how many
gates are blocked each day to signal cleaning
The current hole size is about 10mmWx9.5H... reducing this down to 7.5mm
(wide) would be interesting to see and probably wouldn't result in too much
blockage. I forgot, have you tried a reduction in hole size using shims or
something?
I like the way the graph the data. You can really get a good idea of how
the peaks line up... that is; bees taking pretty short flights... within
say ~20min
[image: image.png]
…On Mon, Oct 25, 2021 at 4:55 AM rodece ***@***.***> wrote:
Hi,
sorry for the delay, very interesting the article you linked, as you can
see the errors in the counts are very small.
I contacted a company that builds electronic boards and I asked if they
can find the dualir to do the tests.
The season is now over, but there are still bees coming out on hot days,
so I would have no problem testing the new software, if you want I can load
it on the couter that I currently have in service in the apiary.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#17 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA3MOPHZJYIYBCRE6DDXR7DUIVATJANCNFSM42YX36LA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
@rodece here is the gist with the state machine version for all 24 gates. I didn't run it, so you may need to tweak the delay at the end to match 100Hz as sampling frequency and maybe tweaks some bits here and there. It has a 130 ms threshold as minimum time for traversing the gate. It could be that during winter you don't need to shrink all the gate as we did in our tests, but it would be better to have it done by spring. I suppose it will work well for the time being since I don't expect too much traffic. It will be interesting to compare the performance of the counter during winter and spring to understand at which threshold the error starts getting out of control. |
Hi, typedef enum { were LOW and HIGH states have other functions on Arduino sketch. I tried to edit but for my knowledge it is too complicated :-) |
Here is the new version of the gist that should compile on Arduino. Changes:
|
Hi Sergio, good work !!! I take this opportunity to wish you and Thomas the best wishes for a Merry Christmas and a Happy New Year!!!! |
Hi rodece, First of all my best wishes for new year. Thx in advance |
Hi svavassori and thomas!!! |
Hello @rodece Here is today's data plotted one over the other: The good news is the two curves have the correct phase, namely bees first go out and then come back in, but you are right about the difference in value between in and out. As a wild guess, I can think the difference in traversal behavior we saw between inbound (go straight in) and outbound (checking the gate or thinking next it) plays a role here, under-counting the out ones. About tuning the two values, the filtering threshold could be reduced to 100ms but I don't think it would make a big difference, since we saw that the bee cannot traverse the gate that fast and in addition the problem is on outbound, so they are even slower there. What I would do is to reduce the reporting time from 30 minutes down to 5 minutes to see if there is some pattern we miss (it can be aggregated later to a wider one if needed). Another data that may be useful to collect is the number of errors for inbound and outbound sequences with the same resolution as above: these can give us an idea of where we are losing some counts. |
Hi Sergio,
I have modify a sketch but not working correct, I have insert this line : 'else if (current == START_EXITING) but the result in test is this: IN : 3; OUT : 3; more transits are counted in the middle trans. |
Hello @rodece I didn't understand exactly the change you applied to the code, but as example of what I was meaning, you can find the updated gist: it will print also the errors (in/out) each time a counter changes, so be prepared for a much higher output on the serial console. Let's see if we can figure out the reason for that difference, because more than a diagnosis, mine was only an hypothesis that has to be verified :-) |
Hello @svavassori My name is Paul and have installed the state machine software with the errorcounters running. I observe the same problem as rodece. I want to diminue the delay to 7. Therefore my question is how can i measure loop time from delay to delay? |
You can measure the loop time in any point of the loop, since it is a constant. An easy way is to do it is when the time is read with this call: currentTime = millis(), nonetheless I wouldn't expect any significant improvement going down to 7ms. For what I can see from your data, you don't have the same problem as @rodece but exactly the opposite: you have more bees going out that coming in. To some extends this is expected since bees born only inside and usually they die outside, but the magnitude is to big. One thing to understand is why your in error is more than the double of the out error. |
Hello @svavassori The reason is that there were a lot of in/out errors due to the fact (probably) that only 6 gates were open to the bees on the outside but still accessible on the inside. I remove the obstruction making all 24 entrances available to the bees. I did this at 13:00 and the rest of the day counting has dramaticaly improved (also the error counters went drastically down). I found the millis function and used it to trim down the delay to 8 ms. I tried to figure out if i could count a train of bees (1,2,3,4...) but i am confused with the content/use of the transition_table and next_state function and how it can be eventually used in this matter. |
Hello @svavassori I also noticed that inbound pattern differs from outbound pattern. I cannot figure out why this is? |
Hello @claespol If you want to close some gates, it is better to close them from both sides or filter them out then looping on the gates About the transition_table, it is a classical implementation of a state machine in which the current state and gate's values (array indexes) tells you which is the future state (array value). |
Hello @svavassori |
Hi Sergio, Hi Paul, welcome into the group, I am also a novice 64Yrs.......... ;-) ;-) |
Hi Sergio, |
Hello all, I'm sorry for the delay but these have been busy weeks. Looking at @rodece data, they confirm that outbound error are roughly the double of inbound errors. I summed all inbound events (correct entering + errors) and outbound events to understand if it was just a problem of detecting the sequence or if there is something else. As shown in the chart, inbound events are more that outbound, and this is really unexpected. This is problematic because given that:
I would expect exactly the opposite result. The only reason I can think of is of some bees queue that is counted as one while exiting and then they are properly counted when entering. I don't know how difficult would be to create a queue breaker similar to the one done by Marc Struye, but that may help improving the error ratio or at least, excluding the queue as possible cause. On the other hand, we still have a very high error rate compared with the total traffic and this means we need to understand in which case an error is detected and see if it is possible to match that sequence in some way or if it is beyond the capability of a 2-sensor gate. In order to do that, we need to have a video of the bee passing synchronized with the serial output of the gate. Nonetheless then there is still the problem to have a good close-up of the gate to view bee's movement and have the recording (as fast as possible) synchronized with the serial output of the microcontroller. As a matter of fact, since we are sampling around 100 Hz, even a 0.1 s of difference would mean a 10 sample offset. |
Hello @svavassori |
hello @svavassori The two channels with the counters |
The problem you raised is a known limitation of the 2-sensor gate, you can find more details up in the messages of this issue. This is not a limitation of the implemented state-machine, but is about the information the 2-sensor gate can give. With 2 binary sensors you can have 4 possible outputs, so it means that from each state you have 4 future states: some of them are meaningful (e.g. 01 > 11) while others are not (e.g. 01 > 10) in our case. We thought about a 4-sensors gate in order to overcome this problem and to have more information about the bee's position and movement, but it turns out there is a tunnel effect that makes things worse. So in the example you brought, the first case will be considered as an aborted exit (00 > 10 > 11 > 10 > 00), and it won't count anything (even though a bee is actually entered) while the second will be considered an exit (00 > 10 > 11 > 01 > 00) and it will be counted as such. The problem we are trying to tackle is to reduce the actual reported errors: the machine doesn't recognize the sequence as a valid one, so we need to understand if this is a result of the erratic movement of the bee inside the gate and if it would be detectable or not with a 2-sensors gate. |
Hello all, I was wondering how would be affected the error rate (1 out 8) if we increase in a significant way the sampling rate. To do that in a safe way:
With these settings we should get close to 500 Hz sampling frequency. I'm not an expert, but looking at the LED datasheet it reports a 5us rise time with 200Ω load resistance in series.
to reach 1kHz sampling frequency? |
hello @svavassori |
Hi Sergio
I could not change the delay to 15us because after two transit the system no longer counted the steps, the optimal value I found is 40us. There are not many transits on doors 1 - 12 the bees now prefer to use doors 15 to 24 .... |
@claespol The goal is to understand if the ratio between errors and correctly counted bees changes with the sample frequency or not. If it is dependent, I would expect a reduction of the ratio (less errors) by increasing the frequency; if it is not, then we know that ratio is probably given by the way the gate is build (e.g. distance between sensors). Nonetheless I don't expect any major improvements: it is like "let's throw all the power we have to see if it changes something" test. @rodece do you mean that even if the For the test, it should not matter if the powered gates are the first 12 or the last 12, so you could just comment |
First of all I'd like to thank you to put freely available the design of the board and the code to run it.
Looking at the Arduino code I saw that your counter is based on time threshold (200 ms and 600-650 ms) to avoid some bouncing in the reading.
This gave me the idea to try to detect the entering or the exiting pattern in a way that is robust with respect to the bouncing of a single sensor of the gate at a time. This gist ( https://gist.github.com/svavassori/431e78c2d9f1ff55adb63623408eb033 ) implements a state machine that detects the entering or exiting of a bee for a gate, the extension to multiple gate can be easily done be extending the
State current[]
array to the desired size.Unfortunately I have no access to a beehive until some months, so I was wondering about these two possibilities:
Regards,
SV
The text was updated successfully, but these errors were encountered: