This commit is contained in:
Oleksiy
2024-10-17 18:49:02 +03:00
parent cb88ec0e30
commit 5729650a34
2 changed files with 37 additions and 1 deletions

View File

@ -0,0 +1,36 @@
//
//Abel: at 120bpm the actual output is 119.3bpm (47.7Hz). Does this depend on each individual power supply? Would it be possible to calibrate 120bpm to 48Hz?
//
// in theory it should be 600000 / (120 * 24) = 208.333(3). 20.8ms should result in 48.076923076923
#include <FixedPoints.h>
#include <FixedPointsCommon.h>
//uint16_t pulsePeriod; //useful range of 0 to 65,535 ((2^16) - 1).
UFixed<7, 9> bpm = 120; //0-255
#define PPQN 24
#define PULSE_LENGTH 120 //1/10ms resolution. 12ms was failing at 1ms resolution at higher bpm. 60000/200/24 = 12.5 the max pulse length at 1ms resolution for 200bpm is 11ms
#define MAXBPM 200 //250 at 24ppqn with 5ms pulse will be 50/50 square wave
#define MINBPM 20
void setup() {
Serial.begin(19200);
int pulsePeriod = 600000 / (bpm.getInteger() * PPQN);
Serial.print("original uint16_t: ");
Serial.println(pulsePeriod);
float floatperiod = 600000 / ((float)bpm * (float)PPQN);
Serial.print("float: ");
Serial.println(floatperiod);
// fpperiod = 600000 / (bpm * PPQN);
//Serial.print("UQ8x8: ");
//Serial.println((float)fpperiod);
UFixed<7, 9> fpperiodplus = 600000 / (bpm * PPQN);
Serial.print("UQ7x9: ");
Serial.println((float)fpperiodplus);
}
void loop() {
// put your main code here, to run repeatedly:
}

View File

@ -6,7 +6,7 @@
#include <avr/wdt.h>
#include <NeoHWSerial.h>
#define VERSION "V:1.1.1B"
#define VERSION "V:1.1.1"
byte memCode = 'D'; //Change to different letter if you changed the data structure