Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- mwthewsey
- Date:
- 2017-11-23
- Revision:
- 0:d39a06ca6bf1
- Child:
- 1:b088b771a591
File content as of revision 0:d39a06ca6bf1:
#include "mbed.h"
#include "rtos.h"
#include "Filter.hpp"
unsigned short ADC_DATA;
//Init values for difference equation
//MBED Class Instances follows
DigitalOut SampLED(LED1); //Digital Output (GREEN LED is PB_3, D13 You can use an Oscilloscope on This pin to confirm sample rate)
AnalogIn Ain(PA_1); //Analog Input (Signal Input 0 to +3 Volts)
AnalogOut Aout(PA_4); //Analog Output (Signal Input 0 to +3 Volts)
Ticker sample_timer;
Thread T1;
Thread T2;
FILTER BP_filter(35000,4000,2,2); //Create object of type Filter(Fs,Fo,Boost,Q)
void sampler(void);
int main()
{
float sample_rate = (1.0/35000) ;
sample_timer.attach(&sampler,sample_rate);
while(1) {
sleep();
}
}
void sampler(void)
{
SampLED = 1; //LED Indicates start of sampling
float input = Ain;
BP_filter.setvalue(input); //Input ADC. N.B. ADC in MBED is 0.0 to 1.0 float!!!!!!
Aout = BP_filter.getvalue();
SampLED = 0; //LED Indicates end of sampling
}
