-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
2297 lines (2191 loc) · 160 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<style>
h2.ex1 {
padding: 35px;
}
h4.ex1 {
padding: 10px;
}
</style>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>:angry: - ECE3400</title>
<link rel="icon" href="img/angry-face.png">
<!-- Bootstrap core CSS -->
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom fonts for this template -->
<link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic" rel="stylesheet" type="text/css">
<!-- Plugin CSS -->
<link href="vendor/magnific-popup/magnific-popup.css" rel="stylesheet" type="text/css">
<!-- Custom styles for this template -->
<link href="css/freelancer.min.css" rel="stylesheet">
</head>
<body id="page-top">
<!-- Navigation -->
<nav class="navbar navbar-expand-lg bg-secondary fixed-top text-uppercase" id="mainNav">
<div class="container">
<a class="navbar-brand js-scroll-trigger" href="#page-top">:angry:</a>
<button class="navbar-toggler navbar-toggler-right text-uppercase bg-primary text-white rounded" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
Menu
<i class="fa fa-bars"></i>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item mx-0 mx-lg-1">
<a class="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger" href="#about">About</a>
</li>
<li class="nav-item mx-0 mx-lg-1">
<a class="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger" href="#team">The Team</a>
</li>
<li class="nav-item mx-0 mx-lg-1">
<a class="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger" href="#labs">Labs</a>
</li>
<li class="nav-item mx-0 mx-lg-1">
<a class="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger" href="#milestones">Milestones</a>
</li>
</ul>
</div>
</div>
</nav>
<!-- Header -->
<header class="masthead text-white text-center">
<div class="container">
<img class="img-fluid mb-4 d-block mx-auto" src="img/angry-face.png" alt="The Facebook Angry React">
<h1 class="text-uppercase mb-0">:angry:</h1>
<hr class="star-light">
<h2 class="font-weight-light mb-0">
1ST PLACE || ECE 3400 Fall 2018
</h2>
</div>
</header>
<!-- About Section -->
<section class="bg-primary text-white mb-0" id="about">
<div class="container">
<h2 class="text-center text-uppercase text-white">About</h2>
<hr class="star-light mb-5">
<div class="row">
<div class="col-lg-5 ml-auto" id="video">
<a href="https://youtu.be/NN6Hub6EWgc">
<img class="img-fluid mb-3 d-block mx-auto" src="img/FinalPhotos/robo_portrait.jpg" alt="The Robot">
<!-- I apologize for the profanity in this video - I hadn't realized this practice run would end up here! -Kevin -->
</a>
<p id="unhide">Click or hover over parts of our website to see more.</p>
<p id="list">Click to see our robot win the final round of the competition! :)</p>
</div>
<div class="col-lg-7 mr-auto">
<p class="lead">Team 28, also known as :ANGRY: or the Angry Reacts, is the highest numbered - and highest quality - team in the ECE 3400 maze exploration robot competition.</p>
<p>The AngryBot is fully autonomous and capable of line following, wall-following, tone detection, and IR detection and avoidance of other robots. In addition, it communicates its current location and surroundings <a class="portfolio-item" href="#portfolio-modal-3">using an RF transceiver</a> to an external GUI base station as we map it. Our robot explores its surroundings with the <a class="portfolio-item" href="#portfolio-modal-7">Depth First Search graph algorithm</a>, and while not included in the competition robot, we <a class="portfolio-item" href="#portfolio-modal-4">integrated a camera and FPGA</a> to detect visual treasures. Our robots were built with an Arduino Uno, a DE0-nano FPGA, custom 3D-printed components, and various sensors and servos. </p>
<p>To the surprise of our team, our quick quip about being the highest quality team proved true; AngryBot mapped out the most squares in both the first and final rounds of the ECE 3400 competition on December 4th, leading us to a 1st place finish! Click on the photo to the photo of our robot to see a video of the final round.</p>
<p>For more about the competition or the robot, please take a look at the <a href="https://cei-lab.github.io/ece3400-2018/">ECE 3400 course page</a> or the <a href="#footer">final design write-up.</a></p>
</div>
</div>
</div>
</section>
<!-- Team Section -->
<section class="bg-dark text-white mb-0" id="team">
<div class="container">
<h2 class="text-center text-uppercase text-white ex1">
The Team
</h2>
<div class="row">
<div class="col-sm-3 text-center">
<div class="team-member">
<img class="mx-auto rounded-circle" src="img/tony.png" alt="">
<h4 class="ex1">Anthony Viego</h4>
<h5 class="font-weight-light">Junior, ECE</h5>
</div>
</div>
<div class="col-sm-3 text-center">
<div class="team-member">
<img class="mx-auto rounded-circle" src="img/Glenna.png" alt="">
<h4 class="ex1">Glenna Zhang</h4>
<h5 class="font-weight-light">Junior, ECE</h5>
</div>
</div>
<div class="col-sm-3 text-center">
<div class="team-member">
<img class="mx-auto rounded-circle" src="img/Liliet.jpg" alt="">
<h4 class="ex1">Liliet Sosa</h4>
<h5 class="font-weight-light">Junior, ECE</h5>
</div>
</div>
<div class="col-sm-3 text-center">
<div class="team-member" id="kevin">
<a href="https://kevinzying.github.io/resume/"><img class="mx-auto rounded-circle" src="img/Kevin.jpg" alt="A Picture of Kevin Ying at the One World Trade Center"></a>
<h4 class="ex1">Kevin Ying</h4>
<h5 class="font-weight-light">Junior, ECE</h5>
<p class="mb-1 small" id="moreinfo">My focus during the final weeks was on IR detection, radio communication, and treasure detection (camera I2C communication and FPGA image processor). </p>
<p class="mb-1 small" id="moreinfo">To check out more of my work, take a look at my online resume <a href="https://kevinzying.github.io/resume/">here</a>. </p>
<p class="mb-0 small" id="moreinfo">I really just wanted to show off that I found this cool CSS transition on StackExchange. </p>
<!-- Aforementioned stackexchange link: https://stackoverflow.com/a/30531678 -->
</div>
</div>
</div>
</div>
</section>
<!-- Lab Grid Section -->
<section class="portfolio" id="labs">
<div class="container">
<h2 class="text-center text-uppercase text-secondary mb-0">Labs</h2>
<hr class="star-dark mb-5">
<div class="row">
<div class="col-md-6 col-lg-3" id="lab-hover">
<a class="portfolio-item d-block mx-auto" href="#portfolio-modal-1">
<div class="portfolio-item-caption d-flex position-absolute h-100 w-100">
<div class="portfolio-item-caption-content my-auto w-100 text-center text-white">
<i class="fa fa-search-plus fa-3x"></i>
</div>
</div>
<img class="img-fluid" src="Lab1/img/lab1.png" alt="">
</a>
<p class="mb-1" id="moreinfo">Microcontroller</p>
<p class="mb-1 small" id="moreinfo">In which we discover the Arduino Uno and start to get a moving robot.</p>
</div>
<div class="col-md-6 col-lg-3" id="lab-hover">
<a class="portfolio-item d-block mx-auto" href="#portfolio-modal-2">
<div class="portfolio-item-caption d-flex position-absolute h-100 w-100">
<div class="portfolio-item-caption-content my-auto w-100 text-center text-white">
<i class="fa fa-search-plus fa-3x"></i>
</div>
</div>
<img class="img-fluid" src="img/portfolio/IR_circuit.png" alt="">
</a>
<p class="mb-1" id="moreinfo">Analog Circuitry and FFTs</p>
<p class="mb-1 small" id="moreinfo">In which we create detect tones and high frequency IR pulses.</p>
</div>
<div class="col-md-6 col-lg-3" id="lab-hover">
<a class="portfolio-item d-block mx-auto" href="#portfolio-modal-3">
<div class="portfolio-item-caption d-flex position-absolute h-100 w-100">
<div class="portfolio-item-caption-content my-auto w-100 text-center text-white">
<i class="fa fa-search-plus fa-3x"></i>
</div>
</div>
<img class="img-fluid" src="img/Lab 3 Photos/GUI.png" alt="">
</a>
<p class="mb-1" id="moreinfo">System Integration and Radio</p>
<p class="mb-1 small" id="moreinfo">In which we talk to a GUI, and rediscover all of our sensors.</p>
</div>
<div class="col-md-6 col-lg-3" id="lab-hover">
<a class="portfolio-item d-block mx-auto" href="#portfolio-modal-4">
<div class="portfolio-item-caption d-flex position-absolute h-100 w-100">
<div class="portfolio-item-caption-content my-auto w-100 text-center text-white">
<i class="fa fa-search-plus fa-3x"></i>
</div>
</div>
<img class="img-fluid" src="img/Lab4Photos/l4cover.png" alt="">
</a>
<p class="mb-1" id="moreinfo">FPGA and Color Detection</p>
<p class="mb-1 small" id="moreinfo">In which we add a camera and learn the joys of visual processing.</p>
</div>
</div>
</div>
</section>
<!-- Milestone Grid Section -->
<section class="portfolio bg-red text-white" id="milestones">
<div class="container">
<h2 class="text-center text-uppercase mb-0">Milestones</h2>
<hr class="star-light mb-5">
<div class="row">
<div class="col-md-6 col-lg-3" id="lab-hover">
<a class="portfolio-item d-block mx-auto" href="#portfolio-modal-5">
<div class="portfolio-item-caption d-flex position-absolute h-100 w-100">
<div class="portfolio-item-caption-content my-auto w-100 text-center text-white">
<i class="fa fa-search-plus fa-3x"></i>
</div>
</div>
<img class="img-fluid" src="img/portfolio/robot2.png" alt="">
</a>
<p class="mb-1" id="moreinfo">Line Tracking</p>
<p class="mb-1 small" id="moreinfo">In which our robot learns to perform a figure eight.</p>
</div>
<div class="col-md-6 col-lg-3" id="lab-hover">
<a class="portfolio-item d-block mx-auto" href="#portfolio-modal-6">
<div class="portfolio-item-caption d-flex position-absolute h-100 w-100">
<div class="portfolio-item-caption-content my-auto w-100 text-center text-white">
<i class="fa fa-search-plus fa-3x"></i>
</div>
</div>
<img class="img-fluid" src="img/Milestone 2 Photos/wallsensor.png" alt="">
</a>
<p class="mb-1" id="moreinfo">Wall Detection</p>
<p class="mb-1 small" id="moreinfo">In which our robot learns to stop hitting itself.</p>
</div>
<div class="col-md-6 col-lg-3" id="lab-hover">
<a class="portfolio-item d-block mx-auto" href="#portfolio-modal-7">
<div class="portfolio-item-caption d-flex position-absolute h-100 w-100">
<div class="portfolio-item-caption-content my-auto w-100 text-center text-white">
<i class="fa fa-search-plus fa-3x"></i>
</div>
</div>
<img class="img-fluid" src="img/Milestone3Photos/m3cover.png" alt="">
</a>
<p class="mb-1" id="moreinfo">Maze Exploration</p>
<p class="mb-1 small" id="moreinfo">In which our robot learns to search for what it wants.</p>
</div>
<div class="col-md-6 col-lg-3" id="lab-hover">
<a class="portfolio-item d-block mx-auto" href="#portfolio-modal-8">
<div class="portfolio-item-caption d-flex position-absolute h-100 w-100">
<div class="portfolio-item-caption-content my-auto w-100 text-center text-white">
<i class="fa fa-search-plus fa-3x"></i>
</div>
</div>
<img class="img-fluid" src="img/Milestone4Photos/m4cover.png" alt="">
</a>
<p class="mb-1" id="moreinfo">Treasure Shape Detection</p>
<p class="mb-1 small" id="moreinfo">In which our robot learns to tell triangles from squares.</p>
</div>
</div>
</div>
</section>
<footer class="bg-info footer text-center" id="footer">
<div class="container">
<div class="row">
<div class="col-md-6 mb-0 mb-lg-0">
<a class="btn btn-primary btn-lg btn-block" href="https://github.com/ECE3400Team28/website/">View Code on GitHub</a>
<a class="portfolio-item btn btn-secondary btn-lg btn-block" href="#contract-modal">View Team Contract</a>
<a class="portfolio-item btn btn-primary btn-lg btn-block" href="#ethics-modal">View Ethics Assignment</a>
<a class="portfolio-item btn btn-secondary btn-lg btn-block" href="#report-modal">View Final Report</a>
</div>
</div>
</div>
</footer>
<!-- Scroll to Top Button (Only visible on small and extra-small screen sizes) -->
<div class="scroll-to-top d-lg-none position-fixed ">
<a class="js-scroll-trigger d-block text-center text-white rounded" href="#page-top">
<i class="fa fa-chevron-up"></i>
</a>
</div>
<!-- Portfolio Modals -->
<!-- Portfolio Modal 1 -->
<div class="portfolio-modal mfp-hide" id="portfolio-modal-1">
<div class="portfolio-modal-dialog bg-white">
<a class="close-button d-none d-md-block portfolio-modal-dismiss" href="#">
<i class="fa fa-3x fa-times"></i>
</a>
<div class="container text-center">
<div class="row">
<div class="col-lg-8 mx-auto">
<h2 class="text-secondary text-uppercase mb-0">Lab 1: Microcontroller</h2>
<hr class="star-dark mb-5">
<h3 class="mb-4">Description</h3>
<p class="mb-2 text-left">This lab introduces the Arduino Uno and Arduino IDE, and ends with the assembly of a basic robot performing autonomous driving. The lab takes approximately three hours, and requires the following <strong>materials</strong>:</p>
<ul class="mb-5 text-left">
<li class="li-center">1x Arduino Uno</li>
<li class="li-center">1x USB A/B cable</li>
<li class="li-center">2x Continuous Parallax Servos</li>
<li class="li-center">1x Solderless breadboard</li>
<li class="li-center">1x 1k-100k Potentiometer</li>
<li class="li-center">1x LED, any color</li>
<li class="li-center">Several 1k and 330 Ohm resistors</li>
</ul>
<hr>
<div class="media">
<div class="media-left">
<div class="embed-responsive video">
<iframe width="560" height="315" src="https://www.youtube.com/embed/ZAQedv_tLnw?rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
</div>
</div>
<div class="media-body">
<h4 class="media-heading">Blinking an internal LED</h4>
<span>After installing the <a href="https://www.arduino.cc/en/Main/Software">Arduino IDE</a> and any necessary drivers, we found the Blink.ino example provided under <mark>File</mark> >> <mark>Examples</mark> >> <mark>1.Basics</mark> >> <mark>Blink</mark>, which toggles the board’s built-in LED once per second.</span>
</div>
</div>
<hr>
<div class="media mb-2">
<div class="media-body">
<h4 class="media-heading">Blinking an external LED</h4>
<span>In order to test the other digital pins provided on the Uno, we created a global variable named <code>LED_PIN</code>, and modified the existing code to use this pin. We then changed the number assigned to the variable to test each digital pin. The following example tests digital pin 7.</span>
</div>
<div class="media-right">
<div class="embed-responsive video">
<iframe width="560" height="315" src="https://www.youtube.com/embed/-SuszBuhR4I?rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
</div>
</div>
</div>
<pre class="text-left">
<code>
const short LED_PIN = 7;
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_PIN as an output.
pinMode(LED_PIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_PIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_PIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
</code>
</pre>
<hr>
<div class="media mb-3">
<div class="media-left">
<div class="embed-responsive video">
<iframe width="560" height="315" src="https://www.youtube.com/embed/9hQ8VjL0_DI?rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
</div>
</div>
<div class="media-body">
<h4 class="media-heading">Reading the value of a potentiometer via the serial port</h4>
<span>For this portion of the lab we used a potentiometer to change the voltages on the analog input pin of the arduino, and then programmed the arduino to output these voltages to the serial monitor.</span>
</div>
</div>
<p class="mb-2 text-left">To do this we started serial communication and then read the analog input using <code>analogRead(INPUT_PIN)</code>. It should be noted that this does NOT return the actual voltage.</p>
<pre class="mb-0 text-left">
<code>
int INPUT_PIN = A0;
// the setup function runs once when you press reset or power the board
void setup() {
Serial.begin(9600);
}
// the loop function runs over and over again forever
void loop() {
delay(100);
// Analog input read
int input = analogRead(INPUT_PIN);
Serial.println(input);
}
</code>
</pre>
<p class="text-left mb-5">To set up the circuit we wired the output of the potentiometer to the Arudino’s A0(analog input) pin. We then supplied VCC to the wiper pin of the potentiometer and attached a 330 ohm resistor the the output of the potentiometer and GND to form a voltage divider. </p>
<hr>
<div class="media mb-3">
<div class="media-body">
<h4 class="media-heading">Mapping values to the LED</h4>
<span>To simulate and display an analog output, we connected an LED in series with a 330 ohm resistor to a digital pin with PWM capability (pin ~11). Then, we used our code for the potentiometer to pass its value as an input to the <code>analogWrite</code> function, along with the pin connected to the LED. </span>
</div>
<div class="media-right">
<div class="embed-responsive video">
<iframe width="560" height="315" src="https://www.youtube.com/embed/3bNpFlZQYro?rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
</div>
</div>
</div>
<p class="mb-2 text-left">We had to scale the potentiometer value because <code>analogWrite</code> only writes values from 0 to 255, whereas the 10-bit analog input results in a value from 0 to 1023. Different values for the potentiometer changed the brightness of the LED. The code is shown below.</p>
<pre class="mb-0 text-left">
<code>
const short LED_PIN = 11;
int INPUT_PIN = A0;
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_PIN as an output.
pinMode(LED_PIN, OUTPUT);
Serial.begin(9600);
}
// the loop function runs over and over again forever
void loop() {
delay(100);
// Analog input read
int input = analogRead(INPUT_PIN);
Serial.println(input);
// PWM
analogWrite(LED_PIN, input/4);
}
</code>
</pre>
<hr>
<div class="media mb-3">
<div class="media-left">
<div class="embed-responsive video">
<iframe width="560" height="315" src="https://www.youtube.com/embed/PLP5Jh7I-W8?rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
</div>
</div>
<div class="media-body">
<h4 class="media-heading">Mapping values to the servo</h4>
<span>We later used the value from the potentiometer to control a parallax servo. Similarly to the LED, we connected the servo to a PWM pin on the arduino (pin ~10). However, instead of using <code>analogWrite</code>, we imported the <code>Servo.h</code> library which takes care of setting the pin as an output and generating a proper waveform when we use its <code>attach()</code> and <code>write()</code> functions.</span>
</div>
</div>
<p class="mb-2 text-left">Again, the values had to be scaled, this time to the range of 0 to 180 that the servo library takes in for its write function. We also added some initial code which demonstrates the servo moving at full speed in both directions, and at a stop.</p>
<pre class="mb-0 text-left">
<code>
const short SERVO_PIN = 10;
int INPUT_PIN = A0;
Servo angrySpin;
// the setup function runs once when you press reset or power the board
void setup() {
Serial.begin(9600);
angrySpin.attach(SERVO_PIN);
angrySpin.write(0);
delay(1000);
angrySpin.write(90);
delay(1000);
angrySpin.write(180);
delay(1000);
}
// the loop function runs over and over again forever
void loop() {
delay(100);
// Analog input read
int input = analogRead(INPUT_PIN);
Serial.println(input);
// PWM
angrySpin.write(input/6);
}
</code>
</pre>
<hr>
<div class="media mb-3">
<div class="media-body">
<h4 class="media-heading">Assembling our robot</h4>
<span>To assemble our robot we used:</span>
<ul>
<li>A chassis</li>
<li>Two wheels</li>
<li>Several screws</li>
<li>A 9V battery</li>
<li>Ball bearing</li>
<li>Two servos</li>
<li>Arduino Uno</li>
</ul>
</div>
<div class="media-right">
<img class="media-object img-fluid" src="img/Robot.png" alt="Assembling our robot">
</div>
</div>
<p class="mb-5 text-left">To begin, we attached the servos to the mounts, and then attached them to the base of the robot. We then attached the wheels, which took some time because not all wheels fit nicely into the servos. We had to get a bit creative when attaching the ball bearing because there was only one left and it was too short for our robot. We ended up attaching a piece to the base of the robot to elongate the part where the ball bearing attached. This temporarily solved the issue. Lastly, we mounted the arduino and the battery with velcro.</p>
<hr>
<div class="media mb-3">
<div class="media-left">
<div class="embed-responsive video">
<iframe width="560" height="315" src="https://www.youtube.com/embed/JGP3CFYPiuo?rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
</div>
</div>
<div class="media-body">
<h4 class="media-heading">Driving our robot autonomously</h4>
<span>After assembling the robot, we wrote code for it to move autonomously. Initially, it was meant to move in a square, but the code did not work as expected and we did not have enough time to debug. The robot ended up moving in what appeared to be a pentagon.</span>
</div>
</div>
<pre class="mb-0 text-left">
<code>
void setup() {
// we set up two of our pins as outputs and attach our servos
int PWM1 = 3;
int PWM2 = 5;
pinMode(PWM1, OUTPUT);
pinMode(PWM2, OUTPUT);
Motor1.attach(PWM1);
Motor2.attach(PWM2);
}
void loop() {
// we write a loop to control the speed and direction that the motors spin
Motor1.write(180);
Motor2.write(0);
delay(1200);
Motor1.write(90);
Motor2.write(90);
delay(600);
turn();
}
void turn(){
// this function turns the robot
Motor1.write(180);
Motor2.write(180);
delay(350);
Motor1.write(90);
Motor2.write(90);
delay(250);
return;
}
</code>
</pre>
<a class="btn btn-secondary btn-lg rounded-pill" href="https://github.com/ECE3400Team28/website/tree/master/Lab1">View Lab 1 Code on GitHub</a>
<a class="btn btn-primary btn-lg rounded-pill portfolio-modal-dismiss" href="#">
<i class="fa fa-close"></i>
Close Lab 1</a>
</div>
</div>
</div>
</div>
</div>
<!-- Portfolio Modal 2 -->
<div class="portfolio-modal mfp-hide" id="portfolio-modal-2">
<div class="portfolio-modal-dialog bg-white">
<a class="close-button d-none d-md-block portfolio-modal-dismiss" href="#">
<i class="fa fa-3x fa-times"></i>
</a>
<div class="container text-center">
<div class="row">
<div class="col-lg-8 mx-auto">
<h2 class="text-secondary text-uppercase mb-0">Lab 2: Analog Circuitry and FFTs</h2>
<hr class="star-dark mb-5">
<h3 class="text-secondary mb-1">Acoustic Team</h3>
<h4 class="text-secondary mb-3">Liliet Sosa and Glenna Zhang</h4>
<h4 class="text-secondary text-left mb-3">Goal</h4>
<p class="mb-5 text-left">
Create a microphone circuit that will detect a 660 Hz whistle blow signifying the beginning of our maze mapping.
</p>
<hr class="mb-5">
<h4 class="text-secondary text-left mb-3">Prelab</h4>
<p class="mb-3 text-left">
We need at least a 660Hz x 2 = 1320Hz sampling rate based on the Nyquist sampling rate to avoid aliasing.<br />
Using the sketch found <a href="https://playground.arduino.cc/Main/ShowInfo">here</a>, these are the results of our speed test:
</p>
<img class="img-fluid mb-5" src="img/Lab 2 Photos/ShowInfoResult.png" alt="Serial Monitor result of ShowInfo"></img>
<p class="mb-3 text-left">
Based on this, <code>analogRead()</code> is sufficient (don’t need to use ADC) because its maximum rate is 111.987µs / sample = 1/111.987e-6 samples/s = 8930Hz, which is more than enough to detect the 660 Hz frequency.<br />
We used the following materials:
</p>
<ul class="mb-5 text-left">
<li><a href="https://www.mouser.com/datasheet/2/670/cma-4544pf-w-1309465.pdf">Electret microphone</a></li>
<li>One 6.8µF polarized capacitor</li>
<li>Resistors: 330Ω, 3.8kΩ, 380kΩ, 10kΩ x2</li>
<li>LM358 Op-amp</li>
<li>Wires</li>
</ul>
<hr class="mb-5">
<h4 class="text-secondary text-left mb-3">Unit Tests</h4>
<p class="mb-3 text-left">
<i>Unit Test 1: Set up a signal generator to deliver a signal that matches what you expect to see from your sensor. This signal must be between 0-5V to not damage the Arduino. Test that the frequency output from your signal generator matches what you see on the serial monitor.
</i><br />
<br />
The following is an image of our signal generator (set to 660Hz, 2V<sub>pp</sub>, 1V offset)
</p>
<img class="img-fluid mb-3" src="img/Lab 2 Photos/SigGen.jpg" alt="photo of signal generator"></img>
<p class="mb-3 text-left">
We then coded a quick FFT analysis and output the results to the serial monitor:
</p>
<img class="img-fluid mb-3" src="img/Lab 2 Photos/SerialOutput.png" alt="photo of signal generator"></img>
<p class="mb-0 text-left">
For each line in the image above, the first number is the output of the FFT, and the second number is the index of the bin for readability. As you can see, we have a peak at 0 and at 19. Our bin size should be around 8930Hz / 256samples = 34.883Hz/bin
So, our results make sense but are off by seemingly 1 bin.<br />
<br />
Our FFT code:
</p>
<pre class="mb-0 text-left"><code>
#define LOG_OUT 1 // use the log output function
#define FFT_N 256 // set to 256 point fft
#include <FFT.h> // include the library
void setup() {
Serial.begin(9600); // use the serial port
}
void loop() {
cli(); // UDRE interrupt slows this way down on arduino1.0
for (int i = 0 ; i < 512 ; i += 2) { // save 256 samples
fft_input[i] = analogRead(A4); // put real data into even bins
fft_input[i+1] = 0; // set odd bins to 0
}
fft_window(); // window the data for better frequency response
fft_reorder(); // reorder the data before doing the fft
fft_run(); // process the data in the fft
fft_mag_log(); // take the output of the fft
sei();
Serial.println("start");
String out = "";
for (byte i = 0 ; i < FFT_N/2 ; i++) {
Serial.println(out + fft_log_out[i] + " " + i); //send out data
}
while(1) {} // we inserted this so that it only prints one result
}
</code></pre>
<p class="mb-3 text-left">
<i>Unit Test 2: Use the app you downloaded during the pre-lab to generate a 660Hz tone. Measure the output from the microphone with the oscilloscope, and try to get an idea of what you need to do to the signal to be able to detect it securely from the Arduino.
</i><br />
<br />
The following is the microphone circuit thus far, as taken from the lab handout:
</p>
<img class="img-fluid mb-2" src="img/Lab 2 Photos/MicrophoneCircuit_OG.png" alt="Original microphone circuit"></img>
<p class="mb-3 text-left">
After generating the tone, the microphone could not pick up the signal, but we knew the microphone was working because if we blew into the microphone the output would obviously change, as shown below:
</p>
<p class="mb-4"><b>Resting state of microphone</b></p>
<img class="img-fluid mb-4" src="img/Lab 2 Photos/Microphone_Resting.jpg" alt="Output of microphone resting"></img>
<p class="mb-4"><b>Microphone being blown on</b></p>
<img class="img-fluid mb-4" src="img/Lab 2 Photos/Microphone_Blowing.jpg" alt="Output of microphone resting"></img>
<p class="mb-3 text-left">
From this result, we decided to add an amplifier and a filter. After struggling to get our own design to work, we decided to use <a href="https://cei-lab.github.io/ECE3400-2017-teamAlpha/lab2.html">Team Alpha's design</a> that incorporates an inverting amplifier, has a voltage divider to center the output voltage around 2.5V, and has a gain of 100:
</p>
<img class="img-fluid mb-2" src="img/Lab 2 Photos/MicCircuit.png" alt="Output of microphone resting"></img>
<p class="mb-3 text-left">
<i>Unit Test: Check your circuitry before hooking it up to the Arduino.</i><br />
<br />
Below is the result of using the amplifier while playing a 660Hz tone, displayed on the oscilloscope:
</p>
<img class="img-fluid mb-3" src="img/Lab 2 Photos/Microphone_Signal.jpg" alt="Output of microphone resting"></img>
<p class="mb-3 text-left">
Clearly, this signal can be sent into the Arduino as its minimum voltage is 2.12V and its peak-to-peak voltage is 840mV, which is well within the 0-5V range. The frequency is also correct.<br />
The following is a picture of the physical circuit, where the purple wire is the output signal:
</p>
<img class="img-fluid mb-5" src="img/Lab 2 Photos/Circuit.jpg" alt="Output of microphone resting"></img>
<hr class="mb-5">
<h4 class="text-secondary text-left mb-3">Results</h4>
<p class="mb-3 text-left">
After connecting the circuit to our robot and changing the code that controls how the robot starts to incorporate waiting for the 660Hz signal, this is a video of our successful result:
</p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/aNj-LKDwgoE?rel=0" frameborder="0" allow="autoplay; encrypted-media" class="mb-3" allowfullscreen></iframe>
<p class="mb-0 text-left">
The following is our updated line following code to show that our robot waits for a signal before starting:
</p>
<pre class="mb-0 text-left"><code>
// In set-up, we wait while the signal has not been heard and the button has not been pressed:
while(!readSignal() && digitalRead(8) != HIGH);
// The following is our readSignal() method that calculates the FFT and returns true or false based on if the signal has been heard. We are reading the analog signal from A4:
boolean readSignal() {
cli(); // UDRE interrupt slows this way down on arduino1.0
for (int i = 0 ; i < 512 ; i += 2) { // save 256 samples
fft_input[i] = analogRead(A4); // put real data into even bins
fft_input[i+1] = 0; // set odd bins to 0
}
fft_window(); // window the data for better frequency response
fft_reorder(); // reorder the data before doing the fft
fft_run(); // process the data in the fft
fft_mag_log(); // take the output of the fft
sei();
if (fft_log_out[19] >= 50){ // check that bin 19 contains a significant value
return true;
}
return false;
}
</code></pre>
<hr class="mb-5">
<h3 class="text-secondary mb-1">Optical Team</h3>
<h4 class="text-secondary mb-3">Anthony Viego and Kevin Ying</h4>
<h4 class="text-secondary text-left mb-3">Goal</h4>
<p class="mb-5 text-left">
Create a circuit which is able to detect a 6.08kHz IR signal signifying other robots which have to be avoided in the maze while discarding 18kHz decoy IR signals.
</p>
<hr class="mb-5">
<h4 class="text-secondary text-left mb-3">Prelab</h4>
<p class="mb-3 text-left">
Unlike the microphone circuit, using AnalogRead will not be fast enough for IR purposes.
We want to be able to detect 6kHz signals, which would require a sampling frequency of
approximately 12kHz. However, the maximum with AnalogRead is approximately 8930Hz,
as discussed above. Instead, we will have to read directly from the ADC pin result
register to increase our sampling frequency. Since we will have to sample at such a high frequency,
it will be difficult to do other processing simultaneously - we will have to carefully
determine when to measure as to not miss other robots while were are making decisions
about where to drive.
</p>
<p class="mb-3 text-left">
Thankfully, we don't have to worry as much about other sources of IR, which are unlikely to occur at the same frequency. For example, one common source of IR is fluorescent lights, but they emit approximately 30-60kHz signals. Testing in lab confirms that even in the presence of artificial lights and sunlike, the main source of noise for IR is 60Hz coming from the walls.
</p>
<hr class="mb-5">
<h4 class="text-secondary text-left mb-3">Frequency Detection and Amplification Circuit</h4>
<p class="mb-3 text-left">
In order to build the amplification circuit, we needed the following materials in addition to our usual Arduino Uno setup:
</p>
<ul class="mb-5 text-left">
<li class="li-center">2x OP598A Phototransistor</li>
<li class="li-center">2x LM358 Dual OP-Amp</li>
<li class="li-center">1x 430 Ohm Resistor</li>
<li class="li-center">1x Solderless breadboard</li>
<li class="li-center">2x 1k Resistor</li>
<li class="li-center">1x 10k Resistor</li>
<li class="li-center">1x 100k Resistor</li>
<li class="li-center">1x 24k Resistor</li>
<li class="li-center">1x 10nF Capacitor</li>
</ul>
<p class="mb-3 text-left">
Overall our circuit for detecting other robots can be broken down into 3 stages.
A picture of our completed IR circuit is below. You can see that one the top right
of the image, there exist two phototransistors in series. That then feeds into the
op-amp ICs, and the output commes out of the light blue wire which goes off-screen
to the left.
</p>
<figure>
<img class="img-fluid mb-3" src="img/Lab 2 Photos/IR_circuit.jpg" alt="Completed IR Capture and Amplification Circuit"></img>
<figcaption>Figure: Completed IR Capture and Amplification Circuit</figcaption>
</figure>
<h5 class="text-secondary text-left mb-3">Stage 1: IR Capture</h4>
<p class="mb-3 text-left">
The first stage of our circuit is similar to the suggested circuit in the <a href="https://cei-lab.github.io/ece3400-2018/lab2.html">lab 2 handout</a>. However, rather we chose to use two resistors in parallel and two phototransistors in series to increase the amplitude of the produced signal. Figure 1 shows this stage of the circuit. As the output of our circuit ranged from 20mVpp to 100mVpp at very close distances, we decided to amplify the output of this stage to increase the distance we can detect other robots from.
</p>
<figure>
<img class="img-fluid mb-3" src="img/Lab 2 Photos/IR_capture_circuit.png" alt="IR Capture Circuit"></img>
<figcaption>Figure: IR Capture Circuit</figcaption>
</figure>
<p class="mb-3 text-left">
Once we implemented the output capture circuit, we probed the output of
the first stage with an oscilloscope when holding a treasure close to
the phototransistors. The treasures were tunable in frequency, so we
were able to output both a 6.2kHz signal and a 18kHz signal, which
approximate the frequencies emitted by the other robots and the decoy
robots in the maze respectively. While there is a visible signal, its
peak-to-peak voltage is very small, meaning that the Arduino would not
easily be able to tell when the signal was present. In addition, in
order to even get this clear of a signal, we needed to hold the IR
source very close to the phototransistors, which would not be a viable
solution for detecting robots from several inches away. We needed to
add analog amplification.
</p>
<figure>
<img class="img-fluid mb-3" src="img/Lab 2 Photos/scope_no_amp.png" alt="Oscilloscope Output of IR Signal Before Amplification"></img>
<figcaption>Figure: Output of IR Signal Before Amplification</figcaption>
</figure>
<h5 class="text-secondary text-left mb-3">Stage 2: Amplification</h4>
<figure>
<img class="img-fluid mb-3" src="img/Lab 2 Photos/ir_amp_circuit.png" alt="Amplification Circuit Diagram"></img>
<figcaption>Figure: Amplification Circuit Diagram</figcaption>
</figure>
<p class="mb-3 text-left">
This stage is responsible for amplifying the output of our IR capture circuit.
The circuit itself can be seen in figure 2 below. It should be noted that the
output of the IR capture circuit has a DC bias of approximately 2.5V. Since we
plan to have 20x gain, this would mean our signal would always hit the max voltage
of 5V and would appear to be a constant high signal. Thus, to remove this bias
we implemented a high pass RC filter using a 10k resistor and 10nF capacitor
which has a cutoff frequency of roughly 1592Hz.
</p>
<p class="mb-3 text-left">
We then fed the output of the low pass filter into a non-inverting amplifier.
We used a 20k resistor and 1k resistor set up in a negative feedback loop to
achieve a gain of roughly 20x. We found that this amplification level gave us
the clearest results on our output.
</p>
<h5 class="text-secondary text-left mb-3">Stage 3: Comparator</h4>
<figure>
<img class="img-fluid mb-3" src="img/Lab 2 Photos/ir_comp_circuit.png" alt="Comparator Circuit Diagram"></img>
<figcaption>Figure: Comparator Circuit Diagram</figcaption>
</figure>
<p class="mb-3 text-left">
In order to further amplify our output, we fed the output of the amplification
circuit to a comparator circuit, which we hoped would further increase the
gain of our circuit and improve the signal quality. We first sent the input
through a unity gain voltage buffer which ensured that as we experimented
with different types of amplifiers and comparator circuits, the gain of each
would act independently. With our final design, we no longer need the unity
gain amplifier and may remove it to compact our circuit.
</p>
<p class="mb-3 text-left">
The second half uses a comparator with a voltage generated with a voltage divider.
We first determined a voltage that we wanted to compare against by stepping
through voltage levels on a DC power supply until the desired result was achieved.
We found that we were able to get the clearest signal from the greatest range of
distances for the IR treasure for a comparator reference voltage of
approximately 23mV. The values of the resistors in the voltage divider were then
determined to approximate that voltage, since 5V * (430/100000) = 21.5mV.
</p>
<p class="mb-3 text-left">
With the new amplifier and comparator, we were able to achieve the following output even when the IR emitter treasure was held 3-4 inches away from the phototransistors.
</p>
<figure>
<img class="img-fluid mb-3" src="img/Lab 2 Photos/ir_with_amp.png" alt="Oscilloscope Output of IR Signal With Amplification"></img>
<figcaption>Figure: Output of IR Signal With Amplification</figcaption>
</figure>
<h4 class="text-secondary text-left mb-3">FFT</h4>
<p class="mb-3 text-left">
Once we had a high signal-to-noise ratio and a clear signal, we now wanted to
be able to read data into the Arduino and process the inputs to determine the
frequencies coming in. To do this we connected the output of our comparator
circuit to pin A0 of the arduino. We then used adc0 to read in the output of
the comparator circuit from the ADCL and ADCH registers and converted these
values into a single 16 bit integer. These values were then stored in the
<code>fft_input</code> array which was then used by the fft library to calculate the
magnitude of each bin. The graph below shows the result of this operation
for a 6kHz and 18kHz signal.
</p>
<figure>
<img class="img-fluid mb-3" src="img/Lab 2 Photos/ir_6k_18k_comparison.png" alt="Overlaid FFT Output for Amplified IR Sensor Signal"></img>
<figcaption>Figure: Overlaid FFT Output for Amplified IR Sensor Signal</figcaption>
</figure>
<p class="mb-3 text-left">
As can be seen, the peak magnitude of the 6kHz signal is around bin 40. This
result is relatively accurate as our base clock for the arduino is 16MHz with
an ADC clock prescaler of 32. As each ADC read takes 13 clock cycles this
results in a sampling frequency of 38461.53. As we take 256 samples this
means that each bin represents 150.24 Hz. If we divide 6.08kHz by 150.24Hz
we find that the peak of our 6kHz single should be in bin 40 which is what
we found.
</p>
<p class="mb-3 text-left">
We then use this information to determine when a 6kHz signal is present by
checking to see if the magnitude of bins 38 - 44 are above 150. We decided
to use 150 as our threshold since general noise did not seem to create peaks
above 75 and the 18kHz signal also does not generate peaks in that range
above 100. By checking a range of bins we are able to determine if an
approximate 6kHz signal is present while having some tolerance incase the
frequency is not exact. The code, which is inside of a loop, is as follows:
</p>
<pre class="mb-0 text-left"><code>
cli(); // UDRE interrupt slows this way down on arduino1.0 so we disable interrupts
// save 256 samples
for (int i = 0 ; i < 512 ; i += 2) {
while(!(ADCSRA & 0x10)); // wait for adc to be ready
ADCSRA = 0xf5; // restart adc
byte m = ADCL; // fetch adc data
byte j = ADCH;
int k = (j << 8) | m; // form into an int
k -= 0x0200; // form into a signed int
k <<= 6; // form into a 16b signed int
fft_input[i] = k; // put real data into even bins
fft_input[i+1] = 0; // set odd bins to 0
}
// process FFT data
fft_window(); // window the data for better frequency response
fft_reorder(); // reorder the data before doing the fft
fft_run(); // process the data in the fft
fft_mag_log(); // take the output of the fft
sei(); // re-enable interrupts
Serial.println("start");
for (byte i = 0 ; i < FFT_N/2 ; i++) {
Serial.println(fft_log_out[i]); // send out the data for off-chip processing
}
delay(1000);
for (int j = 38; j < 44; ++j) {
if (fft_log_out[j] >= 150){
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // in reality, delay does not block other cmds so LEDs flash
}
}
</code></pre>
<p class="mb-3 text-left">
The results can be shown below.
</p>
<iframe class="mb-5" width="560" height="315" src="https://www.youtube.com/embed/GuVrt4HzFvU?rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
<hr class="mb-5">
<h3 class="text-secondary mb-1">The Final Integration</h3>
<p class="mb-3 text-left">
We then combined the results of the IR team and the acoustic team into one larger project!
</p>
<iframe class="mb-5" width="560" height="315" src="https://www.youtube.com/embed/RVqd22eCrKk?rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
<a class="btn btn-secondary btn-lg rounded-pill" href="https://github.com/ECE3400Team28/website/tree/master/Lab2">View Lab 2 Code on GitHub</a>
<a class="btn btn-primary btn-lg rounded-pill portfolio-modal-dismiss" href="#">
<i class="fa fa-close"></i>
Close Project
</a>
</div>
</div>
</div>
</div>
</div>
<!-- Portfolio Modal 3 -->
<div class="portfolio-modal mfp-hide" id="portfolio-modal-3">
<div class="portfolio-modal-dialog bg-white">
<a class="close-button d-none d-md-block portfolio-modal-dismiss" href="#">
<i class="fa fa-3x fa-times"></i>
</a>
<div class="container text-center">
<div class="row">
<div class="col-lg-8 mx-auto">
<h2 class="text-secondary text-uppercase mb-0">Lab 3: System Integration and Radio Communication</h2>
<hr class="star-dark mb-5">
<h3 class="text-secondary mb-1">Radio Team</h3>
<h4 class="text-secondary mb-3">Kevin Ying and Glenna Zhang</h4>
<h4 class="text-secondary text-left mb-3">Goal</h4>
<p class="mb-5 text-left">
In this lab we established a communication protocol between one Arduino, which will be on our robot, and another, which will remain at a base station and need to interface with a GUI to display the progress of our robot. This interface will also come in handy for debugging because we will be able to determine the progress of our robot and what it has discovered.<br />
<br />
In order to communicate wirelessly, we used a pair of Nordic nRF24L01+ transceivers, as well as the relevant libraries. (can be found <a href="https://cei-lab.github.io/ece3400-2018/lab3.html">here</a>)
</p>
<hr class="mb-5">
<h4 class="text-secondary text-left mb-3">Data Scheme & Protocol</h4>
<p class="mb-3 text-left">
We use the following two variables to store the current location of our robot:<br />
<code>uint8_t x = 0; // stores the x index/coordinate</code><br />
<code>uint8_t y = 0; // stores the y index/coordinate</code><br />
We use the following 2-D array to store what we discover about each tile of the maze:<br />
<code>uint8_t maze[9][9] = {...};</code>
<br />
We have also defined a set of macros that help us easily construct the correct bit sequence that describes what our robot sees, based on our protocol:
</p>
<pre class="mb-0 text-left">
<code>
// walls
#define bm_wall 15 << 0
#define bm_wall_east 1 << 1
#define bm_wall_north 1 << 3
#define bm_wall_west 1 << 0
#define bm_wall_south 1 << 2
// treasure
#define treasure_shift 4
#define bm_treasure_none 0 << 4
#define bm_treasure_b_sq 1 << 4
#define bm_treasure_r_sq 2 << 4
#define bm_treasure_b_ci 3 << 4
#define bm_treasure_r_ci 4 << 4
#define bm_treasure_b_tr 5 << 4
#define bm_treasure_r_tr 6 << 4
// whether square explored
#define bm_explored 1 << 7
#define bm_not_explored 0 << 7
#define explored_shift 7
// presence of other robot
#define bm_robot 1 << 1
#define bm_no_robot 0 << 1
#define robot_shift 1
</code>
</pre>
<p class="mb-3 text-left">
We learned that the maximum package the Nordic Radio module can send is 32 bytes, but we realized we only need to send 2 bytes of data to fully describe each tile, which means we were able to use a single transmission/packet per tile/cell. The following image describes the structure of our protocol:
</p>
<figure>
<img class="img-fluid mb-3" src="img/Lab 3 Photos/Protocol.png" alt="Protocol of our communication method"></img>
<figcaption>Figure 1: Communication protocol</figcaption>
</figure>
<p class="mb-5 text-left">
We believe that this protocol provides sufficient information about the state of the board. It includes the x and y coordinates of the current tile, which has just been explored. The explored bit is mainly for the robot itself to know if it has explored a tile. The treasure bits represent one of seven options: no treasure, blue square, red square, blue circle, red circle, blue triangle, and red triangle. Lastly, the for the bits representing each wall (north, south, east, west), a 1 represents that the wall is present in this tile and a 0 means it isn’t there.
</p>
<hr class="mb-5">
<h4 class="text-secondary text-left mb-3">Sending maze information wirelessly between Arduinos</h4>
<p class="mb-3 text-left">
We wrote a program to make a virtual robot explore a 9x9 maze with preset walls and treasures in order to test our radio communication and our protocol. We hard-coded the robot’s sequence of exploration for ease- it just snakes around the maze, as there is only one path anyway. We set the role of the virtual robot to “role_ping_out”, a.k.a. the transmitter, and we set the other Arduino to “role_pong_back”, or the receiver.<br />
<br />
The following is our setup code, which is very similar to the setup found in the GettingStarted sketch in the RF24 Arduino library:
</p>
<pre class="mb-0 text-left">
<code>
void setup(void) {
// Print preamble
Serial.begin(9600);
printf_begin();
printf("\n\rRF24/examples/GettingStarted/\n\r");
printf("ROLE: %s\n\r",role_friendly_name[role]);
printf("*** PRESS 'T' to begin transmitting to the other node\n\r");
// Setup and configure rf radio
radio.begin();
radio.setRetries(15,15);
radio.setAutoAck(true);
radio.setChannel(0x50);
// set the power