mcdeoliveira / rcpy

Python Library for Robotics Cape on Beaglebone Black and Beaglebone Blue
MIT License
37 stars 25 forks source link

Analog in? #5

Closed nezra closed 6 years ago

nezra commented 6 years ago

Specifically battery voltage and DC?

What is needed to add these

BrendanSimon commented 6 years ago

Yes, I'm interested in ADC inputs too. e.g. to read distance sensors (optical, ultrasonic, etc).

What's the best way to read ADC inputs to use in conjunction with rcpy. Ideally rcpy would implement an ADC module, but since it's not present is there another solution in the interim?

nezra commented 6 years ago

my current solution, while horrible, was to write a small c program without using the "state" function that just ran once, called the variables and returned the variables via print. From there the python program runs it, takes the output and converts/splits it into variables, which I then use.

I'd be wary of checking the led states for percentages as the battery monitor assumes the battery depletes at a linear fashion instead of how it really depletes. 25% battery and 0 battery are less than a minute apart.

On Wed, Apr 11, 2018, 8:46 AM Brendan Simon notifications@github.com wrote:

Yes, I'm interested in ADC inputs too. e.g. to read distance sensors (optical, ultrasonic, etc).

What's the best way to read ADC inputs to use in conjunction with rcpy. Ideally rcpy would implement an ADC module, but since it's not present is there another solution in the interim?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mcdeoliveira/rcpy/issues/5#issuecomment-380438914, or mute the thread https://github.com/notifications/unsubscribe-auth/AK3vNU5uNzIz_HjuxoaQZqK-Tph8Ur1Rks5tnfsWgaJpZM4Su2Hf .

BrendanSimon commented 6 years ago

The C libraries seem to be very comprehensive, and looking at the Python wrapper code it seems that it shouldn't be too difficult to add for the ADC module (and other missing modules too).

So I've taken the plunge (started a quick hacking investigation) to see if I can create the Python bindings to the low-level C functions.

BrendanSimon commented 6 years ago

I've made some progress and my limited tests seem to suggest that it might work :)

You can find my fork/branch here:

https://github.com/BrendanSimon/rcpy/tree/bjs/adc_bindings

I've submitted a pull request here:

https://github.com/mcdeoliveira/rcpy/pull/7

mcdeoliveira commented 6 years ago

Thank you Brendan! I already merged with master.