From 7cdd6cefe5e51e94684dfd4eb9b8b7896da110a8 Mon Sep 17 00:00:00 2001 From: dtb Date: Tue, 1 Aug 2023 20:41:32 -0400 Subject: [PATCH] boilerplate --- tekubi/Makefile | 41 +++++++++++++++++++++++++++++ tekubi/main.ino | 69 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 tekubi/Makefile create mode 100644 tekubi/main.ino diff --git a/tekubi/Makefile b/tekubi/Makefile new file mode 100644 index 0000000..8e17bdd --- /dev/null +++ b/tekubi/Makefile @@ -0,0 +1,41 @@ +i2cdevlib_url = https://github.com/jrowberg/i2cdevlib.git + +setup: I2Cdev.cpp I2Cdev.h MPU6050.cpp MPU6050.h + +clean_setup: + rm -rf i2cdevlib i2cdevlib_tmp + rm -f I2Cdev.cpp I2Cdev.h + rm -f MPU6050.cpp MPU6050.h + +i2cdevlib: + rm -rf i2cdevlib_tmp + git init i2cdevlib_tmp + git -C i2cdevlib_tmp remote add -f origin $(i2cdevlib_url) + git -C i2cdevlib_tmp config core.sparseCheckout true + git -C i2cdevlib_tmp sparse-checkout set + git -C i2cdevlib_tmp checkout master + mv i2cdevlib_tmp i2cdevlib + +i2cdevlib/Arduino/I2Cdev: i2cdevlib + git -C i2cdevlib sparse-checkout add Arduino/I2Cdev + git -C i2cdevlib sparse-checkout reapply + git fetch + +i2cdevlib/Arduino/MPU6050: i2cdevlib + git -C i2cdevlib sparse-checkout add Arduino/MPU6050 + git -C i2cdevlib sparse-checkout reapply + git fetch + +I2Cdev.cpp: i2cdevlib/Arduino/I2Cdev + cp i2cdevlib/Arduino/I2Cdev/I2Cdev.cpp ./ + +I2Cdev.h: i2cdevlib/Arduino/I2Cdev + cp i2cdevlib/Arduino/I2Cdev/I2Cdev.h ./ + +MPU6050.cpp: i2cdevlib/Arduino/MPU6050 + cp i2cdevlib/Arduino/MPU6050/MPU6050.cpp ./ + +MPU6050.h: i2cdevlib/Arduino/MPU6050 + cp i2cdevlib/Arduino/MPU6050/MPU6050.h ./ + +.PHONY: setup clean_setup diff --git a/tekubi/main.ino b/tekubi/main.ino new file mode 100644 index 0000000..28b8726 --- /dev/null +++ b/tekubi/main.ino @@ -0,0 +1,69 @@ +#include +#include + +/* https://github.com/jrowberg/i2cdevlib/ */ +#include "I2Cdev.h" +#include "MPU6050.h" + +#define RAD_LOG_PERIOD 5000 /* milliseconds; sample rate */ +#define MINUTE 60000 /* milliseconds in a minute */ + +/* USB power + * 5V -> Teensy Vin (100mA) + * GND -> Teensy GND + + * 5V -> Geiger 5V (100mA?) + * GND -> Geiger GND + + * 5V -> Gyro Vcc (10mA) + * GND -> Gyro GND + + * 5V -> ECG Vcc (4mA) + * GND -> ECG GND */ + +/* teensy 4.0 + * https://www.pjrc.com/store/teensy40.html */ + +/* geiger counter + * https://www.rhelectronics.store + * /radiation-detector-geiger-counter-diy-kit-second-edition + * INT -> Teensy D3 */ + +/* gyro + * https://www.elecrow.com/crowtail-mpu6050-accelerometer-gyro.html + * SDA -> Teensy SDA0 + * SCL -> Teensy SCL0 */ + +/* ecg + * https://www.elecrow.com/crowtail-pulse-sensor-p-1673.html + * SDA -> Teensy SDA0 + * SCL -> Teensy SCL0 */ + + +unsigned long rad_count = 0; +unsigned long rad_cpm; +/* https://www.pjrc.com/teensy/td_timing_elaspedMillis.html */ +elapsedMillis rad_period = 0; + +void rad_interrupt(){ + ++rad_count; +} + +void setup(){ + + /* geiger counter */{ + pinMode(3, INPUT); + digitalWrite(3, HIGH); + attachInterrupt(0, rad_interrupt, FALLING); + } +} + +void loop(){ + + /* geiger counter */{ + if(rad_period > RAD_LOG_PERIOD){ + rad_cpm = rad_count * (MINUTE / RAD_LOG_PERIOD); + rad_period = 0; + } + } +}