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:
- NTesla
- Date:
- 2018-10-24
- Revision:
- 0:7ee4334a99fc
- Child:
- 1:616a5dd8ec34
File content as of revision 0:7ee4334a99fc:
#include "mbed.h" #include "FastPWM.h" // https://developer.mbed.org/forum/electronics/topic/15346/ //------------------------------------ //Emission pgrm for the patient transmetting device. It uses the source code //originally made for Arduino. It has been first designed by S.Sahuguede //------------------------------------ /* 17.10.2018 sketch modified by Kostiantyn Vasko together with Borys Shtanhei * Transmitting by IR LED with 38kHz Freq FOR STM32 * Important pins: * D1 - Tx * D0 - Rx * D10 - PWM * A0 - Analog input for ECG */ //Serial Com defined for Tx=D8 and Rx=D2 at 4800 bauds Serial Serial2(D8,D2,38400); //Initializing of clock Output FastPWM mypwm(D10,1); //init variables int cptmesure = 0; unsigned int analogin; //VALUE TO MODIFY BY PATIENT unsigned int patient=2; //creation of variables for transmission control int verif; AnalogIn X(A0); int main() { //pwm_io(16, 0.5); //26.041 us with a duty cycle of 50% ==> Here I get 38kHz as Output with 16µs... //Bytes variables which gonna be sent unsigned int trame1,trame2,trame3,trame8, trame9; //Clock settings for 38kHz //mypwm.period_us(26);//26 // mypwm.pulsewidth_us(13);//13 //Serial Com data sent uint8_t TrameTab[6]; //Clock settings for 455kHz mypwm.period_us(2.1978); mypwm.pulsewidth_us(1.0989);//Duty-Cycle 50% here while(1) { analogin = (int16_t) (65535 * X.read());// Read ECG signal and transforming into digit. trame2=(analogin & 0xFF00) >> 8;//mask 1111 1111 0000 0000 (ECG signal 16 bit) trame3=(analogin & 0xFF);//mask 0000 0000 1111 1111 //increment of measurement: avoids the redundancy of the display on the server cptmesure++; if(cptmesure==8) { cptmesure=0; } verif = (trame2 << 3) + cptmesure ; //first frame: patient + verif (2 bits high) trame1= (patient << 4) + ((verif & 0x700)>>7);//mask 111 0000 0000 trame8= (verif & 0xFF);//mask 1111 1111 //fifth frame: patient + increment measurement trame9= (patient << 4) + (cptmesure << 1); //We fill the table which gonna be sent TrameTab[0] = 255; TrameTab[1] = trame1; TrameTab[2] = trame2; TrameTab[3] = trame3; TrameTab[4] = trame8; TrameTab[5] = trame9; //We sent the table through the serial port Serial2.write(TrameTab,6,0,0); //Serial.write pour envoyer l'information sous 8 bits. Serial.print envoi un nombre chiffre par chiffre à utiliser pour avoir un affichage sur le moniteur. wait(0.0025); } }