Raspberry Pi A1332 Precision Hall-Effect Angle Sensor Python Tutorial
by Dcube Tech Ventures in Circuits > Electronics
40 Views, 0 Favorites, 0 Comments
Raspberry Pi A1332 Precision Hall-Effect Angle Sensor Python Tutorial
A1332 is a 360° contactless high resolution programmable magnetic angle position sensor. It is designed for digital systems using an I2C interface. It is built on Circular Vertical Hall (CVH) technology and a programmable microprocessor based signal processing is also incorporated in this sensor. Here is the demonstration with a python code using Raspberry Pi.
What You Need..!!
Connections:
Take a I2C shield fo raspberry pi and gently push it over the gpio pins of raspberry pi.
Then connect the one end of I2C cable to A1332 sensor and the other end to the I2C shield.
Also connect the Ethernet cable to the pi or you can use a WiFi module.
Connections are shown in the picture above.
Code:
The python code for A1332 can be downloaded from our GitHub repository- Dcube Store
Here is the link for the same :
https://github.com/DcubeTechVentures/A1332/blob/master/Python/A1332.py
We have used SMBus library for python code, the steps to install SMBus on raspberry pi is described here:
https://pypi.python.org/pypi/smbus-cffi/0.5.1
You can also copy the code from here, it is given as follows:
# Distributed with a free-will license.
# Use it any way you want, profit or free, provided it fits in the licenses of its associated works.
# A1332
# This code is designed to work with the A1332_I2CS I2C Mini Module
import smbus
import time
# Get I2C bus
bus = smbus.SMBus(1)
# A1332 address, 0x0C(12)
# Read data back, 2 bytes
# raw_adc MSB, raw_adc LSB
data0 = bus.read_byte(0x0C)
data1 = bus.read_byte(0x0C)
time.sleep(0.5)
# Checking valid data
while (data0 == 0) and (data1 == 0) :
data0 = bus.read_byte(0x0C)
data1 = bus.read_byte(0x0C)
# Convert the data to 12-bits
raw_adc = (data0 & 0x0F) * 256.0 + data1
angle = (raw_adc / 4096.0) * 360.0
# Output data to screen
print "Magnetic Angle : %.2f" %angle
Applicatons:
A1332 is ideal for automotive applications requiring high speed 360° angle measurements, such as: electronic power steering (EPS), transmission, torsion bar, and other systems that require accurate measurement of angles. This sensor is designed for fulfilling the requirements of the systems which incorporate measurement of angle and exact position with high precision.