Hi everyone
I have a project i'm working on which requires really high data rates that i can't really seem to get with arduino, so i wonder if there's a way to accumulate the data and then dump it to a pc.
Here is my code:
//Quadrature new code
#include "Arduino.h"
volatile long pulses = 0;
volatile byte pulsesChanged = 0;
volatile long pulsecount = 0;
int rps= 0;
unsigned long tim=0;
void setup(){
Serial.begin(1000000);
attachInterrupt(1, B_CHANGE, CHANGE);
}//setup
void loop(){
if (pulsesChanged != 0) {
pulsesChanged = 0;
tim= micros();
Serial.println(pulses);
Serial.println(tim)
}
}
void B_CHANGE(){
if ( PIND&(0x04) == 0 ) {
if ( PIND&(0x08) == 0 ) {
// B fell, A is low
pulses++; // moving forward
} else {
// B rose, A is low
pulses--; // moving reverse
}
} else {
if ( PIND&(0x08) == 0 ) {
// B fell, A is high
pulses--; // moving reverse
} else {
// B rose, A is high
pulses++; // moving forward
}
}
// tell the loop that the pulses have changed
pulsesChanged = 1;
}
It prints the time and number of pulses to the serial monitor every time there's a pulse.
What i wonder is if there is a way to save, let's say, 3-5 seconds of said data upon a certain command.
I'd usually just use an array, but the data rate is more than 60,000 readings per second, i don't think there's enough memory on the board for it.
If anyone has an idea how to accomplish this i would be glad to know, or if someone has a different thought about just using an array (or 2 vectors)
Any reply is much appreciated
Thanks