Created
March 14, 2021 19:14
-
-
Save giuliomoro/9575dbc688ff67de9b4905b38bb98186 to your computer and use it in GitHub Desktop.
HC-SR04 for Pd on Bela, sample-accurate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#N canvas 87 19 1280 778 12; | |
#X obj 160 234 samphold~; | |
#X floatatom 160 311 7 0 0 0 - - -; | |
#X obj 160 279 snapshot~; | |
#X obj 49 138 loadbang; | |
#X obj 51 181 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1 | |
1; | |
#X obj 806 40 loadbang; | |
#X obj 808 83 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1 | |
1; | |
#X text 11 253 Printing metro; | |
#X obj 161 346 print; | |
#X msg 799 193 1; | |
#X obj 816 311 dac~ 11; | |
#X obj 30 18 loadbang; | |
#X obj 30 80 s bela_setDigital; | |
#X obj 301 97 adc~ 12; | |
#X text 130 160 "timing capacitor"; | |
#X msg 260 149 0; | |
#X obj 66 221 metro 100; | |
#N canvas 0 22 450 278 (subpatch) 0; | |
#X array diff 4000 float 2; | |
#X coords 0 1 4000 -1 200 70 1 0 0; | |
#X restore 380 467 graph; | |
#N canvas 0 22 450 278 (subpatch) 0; | |
#X array pulse_in 4000 float 2; | |
#X coords 0 1 4000 0 200 30 1 0 0; | |
#X restore 381 418 graph; | |
#X msg 865 225 0, f 2; | |
#X obj 302 175 rzero~ 1; | |
#X obj 302 199 *~ -1; | |
#X obj 864 191 delay 3; | |
#X floatatom 449 51 5 0 0 0 - - -; | |
#X obj 820 251 *~ 1; | |
#X obj 803 138 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 | |
-1 -1; | |
#X obj 449 85 delread~ fake_pulse; | |
#X obj 466 249 delwrite~ fake_pulse 1000; | |
#X msg 30 48 out 11 ~ \, in 12 ~; | |
#X text 460 178 When using with the actual sensor on Bela \, delete | |
delread~ \, delwrite~ and the tabwrite~; | |
#N canvas 0 22 450 278 (subpatch) 0; | |
#X array timing 4000 float 2; | |
#X coords 0 1 4000 0 200 140 1 0 0; | |
#X restore 380 557 graph; | |
#X obj 327 373 tabwrite~ timing; | |
#X obj 433 322 tabwrite~ pulse_in; | |
#X obj 452 374 tabwrite~ diff; | |
#X obj 160 184 phasor~ 1; | |
#X text 750 336 Send pulse to TRIG (digital out 0); | |
#X text 204 64 Receive pulse from ECHO (digital in 1); | |
#X text 492 22 fake delay between TRIG and ECHO to emulate an input | |
pulse of <<< given delay; | |
#X text 637 103 When a pulse starts \, also restart the timing phasor | |
; | |
#X text 5 310 Delay time in 1/T >>> where T is the period of the phasor | |
(proportional to distance); | |
#X text 879 72 Pulse generator. Can run faster \, but not faster than | |
the delay between TRIG OUT and ECHO IN; | |
#X text 5 391 This has a slight offset when emulating via delwrite~ | |
/ delread~. Also when using the actual device there is a minimum delay | |
offset due to block size; | |
#X obj 808 106 metro 100; | |
#X connect 0 0 2 0; | |
#X connect 1 0 8 0; | |
#X connect 2 0 1 0; | |
#X connect 3 0 4 0; | |
#X connect 4 0 16 0; | |
#X connect 5 0 6 0; | |
#X connect 6 0 42 0; | |
#X connect 9 0 24 0; | |
#X connect 11 0 28 0; | |
#X connect 13 0 20 0; | |
#X connect 15 0 34 1; | |
#X connect 16 0 2 0; | |
#X connect 19 0 24 0; | |
#X connect 20 0 21 0; | |
#X connect 21 0 0 1; | |
#X connect 21 0 33 0; | |
#X connect 22 0 19 0; | |
#X connect 23 0 26 0; | |
#X connect 24 0 10 0; | |
#X connect 24 0 27 0; | |
#X connect 25 0 9 0; | |
#X connect 25 0 15 0; | |
#X connect 25 0 22 0; | |
#X connect 25 0 32 0; | |
#X connect 25 0 33 0; | |
#X connect 25 0 31 0; | |
#X connect 26 0 20 0; | |
#X connect 26 0 32 0; | |
#X connect 28 0 12 0; | |
#X connect 34 0 0 0; | |
#X connect 34 0 31 0; | |
#X connect 42 0 25 0; |
Author
giuliomoro
commented
Mar 14, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment