Commit c282b837 authored by Sam Calisch's avatar Sam Calisch

demo

parent 0fc9db0c
Pipeline #741 passed with stage
in 3 seconds
#define N_SAMPLES 12
#define N_SAMPLES 48
#define PACKET_BASE_ADDRESS_LENGTH (2UL) //Packet base address length field size in bytes
//static uint8_t packet = 52; //declare a buffer for our packet to use with easydma
......@@ -9,7 +9,6 @@ uint16_t last_tx_time = 0;
uint16_t tx_period = 100; //ms
static int16_t data_buffer[N_SAMPLES] = {0};
//static int16_t packet[N_SAMPLES] = {0}; //declare a buffer for our packet to use with easydma
//
//RADIO
......
#define N_SAMPLES 12
#define N_SAMPLES 48
#define PACKET_BASE_ADDRESS_LENGTH (2UL) //Packet base address length field size in bytes
......@@ -15,7 +15,7 @@ static int16_t packet[N_SAMPLES] = {0}; //declare a buffer for our packet to use
//
void adc_setup(){
//configure SAADC resolution
NRF_SAADC->RESOLUTION = SAADC_RESOLUTION_VAL_10bit;
NRF_SAADC->RESOLUTION = SAADC_RESOLUTION_VAL_12bit;
//configure sample rate via internal timer
//NRF_SAADC->SAMPLERATE = (( SAADC_SAMPLERATE_MODE_Timers << SAADC_SAMPLERATE_MODE_Pos) & SAADC_SAMPLERATE_MODE_Msk) |
// (( 2047 << SAADC_SAMPLERATE_CC_Pos) & SAADC_SAMPLERATE_CC_Msk);
......@@ -31,7 +31,7 @@ void adc_setup(){
//set channel 0 resistor network, gain, reference, sample time, and mode
NRF_SAADC->CH[0].CONFIG = ((SAADC_CH_CONFIG_RESP_Bypass << SAADC_CH_CONFIG_RESP_Pos) & SAADC_CH_CONFIG_RESP_Msk)
| ((SAADC_CH_CONFIG_RESP_Bypass << SAADC_CH_CONFIG_RESN_Pos) & SAADC_CH_CONFIG_RESN_Msk)
| ((SAADC_CH_CONFIG_GAIN_Gain1 << SAADC_CH_CONFIG_GAIN_Pos) & SAADC_CH_CONFIG_GAIN_Msk)
| ((SAADC_CH_CONFIG_GAIN_Gain4 << SAADC_CH_CONFIG_GAIN_Pos) & SAADC_CH_CONFIG_GAIN_Msk)
| ((SAADC_CH_CONFIG_REFSEL_Internal << SAADC_CH_CONFIG_REFSEL_Pos) & SAADC_CH_CONFIG_REFSEL_Msk)
| ((SAADC_CH_CONFIG_TACQ_5us << SAADC_CH_CONFIG_TACQ_Pos) & SAADC_CH_CONFIG_TACQ_Msk)
| ((SAADC_CH_CONFIG_BURST_Disabled << SAADC_CH_CONFIG_BURST_Pos) & SAADC_CH_CONFIG_BURST_Msk)
......
#!/usr/bin/env python
from numpy import cumsum,asarray,arange
import numpy as np
from math import *
import serial, time
import struct
import sys
import socket
import matplotlib.pyplot as plt
import matplotlib.animation as animation
n_samples = 6
n_samples = 24
def read_int16(bytes,signed=False):
try:
......@@ -22,8 +24,7 @@ def read(ser=None):
#line = bytearray()
c = ser.read(4*n_samples)
data = [read_int16(c[x:x+2],signed=True) for x in xrange(0,4*n_samples,2)]
print data
return data
def main():
try:
......@@ -36,20 +37,43 @@ def main():
ser = None
ser.flush()
#clientsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#clientsocket.bind(('localhost', 8080))
#print "Established socket"
'''
fig, ax = plt.subplots()
line, = ax.plot(np.zeros(n_samples))
ax.set_ylim([-1024,1024])
def animate(i):
try:
data = read(ser=ser)
print data[::2], data[1::2]
line.set_ydata(data[::2]) # update the data
return line,
except(KeyboardInterrupt):
return
ani = animation.FuncAnimation(fig, animate, np.arange(1, 200),
interval=5, blit=False)
plt.show()
print "quitting"
ser.close()
sys.exit(0)
'''
while True:
#connection, address = serversocket.accept()
try:
data = read(ser=ser)
print data[::2], data[1::2]
except(KeyboardInterrupt):
break
#if data:
# clientsocket.send(data)
print "quitting"
ser.close()
if __name__ == '__main__':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment