DIGILENT PmodACL2Follow article
The Pmod HAT Adapter makes it easy to connect Pmods to a Raspberry Pi. It supports plug-and-play functionality, only requiring that the host Raspberry Pi is booted with the Pmod HAT attached. The Pmod HAT has three 2×6 Pmod ports and provides access to additional I/O available via the Raspberry Pi 40-pin GPIO connector. Designed in collaboration with RS Components, users can take advantage of example Python libraries and demo tutorials hosted on DesignSpark.
ACL2 is a 3-axis MEMS accelerometer powered via the SPI protocol, users may receive up to 12 bits of resolution for each axis of acceleration. This Pmod ACL2 module offers freefall detection as well as power-saving features through its motion-activated sleep and wake modes.
We begin by typing the following commands on the terminal:
sudo apt-get update sudo apt-get dist-upgrade sudo apt-get install -y build-essential git libusb-1.0-0-dev libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler libatlas-base-dev git automake byacc lsb-release cmake libgflags-dev libgoogle-glog-dev liblmdb-dev swig3.0 graphviz libxslt-dev libxml2-dev gfortran python3-dev python3-pip python3-setuptools python3-markdown python3-pillow python3-yaml python3-pygraphviz python3-h5py python3-nose python3-lxml python3-matplotlib python3-numpy python3-protobuf python3-dateutil python3-skimage python3-scipy python3-six python3-networkx libfreetype6-dev libjpeg-dev python3-gst-1.0 python3-picamera sudo pip3 install pyserial sudo pip3 install designspark.pmod
We have to turn on the serial function of the Raspberry Pi:
>5 Interfacing Options
>Would you like a login shell to be accessible over serial?
>Would you like the serial port hardware to be enabled?
This program code means that we have to insert the Pmod ACL2 into the Pmod HAT Adapter JB slot.
if __name__ == '__main__': ACL2 = createPmod('ACL2','JB') time.sleep(0.1)
Plug the Pmod ACL2 into the JB slot labelled below.
The following is the code for getting the axis data from the Pmod ACL2:
try: while True: x,y,z,t = ACL2.getXYZT() print(x,y,z,t) time.sleep(0.8) # if maxz < z: # maxz = z except KeyboardInterrupt: pass finally: ACL2.cleanup() # print(maxz)
The KeyboardInterrupt is not set up to do anything yet.
The ACL2 will then clean the previous old data and release a new cache space for the next data.
sudo python3 /home/pi/Desktop/DesignSpark/example/ACL2_example.py or sudo python /home/pi/Desktop/DesignSpark/example/ACL2_example.py