rfsesf

Dependencies:   mbed C12832

Committer:
kwstasfane1
Date:
Tue Apr 20 15:47:54 2021 +0000
Revision:
0:b94498823546
Child:
1:d37c71b35a5a
gddg

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kwstasfane1 0:b94498823546 1 /*
kwstasfane1 0:b94498823546 2 Created by Konstantinos Fane
kwstasfane1 0:b94498823546 3 copy this code to Mbed online simulator
kwstasfane1 0:b94498823546 4 to run the designed application
kwstasfane1 0:b94498823546 5 */
kwstasfane1 0:b94498823546 6
kwstasfane1 0:b94498823546 7 #include "mbed.h"
kwstasfane1 0:b94498823546 8 #include <string>
kwstasfane1 0:b94498823546 9 #include "C12832.h"
kwstasfane1 0:b94498823546 10
kwstasfane1 0:b94498823546 11 // LCD display
kwstasfane1 0:b94498823546 12 C12832 lcd(p5, p7, p6, p8, p11);
kwstasfane1 0:b94498823546 13
kwstasfane1 0:b94498823546 14 //dummy measurement values
kwstasfane1 0:b94498823546 15 float m_freq_hz; // = 120730.546423; //*10^6 Hz
kwstasfane1 0:b94498823546 16 float m_t_interval_ms; //= 988.056475;
kwstasfane1 0:b94498823546 17
kwstasfane1 0:b94498823546 18 //result to be displayed
kwstasfane1 0:b94498823546 19 float m_result;
kwstasfane1 0:b94498823546 20
kwstasfane1 0:b94498823546 21 //variables used for frequency, period and time interval measruements
kwstasfane1 0:b94498823546 22 float count1 = 0.0;
kwstasfane1 0:b94498823546 23 float ton = 0.0;
kwstasfane1 0:b94498823546 24 float toff = 0.0;
kwstasfane1 0:b94498823546 25 float period = 0.0;
kwstasfane1 0:b94498823546 26
kwstasfane1 0:b94498823546 27 const char* range_scale [3][3] = {
kwstasfane1 0:b94498823546 28 {"MHz","KHz","Hz"},
kwstasfane1 0:b94498823546 29 {"ms","ms","s"},
kwstasfane1 0:b94498823546 30 {"ms","ms","s"}
kwstasfane1 0:b94498823546 31 };
kwstasfane1 0:b94498823546 32
kwstasfane1 0:b94498823546 33 /* flag to hold which measurement mode to display
kwstasfane1 0:b94498823546 34 * 0 = Frequency Measurement
kwstasfane1 0:b94498823546 35 * 1 = Period Measurement
kwstasfane1 0:b94498823546 36 * 2 = Time interval Measurement
kwstasfane1 0:b94498823546 37 * to match the index of message display arrays */
kwstasfane1 0:b94498823546 38 int dsp_mode = 0;
kwstasfane1 0:b94498823546 39 const char* mode_msg [] = {"Frequency", "Period", "Time Interval"};
kwstasfane1 0:b94498823546 40
kwstasfane1 0:b94498823546 41 /* flag to hold which measurement range to display
kwstasfane1 0:b94498823546 42 * 0 = High Range
kwstasfane1 0:b94498823546 43 * 1 = Medium Range
kwstasfane1 0:b94498823546 44 * 2 = Low Range */
kwstasfane1 0:b94498823546 45 int dsp_range = 0;
kwstasfane1 0:b94498823546 46 const char* range_msg [] = {"High Resolution", "Medium Resolution", "Low Resolution"};
kwstasfane1 0:b94498823546 47
kwstasfane1 0:b94498823546 48 int dsp_time_interval = 0; //0=R-R, 1=F-F, 2=R-F, 3=F-R
kwstasfane1 0:b94498823546 49
kwstasfane1 0:b94498823546 50 //result string
kwstasfane1 0:b94498823546 51 const char* res[] = {""};
kwstasfane1 0:b94498823546 52
kwstasfane1 0:b94498823546 53 //Interrupt to be used in actual implementation to read the input square wave signal
kwstasfane1 0:b94498823546 54 //InterruptIn squareIN(p#) //# = the pin number where the actual signal would be conected to
kwstasfane1 0:b94498823546 55
kwstasfane1 0:b94498823546 56 InterruptIn squareIN(p17);
kwstasfane1 0:b94498823546 57
kwstasfane1 0:b94498823546 58 //User interface measurement mode and range selection buttons
kwstasfane1 0:b94498823546 59 InterruptIn mode(p12);
kwstasfane1 0:b94498823546 60 InterruptIn range(p15);
kwstasfane1 0:b94498823546 61 InterruptIn time_interval(p13);
kwstasfane1 0:b94498823546 62
kwstasfane1 0:b94498823546 63 /*For simulation purposes only, multiplier for the count1, to achieve higher simulated frequencies
kwstasfane1 0:b94498823546 64 InterruptIn incr_freq(p15);
kwstasfane1 0:b94498823546 65 InterruptIn decr_freq(p16);
kwstasfane1 0:b94498823546 66 float multi = 1.0;
kwstasfane1 0:b94498823546 67 void incr();
kwstasfane1 0:b94498823546 68 void decr();*/
kwstasfane1 0:b94498823546 69
kwstasfane1 0:b94498823546 70 //user defined functions to implement the user interface
kwstasfane1 0:b94498823546 71 void user_interface_disp();
kwstasfane1 0:b94498823546 72 void mode_select();
kwstasfane1 0:b94498823546 73 void range_select();
kwstasfane1 0:b94498823546 74 void time_interval_type_select();
kwstasfane1 0:b94498823546 75 void result_calculator();
kwstasfane1 0:b94498823546 76
kwstasfane1 0:b94498823546 77 //interrupt service routines
kwstasfane1 0:b94498823546 78 void counter1_isr();
kwstasfane1 0:b94498823546 79 void freq_calc_isr();
kwstasfane1 0:b94498823546 80
kwstasfane1 0:b94498823546 81 //Timeout task2;
kwstasfane1 0:b94498823546 82 Ticker freq_meas; //generate a tick
kwstasfane1 0:b94498823546 83 Ticker ui_disp; //generate the 1s interrupt, to measure frequency (direct frequency measurement)
kwstasfane1 0:b94498823546 84 Ticker result_calc;
kwstasfane1 0:b94498823546 85 int main()
kwstasfane1 0:b94498823546 86 {
kwstasfane1 0:b94498823546 87
kwstasfane1 0:b94498823546 88 //ticker, where it is done periodically, timeout only does it once
kwstasfane1 0:b94498823546 89 //Direct frequency measurement, measures the number of rising edges every time they occur
kwstasfane1 0:b94498823546 90 squareIN.rise(&counter1_isr); //maximum frequency related to interrupt operating frequency
kwstasfane1 0:b94498823546 91 freq_meas.attach(&freq_calc_isr,1); //obtain number of sums per second
kwstasfane1 0:b94498823546 92
kwstasfane1 0:b94498823546 93 //To be used with timer() only if it is done
kwstasfane1 0:b94498823546 94 //squareIN.rise(&start_t1_isr);
kwstasfane1 0:b94498823546 95 //squareIN.fall(&start_t2_isr);
kwstasfane1 0:b94498823546 96 //For simulation purposes only
kwstasfane1 0:b94498823546 97 //tick1.attach_us(&counter1_isr, 1); //generate a tick every 100 us = 0.0001s 1us = 100000 s (period)
kwstasfane1 0:b94498823546 98
kwstasfane1 0:b94498823546 99 //ui_disp.attach(&user_interface_disp, 1); //update the screen every 1 second
kwstasfane1 0:b94498823546 100 //result_calc.attach_us(&result_calculator,50); //calculate a new measurement result every 100us
kwstasfane1 0:b94498823546 101
kwstasfane1 0:b94498823546 102 //interrupt routine for mode and range selection user input
kwstasfane1 0:b94498823546 103 mode.rise(&mode_select);
kwstasfane1 0:b94498823546 104 range.rise(&range_select);
kwstasfane1 0:b94498823546 105 time_interval.rise(&time_interval_type_select);
kwstasfane1 0:b94498823546 106
kwstasfane1 0:b94498823546 107 /*interrupt routine for multiplier increase/decrease user input
kwstasfane1 0:b94498823546 108 incr_freq.rise(&incr);
kwstasfane1 0:b94498823546 109 decr_freq.rise(&decr);*/
kwstasfane1 0:b94498823546 110
kwstasfane1 0:b94498823546 111 while(1)
kwstasfane1 0:b94498823546 112 {
kwstasfane1 0:b94498823546 113 lcd.locate(1,1);
kwstasfane1 0:b94498823546 114 lcd.printf("Frequency: %4.4f", m_freq_hz);
kwstasfane1 0:b94498823546 115 wait_ms(10);
kwstasfane1 0:b94498823546 116 }
kwstasfane1 0:b94498823546 117
kwstasfane1 0:b94498823546 118
kwstasfane1 0:b94498823546 119 }
kwstasfane1 0:b94498823546 120
kwstasfane1 0:b94498823546 121 //ISR to count the occurences of incoming signal rising edges
kwstasfane1 0:b94498823546 122 void counter1_isr()
kwstasfane1 0:b94498823546 123 {
kwstasfane1 0:b94498823546 124 //increment counter by 1
kwstasfane1 0:b94498823546 125 count1 = count1 + 1.0;
kwstasfane1 0:b94498823546 126 }
kwstasfane1 0:b94498823546 127
kwstasfane1 0:b94498823546 128 //ISR to calculate the period of incoming signal, every 1 second
kwstasfane1 0:b94498823546 129 void freq_calc_isr()
kwstasfane1 0:b94498823546 130 {
kwstasfane1 0:b94498823546 131 //m_freq_hz = multi * count1;
kwstasfane1 0:b94498823546 132 m_freq_hz = count1;
kwstasfane1 0:b94498823546 133 count1 = 0;
kwstasfane1 0:b94498823546 134 }
kwstasfane1 0:b94498823546 135
kwstasfane1 0:b94498823546 136 /*simulation only
kwstasfane1 0:b94498823546 137 void incr()
kwstasfane1 0:b94498823546 138 {
kwstasfane1 0:b94498823546 139 multi = multi + 1500.5;
kwstasfane1 0:b94498823546 140 }
kwstasfane1 0:b94498823546 141
kwstasfane1 0:b94498823546 142 void decr()
kwstasfane1 0:b94498823546 143 {
kwstasfane1 0:b94498823546 144 multi = multi - 100.5;
kwstasfane1 0:b94498823546 145 if (multi<10.5)
kwstasfane1 0:b94498823546 146 {
kwstasfane1 0:b94498823546 147 multi = 0.5;
kwstasfane1 0:b94498823546 148 }
kwstasfane1 0:b94498823546 149 }*/
kwstasfane1 0:b94498823546 150
kwstasfane1 0:b94498823546 151 void user_interface_disp()
kwstasfane1 0:b94498823546 152 {
kwstasfane1 0:b94498823546 153
kwstasfane1 0:b94498823546 154 //At startup just print a few things on the lcd and then enter a loop until the user does something
kwstasfane1 0:b94498823546 155 lcd.cls(); //clear screen
kwstasfane1 0:b94498823546 156 lcd.locate(1,1);
kwstasfane1 0:b94498823546 157 lcd.printf("Mode: %s", mode_msg[dsp_mode]);
kwstasfane1 0:b94498823546 158
kwstasfane1 0:b94498823546 159 //display the type of time interval measurement if the mode is selected
kwstasfane1 0:b94498823546 160 if(dsp_mode ==2)
kwstasfane1 0:b94498823546 161 {
kwstasfane1 0:b94498823546 162 lcd.locate(90,1);
kwstasfane1 0:b94498823546 163 if(dsp_time_interval == 0)
kwstasfane1 0:b94498823546 164 {
kwstasfane1 0:b94498823546 165 lcd.printf("(R->R)");
kwstasfane1 0:b94498823546 166 }
kwstasfane1 0:b94498823546 167 else if(dsp_time_interval == 1)
kwstasfane1 0:b94498823546 168 {
kwstasfane1 0:b94498823546 169 lcd.printf("(F->F)");
kwstasfane1 0:b94498823546 170 }
kwstasfane1 0:b94498823546 171 else if(dsp_time_interval == 2)
kwstasfane1 0:b94498823546 172 {
kwstasfane1 0:b94498823546 173 lcd.printf("(R->F)");
kwstasfane1 0:b94498823546 174 }
kwstasfane1 0:b94498823546 175 else if(dsp_time_interval == 3)
kwstasfane1 0:b94498823546 176 {
kwstasfane1 0:b94498823546 177 lcd.printf("(F->R)");
kwstasfane1 0:b94498823546 178 }
kwstasfane1 0:b94498823546 179
kwstasfane1 0:b94498823546 180 }
kwstasfane1 0:b94498823546 181 /*else
kwstasfane1 0:b94498823546 182 {
kwstasfane1 0:b94498823546 183 //simulation only - to display the current multiplier
kwstasfane1 0:b94498823546 184 lcd.locate(78,1);
kwstasfane1 0:b94498823546 185 lcd.printf("(x%1.1f)",multi);
kwstasfane1 0:b94498823546 186 }*/
kwstasfane1 0:b94498823546 187
kwstasfane1 0:b94498823546 188 lcd.locate(1,10);
kwstasfane1 0:b94498823546 189 lcd.printf("Range: %s", range_msg[dsp_range]);
kwstasfane1 0:b94498823546 190 lcd.locate(1,20);
kwstasfane1 0:b94498823546 191 //print the result
kwstasfane1 0:b94498823546 192 lcd.printf(*res,m_result,range_scale[dsp_mode][dsp_range]);
kwstasfane1 0:b94498823546 193
kwstasfane1 0:b94498823546 194 }
kwstasfane1 0:b94498823546 195
kwstasfane1 0:b94498823546 196 void time_interval_type_select()
kwstasfane1 0:b94498823546 197 {
kwstasfane1 0:b94498823546 198 if (dsp_time_interval <3)
kwstasfane1 0:b94498823546 199 {
kwstasfane1 0:b94498823546 200 dsp_time_interval++;
kwstasfane1 0:b94498823546 201 }
kwstasfane1 0:b94498823546 202 else
kwstasfane1 0:b94498823546 203 {
kwstasfane1 0:b94498823546 204 dsp_time_interval = 0;
kwstasfane1 0:b94498823546 205 }
kwstasfane1 0:b94498823546 206 }
kwstasfane1 0:b94498823546 207
kwstasfane1 0:b94498823546 208 //Interrupt service routine to handle the measurement mode selection
kwstasfane1 0:b94498823546 209 void mode_select()
kwstasfane1 0:b94498823546 210 {
kwstasfane1 0:b94498823546 211 if (dsp_mode < 2)
kwstasfane1 0:b94498823546 212 {
kwstasfane1 0:b94498823546 213 dsp_mode++;
kwstasfane1 0:b94498823546 214 }
kwstasfane1 0:b94498823546 215 else
kwstasfane1 0:b94498823546 216 {
kwstasfane1 0:b94498823546 217 dsp_mode = 0;
kwstasfane1 0:b94498823546 218 }
kwstasfane1 0:b94498823546 219 }
kwstasfane1 0:b94498823546 220
kwstasfane1 0:b94498823546 221 //Interrupt service routine to handle the measurement range selection
kwstasfane1 0:b94498823546 222 void range_select()
kwstasfane1 0:b94498823546 223 {
kwstasfane1 0:b94498823546 224 if (dsp_range < 2)
kwstasfane1 0:b94498823546 225 {
kwstasfane1 0:b94498823546 226 dsp_range++;
kwstasfane1 0:b94498823546 227 }
kwstasfane1 0:b94498823546 228 else
kwstasfane1 0:b94498823546 229 {
kwstasfane1 0:b94498823546 230 dsp_range = 0;
kwstasfane1 0:b94498823546 231 }
kwstasfane1 0:b94498823546 232 }
kwstasfane1 0:b94498823546 233
kwstasfane1 0:b94498823546 234 void result_calculator()
kwstasfane1 0:b94498823546 235 {
kwstasfane1 0:b94498823546 236
kwstasfane1 0:b94498823546 237 //calculate period from frequency
kwstasfane1 0:b94498823546 238 float m_period_ms = (1/m_freq_hz)*1000; //times by 1000 to convert to ms
kwstasfane1 0:b94498823546 239 //float m_period_ms = period/1000;
kwstasfane1 0:b94498823546 240 //float m_freq_hz = 1/(m_period_ms/1000);
kwstasfane1 0:b94498823546 241 //m_t_interval_ms = ton/1000;
kwstasfane1 0:b94498823546 242
kwstasfane1 0:b94498823546 243 if(dsp_mode == 0) //frequency measurement
kwstasfane1 0:b94498823546 244 {
kwstasfane1 0:b94498823546 245 if(dsp_range == 0) //High resolution (MHz)
kwstasfane1 0:b94498823546 246 {
kwstasfane1 0:b94498823546 247 m_result = m_freq_hz/1000000;
kwstasfane1 0:b94498823546 248 if(m_result <= 10.001)
kwstasfane1 0:b94498823546 249 {
kwstasfane1 0:b94498823546 250 //assigns the decimal point precision for each range
kwstasfane1 0:b94498823546 251 *res="%3.3f %s";
kwstasfane1 0:b94498823546 252 }
kwstasfane1 0:b94498823546 253 else
kwstasfane1 0:b94498823546 254 {
kwstasfane1 0:b94498823546 255 *res="Out-of-range... '>10 MHz !'";
kwstasfane1 0:b94498823546 256 }
kwstasfane1 0:b94498823546 257
kwstasfane1 0:b94498823546 258 }
kwstasfane1 0:b94498823546 259 else if(dsp_range == 1) //medium resolution (KHz)
kwstasfane1 0:b94498823546 260 {
kwstasfane1 0:b94498823546 261 m_result = m_freq_hz/1000;
kwstasfane1 0:b94498823546 262 if(m_result <= 100.001)
kwstasfane1 0:b94498823546 263 {
kwstasfane1 0:b94498823546 264 //assigns the decimal point precision for each range
kwstasfane1 0:b94498823546 265 *res="%3.3f %s";
kwstasfane1 0:b94498823546 266 }
kwstasfane1 0:b94498823546 267 else
kwstasfane1 0:b94498823546 268 {
kwstasfane1 0:b94498823546 269 *res="Out-of-range... '>100 KHz !'";
kwstasfane1 0:b94498823546 270 }
kwstasfane1 0:b94498823546 271 }
kwstasfane1 0:b94498823546 272 else //low resolution (Hz)
kwstasfane1 0:b94498823546 273 {
kwstasfane1 0:b94498823546 274 m_result = m_freq_hz;
kwstasfane1 0:b94498823546 275 if(m_result <= 100.001)
kwstasfane1 0:b94498823546 276 {
kwstasfane1 0:b94498823546 277 //assigns the decimal point precision for each range
kwstasfane1 0:b94498823546 278 *res="%3.3f %s";
kwstasfane1 0:b94498823546 279 }
kwstasfane1 0:b94498823546 280 else
kwstasfane1 0:b94498823546 281 {
kwstasfane1 0:b94498823546 282 *res="Out-of-range... '>100 Hz !'";
kwstasfane1 0:b94498823546 283 }
kwstasfane1 0:b94498823546 284
kwstasfane1 0:b94498823546 285 }
kwstasfane1 0:b94498823546 286
kwstasfane1 0:b94498823546 287 /* '*res' assignment was moved inside the ifs, to that in case the current
kwstasfane1 0:b94498823546 288 nuber to be displayed is higher that acceptable upper limit, to delete
kwstasfane1 0:b94498823546 289 the displayed measurement, and show warning message*/
kwstasfane1 0:b94498823546 290
kwstasfane1 0:b94498823546 291 }
kwstasfane1 0:b94498823546 292 else if (dsp_mode == 1) //period measurement
kwstasfane1 0:b94498823546 293 {
kwstasfane1 0:b94498823546 294 if(dsp_range == 0) //High resolution (2.000 +- 0.0001 ms)
kwstasfane1 0:b94498823546 295 {
kwstasfane1 0:b94498823546 296 m_result = m_period_ms;
kwstasfane1 0:b94498823546 297 if(m_result <= 2.0001)
kwstasfane1 0:b94498823546 298 {
kwstasfane1 0:b94498823546 299 //assigns the decimal point precision for each range
kwstasfane1 0:b94498823546 300 *res="%1.4f %s";
kwstasfane1 0:b94498823546 301 }
kwstasfane1 0:b94498823546 302 else
kwstasfane1 0:b94498823546 303 {
kwstasfane1 0:b94498823546 304 *res="Out-of-range... '>2.000 ms !'";
kwstasfane1 0:b94498823546 305 }
kwstasfane1 0:b94498823546 306 }
kwstasfane1 0:b94498823546 307 else if(dsp_range == 1) //medium resolution (20.00 +- 0.01 ms)
kwstasfane1 0:b94498823546 308 {
kwstasfane1 0:b94498823546 309 m_result = m_period_ms;
kwstasfane1 0:b94498823546 310 if(m_result <= 20.01)
kwstasfane1 0:b94498823546 311 {
kwstasfane1 0:b94498823546 312 //assigns the decimal point precision for each range
kwstasfane1 0:b94498823546 313 *res="%2.2f %s";
kwstasfane1 0:b94498823546 314 }
kwstasfane1 0:b94498823546 315 else
kwstasfane1 0:b94498823546 316 {
kwstasfane1 0:b94498823546 317 *res="Out-of-range... '>20.00 ms !'";
kwstasfane1 0:b94498823546 318 }
kwstasfane1 0:b94498823546 319 }
kwstasfane1 0:b94498823546 320 else //low resolution (2.000 +- 0.001 s)
kwstasfane1 0:b94498823546 321 {
kwstasfane1 0:b94498823546 322 m_result = m_period_ms/1000;
kwstasfane1 0:b94498823546 323 if(m_result <= 2.001)
kwstasfane1 0:b94498823546 324 {
kwstasfane1 0:b94498823546 325 //assigns the decimal point precision for each range
kwstasfane1 0:b94498823546 326 *res="%1.3f %s";
kwstasfane1 0:b94498823546 327 }
kwstasfane1 0:b94498823546 328 else
kwstasfane1 0:b94498823546 329 {
kwstasfane1 0:b94498823546 330 *res="Out-of-range... '>2.000 sec'";
kwstasfane1 0:b94498823546 331 }
kwstasfane1 0:b94498823546 332 }
kwstasfane1 0:b94498823546 333 }
kwstasfane1 0:b94498823546 334 else // "(dsp_mode == 2)" time interval measurement
kwstasfane1 0:b94498823546 335 {
kwstasfane1 0:b94498823546 336 if(dsp_time_interval == 0 || dsp_time_interval == 1) //rising->rising, falling -> falling
kwstasfane1 0:b94498823546 337 {
kwstasfane1 0:b94498823546 338 m_result = m_period_ms;
kwstasfane1 0:b94498823546 339 }
kwstasfane1 0:b94498823546 340 else if(dsp_time_interval == 2 || dsp_time_interval == 3) //rising->falling, falling->rising
kwstasfane1 0:b94498823546 341 {
kwstasfane1 0:b94498823546 342 m_result = m_period_ms/2; //based on the assumption that the square wave has 50% DUTY CYCLE
kwstasfane1 0:b94498823546 343 }
kwstasfane1 0:b94498823546 344
kwstasfane1 0:b94498823546 345 /*else if(dsp_time_interval == 3) //falling->rising (t1)
kwstasfane1 0:b94498823546 346 {
kwstasfane1 0:b94498823546 347 m_result = m_period_ms - (ton/1000);
kwstasfane1 0:b94498823546 348 }*/
kwstasfane1 0:b94498823546 349
kwstasfane1 0:b94498823546 350 if(dsp_range == 0) //High resolution (2.0000 +- 0.0001 ms)
kwstasfane1 0:b94498823546 351 {
kwstasfane1 0:b94498823546 352 if(m_result <= 2.0001)
kwstasfane1 0:b94498823546 353 {
kwstasfane1 0:b94498823546 354 //assigns the decimal point precision for each range
kwstasfane1 0:b94498823546 355 *res="%1.4f %s";
kwstasfane1 0:b94498823546 356 }
kwstasfane1 0:b94498823546 357 else
kwstasfane1 0:b94498823546 358 {
kwstasfane1 0:b94498823546 359 *res="Out-of-range... '>2.000 ms !'";
kwstasfane1 0:b94498823546 360 }
kwstasfane1 0:b94498823546 361 }
kwstasfane1 0:b94498823546 362 else if(dsp_range == 1) //medium resolution (20.00 +- 0.01 ms)
kwstasfane1 0:b94498823546 363 {
kwstasfane1 0:b94498823546 364 if(m_result <= 20.01)
kwstasfane1 0:b94498823546 365 {
kwstasfane1 0:b94498823546 366 //assigns the decimal point precision for each range
kwstasfane1 0:b94498823546 367 *res="%2.2f %s";
kwstasfane1 0:b94498823546 368 }
kwstasfane1 0:b94498823546 369 else
kwstasfane1 0:b94498823546 370 {
kwstasfane1 0:b94498823546 371 *res="Out-of-range... '>20.00 ms !'";
kwstasfane1 0:b94498823546 372 }
kwstasfane1 0:b94498823546 373 }
kwstasfane1 0:b94498823546 374 else //low resolution (2.000+-0.0001ms)
kwstasfane1 0:b94498823546 375 {
kwstasfane1 0:b94498823546 376 //m_result = m_t_interval_ms/10e3;
kwstasfane1 0:b94498823546 377 m_result = m_result/1000;
kwstasfane1 0:b94498823546 378 if(m_result <= 2.001)
kwstasfane1 0:b94498823546 379 {
kwstasfane1 0:b94498823546 380 //assigns the decimal point precision for each range
kwstasfane1 0:b94498823546 381 *res="%1.3f %s";
kwstasfane1 0:b94498823546 382 }
kwstasfane1 0:b94498823546 383 else
kwstasfane1 0:b94498823546 384 {
kwstasfane1 0:b94498823546 385 *res="Out-of-range... '>2.000 sec'";
kwstasfane1 0:b94498823546 386 }
kwstasfane1 0:b94498823546 387 }
kwstasfane1 0:b94498823546 388 }
kwstasfane1 0:b94498823546 389 }