Пример #1
0
 def __init__(self, example_param=1.0):  # only default arguments here
     """arguments to this function show up as parameters in GRC"""
     gr.sync_block.__init__(
         self,
         name='Embedded Python Block',  # will show up in GRC
         in_sig=[np.single],
         out_sig=[np.single])
     # if an attribute with the same name as a parameter is found,
     # a callback is registered (properties work, too).
     self.example_param = example_param
     self.myacc = adi.adxl345(uri="local:")
Пример #2
0
def test_adxl345(iio_uri):
    dev = adi.adxl345(iio_uri)
    assert dev
    del dev
Пример #3
0
"""
Read ADXL345 raw values, publish to topic 10001, localhost
"""

import zmq
import sys
import time
import adi

port = "5556"
if len(sys.argv) > 1:
    port =  sys.argv[1]
    int(port)

context = zmq.Context()
socket = context.socket(zmq.PUB)
socket.bind("tcp://*:%s" % port)

myacc = adi.adxl345(uri="ip:localhost")
myacc.sampling_frequency = 100.0


while True:
    topic = 10001
    x = myacc.accel_x.raw
    y = myacc.accel_y.raw
    z = myacc.accel_z.raw
    print("%d %d %d %d" % (topic, x, y, z))
    socket.send_string("%d %d %d %d" % (topic, x, y, z))
    time.sleep(0.4)
Пример #4
0
 def __init__(self, example_param=1.0):  # only default arguments here
     #Standard epy init stuff...
     self.example_param = example_param
     self.myacc = adi.adxl345(uri="local:")
Пример #5
0
# INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A
# PARTICULAR PURPOSE ARE DISCLAIMED.
#
# IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY
# RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import time

import adi

# Set up ADXL345
myacc = adi.adxl345(uri="ip:192.168.1.232")
myacc.rx_output_type = "SI"
myacc.rx_buffer_size = 4
myacc.rx_enabled_channels = [0, 1, 2]

sfa = myacc.sampling_frequency_available
print("Sampling frequencies available:")
print(sfa)

print("\nX acceleration: " + str(myacc.accel_x.raw))
print("Y acceleration: " + str(myacc.accel_y.raw))
print("Z acceleration: " + str(myacc.accel_z.raw))

print("\nSample rate: " + str(myacc.sampling_frequency))

print("Setting sample rate to 12.5 sps...")