Skip to content

Instantly share code, notes, and snippets.

View branw's full-sized avatar
🐠
<º)))><

Brandon W branw

🐠
<º)))><
View GitHub Profile
@branw
branw / goose.py
Created September 20, 2018 18:26
import matplotlib.pyplot as plt
from datetime import datetime
import serial
import struct
import math
import os
# Show all packets
VERBOSE = 0
t = np.linspace(0, 25, num=10000)
f, (axl, axr) = plt.subplots(1, 2, sharey=True)
newlabel = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
newpos = [t/0.343 for t in newlabel]
axl.grid(linestyle='dashed')
axl.set_xlim([0, 25])
@branw
branw / mega.cpp
Created September 22, 2018 15:15
#include <Arduino.h>
#include <BasicStepperDriver.h>
#define DISABLE_MOTORS false
const int EAR_LEFT_DIR = 48, EAR_LEFT_STEP = 46, EAR_LEFT_ENABLE = 62; // Z
const int EAR_RIGHT_DIR = A1, EAR_RIGHT_STEP = A0, EAR_RIGHT_ENABLE = 38; // X
const int NOSE_TOP_DIR = A7, NOSE_TOP_STEP = A6, NOSE_TOP_ENABLE = A2; // Y
const int NOSE_LEFT_DIR = 34, NOSE_LEFT_STEP = 36, NOSE_LEFT_ENABLE = 30; // E1
@branw
branw / due.cpp
Created September 22, 2018 15:44
High-speed data collection with alternating dynamic and static motion
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
// 1.6 MHz is the max frequency of the DAC, so it's easiest
// just to scale everything off of it
const int freq = 1.6e6;
// Duration of a single chirp
const double chirp_duration = 15E-3;
@branw
branw / mega.cpp
Last active September 24, 2018 17:37
#include <Arduino.h>
#include <BasicStepperDriver.h>
// Accept a trigger of 's' over Serial1 or Serial2
#define USE_SERIAL_TRIGGER true
// Enable the motors only when they are being moved
#define DISABLE_MOTORS false
const int EAR_LEFT_DIR = 48, EAR_LEFT_STEP = 46, EAR_LEFT_ENABLE = 62; // Z
bool flash_read_unique_id(uint32_t *pul_data) {
// Initialize the first EEFC bank in 128-bit mode with 4 wait states
if (efc_init(EFC0, 0, 4)) {
return false;
}
// Enter the unique identifier mode, copy it, and exit
return !efc_perform_read_sequence(EFC0, EFC_FCMD_STUI, EFC_FCMD_SPUI, pul_data, 4);
}
def main():
try:
ptu = PTU(PTU_PORT)
except serial.serialutil.SerialException:
print(f'Could not connect to pan-tilt on port {PTU_PORT}')
return
# Open connection to device
ser = serial.Serial(DUE_PORT)
ser.setDTR(False)
import matplotlib.pyplot as plt
from datetime import datetime
import numpy as np
import serial
import struct
import time
import math
import os
# Native USB port of Due (use Device Manager to find)
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
// 1.6 MHz is the max frequency of the DAC, so it's easiest
// just to scale everything off of it. 1 ADC channel runs at
// 41.25% (~660 kHz); 2 ADC channels run at 25% (400 kHz each)
const int freq = 1.6e6;
// Duration of a single chirp
const double chirp_duration = 15E-3;
import matplotlib.pyplot as plt
from datetime import datetime
import numpy as np
import serial
import struct
import time
import math
import os
# Native USB port of Due (use Device Manager to find)