manchester encoding avoids the necessity of a clock for >8 serial bits. asynchronous data (using a UART) resychronizes every byte using Start and Stop bits
yes but its also mandatory
something maybe like this?
currentBitState = digitalRead(inputPin);
// If the bit state changes (edge detection), record the bit
if (currentBitState != lastBitState) {
lastBitState = currentBitState; // Update the last bit state
// If it's a HIGH-to-LOW transition, consider it as a '0', LOW-to-HIGH as a '1'
char bitChar = (currentBitState == HIGH) ? '1' : '0';
bitBuffer += bitChar;
that looks a bit like what youve made
but what do i do when for example the timing isnt good enough? Do i just change the bitrate at the start of my code and try untill it works?
OIC. Thanks for the clarification. Maybe it is now when a professor "suggests" something it is to be interpreted as mandatory. Or maybe it was explicitly mandated.
a7
this could capture both rising and falling the transitions, which i believe are necessary, but there can be 2 transitions per bit.
looks like Machester requires that the first bit is a one, allowing the receiver to determine the bit half-period from the first pair of transitions.
i'm trying to understand the by simulating code on my latop using the values i used to produce those plots. here's the text data. there's a transition when the y value (2nd column) changes. the value is msec
thickness = 1.5
color = green
next
anno 100 4.0 1
0 5.00
100 5.00
100 4.40
200 4.40
anno 323 4.0 1
200 5.00
323 5.00
323 4.40
447 4.40
anno 609 4.0 1
447 5.00
609 5.00
609 4.40
772 4.40
anno 962 4.0 1
772 5.00
962 5.00
962 4.40
1151 4.40
anno 1322 4.0 1
1151 5.00
1322 5.00
1322 4.40
1492 4.40
anno 1623 4.0 1
1492 5.00
1623 5.00
1623 4.40
1754 4.40
anno 1857 4.0 1
1754 5.00
1857 5.00
1857 4.40
1960 4.40
anno 2058 4.0 0
1960 4.40
2058 4.40
2058 5.00
2156 5.00
anno 2273 4.0 0
2156 4.40
2273 4.40
2273 5.00
2390 5.00
anno 2544 4.0 1
2390 5.00
2544 5.00
2544 4.40
2699 4.40
anno 2886 4.0 0
2699 4.40
2886 4.40
2886 5.00
3073 5.00
anno 3251 4.0 0
3073 4.40
3251 4.40
3251 5.00
3429 5.00
anno 3567 4.0 0
3429 4.40
3567 4.40
3567 5.00
3706 5.00
anno 3813 4.0 1
3706 5.00
3813 5.00
3813 4.40
3920 4.40
anno 4017 4.0 0
3920 4.40
4017 4.40
4017 5.00
4114 5.00
anno 4225 4.0 1
4114 5.00
4225 5.00
4225 4.40
4337 4.40
anno 4483 4.0 0
4337 4.40
4483 4.40
4483 5.00
4629 5.00
anno 4811 4.0 0
4629 4.40
4811 4.40
4811 5.00
4994 5.00
anno 5178 4.0 0
4994 4.40
5178 4.40
5178 5.00
5361 5.00
anno 5508 4.0 0
5361 4.40
5508 4.40
5508 5.00
5656 5.00
anno 5767 4.0 1
5656 5.00
5767 5.00
5767 4.40
5879 4.40
anno 5976 4.0 0
5879 4.40
5976 4.40
5976 5.00
6074 5.00
anno 6180 4.0 0
6074 4.40
6180 4.40
6180 5.00
6286 5.00
anno 6424 4.0 0
6286 4.40
6424 4.40
6424 5.00
6562 5.00
anno 6739 4.0 0
6562 4.40
6739 4.40
6739 5.00
6916 5.00
anno 7103 4.0 1
6916 5.00
7103 5.00
7103 4.40
7290 4.40
anno 7446 4.0 0
7290 4.40
7446 4.40
7446 5.00
7602 5.00
anno 7720 4.0 0
7602 4.40
7720 4.40
7720 5.00
7837 5.00
anno 7935 4.0 1
7837 5.00
7935 5.00
7935 4.40
8034 4.40
anno 8136 4.0 0
8034 4.40
8136 4.40
8136 5.00
8239 5.00
anno 8369 4.0 1
8239 5.00
8369 5.00
8369 4.40
8498 4.40
anno 8668 4.0 0
8498 4.40
8668 4.40
8668 5.00
8838 5.00
anno 9027 4.0 1
8838 5.00
9027 5.00
9027 4.40
9217 4.40
anno 9381 4.0 0
9217 4.40
9381 4.40
9381 5.00
9545 5.00
anno 9669 4.0 0
9545 4.40
9669 4.40
9669 5.00
9794 5.00
anno 9894 4.0 1
9794 5.00
9894 5.00
9894 4.40
9994 4.40
anno 10094 4.0 0
9994 4.40
10094 4.40
10094 5.00
10194 5.00
anno 10316 4.0 0
10194 4.40
10316 4.40
10316 5.00
10439 5.00
anno 10601 4.0 1
10439 5.00
10601 5.00
10601 4.40
10763 4.40
anno 10952 4.0 1
10763 5.00
10952 5.00
10952 4.40
11140 4.40
anno 11312 4.0 1
11140 5.00
11312 5.00
11312 4.40
11484 4.40
anno 11616 4.0 0
11484 4.40
11616 4.40
11616 5.00
11748 5.00
anno 11851 4.0 0
11748 4.40
11851 4.40
11851 5.00
11955 5.00
anno 12053 4.0 0
11955 4.40
12053 4.40
12053 5.00
12150 5.00
anno 12267 4.0 0
12150 4.40
12267 4.40
12267 5.00
12383 5.00
anno 12536 4.0 1
12383 5.00
12536 5.00
12536 4.40
12690 4.40
anno 12876 4.0 0
12690 4.40
12876 4.40
12876 5.00
13063 5.00
anno 13241 4.0 0
13063 4.40
13241 4.40
13241 5.00
13420 5.00
anno 13560 4.0 0
13420 4.40
13560 4.40
13560 5.00
13700 5.00
anno 13807 4.0 0
13700 4.40
13807 4.40
13807 5.00
13915 5.00
anno 14012 4.0 1
13915 5.00
14012 5.00
14012 4.40
14109 4.40
anno 14219 4.0 0
14109 4.40
14219 4.40
14219 5.00
14330 5.00
anno 14475 4.0 0
14330 4.40
14475 4.40
14475 5.00
14620 5.00
anno 14802 4.0 1
14620 5.00
14802 5.00
14802 4.40
14984 4.40
anno 15168 4.0 0
14984 4.40
15168 4.40
15168 5.00
15352 5.00
anno 15500 4.0 1
15352 5.00
15500 5.00
15500 4.40
15649 4.40
anno 15761 4.0 0
15649 4.40
15761 4.40
15761 5.00
15874 5.00
anno 15971 4.0 0
15874 4.40
15971 4.40
15971 5.00
16068 5.00
anno 16174 4.0 0
16068 4.40
16174 4.40
16174 5.00
16280 5.00
anno 16416 4.0 1
16280 5.00
16416 5.00
16416 4.40
16553 4.40
anno 16729 4.0 0
16553 4.40
16729 4.40
16729 5.00
16905 5.00
anno 17093 4.0 0
16905 4.40
17093 4.40
17093 5.00
17281 5.00
anno 17438 4.0 0
17281 4.40
17438 4.40
17438 5.00
17594 5.00
anno 17713 4.0 0
17594 4.40
17713 4.40
17713 5.00
17832 5.00
anno 17930 4.0 0
17832 4.40
17930 4.40
17930 5.00
18028 5.00
anno 18131 4.0 0
18028 4.40
18131 4.40
18131 5.00
18233 5.00
anno 18361 4.0 1
18233 5.00
18361 5.00
18361 4.40
18490 4.40
anno 18659 4.0 1
18490 5.00
18659 5.00
18659 4.40
18828 4.40
anno 19017 4.0 1
18828 5.00
19017 5.00
19017 4.40
19207 4.40
anno 19372 4.0 1
19207 5.00
19372 5.00
19372 4.40
19537 4.40
anno 19662 4.0 1
19537 5.00
19662 5.00
19662 4.40
19788 4.40
anno 19888 4.0 1
19788 5.00
19888 5.00
19888 4.40
19989 4.40
anno 20088 4.0 1
19989 5.00
20088 5.00
20088 4.40
20188 4.40
anno 20309 4.0 0
20188 4.40
20309 4.40
20309 5.00
20431 5.00
anno 20592 4.0 1
20431 5.00
20592 5.00
20592 4.40
20753 4.40
anno 20941 4.0 1
20753 5.00
20941 5.00
20941 4.40
21130 4.40
anno 21303 4.0 0
21130 4.40
21303 4.40
21303 5.00
21476 5.00
anno 21609 4.0 1
21476 5.00
21609 5.00
21609 4.40
21742 4.40
anno 21846 4.0 1
21742 5.00
21846 5.00
21846 4.40
21949 4.40
anno 22047 4.0 0
21949 4.40
22047 4.40
22047 5.00
22145 5.00
anno 22260 4.0 1
22145 5.00
22260 5.00
22260 4.40
22375 4.40
anno 22528 4.0 1
22375 5.00
22528 5.00
22528 4.40
22680 4.40
anno 22866 4.0 0
22680 4.40
22866 4.40
22866 5.00
23052 5.00
color = cyan
next
anno 100 2.0 1
0 3.00
100 3.00
100 2.40
200 2.40
anno 323 2.0 1
200 3.00
323 3.00
323 2.40
447 2.40
anno 609 2.0 1
447 3.00
609 3.00
609 2.40
772 2.40
anno 962 2.0 1
772 3.00
962 3.00
962 2.40
1151 2.40
anno 1322 2.0 1
1151 3.00
1322 3.00
1322 2.40
1492 2.40
anno 1623 2.0 1
1492 3.00
1623 3.00
1623 2.40
1754 2.40
anno 1857 2.0 1
1754 3.00
1857 3.00
1857 2.40
1960 2.40
anno 2058 2.0 0
1960 2.40
2058 2.40
2058 3.00
2156 3.00
anno 2273 2.0 0
2156 2.40
2273 2.40
2273 3.00
2390 3.00
anno 2544 2.0 1
2390 3.00
2544 3.00
2544 2.40
2699 2.40
anno 2886 2.0 0
2699 2.40
2886 2.40
2886 3.00
3073 3.00
anno 3251 2.0 0
3073 2.40
3251 2.40
3251 3.00
3429 3.00
anno 3567 2.0 0
3429 2.40
3567 2.40
3567 3.00
3706 3.00
anno 3813 2.0 1
3706 3.00
3813 3.00
3813 2.40
3920 2.40
anno 4017 2.0 0
3920 2.40
4017 2.40
4017 3.00
4114 3.00
anno 4225 2.0 0
4114 2.40
4225 2.40
4225 3.00
4337 3.00
anno 4483 2.0 0
4337 2.40
4483 2.40
4483 3.00
4629 3.00
anno 4811 2.0 0
4629 2.40
4811 2.40
4811 3.00
4994 3.00
anno 5178 2.0 0
4994 2.40
5178 2.40
5178 3.00
5361 3.00
anno 5508 2.0 0
5361 2.40
5508 2.40
5508 3.00
5656 3.00
anno 5767 2.0 0
5656 2.40
5767 2.40
5767 3.00
5879 3.00
anno 5976 2.0 0
5879 2.40
5976 2.40
5976 3.00
6074 3.00
anno 6180 2.0 0
6074 2.40
6180 2.40
6180 3.00
6286 3.00
anno 6424 2.0 0
6286 2.40
6424 2.40
6424 3.00
6562 3.00
anno 6739 2.0 0
6562 2.40
6739 2.40
6739 3.00
6916 3.00
anno 7103 2.0 1
6916 3.00
7103 3.00
7103 2.40
7290 2.40
anno 7446 2.0 0
7290 2.40
7446 2.40
7446 3.00
7602 3.00
anno 7720 2.0 0
7602 2.40
7720 2.40
7720 3.00
7837 3.00
anno 7935 2.0 0
7837 2.40
7935 2.40
7935 3.00
8034 3.00
anno 8136 2.0 1
8034 3.00
8136 3.00
8136 2.40
8239 2.40
anno 8369 2.0 0
8239 2.40
8369 2.40
8369 3.00
8498 3.00
anno 8668 2.0 0
8498 2.40
8668 2.40
8668 3.00
8838 3.00
anno 9027 2.0 0
8838 2.40
9027 2.40
9027 3.00
9217 3.00
anno 9381 2.0 1
9217 3.00
9381 3.00
9381 2.40
9545 2.40
anno 9669 2.0 0
9545 2.40
9669 2.40
9669 3.00
9794 3.00
anno 9894 2.0 0
9794 2.40
9894 2.40
9894 3.00
9994 3.00
anno 10094 2.0 0
9994 2.40
10094 2.40
10094 3.00
10194 3.00
anno 10316 2.0 0
10194 2.40
10316 2.40
10316 3.00
10439 3.00
anno 10601 2.0 0
10439 2.40
10601 2.40
10601 3.00
10763 3.00
anno 10952 2.0 0
10763 2.40
10952 2.40
10952 3.00
11140 3.00
anno 11312 2.0 0
11140 2.40
11312 2.40
11312 3.00
11484 3.00
anno 11616 2.0 0
11484 2.40
11616 2.40
11616 3.00
11748 3.00
anno 11851 2.0 0
11748 2.40
11851 2.40
11851 3.00
11955 3.00
anno 12053 2.0 0
11955 2.40
12053 2.40
12053 3.00
12150 3.00
anno 12267 2.0 1
12150 3.00
12267 3.00
12267 2.40
12383 2.40
anno 12536 2.0 0
12383 2.40
12536 2.40
12536 3.00
12690 3.00
anno 12876 2.0 0
12690 2.40
12876 2.40
12876 3.00
13063 3.00
anno 13241 2.0 0
13063 2.40
13241 2.40
13241 3.00
13420 3.00
anno 13560 2.0 0
13420 2.40
13560 2.40
13560 3.00
13700 3.00
anno 13807 2.0 1
13700 3.00
13807 3.00
13807 2.40
13915 2.40
anno 14012 2.0 1
13915 3.00
14012 3.00
14012 2.40
14109 2.40
anno 14219 2.0 0
14109 2.40
14219 2.40
14219 3.00
14330 3.00
anno 14475 2.0 0
14330 2.40
14475 2.40
14475 3.00
14620 3.00
anno 14802 2.0 1
14620 3.00
14802 3.00
14802 2.40
14984 2.40
anno 15168 2.0 0
14984 2.40
15168 2.40
15168 3.00
15352 3.00
anno 15500 2.0 0
15352 2.40
15500 2.40
15500 3.00
15649 3.00
anno 15761 2.0 1
15649 3.00
15761 3.00
15761 2.40
15874 2.40
anno 15971 2.0 1
15874 3.00
15971 3.00
15971 2.40
16068 2.40
anno 16174 2.0 1
16068 3.00
16174 3.00
16174 2.40
16280 2.40
anno 16416 2.0 1
16280 3.00
16416 3.00
16416 2.40
16553 2.40
anno 16729 2.0 1
16553 3.00
16729 3.00
16729 2.40
16905 2.40
anno 17093 2.0 1
16905 3.00
17093 3.00
17093 2.40
17281 2.40
anno 17438 2.0 1
17281 3.00
17438 3.00
17438 2.40
17594 2.40
anno 17713 2.0 0
17594 2.40
17713 2.40
17713 3.00
17832 3.00
anno 17930 2.0 1
17832 3.00
17930 3.00
17930 2.40
18028 2.40
anno 18131 2.0 1
18028 3.00
18131 3.00
18131 2.40
18233 2.40
anno 18361 2.0 0
18233 2.40
18361 2.40
18361 3.00
18490 3.00
anno 18659 2.0 1
18490 3.00
18659 3.00
18659 2.40
18828 2.40
anno 19017 2.0 0
18828 2.40
19017 2.40
19017 3.00
19207 3.00
anno 19372 2.0 1
19207 3.00
19372 3.00
19372 2.40
19537 2.40
anno 19662 2.0 1
19537 3.00
19662 3.00
19662 2.40
19788 2.40
anno 19888 2.0 0
19788 2.40
19888 2.40
19888 3.00
19989 3.00
anno 20088 2.0 0
19989 2.40
20088 2.40
20088 3.00
20188 3.00
color = yellow
next
anno 100 0.0 1
0 1.00
100 1.00
100 0.40
200 0.40
anno 323 0.0 1
200 1.00
323 1.00
323 0.40
447 0.40
anno 609 0.0 1
447 1.00
609 1.00
609 0.40
772 0.40
anno 962 0.0 1
772 1.00
962 1.00
962 0.40
1151 0.40
anno 1322 0.0 1
1151 1.00
1322 1.00
1322 0.40
1492 0.40
anno 1623 0.0 1
1492 1.00
1623 1.00
1623 0.40
1754 0.40
anno 1857 0.0 1
1754 1.00
1857 1.00
1857 0.40
1960 0.40
anno 2058 0.0 0
1960 0.40
2058 0.40
2058 1.00
2156 1.00
anno 2273 0.0 0
2156 0.40
2273 0.40
2273 1.00
2390 1.00
anno 2544 0.0 1
2390 1.00
2544 1.00
2544 0.40
2699 0.40
anno 2886 0.0 0
2699 0.40
2886 0.40
2886 1.00
3073 1.00
anno 3251 0.0 0
3073 0.40
3251 0.40
3251 1.00
3429 1.00
anno 3567 0.0 0
3429 0.40
3567 0.40
3567 1.00
3706 1.00
anno 3813 0.0 0
3706 0.40
3813 0.40
3813 1.00
3920 1.00
anno 4017 0.0 1
3920 1.00
4017 1.00
4017 0.40
4114 0.40
anno 4225 0.0 1
4114 1.00
4225 1.00
4225 0.40
4337 0.40
anno 4483 0.0 0
4337 0.40
4483 0.40
4483 1.00
4629 1.00
anno 4811 0.0 0
4629 0.40
4811 0.40
4811 1.00
4994 1.00
anno 5178 0.0 0
4994 0.40
5178 0.40
5178 1.00
5361 1.00
anno 5508 0.0 0
5361 0.40
5508 0.40
5508 1.00
5656 1.00
anno 5767 0.0 1
5656 1.00
5767 1.00
5767 0.40
5879 0.40
anno 5976 0.0 0
5879 0.40
5976 0.40
5976 1.00
6074 1.00
anno 6180 0.0 0
6074 0.40
6180 0.40
6180 1.00
6286 1.00
anno 6424 0.0 1
6286 1.00
6424 1.00
6424 0.40
6562 0.40
anno 6739 0.0 0
6562 0.40
6739 0.40
6739 1.00
6916 1.00
anno 7103 0.0 0
6916 0.40
7103 0.40
7103 1.00
7290 1.00
anno 7446 0.0 0
7290 0.40
7446 0.40
7446 1.00
7602 1.00
anno 7720 0.0 0
7602 0.40
7720 0.40
7720 1.00
7837 1.00
anno 7935 0.0 0
7837 0.40
7935 0.40
7935 1.00
8034 1.00
anno 8136 0.0 1
8034 1.00
8136 1.00
8136 0.40
8239 0.40
anno 8369 0.0 0
8239 0.40
8369 0.40
8369 1.00
8498 1.00
anno 8668 0.0 0
8498 0.40
8668 0.40
8668 1.00
8838 1.00
anno 9027 0.0 0
8838 0.40
9027 0.40
9027 1.00
9217 1.00
anno 9381 0.0 0
9217 0.40
9381 0.40
9381 1.00
9545 1.00
anno 9669 0.0 0
9545 0.40
9669 0.40
9669 1.00
9794 1.00
anno 9894 0.0 1
9794 1.00
9894 1.00
9894 0.40
9994 0.40
anno 10094 0.0 0
9994 0.40
10094 0.40
10094 1.00
10194 1.00
anno 10316 0.0 0
10194 0.40
10316 0.40
10316 1.00
10439 1.00
anno 10601 0.0 1
10439 1.00
10601 1.00
10601 0.40
10763 0.40
anno 10952 0.0 0
10763 0.40
10952 0.40
10952 1.00
11140 1.00
anno 11312 0.0 1
11140 1.00
11312 1.00
11312 0.40
11484 0.40
anno 11616 0.0 0
11484 0.40
11616 0.40
11616 1.00
11748 1.00
anno 11851 0.0 0
11748 0.40
11851 0.40
11851 1.00
11955 1.00
anno 12053 0.0 0
11955 0.40
12053 0.40
12053 1.00
12150 1.00
anno 12267 0.0 1
12150 1.00
12267 1.00
12267 0.40
12383 0.40
anno 12536 0.0 0
12383 0.40
12536 0.40
12536 1.00
12690 1.00
anno 12876 0.0 1
12690 1.00
12876 1.00
12876 0.40
13063 0.40
anno 13241 0.0 1
13063 1.00
13241 1.00
13241 0.40
13420 0.40
anno 13560 0.0 1
13420 1.00
13560 1.00
13560 0.40
13700 0.40
anno 13807 0.0 1
13700 1.00
13807 1.00
13807 0.40
13915 0.40
anno 14012 0.0 1
13915 1.00
14012 1.00
14012 0.40
14109 0.40
anno 14219 0.0 1
14109 1.00
14219 1.00
14219 0.40
14330 0.40
anno 14475 0.0 1
14330 1.00
14475 1.00
14475 0.40
14620 0.40
anno 14802 0.0 0
14620 0.40
14802 0.40
14802 1.00
14984 1.00
anno 15168 0.0 1
14984 1.00
15168 1.00
15168 0.40
15352 0.40
anno 15500 0.0 1
15352 1.00
15500 1.00
15500 0.40
15649 0.40
anno 15761 0.0 0
15649 0.40
15761 0.40
15761 1.00
15874 1.00
anno 15971 0.0 1
15874 1.00
15971 1.00
15971 0.40
16068 0.40
anno 16174 0.0 1
16068 1.00
16174 1.00
16174 0.40
16280 0.40
anno 16416 0.0 0
16280 0.40
16416 0.40
16416 1.00
16553 1.00
anno 16729 0.0 0
16553 0.40
16729 0.40
16729 1.00
16905 1.00
anno 17093 0.0 1
16905 1.00
17093 1.00
17093 0.40
17281 0.40
anno 17438 0.0 0
17281 0.40
17438 0.40
17438 1.00
17594 1.00
color = red
next
anno 100 6.0 1
0 7.00
100 7.00
100 6.40
200 6.40
anno 323 6.0 1
200 7.00
323 7.00
323 6.40
447 6.40
anno 609 6.0 1
447 7.00
609 7.00
609 6.40
772 6.40
anno 962 6.0 1
772 7.00
962 7.00
962 6.40
1151 6.40
anno 1322 6.0 1
1151 7.00
1322 7.00
1322 6.40
1492 6.40
anno 1623 6.0 1
1492 7.00
1623 7.00
1623 6.40
1754 6.40
anno 1857 6.0 1
1754 7.00
1857 7.00
1857 6.40
1960 6.40
anno 2058 6.0 1
1960 7.00
2058 7.00
2058 6.40
2156 6.40
anno 2273 6.0 1
2156 7.00
2273 7.00
2273 6.40
2390 6.40
anno 2544 6.0 1
2390 7.00
2544 7.00
2544 6.40
2699 6.40
anno 2886 6.0 1
2699 7.00
2886 7.00
2886 6.40
3073 6.40
anno 3251 6.0 1
3073 7.00
3251 7.00
3251 6.40
3429 6.40
anno 3567 6.0 1
3429 7.00
3567 7.00
3567 6.40
3706 6.40
anno 3813 6.0 1
3706 7.00
3813 7.00
3813 6.40
3920 6.40
anno 4017 6.0 1
3920 7.00
4017 7.00
4017 6.40
4114 6.40
anno 4225 6.0 1
4114 7.00
4225 7.00
4225 6.40
4337 6.40
anno 4483 6.0 1
4337 7.00
4483 7.00
4483 6.40
4629 6.40
anno 4811 6.0 1
4629 7.00
4811 7.00
4811 6.40
4994 6.40
anno 5178 6.0 1
4994 7.00
5178 7.00
5178 6.40
5361 6.40
anno 5508 6.0 1
5361 7.00
5508 7.00
5508 6.40
5656 6.40
anno 5767 6.0 1
5656 7.00
5767 7.00
5767 6.40
5879 6.40
anno 5976 6.0 1
5879 7.00
5976 7.00
5976 6.40
6074 6.40
anno 6180 6.0 1
6074 7.00
6180 7.00
6180 6.40
6286 6.40
anno 6424 6.0 1
6286 7.00
6424 7.00
6424 6.40
6562 6.40
anno 6739 6.0 1
6562 7.00
6739 7.00
6739 6.40
6916 6.40
anno 7103 6.0 1
6916 7.00
7103 7.00
7103 6.40
7290 6.40
anno 7446 6.0 1
7290 7.00
7446 7.00
7446 6.40
7602 6.40
anno 7720 6.0 1
7602 7.00
7720 7.00
7720 6.40
7837 6.40
anno 7935 6.0 1
7837 7.00
7935 7.00
7935 6.40
8034 6.40
anno 8136 6.0 1
8034 7.00
8136 7.00
8136 6.40
8239 6.40
anno 8369 6.0 1
8239 7.00
8369 7.00
8369 6.40
8498 6.40
anno 8668 6.0 1
8498 7.00
8668 7.00
8668 6.40
8838 6.40
anno 9027 6.0 1
8838 7.00
9027 7.00
9027 6.40
9217 6.40
anno 9381 6.0 1
9217 7.00
9381 7.00
9381 6.40
9545 6.40
anno 9669 6.0 1
9545 7.00
9669 7.00
9669 6.40
9794 6.40
anno 9894 6.0 1
9794 7.00
9894 7.00
9894 6.40
9994 6.40
anno 10094 6.0 1
9994 7.00
10094 7.00
10094 6.40
10194 6.40
anno 10316 6.0 1
10194 7.00
10316 7.00
10316 6.40
10439 6.40
anno 10601 6.0 1
10439 7.00
10601 7.00
10601 6.40
10763 6.40
anno 10952 6.0 1
10763 7.00
10952 7.00
10952 6.40
11140 6.40
anno 11312 6.0 1
11140 7.00
11312 7.00
11312 6.40
11484 6.40
anno 11616 6.0 1
11484 7.00
11616 7.00
11616 6.40
11748 6.40
anno 11851 6.0 1
11748 7.00
11851 7.00
11851 6.40
11955 6.40
anno 12053 6.0 1
11955 7.00
12053 7.00
12053 6.40
12150 6.40
anno 12267 6.0 1
12150 7.00
12267 7.00
12267 6.40
12383 6.40
anno 12536 6.0 1
12383 7.00
12536 7.00
12536 6.40
12690 6.40
anno 12876 6.0 1
12690 7.00
12876 7.00
12876 6.40
13063 6.40
anno 13241 6.0 1
13063 7.00
13241 7.00
13241 6.40
13420 6.40
anno 13560 6.0 1
13420 7.00
13560 7.00
13560 6.40
13700 6.40
anno 13807 6.0 1
13700 7.00
13807 7.00
13807 6.40
13915 6.40
anno 14012 6.0 1
13915 7.00
14012 7.00
14012 6.40
14109 6.40
anno 14219 6.0 1
14109 7.00
14219 7.00
14219 6.40
14330 6.40
anno 14475 6.0 1
14330 7.00
14475 7.00
14475 6.40
14620 6.40
anno 14802 6.0 1
14620 7.00
14802 7.00
14802 6.40
14984 6.40
anno 15168 6.0 1
14984 7.00
15168 7.00
15168 6.40
15352 6.40
anno 15500 6.0 1
15352 7.00
15500 7.00
15500 6.40
15649 6.40
anno 15761 6.0 1
15649 7.00
15761 7.00
15761 6.40
15874 6.40
anno 15971 6.0 1
15874 7.00
15971 7.00
15971 6.40
16068 6.40
anno 16174 6.0 1
16068 7.00
16174 7.00
16174 6.40
16280 6.40
anno 16416 6.0 1
16280 7.00
16416 7.00
16416 6.40
16553 6.40
anno 16729 6.0 1
16553 7.00
16729 7.00
16729 6.40
16905 6.40
anno 17093 6.0 1
16905 7.00
17093 7.00
17093 6.40
17281 6.40
anno 17438 6.0 1
17281 7.00
17438 7.00
17438 6.40
17594 6.40
anno 17713 6.0 1
17594 7.00
17713 7.00
17713 6.40
17832 6.40
anno 17930 6.0 1
17832 7.00
17930 7.00
17930 6.40
18028 6.40
anno 18131 6.0 1
18028 7.00
18131 7.00
18131 6.40
18233 6.40
anno 18361 6.0 1
18233 7.00
18361 7.00
18361 6.40
18490 6.40
anno 18659 6.0 1
18490 7.00
18659 7.00
18659 6.40
18828 6.40
anno 19017 6.0 1
18828 7.00
19017 7.00
19017 6.40
19207 6.40
anno 19372 6.0 1
19207 7.00
19372 7.00
19372 6.40
19537 6.40
anno 19662 6.0 1
19537 7.00
19662 7.00
19662 6.40
19788 6.40
anno 19888 6.0 1
19788 7.00
19888 7.00
19888 6.40
19989 6.40
anno 20088 6.0 1
19989 7.00
20088 7.00
20088 6.40
20188 6.40
anno 20309 6.0 1
20188 7.00
20309 7.00
20309 6.40
20431 6.40
anno 20592 6.0 1
20431 7.00
20592 7.00
20592 6.40
20753 6.40
anno 20941 6.0 1
20753 7.00
20941 7.00
20941 6.40
21130 6.40
anno 21303 6.0 1
21130 7.00
21303 7.00
21303 6.40
21476 6.40
anno 21609 6.0 1
21476 7.00
21609 7.00
21609 6.40
21742 6.40
anno 21846 6.0 1
21742 7.00
21846 7.00
21846 6.40
21949 6.40
anno 22047 6.0 1
21949 7.00
22047 7.00
22047 6.40
22145 6.40
anno 22260 6.0 1
22145 7.00
22260 7.00
22260 6.40
22375 6.40
anno 22528 6.0 1
22375 7.00
22528 7.00
22528 6.40
22680 6.40
anno 22866 6.0 1
22680 7.00
22866 7.00
22866 6.40
23052 6.40
what do you think the alernative encoding could be
Sometime these are irresistible.
As a little exercise for myself, I decided to the OP's homework. Usually I don't do this but the OP cannot use it without it being clear that there was some external intervention. It covers only the reconstruction of the original data stream ie. it does not interpret the payload.
It is rough work but appears to function OK and is quite tolerant of timing errors.
I would be curious to know if it can recognise the code from the prof's "special" transmitter.
I have not worked with Manchester before so there may be some subtle edge cases which are not handled.
Here it is:
/*
Manchester.ino
Interprets a Manchester waveform on pin 2 , buffers it and dumps it.
Hard coded for:
data rate 100 bits/second, falling edge= 0.
It requires the clockHalfPeriodUs in the initial pre-sync phase
to identify the first transition from 0 to 1 or 1 to 0.
The initial timings can be +/- around 20%
After that first transition it can retrospectivly identify the bits
accumulated before that transition and push them out.
With more effort, it would be possible to do this without any hard coded timings.
The problem is that an initial stream of all zeros or all ones or alternating zeros
and ones all look the same.
In the sync phase, the timings are derived from the data stream.
It has been roughly tested with the supplied generator script.
*/
const bool debug = false; // true or false
const uint8_t input = 2; // external pull down c. 10k
const uint16_t clockHalfPeriodUs = 5000UL; // half rate. Used only for pre-sync phase
byte buf[256] = { 0 };
uint16_t bufIndex = 0;
void bufWrite(uint8_t inByte) {
buf[bufIndex] = inByte;
if ( bufIndex < sizeof(buf)-1 ) bufIndex++ ;
if (debug) Serial.print(">>> ");
if (debug) Serial.println(inByte);
}
void dumpBuf() {
Serial.println("dumping bitStream");
for (uint16_t i = 0; i < bufIndex; i++) Serial.print(buf[i]);
Serial.println();
bufIndex = 0;
}
bool approxWholeNumber(float inPar) {
// returns true if inPar is within 15% of a whole number, false otherwise
return (fabs(inPar - (uint32_t)(inPar + 0.49)) < 0.15);
}
void fsm() {
static uint16_t edgeCount = 0; // used until sync
static uint32_t lastTransitionAtUs = 0;
static uint32_t lastSyncAtUs = 0;
static uint32_t currentTransitionAtUs = 0;
static bool oldDigRead = LOW;
static uint32_t inStateAtMs = 0;
enum class State { WAIT_FIRST_TRANSITION,
WAIT_FIRST_DOUBLE,
SYNCED,
ERROR };
static State state = State::WAIT_FIRST_TRANSITION;
static State oldState = State::ERROR;
enum class Transition { TO_HIGH,
TO_LOW,
NONE };
static Transition transition = Transition::NONE;
bool digRead = digitalRead(input);
if (digRead != oldDigRead) {
lastTransitionAtUs = currentTransitionAtUs;
currentTransitionAtUs = micros();
transition = (digRead == HIGH) ? Transition::TO_HIGH : Transition::TO_LOW;
oldDigRead = digRead;
if (debug) Serial.print("transition found. Now: ");
if (debug) Serial.println(digRead ? "HIGH" : "LOW");
} else transition = Transition::NONE;
if (debug) {
if (state != oldState) {
Serial.print("State: ");
Serial.print((int)state);
Serial.print(" ");
Serial.println((int)oldState);
oldState = state;
}
}
switch (state) {
case State::WAIT_FIRST_TRANSITION:
{
// pin is low to the first transition is to high
if (transition == Transition::TO_HIGH) {
edgeCount = 1;
state = State::WAIT_FIRST_DOUBLE;
}
break;
}
case State::WAIT_FIRST_DOUBLE:
{
if (transition == Transition::TO_HIGH || transition == Transition::TO_LOW) {
if (currentTransitionAtUs - lastTransitionAtUs > 1.5 * clockHalfPeriodUs && currentTransitionAtUs - lastTransitionAtUs < 2.5 * clockHalfPeriodUs) {
// first double found so we can synchronise and flush out pending items
if (debug) Serial.print("edge count: ");
if (debug) Serial.println(edgeCount);
if (edgeCount % 2 == 0)
for (uint8_t i = 0; i < (edgeCount) / 2; i++) bufWrite(0);
else
for (uint8_t i = 0; i < (edgeCount + 1) / 2; i++) bufWrite(1);
if (transition == Transition::TO_HIGH) bufWrite(1);
else bufWrite(0);
state = State::SYNCED;
lastSyncAtUs = currentTransitionAtUs;
} else if (currentTransitionAtUs - lastTransitionAtUs > 0.75 * clockHalfPeriodUs && currentTransitionAtUs - lastTransitionAtUs < 1.25 * clockHalfPeriodUs) {
edgeCount++;
} else {
Serial.println("timing error in WAIT_FIRST_DOUBLE ");
Serial.print("currentTransitionAtUs: ");
Serial.println(currentTransitionAtUs);
Serial.print("lastTransitionAtUs: ");
Serial.print(lastTransitionAtUs);
Serial.println();
state = State::ERROR;
inStateAtMs = millis();
}
}
break;
}
case State::SYNCED:
{
// If transition and in the middle of a bit period, then flush out the bit otherwise ignore
if (transition == Transition::TO_HIGH || transition == Transition::TO_LOW) {
if (approxWholeNumber((currentTransitionAtUs - lastSyncAtUs) / (clockHalfPeriodUs * 2.0))) {
// This transition is in mid bit period so we have a sync
if (transition == Transition::TO_HIGH) bufWrite(1);
else bufWrite(0);
lastSyncAtUs = currentTransitionAtUs; // resync
}
}
if (micros() - currentTransitionAtUs > 1000000UL ) { // 1 second
// timeout - not data for 1 second so restart.
Serial.println("at end");
dumpBuf();
state = State::WAIT_FIRST_TRANSITION;
}
break;
}
case State::ERROR:
{
if (millis() - inStateAtMs > 1000) {
// restart
Serial.println("in ERROR");
// state = State::WAIT_FIRST_TRANSITION;
while (1) { ; } // wait for ever.
}
break;
}
} // switch
}
void setup() {
delay(2000);
Serial.begin(115200);
Serial.println("Starting. . . ");
}
void loop() {
static uint32_t lastLoopAtMs = 0;
if (millis() - lastLoopAtMs >= 1) {
lastLoopAtMs = millis();
fsm();
}
}
and the test generator code derived from that of the OP:
const int outputPin = 9;
const int led = 13;
const char* bitstring = "0101010101010101011111000011110000101010000111010101110001001" ;
// const char* bitstring = "000000001010111111111101010101010101000000111111010101010111000111";
// const char* bitstring = "1111111001000100000000000100010001000000000010000110010011111110110101100"; // 4 coordinaten (0,0) (1,2) (2,3) (4,4) freq:44kHz
//const char* bitstring = "111111100100001100001001000001000001001010001011111110110110010";// 3 coordinaten (1,1) (4,5) (2,2) freq:50kHz
//const char* bitstring = "11111110010001010000100001001010100100111000010000100101000100000011111110110110110"; // 5 coordinaten (1,1) (1,1) (5,5) (9,2) (7,0) freq:54kHz
// const float bitRate = 105.0; // was 100
// const float bitDuration = 1000.0 / bitRate; // 10 ms
// const float halfBitDurationUs = 5000UL ; //microseconds
uint32_t halfBitDurationUsRandom() {
// return random timings for halfBitDuration (nominal 5000 us)
return random( 4600, 5400 ) ;
}
void setup() {
pinMode(outputPin, OUTPUT);
pinMode(led, OUTPUT);
}
void loop() {
for (int i = 0; bitstring[i] != '\0'; i++) {
char bit = bitstring[i];
if (bit == '0') {
digitalWrite(outputPin, HIGH);
digitalWrite(led, HIGH);
delayMicroseconds(halfBitDurationUsRandom());
digitalWrite(outputPin, LOW);
digitalWrite(led, LOW);
delayMicroseconds(halfBitDurationUsRandom());
} else if (bit == '1') {
digitalWrite(outputPin, LOW);
delayMicroseconds(halfBitDurationUsRandom());
digitalWrite(outputPin, HIGH);
delayMicroseconds(halfBitDurationUsRandom());
}
}
delay(500); // ensure we start LOW for the next batch
digitalWrite(outputPin, LOW); // reset
delay(10000); //
}
i will be testing again with the real life transmitter next monday, ive now also refind some things of my own but if you want i could try and see if your code also works
@yvesn, the code below for your Nano will report the actual time in microseconds that the input signal spends in each state. It was written for IR decoding, but will work as well for this. I think it might be helpful to everyone to see what is actually being sent out by your professor's transmitter. The input is on D8. Ignore the Adjust variable.
// IRCaptureRaw.ino Rev 3
// for ATmega328P processors (Uno, Nano, ProMini - 8 or 16MHz)
// This captures incoming IR from a remote control as raw data.
// An IR receiver module should be connected to D8.
// The Adjust variable adjusts time between On and Off periods since
// receivers may turn on faster than they turn off, or vice versa.
// Results will include any repeats.
// The displayed numbers alternate between transmitting and idle states.
#ifndef __AVR_ATmega328P__
#error - Board must use ATmega328P microcontroller
#endif
const int maxEntries = 500; // total number of entries
const int maxExtras = 32; // number of long entries
unsigned int bitTime[maxEntries]; // store uSeconds in each state - integers
unsigned long Extra[maxExtras]; // long Extra entries
int Adjust = 0, newAdjust; // receiver turn on, turn off times not the same
const byte recvPin = 8; // Timer1 output - do not change
volatile unsigned int timerMSB, capMSB; // third byte of 24-bit timer (ICR1 = 1st two)
volatile bool Capture; // a state change occurred, and time was captured
unsigned long timerLO, timerHI, newTime, prevTime, longTime, outVal;
int i, j, k, n, maxMSB;
bool activeLO; // receiver output is low when receiving carrier
bool Waiting, Start, nothing;
void setup() {
delay(1000);
Serial.begin (9600);
Serial.println();
pinMode(recvPin, INPUT_PULLUP);
activeLO = true; // assume no transmission happening now
if (digitalRead(recvPin) == LOW) activeLO = false;
maxMSB = 60 >> (F_CPU == 8000000); // capture time = ~2 sec
cli();
TCCR1A = 0; // set up Timer1
TCCR1B = 0;
TCCR1C = 0;
TCNT0 = 0; // clear Timer1 count
sei();
Start = true;
}
void loop() {
if (Start) { // initialize everything on start or restart
Start = false;
i = 0;
n = 0;
j = 1;
Waiting = true;
Capture = false;
nothing = false;
Serial.print(F("Adjust = ")); Serial.println(Adjust);
Serial.println(F("Enter new Adjust value, or [Enter]"));
while (!Serial.available());
if ((Serial.peek() == 13) || (Serial.peek() == 10)) nothing = true;
newAdjust = Serial.parseInt(SKIP_NONE); // Adjust can be negative
if ((newAdjust) || !nothing) Adjust = newAdjust;
Serial.print(F("Adjust = ")); Serial.println(Adjust);
while (Serial.available()) Serial.read();
Serial.println(F("Waiting for IR transmission..."));
timerMSB = 0;
cli();
TIMSK0 = 0; // Disable Timer0 interrupts (millis)
TIFR1 = 0xFF; // clear flags register
if (activeLO) TCCR1B = 0b00000010; // falling edge capture, timer1 on, prescale /8
else TCCR1B = 0b01000010; // rising edge capture, timer1 on, prescale /8
TIFR1 = 0xFF; // clear flags
TIMSK1 = 0b00100001; // enable capture and overflow interrupts
TIFR1 = 0xFF; // clear flags
TCCR1A = 0b00000000; // Normal mode, no output, WGM #0
sei();
}
if (Waiting) { // keep MSB cleared
if (timerMSB) timerMSB = 0;
}
if (Capture) { // input has changed state
Capture = false;
Waiting = false;
timerLO = ICR1; // read timer values
timerHI = capMSB;
newTime = (timerHI << 16) + timerLO; // combine timer counts to one long value
if (maxMSB == 60) newTime = (newTime + 1) >> 1;
if (i) { // skip i=0
longTime = newTime - prevTime; // collect duration and activity state
if (longTime > 0xFFFF) {
bitTime[i] = n;
Extra[n] = longTime;
n++;
}
else bitTime[i] = longTime;
}
prevTime = newTime; // prepare for next state change
TCCR1B ^= 0b01000000; // switch to capture on opposite edge
i++;
}
if ((timerMSB > maxMSB) || (i > maxEntries)) { // collect data for two seconds after first
TCCR1B &= 0xFE; // stop Timer1 clock
TIMSK1 = 0b000000000; // disable capture and overflow interrupt
TIMSK0 = 1; // resume millis interrupt
for (k = 1; k < i; k++) { // adjust on (Mark) and off (Space) times
if (bitTime[k] >= maxExtras) { // not an Extra
if (k & 1) bitTime[k] -= Adjust; // shift Adjust from On to Off
else bitTime[k] += Adjust;
}
else {
if (k & 1) Extra[bitTime[k]] -= Adjust;
else Extra[bitTime[k]] += Adjust;
}
}
Serial.println(); // display output
Serial.println(F(" On Off On Off On Off On Off"));
Serial.println();
while (j < i) {
for (k = 0; k < 8; k++) {
outVal = bitTime[j];
if (outVal < maxExtras) outVal = Extra[bitTime[j]];
Serial.print(" ");
if (outVal < 100000) Serial.print(" ");
if (outVal < 10000) Serial.print(" ");
if (outVal < 1000) Serial.print(" ");
if (outVal < 100) Serial.print(" ");
if (outVal < 10) Serial.print(" ");
Serial.print (outVal);
j++;
if (j == i) break;
else Serial.print (",");
}
Serial.println();
}
Serial.println();
Start = true;
}
}
ISR(TIMER1_CAPT_vect) {
capMSB = timerMSB; // also capture MSB at same instant
Capture = true;
}
ISR(TIMER1_OVF_vect) {
timerMSB++; // increment MSB on overflow
}
I haven't gone through the details but this application note has some ideas.
It may of course not be malice. He may simply have accumulated a load of old lecture notes and this trick box transmitter and puts all his students through this exercise. Anyway, one can argue about the appropriateness of Manchester encoding to that particular use case, however the students should learn something useful apart, that is, from piling the problem into ChatGPT and the odd online forum.
I actually consider the OP quite fortunate in having such an interesting exercise and it could certainly be a lot worse. When I was in higher education we had also good and bad. The bad was learning the theory behind magnetic core memory for computers (destructive reads etc.) and that was at a time when 4k DRAM chips were becoming available. All completely useless of course even at that time.
Yes its transmitted via a zybo, and they use very old devices at my school. So he said that thats why the waves could be deviating. I dont think there was any malice haha
I thought you were using a Nano or is it an ESP ? AVR doesn't have IRAM.
I was thinking something along this way.
#define MAN_RX_PIN 2 // or 3 just 2 interrupt pins. PCINTs is also an option
#define NR_OF_BITS 40
#define BUF_SIZE (((NR_OF_BITS - 1) / 4) + 1)
#define MIN_BREAK 15 // basically when there has not been a change for more that 10ms there is no new bit coming in
// but it could be set higher.
#define DOUBLE_STATE 7 // anything more than 7 ms is definetly that
#define SINGLE_STATE 2 // reject any pulse shorter than 2 ms
volatile uint8_t buf[2][BUF_SIZE];
volatile uint8_t bufNdx = 0;
volatile bool swapped = false;
void setup() {
pinMode(MAN_RX_PIN, INPUT);
attachInterrupt(digitalPinToInterrupt(MAN_RX_PIN), Pulse, CHANGE);
}
void loop() {
if (swapped) { // the buffer has been swapped over, which means it is ready to be parsed.
swapped = false; // this does actually mean that a new pulse has come in
ParseTheBuffer();
}
}
void ParseTheBuffer(){
// do the parsing, any 10 = 1 any 01 equals 0 , basically you can goo through the buffer starting at byte 0 and bit 7
// the first 1 you find should be the start of the message
}
void Pulse() {
static uint32_t lastChange = millis(); // i actually think ms will be accurate enough for something close to 100bps
static uint8_t ndx = 0;
static uint8_t bitNdx = 0;
uint8_t pinState = digitalRead(MAN_RX_PIN);
if (millis() - lastChange > MIN_BREAK) { // time out, so time to parse
bitNdx = 0;
ndx = 0; // reset the index
bufNdx = 1 - bufNdx; // swap to the other buffer
swapped = true; // set the flag for the main loop
}
else if (millis() - lastChange > DOUBLE_STATE) {
if (ndx < BUF_SIZE) {
buf[bufNdx][ndx] = buf[bufNdx][ndx] << 1;
buf[bufNdx][ndx] |= pinState;
bitNdx++;
if (bitNdx > 7) {
ndx++;
bitNdx = 0;
}
}
if (ndx < BUF_SIZE) {
buf[bufNdx][ndx] = buf[bufNdx][ndx] << 1;
buf[bufNdx][ndx] |= pinState;
bitNdx++;
if (bitNdx > 7) {
ndx++;
bitNdx = 0;
}
}
}
else if (millis() - lastChange > SINGLE_STATE) { // just a single bit
if (ndx < BUF_SIZE) {
buf[bufNdx][ndx] = buf[bufNdx][ndx] << 1;
buf[bufNdx][ndx] |= pinState;
bitNdx++;
if (bitNdx > 7) {
ndx++;
bitNdx = 0;
}
}
}
lastChange = millis();
}
Haven't tested it at all, and i see a couple of flaws in it already
- It requires a pulse to reset the thing and swap the buffer. Maybe timeout could be done 'outside' the ISR.
Probably the easiest way to do this is to invert the use of the swapped flag. Set it in the main loop and reset it in the
ISR. - the final 'LOW' or period is not registered, which will leave the bits in the final byte that was used, 1 bit to far to the
if (millis() - lastChange > MIN_BREAK) { // time out, so time to parse
if (ndx < BUF_SIZE) {
buf[bufNdx][ndx] = buf[bufNdx][ndx] << 1;
buf[bufNdx][ndx] |= pinState
}
bitNdx = 0;
ndx = 0; // reset the index
bufNdx = 1 - bufNdx; // swap to the other buffer
swapped = true; // set the flag for the main loop
}
- The pinState should be inverted. We register a change, and want to record, not what it is now but what it was before
so
uint8_t pinState = HIGH - digitalRead(MAN_RX_PIN); // HIGH = 1, LOW = 0 atm
Oh yeah true, i didnt test my code today so thats an oversight by me. Im indeed using a nano so IRAM wont work
this ESP32 code using timer algorithm page 6 section 4.1 Timing Based Manchester Decode
from Atmel Application Note "Manchester Coding Basics" referenced in post 72 by @oldcurmudgeon may give you some ideas
// ESP32 - manchester decoder - works with C E Thomas and IEEE 802.3 coding techniques
// using timer algorithm page 6 section 4.1 Timing Based Manchester Decode
// from Atmel Application Note "Manchester Coding Basics"
// https://ww1.microchip.com/downloads/en/Appnotes/Atmel-9164-Manchester-Coding-Basics_Application-Note.pdf
// referenced in post https://forum.arduino.cc/t/manchester-decoding-200hz/1379346/72
int syncPulses = 3; // number of sync pulses at start of message
float midBitTime_T = 5000; // if using sync pulses with calculate from bit timing
hw_timer_t *Timer1_Cfg_1 = NULL; // CHANGE times timer object
// arrays to hold pulse CHANGE timing and bit data
uint64_t edges[1000] = { 0 };
byte bit[1000] = { 0 };
int edgeIndex = 0;
unsigned long int millisTimeOut = 0;
// edge interrupt read time in uSec
void IRAM_ATTR changeEdge() {
if (edgeIndex == 0) {
timerWrite(Timer1_Cfg_1, 0);
}
if (edgeIndex >= sizeof(edges) / sizeof(uint64_t)) return;
edges[edgeIndex] = timerReadMicros(Timer1_Cfg_1);
bit[edgeIndex++] = digitalRead(digitalPinToGPIONumber(16));
millisTimeOut = millis();
}
void setup() {
Serial.begin(115200);
delay(1000);
Serial.printf("\n\nESP32 manchester decoder (input on pin 16) \n");
if ((Timer1_Cfg_1 = timerBegin(1000000)) == NULL) // API 3.0 setup timer for 1uSec
Serial.println("Timer1_Cfg_1 timerBegin Failed!!");
Serial.print("Timer1_Cfg_1 timerBegin() OK frequenmcy ");
Serial.println(timerGetFrequency(Timer1_Cfg_1));
// setup interrput routines - connect signal to pins 16 and 17
attachInterrupt(digitalPinToGPIONumber(16), changeEdge, CHANGE); // detect edge on pin 16
Serial.print("displaying results ");
Serial.println(timerReadMicros(Timer1_Cfg_1));
Serial.printf("sizeof(edges) %d uint64_t array %d\n", sizeof(edges), sizeof(edges) / sizeof(uint64_t));
}
const char edge[2][10] = { "HIGH>LOW", "LOW>HIGH" };
void loop() {
// if 2 seconds have elapsed since last reading attempt to decode print results
if (edgeIndex > 0 && millis() - millisTimeOut > 2000) { //timerReadMicros(Timer1_Cfg)-risingTime[riseIndex-1]>2e6) {
Serial.println("\n\nManchester Decoder");
if (syncPulses) { // if there are sync pulses
Serial.printf("Calculate mid bit time T from sync pulses - ignor first pulse\n");
midBitTime_T = 0;
for (int i = 2; i < 2 + (syncPulses - 1) * 2; i++) {
midBitTime_T += (edges[i + 1] - edges[i]);
Serial.printf("i %d edge %lld bit %d midBitTime T %f\n", i, edges[i], bit[i], midBitTime_T);
}
Serial.printf("midBitTime T %f\n", midBitTime_T /= ((syncPulses - 1) * 2.0));
}
Serial.printf("\ndisplay bit timings and calculate time/T\n");
Serial.printf("i 0 edge %lld bit %s \n", edges[0], edge[bit[0]]);
//for (int i = syncPulses * 2; (i < edgeIndex) && (edges[i + 1] > 0); i++) {
for (int i = 1; (i < edgeIndex) && (edges[i + 1] > 0); i++) {
//for (int i = 0; i < edgeIndex; i++) {
Serial.printf("i %d edge %lld bit %s time %llduSec time/T %d\n",
i, edges[i], edge[bit[i]], edges[i] - edges[i - 1], (int)round((edges[i] - edges[i - 1]) / midBitTime_T));
}
Serial.println("\nManchester Decode - assume starting with sync bit 1 ");
int data[1000] = { 0 };
data[0] = 1; // assume starting with data = 1
int dataIndex = 0;
int i = 2; // start decoding next bit
while ((i < edgeIndex) && (edges[i] > 0)) {
int time = (int)round((edges[i] - edges[i - 1]) / midBitTime_T);
i++;
if (time == 1) { // If value = T
time = (int)round((edges[i] - edges[i - 1]) / midBitTime_T);
i++;
// Capture next edge and make sure this value also = T (else error)
if (time == 1) {
dataIndex++;
data[dataIndex] = data[dataIndex - 1]; // Next bit = current bit
Serial.printf("dataIndex %d time %d data %d\n", dataIndex, time, data[dataIndex]);
} else Serial.printf("ERROR 1 time %d\n", time); // else error!!
} else if (time == 2) { // Else if value = 2T
dataIndex++;
data[dataIndex] = !data[dataIndex - 1]; // Next bit = current bit
Serial.printf("dataIndex %d time %d data %d\n", dataIndex, time, data[dataIndex]);
} else Serial.printf("ERROR 2 time %d\n", time); // else error!!
}
Serial.print("\nDecoded data ");
for (int j = 0; j <= dataIndex; j++)
Serial.printf("%d", data[j]);
memset(edges, 0, sizeof(edges));
edgeIndex = 0;
}
}
test results data "11110100111001" using G E Thomas encoding ( 1 bit is HIGH to LOW transition 0 bit is LOW to HIGH transition)
ESP32 manchester decoder (input on pin 16)
Timer1_Cfg_1 timerBegin() OK frequenmcy 1000000
displaying results 282
sizeof(edges) 8000 uint64_t array 1000
Manchester Decoder
Calculate mid bit time T from sync pulses - ignor first pulse
i 2 edge 9898 bit 1 midBitTime T 5000.000000
i 3 edge 14898 bit 0 midBitTime T 10000.000000
i 4 edge 19898 bit 1 midBitTime T 14999.000000
i 5 edge 24897 bit 0 midBitTime T 19999.000000
midBitTime T 4999.750000
display bit timings and calculate time/T
i 0 edge 2 bit LOW>HIGH
i 1 edge 4898 bit HIGH>LOW time 4896uSec time/T 1
i 2 edge 9898 bit LOW>HIGH time 5000uSec time/T 1
i 3 edge 14898 bit HIGH>LOW time 5000uSec time/T 1
i 4 edge 19898 bit LOW>HIGH time 5000uSec time/T 1
i 5 edge 24897 bit HIGH>LOW time 4999uSec time/T 1
i 6 edge 29897 bit LOW>HIGH time 5000uSec time/T 1
i 7 edge 34897 bit HIGH>LOW time 5000uSec time/T 1
i 8 edge 44897 bit LOW>HIGH time 10000uSec time/T 2
i 9 edge 54897 bit HIGH>LOW time 10000uSec time/T 2
i 10 edge 64897 bit LOW>HIGH time 10000uSec time/T 2
i 11 edge 69897 bit HIGH>LOW time 5000uSec time/T 1
i 12 edge 74897 bit LOW>HIGH time 5000uSec time/T 1
i 13 edge 84896 bit HIGH>LOW time 9999uSec time/T 2
i 14 edge 89896 bit LOW>HIGH time 5000uSec time/T 1
i 15 edge 94896 bit HIGH>LOW time 5000uSec time/T 1
i 16 edge 99896 bit LOW>HIGH time 5000uSec time/T 1
i 17 edge 104896 bit HIGH>LOW time 5000uSec time/T 1
i 18 edge 114896 bit LOW>HIGH time 10000uSec time/T 2
i 19 edge 119896 bit HIGH>LOW time 5000uSec time/T 1
i 20 edge 124896 bit LOW>HIGH time 5000uSec time/T 1
Manchester Decode - assume starting with sync bit 1
dataIndex 1 time 1 data 1
dataIndex 2 time 1 data 1
dataIndex 3 time 1 data 1
dataIndex 4 time 2 data 0
dataIndex 5 time 2 data 1
dataIndex 6 time 2 data 0
dataIndex 7 time 1 data 0
dataIndex 8 time 2 data 1
dataIndex 9 time 1 data 1
dataIndex 10 time 1 data 1
dataIndex 11 time 2 data 0
dataIndex 12 time 1 data 0
dataIndex 13 time 2 data 1
Decoded data 11110100111001
test results data "11110100111001" using IEE 802.3 encoding 1 bit is LOW to HIGH transition 0 bit is HIGH to LOW transition
Manchester Decoder
Calculate mid bit time T from sync pulses - ignor first pulse
i 2 edge 154131 bit 1 midBitTime T 18446744073709551616.000000
i 3 edge 0 bit 0 midBitTime T 18446744073709551616.000000
i 4 edge 0 bit 1 midBitTime T 18446744073709551616.000000
i 5 edge 0 bit 0 midBitTime T 18446744073709551616.000000
midBitTime T 4611686018427387904.000000
display bit timings and calculate time/T
i 0 edge 2 bit LOW>HIGH
i 1 edge 177 bit HIGH>LOW time 175uSec time/T 0
Manchester Decode - assume starting with sync bit 1
ERROR 2 time 0
Decoded data 1
Manchester Decoder
Calculate mid bit time T from sync pulses - ignor first pulse
i 2 edge 9915 bit 0 midBitTime T 4999.000000
i 3 edge 14914 bit 1 midBitTime T 9999.000000
i 4 edge 19914 bit 0 midBitTime T 14999.000000
i 5 edge 24914 bit 1 midBitTime T 19999.000000
midBitTime T 4999.750000
display bit timings and calculate time/T
i 0 edge 2 bit HIGH>LOW
i 1 edge 4914 bit LOW>HIGH time 4912uSec time/T 1
i 2 edge 9915 bit HIGH>LOW time 5001uSec time/T 1
i 3 edge 14914 bit LOW>HIGH time 4999uSec time/T 1
i 4 edge 19914 bit HIGH>LOW time 5000uSec time/T 1
i 5 edge 24914 bit LOW>HIGH time 5000uSec time/T 1
i 6 edge 29914 bit HIGH>LOW time 5000uSec time/T 1
i 7 edge 34914 bit LOW>HIGH time 5000uSec time/T 1
i 8 edge 44913 bit HIGH>LOW time 9999uSec time/T 2
i 9 edge 54913 bit LOW>HIGH time 10000uSec time/T 2
i 10 edge 64913 bit HIGH>LOW time 10000uSec time/T 2
i 11 edge 69913 bit LOW>HIGH time 5000uSec time/T 1
i 12 edge 74913 bit HIGH>LOW time 5000uSec time/T 1
i 13 edge 84913 bit LOW>HIGH time 10000uSec time/T 2
i 14 edge 89913 bit HIGH>LOW time 5000uSec time/T 1
i 15 edge 94913 bit LOW>HIGH time 5000uSec time/T 1
i 16 edge 99913 bit HIGH>LOW time 5000uSec time/T 1
i 17 edge 104913 bit LOW>HIGH time 5000uSec time/T 1
i 18 edge 114912 bit HIGH>LOW time 9999uSec time/T 2
i 19 edge 119912 bit LOW>HIGH time 5000uSec time/T 1
i 20 edge 124912 bit HIGH>LOW time 5000uSec time/T 1
Manchester Decode - assume starting with sync bit 1
dataIndex 1 time 1 data 1
dataIndex 2 time 1 data 1
dataIndex 3 time 1 data 1
dataIndex 4 time 2 data 0
dataIndex 5 time 2 data 1
dataIndex 6 time 2 data 0
dataIndex 7 time 1 data 0
dataIndex 8 time 2 data 1
dataIndex 9 time 1 data 1
dataIndex 10 time 1 data 1
dataIndex 11 time 2 data 0
dataIndex 12 time 1 data 0
dataIndex 13 time 2 data 1
Decoded data 11110100111001
using test data "1111111001000100000000000100010001000000000010000110010011111110110101100" from post 69 IEEE 802.3 encoding
test data IEEE 802.3
Manchester Decoder
Calculate mid bit time T from sync pulses - ignor first pulse
i 2 edge 154123 bit 1 midBitTime T 18446744073709551616.000000
i 3 edge 0 bit 1 midBitTime T 18446744073709551616.000000
i 4 edge 0 bit 0 midBitTime T 18446744073709551616.000000
i 5 edge 0 bit 1 midBitTime T 18446744073709551616.000000
midBitTime T 4611686018427387904.000000
display bit timings and calculate time/T
i 0 edge 2 bit LOW>HIGH
i 1 edge 180 bit HIGH>LOW time 178uSec time/T 0
Manchester Decode - assume starting with sync bit 1
ERROR 2 time 0
Decoded data 1
Manchester Decoder
Calculate mid bit time T from sync pulses - ignor first pulse
i 2 edge 9916 bit 0 midBitTime T 4999.000000
i 3 edge 14915 bit 1 midBitTime T 9999.000000
i 4 edge 19915 bit 0 midBitTime T 14999.000000
i 5 edge 24915 bit 1 midBitTime T 19999.000000
midBitTime T 4999.750000
display bit timings and calculate time/T
i 0 edge 2 bit HIGH>LOW
i 1 edge 4915 bit LOW>HIGH time 4913uSec time/T 1
i 2 edge 9916 bit HIGH>LOW time 5001uSec time/T 1
i 3 edge 14915 bit LOW>HIGH time 4999uSec time/T 1
i 4 edge 19915 bit HIGH>LOW time 5000uSec time/T 1
i 5 edge 24915 bit LOW>HIGH time 5000uSec time/T 1
i 6 edge 29915 bit HIGH>LOW time 5000uSec time/T 1
i 7 edge 34915 bit LOW>HIGH time 5000uSec time/T 1
i 8 edge 39915 bit HIGH>LOW time 5000uSec time/T 1
i 9 edge 44914 bit LOW>HIGH time 4999uSec time/T 1
i 10 edge 49914 bit HIGH>LOW time 5000uSec time/T 1
i 11 edge 54914 bit LOW>HIGH time 5000uSec time/T 1
i 12 edge 59914 bit HIGH>LOW time 5000uSec time/T 1
i 13 edge 64914 bit LOW>HIGH time 5000uSec time/T 1
i 14 edge 74914 bit HIGH>LOW time 10000uSec time/T 2
i 15 edge 79914 bit LOW>HIGH time 5000uSec time/T 1
i 16 edge 84914 bit HIGH>LOW time 5000uSec time/T 1
i 17 edge 94914 bit LOW>HIGH time 10000uSec time/T 2
i 18 edge 104914 bit HIGH>LOW time 10000uSec time/T 2
i 19 edge 109914 bit LOW>HIGH time 5000uSec time/T 1
i 20 edge 114913 bit HIGH>LOW time 4999uSec time/T 1
i 21 edge 119913 bit LOW>HIGH time 5000uSec time/T 1
i 22 edge 124913 bit HIGH>LOW time 5000uSec time/T 1
i 23 edge 134913 bit LOW>HIGH time 10000uSec time/T 2
i 24 edge 144913 bit HIGH>LOW time 10000uSec time/T 2
i 25 edge 149913 bit LOW>HIGH time 5000uSec time/T 1
i 26 edge 154913 bit HIGH>LOW time 5000uSec time/T 1
i 27 edge 159913 bit LOW>HIGH time 5000uSec time/T 1
i 28 edge 164912 bit HIGH>LOW time 4999uSec time/T 1
i 29 edge 169913 bit LOW>HIGH time 5001uSec time/T 1
i 30 edge 174912 bit HIGH>LOW time 4999uSec time/T 1
i 31 edge 179912 bit LOW>HIGH time 5000uSec time/T 1
i 32 edge 184912 bit HIGH>LOW time 5000uSec time/T 1
i 33 edge 189913 bit LOW>HIGH time 5001uSec time/T 1
i 34 edge 194912 bit HIGH>LOW time 4999uSec time/T 1
i 35 edge 199912 bit LOW>HIGH time 5000uSec time/T 1
i 36 edge 204912 bit HIGH>LOW time 5000uSec time/T 1
i 37 edge 209912 bit LOW>HIGH time 5000uSec time/T 1
i 38 edge 214912 bit HIGH>LOW time 5000uSec time/T 1
i 39 edge 219912 bit LOW>HIGH time 5000uSec time/T 1
i 40 edge 224912 bit HIGH>LOW time 5000uSec time/T 1
i 41 edge 229912 bit LOW>HIGH time 5000uSec time/T 1
i 42 edge 234912 bit HIGH>LOW time 5000uSec time/T 1
i 43 edge 239912 bit LOW>HIGH time 5000uSec time/T 1
i 44 edge 244912 bit HIGH>LOW time 5000uSec time/T 1
i 45 edge 254911 bit LOW>HIGH time 9999uSec time/T 2
i 46 edge 264911 bit HIGH>LOW time 10000uSec time/T 2
i 47 edge 269911 bit LOW>HIGH time 5000uSec time/T 1
i 48 edge 274911 bit HIGH>LOW time 5000uSec time/T 1
i 49 edge 279911 bit LOW>HIGH time 5000uSec time/T 1
i 50 edge 284911 bit HIGH>LOW time 5000uSec time/T 1
i 51 edge 294911 bit LOW>HIGH time 10000uSec time/T 2
i 52 edge 304911 bit HIGH>LOW time 10000uSec time/T 2
i 53 edge 309911 bit LOW>HIGH time 5000uSec time/T 1
i 54 edge 314911 bit HIGH>LOW time 5000uSec time/T 1
i 55 edge 319911 bit LOW>HIGH time 5000uSec time/T 1
i 56 edge 324910 bit HIGH>LOW time 4999uSec time/T 1
i 57 edge 334910 bit LOW>HIGH time 10000uSec time/T 2
i 58 edge 344910 bit HIGH>LOW time 10000uSec time/T 2
i 59 edge 349910 bit LOW>HIGH time 5000uSec time/T 1
i 60 edge 354910 bit HIGH>LOW time 5000uSec time/T 1
i 61 edge 359910 bit LOW>HIGH time 5000uSec time/T 1
i 62 edge 364910 bit HIGH>LOW time 5000uSec time/T 1
i 63 edge 369910 bit LOW>HIGH time 5000uSec time/T 1
i 64 edge 374910 bit HIGH>LOW time 5000uSec time/T 1
i 65 edge 379910 bit LOW>HIGH time 5000uSec time/T 1
i 66 edge 384910 bit HIGH>LOW time 5000uSec time/T 1
i 67 edge 389910 bit LOW>HIGH time 5000uSec time/T 1
i 68 edge 394909 bit HIGH>LOW time 4999uSec time/T 1
i 69 edge 399909 bit LOW>HIGH time 5000uSec time/T 1
i 70 edge 404909 bit HIGH>LOW time 5000uSec time/T 1
i 71 edge 409909 bit LOW>HIGH time 5000uSec time/T 1
i 72 edge 414909 bit HIGH>LOW time 5000uSec time/T 1
i 73 edge 419909 bit LOW>HIGH time 5000uSec time/T 1
i 74 edge 424909 bit HIGH>LOW time 5000uSec time/T 1
i 75 edge 429909 bit LOW>HIGH time 5000uSec time/T 1
i 76 edge 434909 bit HIGH>LOW time 5000uSec time/T 1
i 77 edge 444909 bit LOW>HIGH time 10000uSec time/T 2
i 78 edge 454909 bit HIGH>LOW time 10000uSec time/T 2
i 79 edge 459909 bit LOW>HIGH time 5000uSec time/T 1
i 80 edge 464908 bit HIGH>LOW time 4999uSec time/T 1
i 81 edge 469909 bit LOW>HIGH time 5001uSec time/T 1
i 82 edge 474908 bit HIGH>LOW time 4999uSec time/T 1
i 83 edge 479908 bit LOW>HIGH time 5000uSec time/T 1
i 84 edge 484908 bit HIGH>LOW time 5000uSec time/T 1
i 85 edge 494908 bit LOW>HIGH time 10000uSec time/T 2
i 86 edge 499908 bit HIGH>LOW time 5000uSec time/T 1
i 87 edge 504908 bit LOW>HIGH time 5000uSec time/T 1
i 88 edge 514908 bit HIGH>LOW time 10000uSec time/T 2
i 89 edge 519908 bit LOW>HIGH time 5000uSec time/T 1
i 90 edge 524908 bit HIGH>LOW time 5000uSec time/T 1
i 91 edge 534908 bit LOW>HIGH time 10000uSec time/T 2
i 92 edge 544907 bit HIGH>LOW time 9999uSec time/T 2
i 93 edge 549907 bit LOW>HIGH time 5000uSec time/T 1
i 94 edge 554907 bit HIGH>LOW time 5000uSec time/T 1
i 95 edge 564907 bit LOW>HIGH time 10000uSec time/T 2
i 96 edge 569907 bit HIGH>LOW time 5000uSec time/T 1
i 97 edge 574907 bit LOW>HIGH time 5000uSec time/T 1
i 98 edge 579907 bit HIGH>LOW time 5000uSec time/T 1
i 99 edge 584907 bit LOW>HIGH time 5000uSec time/T 1
i 100 edge 589907 bit HIGH>LOW time 5000uSec time/T 1
i 101 edge 594907 bit LOW>HIGH time 5000uSec time/T 1
i 102 edge 599906 bit HIGH>LOW time 4999uSec time/T 1
i 103 edge 604907 bit LOW>HIGH time 5001uSec time/T 1
i 104 edge 609906 bit HIGH>LOW time 4999uSec time/T 1
i 105 edge 614906 bit LOW>HIGH time 5000uSec time/T 1
i 106 edge 619906 bit HIGH>LOW time 5000uSec time/T 1
i 107 edge 624906 bit LOW>HIGH time 5000uSec time/T 1
i 108 edge 634906 bit HIGH>LOW time 10000uSec time/T 2
i 109 edge 644906 bit LOW>HIGH time 10000uSec time/T 2
i 110 edge 649907 bit HIGH>LOW time 5001uSec time/T 1
i 111 edge 654906 bit LOW>HIGH time 4999uSec time/T 1
i 112 edge 664906 bit HIGH>LOW time 10000uSec time/T 2
i 113 edge 674905 bit LOW>HIGH time 9999uSec time/T 2
i 114 edge 684906 bit HIGH>LOW time 10001uSec time/T 2
i 115 edge 694905 bit LOW>HIGH time 9999uSec time/T 2
i 116 edge 699905 bit HIGH>LOW time 5000uSec time/T 1
i 117 edge 704905 bit LOW>HIGH time 5000uSec time/T 1
i 118 edge 714905 bit HIGH>LOW time 10000uSec time/T 2
i 119 edge 719905 bit LOW>HIGH time 5000uSec time/T 1
i 120 edge 724905 bit HIGH>LOW time 5000uSec time/T 1
Manchester Decode - assume starting with sync bit 1
dataIndex 1 time 1 data 1
dataIndex 2 time 1 data 1
dataIndex 3 time 1 data 1
dataIndex 4 time 1 data 1
dataIndex 5 time 1 data 1
dataIndex 6 time 1 data 1
dataIndex 7 time 2 data 0
dataIndex 8 time 1 data 0
dataIndex 9 time 2 data 1
dataIndex 10 time 2 data 0
dataIndex 11 time 1 data 0
dataIndex 12 time 1 data 0
dataIndex 13 time 2 data 1
dataIndex 14 time 2 data 0
dataIndex 15 time 1 data 0
dataIndex 16 time 1 data 0
dataIndex 17 time 1 data 0
dataIndex 18 time 1 data 0
dataIndex 19 time 1 data 0
dataIndex 20 time 1 data 0
dataIndex 21 time 1 data 0
dataIndex 22 time 1 data 0
dataIndex 23 time 1 data 0
dataIndex 24 time 1 data 0
dataIndex 25 time 2 data 1
dataIndex 26 time 2 data 0
dataIndex 27 time 1 data 0
dataIndex 28 time 1 data 0
dataIndex 29 time 2 data 1
dataIndex 30 time 2 data 0
dataIndex 31 time 1 data 0
dataIndex 32 time 1 data 0
dataIndex 33 time 2 data 1
dataIndex 34 time 2 data 0
dataIndex 35 time 1 data 0
dataIndex 36 time 1 data 0
dataIndex 37 time 1 data 0
dataIndex 38 time 1 data 0
dataIndex 39 time 1 data 0
dataIndex 40 time 1 data 0
dataIndex 41 time 1 data 0
dataIndex 42 time 1 data 0
dataIndex 43 time 1 data 0
dataIndex 44 time 2 data 1
dataIndex 45 time 2 data 0
dataIndex 46 time 1 data 0
dataIndex 47 time 1 data 0
dataIndex 48 time 1 data 0
dataIndex 49 time 2 data 1
dataIndex 50 time 1 data 1
dataIndex 51 time 2 data 0
dataIndex 52 time 1 data 0
dataIndex 53 time 2 data 1
dataIndex 54 time 2 data 0
dataIndex 55 time 1 data 0
dataIndex 56 time 2 data 1
dataIndex 57 time 1 data 1
dataIndex 58 time 1 data 1
dataIndex 59 time 1 data 1
dataIndex 60 time 1 data 1
dataIndex 61 time 1 data 1
dataIndex 62 time 1 data 1
dataIndex 63 time 2 data 0
dataIndex 64 time 2 data 1
dataIndex 65 time 1 data 1
dataIndex 66 time 2 data 0
dataIndex 67 time 2 data 1
dataIndex 68 time 2 data 0
dataIndex 69 time 2 data 1
dataIndex 70 time 1 data 1
dataIndex 71 time 2 data 0
dataIndex 72 time 1 data 0
ERROR 1 time 2147483647
Decoded data 1111111001000100000000000100010001000000000010000110010011111110110101100


