Raspberry Pi High-Precision AD/DA Board Test Code

Hello everyone!!

I am experimenting with the High Precision AD/DA Board connected with a Raspberry Pi 3B+. I have followed all the installation instructions and installed the required libraries and code, as per the user manual. I then proceeded to run the two test codes that was supplied (the instructions can be found here.)

The first test, for DAC conversion worked fine and the lights alternated bright/off. But I’m having my trouble with the second test, for ADC conversion. It monitors the value of 8 pins, and should show the varying output of the first 2 pins, as one is connected to a potentiometer, the other a photoresistor. The program does run and prints output to the screen, but the values for all 8 AD pins just flicker randomly between 0 and different numbers, and changing the pot or resistor does not seem to do anything.

I’ve been reading the user manual, and wondering if this has something to do with the settings (such as the noise settings or PGA) but I don’t know enough to understand some parts of the data sheet, or how to find/configure those settings. (I also might be totally wrong here)

If anyone could offer suggestions as to why they think this isn’t working, and ideas for fixing it, that would be wonderful!

Thanks so much!! Cheers

Hi @lezzlexx

I did a little research on the problem you mentioned and it turns out it’s pretty common, seems like not a lot of people are able to make the ADC work with that sample code. Also, you are not so off by saying that the issue might be noise because the Pi’s 5V supply is unregulated and potentiometers tend to be noisy as well, still this shouldn’t result in random sampling.

I found that lots of people suggest using this library. It is implemented in Python so it cannot sample above about 1k samples per second, however, it solved the problem for many people.

It would be great if you can give it a try and share your results :wink:

1 Like

Hello @lezzlexx !

Sorry to hear about that. I was looking into that and I found this tutorial that I think could help you: https://www.hackster.io/laserbrain/raspberry-pi-ad-da-board-library-for-window-10-iot-core-c8cc34
And a forum where it is discuss the topic: https://www.raspberrypi.org/forums/viewtopic.php?t=135775 .

Hope this help you!:grin:

1 Like

Hey @geraldinebc15 - thank you tons for your prompt reply!! If definitely helped; that sample python code works perfectly with my board,
so now at least I know the chip is working and I can communicate with it.

Also:
Hi @RoboCS - these links were really helpful too, to look at an additional program and especially reading about how the specifics of
the board works, as I was having some trouble with parts of the data sheet.

So, now, I’m going to try to figure out why that C test code that was provided doesn’t work…I think I’ll start with writing a little piece of my own code to write to the registers, just to see if changing some of the settings makes a difference, and then I thought I could look into downloading a different version of the bcm library as they’ve released a couple - otherwise, I’ll just be comparing that code with the codes you both found (awesome!!) to see if I can find the discrepancy.

Thank you both so much this helped a ton!!

1 Like

That is great! I’m glad we could help :grin:

It is nice that you want to debug the C code and your approach sounds good to me. Also, when I was doing my research I saw some people suggesting to try the bcm2835-1.45 version so it is great that you mentioned you want to give that a try.

If that doesn’t work maybe you can give a look to this code too, it uses Wiring Pi instead of the bcm2835 library and it is written in C++ so it could help you out as well.

Also, if you find a solution it would be awesome if you can share it because maybe someone will stumble upon the same issue :grinning:

1 Like

Awesome! Thanks for even more info!

So far, I have tried the bcm2835-1.45 version, but the code won’t even run using this library, so it seems the later version is necessary. Otherwise, I haven’t found an issue as to why it doesn’t work - I’m guessing it must be within the actual settings/parameters of the board because the code itself actually works, it just doesn’t seem to be effectively communicating with the pins, as the values are not consistent. That other code you found looks great too - something else to try!

I’ll keep everyone posted :slight_smile:

1 Like