Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Bexin3 authored Mar 14, 2023
1 parent 97991c3 commit 349579c
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions examples/TwoChannelPlotter/TwoChannelPlotter.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include "STMSpeeduino.h"

const long ValuesToStore = 300; //How many values to store, max 30000, the more the higher accuracy
int16_t CurrentValue = 0; //tracks current stored value

int ADC1Values[ValuesToStore] = {};
int ADC2Values[ValuesToStore] = {};

const int ADC1Channel = A0; //ADC 1 channel
const int ADC2Channel = A1; //ADC 2 channel
const int Resolution = 16; //8, 10, 12, 14, 16
double ClockSpeed = 40; //Clock speed in mhz, stable up to 40mhz, may decrease range further
int SampleTime = 0; //0 to 7
int Samplenum = 0; //Number of samples, is 1 more, 0 to 1023

long Val1;
long Val2;


void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
ADCSimultaneous(ADC1Channel, ADC2Channel, Resolution, ClockSpeed, SampleTime, Samplenum);

}

void loop() {

while (CurrentValue < ValuesToStore) {
collectloop();
};
CurrentValue = 0;
while (CurrentValue < ValuesToStore) {
printloop();
};
CurrentValue = 0;

}

void collectloop() {
ADC1Values[CurrentValue] = CatchADC1Value();
ADC2Values[CurrentValue] = CatchADC2Value();
CurrentValue += 1;
}

void printloop() {
Serial.print("ADC1 Voltage: ");
Serial.println(ADC1Values[CurrentValue]*3.3f/pow(2, Resolution),4);
Serial.print("ADC2 Voltage: ");
Serial.println(ADC2Values[CurrentValue]*3.3f/pow(2, Resolution),4);
CurrentValue += 1;
}

0 comments on commit 349579c

Please sign in to comment.