This project provides Python support for both the ADS1256 (A/D) and DAC8552 (D/A) chips on the Waveshare ADC/DAC HAT board. It stands on the shoulders of two other projects that used disparate low-level GPIO drivers.
- https://github.com/ul-gh/PiPyADC: ADS1256 driver, made use of the WiringPi low level library.
- https://github.com/adn05/dac8552: DAC8552 driver, made use of the PiGPIO low level library.
The original code for both of these projects (as of March 2020) are in their respective folders. This code is not used in this project, it is simply there for reference. Check their respective repos for the latest code.
I decided to use the PiGPIO library, primarily because of the remote control capability. PiGPIO runs as a daemon on the Pi and code using the daemon can run on a Mac/PC and connect over TCP. Works for me!
PiGPIO needs to be installed on every Raspberry Pi you intend to run this code on, or control remotely via TCP. Instructions can ba found here: http://abyz.me.uk/rpi/pigpio/download.html.
You can also install via apt-get
. The whole process is explained here: https://gpiozero.readthedocs.io/en/stable/remote_gpio.html
You will likely want to make sure the PiGPIO daemon is launched on reboot:
sudo systemctl enable pigpiod
systemctl start pigpiod
Python 2.x is officially dead, so as a part of the project, I've moved everything to Python 3, though most of it already was.
This code can be run two different ways:
- Everything running on the Raspberry Pi.
- Python runs on a PC/Mac/Linux controlling the Pi over TCP.
In both cases, you'll need to get the PiGPIO daemon installed and running as described above.
I find this to be the best way for development. You can use a real IDE like PyCharm and not be subjected to painful performance issues.
- Get the daemon running and enable remote access to the PiGPIO daemon as described above.
- Make sure you can
ping
your Pi using local DNS. Raspian Pi devices normally have the default hostnameraspberrypi
so you can ping them withping raspberrypi.local
. If you can't ping, check your networking setup. If you changed the hostname, you will need to ping[hostname].local
. - Run any of the
example
applications.full-example.py
prompts for a hostname. The others require you edit the file. Instructions are in the files.
If you want the application to run stand-alone on the target, do the following:
- Get the daemon running as described above. You don't need to worry about enabling remote access.
- Run any of the
example
applications.full-example.py
prompts for a hostname. The others require you edit the file. Instructions are in the files. For local operation, you can use a blank hostname and the code will uselocalhost
.