Unicorpse Analog 5V:
- one sensor connected: 3.5V (working: sends/receives data on Bela IDE console/Pure Data audio reacts)
- two sensors connected: 2.9V (no data)

ok this is expected. That pin has 100ohm in series, so the voltage goes down when you connect a load that is too high.

Unicorpse P9.07:
- one sensor connected: 4.9V (no data - weird?)
- two sensors connected: 3-4V (no data)

Now, this is very weird. One sensor connected should work just fine. Not sure what to say about it, have you tried both sensors (one at a time)? Where do you connect the ground of the sensor? It shouldn't make any difference, but make sure you plug it in P9.01/P9.02.

Unicorpse Not sure if this is weird or a clue - one sensor works/sends data when using the analog 5V, but switch to P9.07 and that sensor stops working.

Yeah this is crazy. Also, only now I notice that you wrote this in your first post, apologies for missing it.

Unicorpse running negative to the Bela & sensor, positive just to the sensor, and trigger/echos to BELA (if I've understood this correctly?).

Yes.

Unicorpse I get fairly consistent readings of 3-4.5V

this sounds pretty weird. You have "consistent" readings between 3V and 4.5V ???

Unicorpse both Bela & sensor don't power on/no reaction.

You should still power Bela through the USB port, it wouldn't be powered by the battery in this configuration.

Thanks a lot! I'm slightly reassured that I'm not the only one finding it weird.

I'll be back in the studio tomorrow so can come back to this properly then - I'm wondering though is it at all possible that something in the code is preventing the trigger from going, is there a part about voltage "send"?

there are many ways the code can go wrong πŸ™‚ however, if the sensor is working on the 5V from the analog in header, and it stops working the moment you move it to the 5V supply on P9.07 (without code changes) [which is what my understanding of what is happening to you], then there is definitely something weird, although I would be very surprised if the power management IC just decides to shut down or throttle the 5V supply, with the rest of the board being happy and healthy.

Can you try removing the audio expander capelet and see if the problem persists?

Another thing to try: run a regular program which uses audio and analog inputs. Plug in the two sensors between GND and 5V. If you read a voltage lower than 5V there, does that affect the audio and the analog inputs?

I also have another unorthodox thing to try: what about you just power the HC-SR04 from 3.3V? I know, the datasheet calls for 5V, however you have been successfully running it from 3.5V so far (because of the 100 ohm resistance in series with the output you were using), so it's worth trying if it works fine from 3.3V. When running from 3.3V, you may have to adjust (or remove) the resistor divider for the echo pin, but most likely it'll be fine . DO NOT run it without the resistor divider when you are powering (or trying to power it πŸ™‚ ) from 5V!

Thanks again Giuliomoro - so I tried the 3.3V and basically went back to basics, even resoldering one of the resistor dividers and trying the different voltage out pins etc, still with no change.

However and I hope this isn't me being dumb from the very start... But I tried powering one of the sensors from the analog 5V, and the second sensor separately powered from the P9.07 pin - and it worked! (Still resistor divider on each sensor echo out).

Both sensors are a teeny bit delayed it seems but I'm over the moon that they are both working and sending readable data! I just need to get my Pure Data patch sounding better now ha.

What do you think? Is this performing as expected - was I supposed to do this from the very start?? Vice versa are there any reasons why I shouldn't do this?

Thank you so much again for all your help with this - there's no way I would have kept pushing on without your suggestions or support and I've learned a lot in the process.

    Unicorpse - so I tried the 3.3V and basically went back to basics, even resoldering one of the resistor dividers and trying the different voltage out pins etc, still with no change.

    I take it this means that it didn't work powering from 3.3V ? Ok, but that was worth trying.

    Unicorpse However and I hope this isn't me being dumb from the very start... But I tried powering one of the sensors from the analog 5V, and the second sensor separately powered from the P9.07 pin - and it worked! (Still resistor divider on each sensor echo out).

    That does not make any sense, I have no idea what is going on here.

    Unicorpse Both sensors are a teeny bit delayed it seems but I'm over the moon that they are both working and sending readable data! I

    Not sure how any of the above would make any difference in terms of delay, but again, I don't understand what the problem was /is.

    Unicorpse What do you think? Is this performing as expected - was I supposed to do this from the very start?? Vice versa are there any reasons why I shouldn't do this?

    I am very surprised it didn't work otherwise. If it works... good for you! but I am very confused.

    Unicorpse Thank you so much again for all your help with this - there's no way I would have kept pushing on without your suggestions or support and I've learned a lot in the process.

    ha, you are welcome. In the process I lost a lot of confidence in determinism and science πŸ™‚

    Unicorpse But I tried powering one of the sensors from the analog 5V, and the second sensor separately powered from the P9.07 pin - and it worked!

    I mean ... maybe there is one explanation, but it will sound very silly. Let's say you that [for whatever reason], you have exactly 29mA spare current available from the 5V supply. Now:
    - if you connect the two sensors to P9.07, they will draw 30mA total (15mA each) and therefore will not work.
    - If you connect only one sensor at the 5V from the analog out header, this will actually be underpowered at 3.5V, and draw less current, 10.5mA, but nevertheless work.
    - If you connect both sensors there, then the voltage will be so low that they will both stop working (even though they do not exceed the available current).
    - if you plug one on P9.07 and one on the analog out, they will absorb 15mA and 10.5mA respectively, so everything will work fine

    However:

    • I would expect you to have far more than 29mA available on the 5V rail (there should be at least 200mA, I estimate)
    • if you were actually overloading the 5V rail, I would expect the power management IC to just shut down everything.
    • this does not explain why connecting only one sensor to P9.07 does not work.
    • Β―\_(ツ)_/Β―
    13 days later

    Hi! Sorry for the slow reply... I've been working away on the project but was meaning to get back to you to talk it through to see if we can't get to the bottom of this mystery πŸ™‚

    However in the meantime a terrible thing has happened (day before installation - wonderful...). I'm not sure how but my render file has completely disappeared from the Bela completely randomly. I remember I had copy and pasted my code onto this thread but that appears to have been edited out. Is it possible to go back through the thread archive to recover the code I copied, so I can copy it back onto the bela please??

    Once this project is over I'd love to go through the possibilities to see what the issue might have been!

    Unicorpse Me again... I'm trying to recreate the custom cpp file but now getting this error:

    ehmm... I posted it above, minutes after your earlier comment.

    giuliomoro Sorry I missed this reply before writing again! Thanks - I'll test that out now

    How do I check the board version?

      Unicorpse How do I check the board version?

      run grep v0 /etc/motd in the console at the bottom of the IDE. Also, do you know when you last updated your core code (if ever?)

      (also, I am going to edit out your code again).

        giuliomoro Sorry, yes my page didn't update before I wrote again in a panic πŸ™‚ I tested that code you linked to and it is working again! Thank you!! Edit away... Got that code saved this time...!

        I do not think I have ever updated my core code! Is there a description of that on the bela guides?

        And on running the version check it's "Bela image, v0.3.6b, 23 October 2018"

        Sound quality is suddenly very bad even though it's running the same PD patch & audio files... Not sure what could have changed there...

          hmm. Do you get error messages in the console?

          Unicorpse And on running the version check it's "Bela image, v0.3.6b, 23 October 2018"

          Oh that's sad: I believe a fix to a problem similar to the one you reported (content of the file disappearing) was fixed around March 2018, so the above tells us that you already have the fix in your code, which means we should start chasing a new bug.

            giuliomoro Ah ok, that is sad πŸ™ hopefully it helps hone down the issue though!

            Also now seeing these errors, may have seen some of these previously with the old code but not sure:

            Too many messages have been printed to the console too quickly. Reduce your printing frequency
            Underrun detected: 8 blocks dropped
            3 mode switches detected on the audio thread!

              Unicorpse Too many messages have been printed to the console too quickly. Reduce your printing frequency
              Underrun detected: 8 blocks dropped
              3 mode switches detected on the audio thread!

              if you get these only once at the beginning, then it should be fine. Not sure what else could have changed since then? Can you print the values from the sensors and make sure they are ok?

                giuliomoro The sensor values are printing ok so that seems fine.

                I just tried to restart the bela & the ide to see if there were any changes and got these errors though, that I've never seen before... Something seems to have gone awry here?

                Nov 03 17:17:08 bela stdbuf[740]: make: Leaving directory '/root/Bela'
                Nov 03 17:17:08 bela systemd[1]: bela_startup.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
                Nov 03 17:17:08 bela systemd[1]: bela_startup.service: Unit entered failed state.
                Nov 03 17:17:08 bela systemd[1]: bela_startup.service: Failed with result 'exit-code'.
                Nov 03 17:17:08 bela systemd[1]: bela_startup.service: Service hold-off time over, scheduling restart.
                Nov 03 17:17:08 bela systemd[1]: Stopped Run Bela at boot.
                Nov 03 17:17:08 bela systemd[1]: bela_startup.service: Start request repeated too quickly.
                Nov 03 17:17:08 bela systemd[1]: Failed to start Run Bela at boot.
                Nov 03 17:17:08 bela systemd[1]: bela_startup.service: Unit entered failed state.
                Nov 03 17:17:08 bela systemd[1]: bela_startup.service: Failed with result 'exit-code'.

                  Unicorpse Nov 03 17:17:08 bela systemd[1]: bela_startup.service: Unit entered failed state.

                  this means that the program that starts at boot has crashed repeatedly shortly after being started. Not sure what the reason for that would be. Try maybe to clean the project (in the project tab), then rebuild it. Then go to the configuration tab and set the startup program to "β€’none" and then to your program again.

                    giuliomoro Thanks - I'm not sure how to clean it or what to change...

                    Do you mean change "Run project on boot" in the Settings tab to "none"? When this is the case the project still runs when started manually but the audio still sounds really bad.

                    Could it be a settings thing - though I'm not sure what could differ from the old code? The sample rate is set to 22050 just now (for 8 channels) - it must have been that before but the audio sounds stuttery and low quality so could it be related?

                    Alternatively, if this has happened from nowhere with the code disappearing - has the board failed somewhere?