That may be due to the zoom of the browser tab containing your IDE window not being 100%.
Help needed involving HC-SR04 Ultrasound Sensors
giuliomoro Yep I zoomed out for one of the screenshots haha
https://github.com/BelaPlatform/Bela/issues/275
Or maybe try to clear the console manually (with the button or cmd-k or ctrl-k).
I have a full PD solution for this if you're interested
https://github.com/5un/bela-ultrasonic-distance-pd
(Connection is all like in Bela's official c++ example)
soravis I have a full PD solution for this if you're interested
Brilliant! What is the purpose of the [metro]
banging the [print]
?
If @sambilbow was interested in a similar solution, be advised that this is using the analog outputs ([adc~ 3]
) so you will have to change it to use the Digitals.
Incidentally, @sambilbow: did you need an external transistor to amplify the 3.3V to 5V to trigger the HC-SR04 or did it work straight from the 3.3V ?
giuliomoro
The [metro] and [print] was totally unnecessary and it's just for logging out the current distance from time to time. In terms of power source, I feed HC-SR04's vcc with Bela's SYS 5V like advised in the C++ example.
giuliomoro It worked straight from the digital outputs I connected it to. !
By the way, the patch is going well now, I'm just fiddling with some Pd at the moment. I've come across a problem where if i stop the patch running in the IDE before a solenoid has received a 0 message, the solenoid will stay ON, causing it to get very hot (burnt one out yesterday) (its also connected to 12v). Is there any sort of reverse loadbang? where I can bang 0 to all solenoids upon closing the patch (stopping the IDE). I saw the bottom section of the render.cpp and it seems that would be the place to put it, but I'm not sure...
There is no such possibility unfortunately, though you could implement it using a custom render file.
However, if your program was to crash, then there would be no way for it to terminate gracefully. Also, no one would prevent you from having a bug in your code that would cause a similar behaviour while the patch is running.
Generally speaking, it is often best to have a software-proof hardware, so that any bug or unexpected behaviour of the software will not cause a hardware failure. In your case, as you are making a percussion instrument, you may want to have a high-pass filter to provide AC coupling between the digital output and the mosfet, so that the solenoid is only triggered on a positive voltage change and it never sticks "on".
- Edited
I think I've fixed the problem, the delay between the 1 and 0 message was way too long, and now I make sure there is nothing within my operating range on the sensors (5-45cm).
But, as always, I have a new problem . Well, not exactly a problem, more of an oversight. I didnt realise how much of a flat surface has to be used for the sensor to 'hear' the echo back. After a long time looking at my code, wondering why suddenly sometimes all of the solenoids actuate, I realised it was because when the sensor doesn't receive an echo, it panics and sends an output to some or all of the solenoids, causing them to turn on (I think its something to do with Bela as I get a block dropped when it happens. Normally what happens is there is a massive spike in the distance received which is normally 5-45cm, so it spikes 300 or something, and then block dropped, and then the solenoids panic actuate... My pure data patch has conditions in it, so that the only time the solenoids actuate should be when the distance is between 5-45cm, this leads me to believe that its a bela/cpp problem).
On an unrelated note, I've just Run the project and nothings working??? No print data going to the console, no solenoids reacting to the sensors. I made a test metro-print patch, and its not printing anything to the console. I've tried unplugging, ejecting the SD card. Any ideas?
Thanks for any help
https://i.imgur.com/X1YTxGb.jpg This works
https://i.imgur.com/F4d8hES.jpg This angle sometimes fails to return the signal to the sensor causing Bela to panic
you should find the cause of the dropped block and fix it. That is typically caused by an infrequent but expensive computation, for instance a large block of audio data processed at once, a large message parsed occasionally, an unusually large number of messages fired/processed in the same audio block. In your case it may well be this last one, and it only happens for certain distances perhaps?
When a dropout occurs, all the outputs send out zeros.
I seem to remember that the sensor detects objects not just in front of it but also at an angle of about 15 degrees.
giuliomoro re: my second problem of not getting any printed messages in the console or any solenoids actuating, I tried to update my Bela board but got this error
- Edited
Previous to updating the Bela, this is all that would happen when I hit run. There should be printed messages in the console after this initiation (there used to be anyway) but it just stopped happening....
Okay so I reflashed the SD card and we're back to having no printed messages in the console. No more errors but none of my project is working anymore like before
- Edited
Here is the test I was talking about, surely a bang should be being printed every 100ms? This was done in a new Pd project, with no render file.
- Edited
Ok we're back up and running, realised that one of my resistors blew at some point (bit worrying but I think we're ok, might also have been disconnected slightly because I was messing around with the sensors. Basically the way I had the print object wired meant that it needed both sensors to send info in order to print (hot and cold inlet on the {list} object). Since the main sensor wasn't sending info because the circuit wasn't complete, I wasn't getting any printed messages, and because the main sensor is what actuates the solenoids, thats why they weren't getting any messages
Sorry for all the posts, but it might help someone in the future, and is also helpful for my writeup next week.
Good that it worked out for you in the end. Bad that the update boars didn't work, I will have to investigate that. Could you confirm what image used to be on your board, or when you received the board?
Which image did you flash now?
giuliomoro I flashed the latest Github zip to the board, don't know what was on it before I'm afraid as it belongs to the university. I flashed probably the latest version to the SD card, unless thats the same thing, in which case, yep the latest version.
giuliomoro Just because I'm curious, in post 46 of this thread, why wasn't I receiving the bang message in the console?