![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
not yet completed
Dependencies: FatFileSystem MSCFileSystem TextLCD mbed
Fork of TextLCD_HelloWorld by
main.cpp@3:8228ff1c1999, 2016-05-04 (annotated)
- Committer:
- safuanCMS
- Date:
- Wed May 04 06:34:59 2016 +0000
- Revision:
- 3:8228ff1c1999
- Parent:
- 2:ad0b044d0a10
- Child:
- 4:eda6dbfa1d1c
dpv pulse
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
simon | 0:334327d1a416 | 1 | #include "mbed.h" |
simon | 0:334327d1a416 | 2 | #include "TextLCD.h" |
safuanCMS | 3:8228ff1c1999 | 3 | #include "string" |
safuanCMS | 3:8228ff1c1999 | 4 | #include "MSCFileSystem.h" |
simon | 0:334327d1a416 | 5 | |
safuanCMS | 3:8228ff1c1999 | 6 | TextLCD lcd(p15, p16, p10, p11, p12, p13); // rs, e, d4-d7 ;LCD configuration |
safuanCMS | 3:8228ff1c1999 | 7 | |
safuanCMS | 3:8228ff1c1999 | 8 | LocalFileSystem fs("fs"); |
safuanCMS | 3:8228ff1c1999 | 9 | |
safuanCMS | 3:8228ff1c1999 | 10 | AnalogOut aout(p18); //DAC |
safuanCMS | 3:8228ff1c1999 | 11 | AnalogIn ain(p17); //ADC current read |
safuanCMS | 3:8228ff1c1999 | 12 | DigitalIn pb(p9); //Switch |
safuanCMS | 3:8228ff1c1999 | 13 | DigitalOut dout(LED1); |
safuanCMS | 3:8228ff1c1999 | 14 | DigitalOut trig(p5); // |
safuanCMS | 3:8228ff1c1999 | 15 | DigitalOut trigstop(p6); // |
safuanCMS | 3:8228ff1c1999 | 16 | int pbb; |
safuanCMS | 3:8228ff1c1999 | 17 | |
safuanCMS | 3:8228ff1c1999 | 18 | float mini = 0.4f,maxi = 1.2f,stepsize = 0.005f,highV=0,highC=0; |
safuanCMS | 3:8228ff1c1999 | 19 | float pulsedur=0.5,step,sample,width=0.2,current,pulseamplitude=0.1; |
safuanCMS | 3:8228ff1c1999 | 20 | |
safuanCMS | 3:8228ff1c1999 | 21 | void lcdprintnum(float number); |
simon | 0:334327d1a416 | 22 | |
simon | 0:334327d1a416 | 23 | int main() { |
safuanCMS | 3:8228ff1c1999 | 24 | lcd.cls(); |
safuanCMS | 3:8228ff1c1999 | 25 | pb.mode(PullDown); |
safuanCMS | 3:8228ff1c1999 | 26 | |
safuanCMS | 3:8228ff1c1999 | 27 | while(1){ |
safuanCMS | 3:8228ff1c1999 | 28 | pbb=pb; |
safuanCMS | 3:8228ff1c1999 | 29 | trig=0; |
safuanCMS | 3:8228ff1c1999 | 30 | trigstop=0; |
safuanCMS | 3:8228ff1c1999 | 31 | lcd.locate(0,0); |
safuanCMS | 3:8228ff1c1999 | 32 | lcd.printf("DEVICE READY..."); |
safuanCMS | 3:8228ff1c1999 | 33 | |
safuanCMS | 3:8228ff1c1999 | 34 | if(pbb==1){ |
safuanCMS | 3:8228ff1c1999 | 35 | FILE *fp = fopen("/fs/test.csv","w"); |
safuanCMS | 3:8228ff1c1999 | 36 | |
safuanCMS | 3:8228ff1c1999 | 37 | lcd.cls(); |
safuanCMS | 3:8228ff1c1999 | 38 | wait(0.1); |
safuanCMS | 3:8228ff1c1999 | 39 | |
safuanCMS | 3:8228ff1c1999 | 40 | lcd.locate(0,0); |
safuanCMS | 3:8228ff1c1999 | 41 | lcd.printf("ScanRate:0.01V/s "); |
safuanCMS | 3:8228ff1c1999 | 42 | |
safuanCMS | 3:8228ff1c1999 | 43 | for(float i = (mini/3.3); i < (maxi/3.3); i += (stepsize/3.3f)) { |
safuanCMS | 3:8228ff1c1999 | 44 | aout=(i - (pulseamplitude/3.3)); //base voltage |
safuanCMS | 3:8228ff1c1999 | 45 | wait(pulsedur-width); //base voltage duration, sample 1 here |
safuanCMS | 3:8228ff1c1999 | 46 | aout=i; //pulse voltage |
safuanCMS | 3:8228ff1c1999 | 47 | lcd.locate(0,1); |
safuanCMS | 3:8228ff1c1999 | 48 | lcdprintnum(aout.read()*3.3); |
safuanCMS | 3:8228ff1c1999 | 49 | lcd.printf(" V"); |
safuanCMS | 3:8228ff1c1999 | 50 | wait(width); //high pulse duration ; pulse = i |
safuanCMS | 3:8228ff1c1999 | 51 | } |
safuanCMS | 3:8228ff1c1999 | 52 | aout=0; |
safuanCMS | 3:8228ff1c1999 | 53 | lcd.cls(); |
safuanCMS | 3:8228ff1c1999 | 54 | } |
safuanCMS | 3:8228ff1c1999 | 55 | } |
simon | 0:334327d1a416 | 56 | } |
safuanCMS | 3:8228ff1c1999 | 57 | |
safuanCMS | 3:8228ff1c1999 | 58 | void lcdprintnum(float number){ //to display number on lcd |
safuanCMS | 3:8228ff1c1999 | 59 | char aoutstring[10]; |
safuanCMS | 3:8228ff1c1999 | 60 | sprintf(aoutstring,"%.4f",(number)); //convert from float to string to display |
safuanCMS | 3:8228ff1c1999 | 61 | lcd.printf(aoutstring); |
safuanCMS | 3:8228ff1c1999 | 62 | } |
safuanCMS | 3:8228ff1c1999 | 63 |