Hardware components | ||||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
Software apps and online services | ||||||
| ||||||
Hand tools and fabrication machines | ||||||
|
For someone who is a hobbyist/pro-developer/engineer, it never hurts to have a spare meter! This is the story of a hobby meter, named DRCC meter. DRCC stands for Diode Resistance Capacitance and Continuity testing meter.
Features- Auto ranging resistance measure: 10 Ohms - 500 kOhms
- Auto ranging fast capacitance measure: 1 uF - 4000 uF
- Diode/LED with forward voltage drop: < 2.0 Volts
- Continuity of circuit trace/wire < 100 Ohms
- Fast update
- Capable of measuring big caps
- Cool icons for components
The hardware is very simple. Just a PSoC 4 4$ kit on a breadboard, few resistors, a buzzer, a 20x4 LCD Character display and 2 connecting probe!
Resistance
From Ohms law V = I * R or R = V/I, injecting known I value and measuring the V with ADC, resistance R can be calculated. The current injection is done in PSoC 4 using IDAC module. Details explained Here from a old project with just resistance measurement capability.
Capacitance
As for Capacitance, C = Q * V, means Capacitance is equal to Charge Q stored in a capacitor times Voltage build up across capacitor terminals. Again, Charge Q = I * t, meaning Current times Time is Charge. Now, injecting a known current for a known time, total charge stored can be calculated. During this charge storage voltage V will build up which is measured using ADC. Finally, capacitance can be measured from multiplying all the measured value C = V * I * t .
Continuity
Continuity of any electrical path means Low Resistance. It can be measured in the same way resistance measurement.
Diode/LED
Diodes exhibit a forward voltage drop known as knee voltage where diode voltage pretty much locks up. By applying full IDAC current through diode or LED this voltage drop can be reached. Next the ADC is used to measure up the FW voltage drop. If there is 0 Volt drop means the diode is Bad/Short.
IDAC is a Digital to Analog Converter Current Source. It can source/sink of current which is programmable.
- IDAC can be shorted to Ground or V supply, without any harm
- IDAC pin goes to 5 volt when set current can not flow through load
- IDAC consumes Analog Routing/paths inside PSoC
- IDAC has current step of 1.2 uA or 2.4 uA
- IDAC current step current's Integer Multiple in 7/8 bit can be programmed
The PSoC Creator (version 3.1 used) is a magical firmware allows to add the cool components and wire up internally the hardware parts, so the complication on external hardware is minimized.
An ADC (12 bit) is used to measure, an IDAC (8 bit) is used to inject known test current to external components, timer to keep track of elapsed test time, LCD component drives the display with breeze, few GPIO pins to change options and press indication on LED. Measurement and current inject is done with an analog pin.
PSoC Components Configuration
LCD icons for ohms, resistor, capacitor, diode etc are made using custom fonts as follows in the LCD component.
LCD is connected to Port 0 Pins: 0-7 as per following table from datasheet:
Few more videos on separate tests:
#include <project.h>
volatile uint32_t us_10=0; // 10 uSec variable
int current =0;
int voltage =0;
int resistance=0;
uint32_t IDAC_Val=0xff;
int c=4095;
int j=0; //use as loop counter
int mode =1;
CY_ISR(Timing_ISR_Handler)
{
us_10++;
Timer_ClearInterrupt(Timer_TC_INTERRUPT_MASK);
}
uint8_t sine_wave[256] = {
0x80, 0x83, 0x86, 0x89, 0x8C, 0x90, 0x93, 0x96,
0x99, 0x9C, 0x9F, 0xA2, 0xA5, 0xA8, 0xAB, 0xAE,
0xB1, 0xB3, 0xB6, 0xB9, 0xBC, 0xBF, 0xC1, 0xC4,
0xC7, 0xC9, 0xCC, 0xCE, 0xD1, 0xD3, 0xD5, 0xD8,
0xDA, 0xDC, 0xDE, 0xE0, 0xE2, 0xE4, 0xE6, 0xE8,
0xEA, 0xEB, 0xED, 0xEF, 0xF0, 0xF1, 0xF3, 0xF4,
0xF5, 0xF6, 0xF8, 0xF9, 0xFA, 0xFA, 0xFB, 0xFC,
0xFD, 0xFD, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFE, 0xFD,
0xFD, 0xFC, 0xFB, 0xFA, 0xFA, 0xF9, 0xF8, 0xF6,
0xF5, 0xF4, 0xF3, 0xF1, 0xF0, 0xEF, 0xED, 0xEB,
0xEA, 0xE8, 0xE6, 0xE4, 0xE2, 0xE0, 0xDE, 0xDC,
0xDA, 0xD8, 0xD5, 0xD3, 0xD1, 0xCE, 0xCC, 0xC9,
0xC7, 0xC4, 0xC1, 0xBF, 0xBC, 0xB9, 0xB6, 0xB3,
0xB1, 0xAE, 0xAB, 0xA8, 0xA5, 0xA2, 0x9F, 0x9C,
0x99, 0x96, 0x93, 0x90, 0x8C, 0x89, 0x86, 0x83,
0x80, 0x7D, 0x7A, 0x77, 0x74, 0x70, 0x6D, 0x6A,
0x67, 0x64, 0x61, 0x5E, 0x5B, 0x58, 0x55, 0x52,
0x4F, 0x4D, 0x4A, 0x47, 0x44, 0x41, 0x3F, 0x3C,
0x39, 0x37, 0x34, 0x32, 0x2F, 0x2D, 0x2B, 0x28,
0x26, 0x24, 0x22, 0x20, 0x1E, 0x1C, 0x1A, 0x18,
0x16, 0x15, 0x13, 0x11, 0x10, 0x0F, 0x0D, 0x0C,
0x0B, 0x0A, 0x08, 0x07, 0x06, 0x06, 0x05, 0x04,
0x03, 0x03, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x03,
0x03, 0x04, 0x05, 0x06, 0x06, 0x07, 0x08, 0x0A,
0x0B, 0x0C, 0x0D, 0x0F, 0x10, 0x11, 0x13, 0x15,
0x16, 0x18, 0x1A, 0x1C, 0x1E, 0x20, 0x22, 0x24,
0x26, 0x28, 0x2B, 0x2D, 0x2F, 0x32, 0x34, 0x37,
0x39, 0x3C, 0x3F, 0x41, 0x44, 0x47, 0x4A, 0x4D,
0x4F, 0x52, 0x55, 0x58, 0x5B, 0x5E, 0x61, 0x64,
0x67, 0x6A, 0x6D, 0x70, 0x74, 0x77, 0x7A, 0x7D
};
void measure_resistance(void);
void measure_continuity(void);
void measure_capacitance(void);
void measure_diode(void);
void measure_inductance(void);
void res_mode(void)
{
}
/////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////// MAIN LOOP /////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
int main()
{
LCD_Start();
ADC_Start();
IDAC_Start();
Timer_Start();
Timing_ISR_StartEx(Timing_ISR_Handler);
// CyGlobalIntEnable;
mode=1;
IDAC_SetValue(IDAC_Val);
ADC_StartConvert();
LCD_Position(1,0);LCD_PrintString(" ! PSoC Auto Range !");
LCD_Position(2,0);LCD_PrintString("*** LRC Meter ***");
CyDelay(2000);
LCD_ClearDisplay();
for(;;)
{
measure_capacitance();
measure_resistance();
measure_continuity();
measure_diode();
if (mode>4) {mode=1;}
} ///////////////////////// Forever for loop ends here /////////////////////////////////*/
} ///////////////////=========== main loop Ends Here ===============/////////////////////////
///////////////////////////// FUNCTIONS BODY /////////////////////////////
void measure_resistance()
{
IDAC_Start();
unsigned long R=0;
while (mode==1)
{
Buzzer_Write(0);
IDAC_Val=0xff;
c=4095;
while((IDAC_Val>0)&&(c>=4000))
{
IDAC_Val=IDAC_Val-0x01;
IDAC_SetValue(IDAC_Val);
CyDelay(3);
while( ADC_IsEndConversion(ADC_RETURN_STATUS)){}
c=ADC_GetResult16(0);
CyDelay(2);
}
if (c<4000)
{
IDAC_SetValue(IDAC_Val);
CyDelay(1);
current= IDAC_Val*1.2; // in uAmp
voltage=c*1000/2; // in uVolt
resistance = voltage/current; // Ohms Law to calculate resistanc
resistance = resistance - 148; // offsetting internal trace resistance of 150 ohms per trace
if (resistance<=0) {resistance = 0;} // omitting any negative value
if (resistance>5000) {resistance = resistance*1.05;} // soft correction to reduce error
LCD_ClearDisplay();
// 500K IS THE LIMIT FOR RESISTANCE
if (resistance<500000)
{
// Show Result on LCD //
LCD_Position(0,0); LCD_PrintString("* RESISTANCE MODE *");
LCD_Position(1,6);LCD_PrintString("o_");LCD_PutChar(LCD_CUSTOM_2);LCD_PutChar(LCD_CUSTOM_3);
LCD_PutChar(LCD_CUSTOM_2);LCD_PutChar(LCD_CUSTOM_3);LCD_PrintString("_o");
LCD_Position(2,5); LCD_PrintU32Number(resistance);
LCD_PrintString(" ");LCD_PutChar(LCD_CUSTOM_0);
LCD_Position(3,5);LCD_PrintU32Number(resistance/1000);
if(resistance%1000>=100)LCD_PrintString(".");
else if(resistance%1000>=10)LCD_PrintString(".0");
else if(resistance%1000<10)LCD_PrintString(".00");
LCD_PrintU32Number(resistance%1000);
LCD_PrintString(" k");
LCD_PutChar(LCD_CUSTOM_0);
CyDelay(100);
}
else
{
LCD_Position(0,0);LCD_PrintString("* RESISTANCE MODE *");
LCD_Position(1,6);LCD_PrintString("o_ _o");
LCD_Position(2,0); LCD_PrintString("No Resistor Detected");
LCD_Position(3,0); LCD_PrintString(" Connect Resistor !!");
CyDelay(100);
}
CyDelay(100);
// mode exit if user press switch
if(LED_Read()==1){mode++;}
}
}
}
void measure_capacitance()
{
while (mode==2)
{
// Timer_WritePeriod(10);
IDAC_Stop();
while( ADC_IsEndConversion(ADC_RETURN_STATUS)){}
c=ADC_GetResult16(0);
LCD_ClearDisplay();
LCD_Position(0,0);
LCD_PrintString("* CAPACITANCE MODE *");
LCD_Position(1,2);
LCD_PrintString("(+) o-- --o (-)");
IDAC_Start();
IDAC_Val=100;
IDAC_SetValue(IDAC_Val);// times 1.2 uA times CHARGE TIME is Q Coulomb charge
int k=0;
uint16 ADC_Level = 2048 ; // caps will charge through IDAC current upto this level
while(c<ADC_Level)
{
if(k==0) // One time loop
{
LCD_Position(0,0);LCD_PrintString("* CAPACITANCE MODE *");
LCD_Position(1,2);LCD_PrintString("(+) o--");LCD_PutChar(LCD_CUSTOM_6);
LCD_PutChar(LCD_CUSTOM_5);LCD_PrintString("--o (-)");
LCD_Position(2,0);LCD_PrintString(" Measuring.....");
k++;CyGlobalIntDisable; us_10=0;CyGlobalIntEnable;
}
// ADC is measuring voltage across capacitor
while( ADC_IsEndConversion(ADC_RETURN_STATUS)){}
c=ADC_GetResult16(0);
}
CyGlobalIntDisable; // disabling interrupt to stop updating time
IDAC_SetValue(0x00); // IDAC current is set 0
IDAC_Stop(); // IDAC is stopped
LCD_ClearDisplay();
// Using C = Q/V = I*t/V formula, Capacitance will be calculated and displayed
while(c>256)
{
LCD_Position(0,0); LCD_PrintString("* CAPACITANCE MODE *");
// Calculation Below //
// float Charge = IDAC_Val*1.2; // 1.2 uA is the step current
// uint32 Time = us_10/100; // microsec to milisec
// float Volt = ADC_Level/2.0;
// Approx Timing Correction for Execution Delay by adding 20% to calculated value (1.2 times)
double nFCaptemp = 1000*1.2*((IDAC_Val*1.2*us_10/100.0)/(ADC_Level/2.0));
uint32 nFCap = nFCaptemp;
uint32 Capacitance = nFCap/1000;
// Displaying Capacitacne on LCD //
LCD_Position(1,2);LCD_PrintString("(+) o-- --o (-)");
// LCD_PrintString("(+) o--");LCD_PutChar(LCD_CUSTOM_6);LCD_PutChar(LCD_CUSTOM_5);LCD_PrintString("--o (-)");
LCD_Position(2,7); LCD_PrintU32Number(Capacitance);LCD_PrintString(" uF ");
LCD_Position(3,7);; LCD_PrintU32Number(nFCap);LCD_PrintString(" nF ");
CyDelay(500);
// Checks for presence of Capacitance connected to Probe //
while( ADC_IsEndConversion(ADC_RETURN_STATUS)){}
c=ADC_GetResult16(0);
}
LCD_ClearDisplay();
// mode exit if user press switch
if(LED_Read()==1){mode++;}
}
}
void measure_continuity()
{
IDAC_Start();
LCD_ClearDisplay();
// Show Result on LCD //
LCD_Position(0,0);LCD_PrintString("* CONTINUITY MODE *");
LCD_Position(1,6);LCD_PrintString("o- -o");
LCD_Position(2,0); LCD_PrintString(" Continuity.... ");
LCD_Position(3,0); LCD_PrintString(" Not Detected !! ");
Buzzer_Write(0);
IDAC_Val=100;
IDAC_SetValue(IDAC_Val);
c=100;
CyDelay(1000);
while (mode==3)
{
if (c<50)
{
while( ADC_IsEndConversion(ADC_RETURN_STATUS)){}
c=ADC_GetResult16(0);
CyDelay(10);
LCD_ClearDisplay();
// Show Result on LCD //
LCD_Position(0,0); LCD_PrintString("* CONTINUITY MODE *");
LCD_Position(1,6);LCD_PrintString("o------o");
LCD_Position(2,0); LCD_PrintString(" Continuity.... ");
LCD_Position(3,0); LCD_PrintString(" Detected !! ");
Buzzer_Write(1);
CyDelay(20);
}
if (c>50)
{
while( ADC_IsEndConversion(ADC_RETURN_STATUS)){}
c=ADC_GetResult16(0);
CyDelay(10);
LCD_ClearDisplay();
// Show Result on LCD //
LCD_Position(0,0);LCD_PrintString("* CONTINUITY MODE *");
LCD_Position(1,6);LCD_PrintString("o- -o");
LCD_Position(2,0); LCD_PrintString(" Continuity.... ");
LCD_Position(3,0); LCD_PrintString(" Not Detected !! ");
Buzzer_Write(0);
CyDelay(20);
}
CyDelay(20);
// mode exit if user press switch
if(LED_Read()==1){mode++;Buzzer_Write(0);}
}
}
//////// diode ///////////////
void measure_diode()
{
IDAC_Start();
LCD_ClearDisplay();
// Show Result on LCD //
LCD_Position(0,0);LCD_PrintString("* DIODE MODE *");
LCD_Position(1,6);LCD_PrintString("o-- --o");
LCD_Position(2,0); LCD_PrintString(" Diode/LED .... ");
LCD_Position(3,0); LCD_PrintString(" Not Detected !! ");
Buzzer_Write(0);
IDAC_Val=255;
IDAC_SetValue(IDAC_Val);
c=100;
CyDelay(1000);
while (mode==4)
{
if (c>3850)
{
while( ADC_IsEndConversion(ADC_RETURN_STATUS)){}
c=ADC_GetResult16(0);
CyDelay(10);
LCD_ClearDisplay();
// Show Result on LCD //
LCD_Position(0,0);LCD_PrintString("* DIODE MODE *");
LCD_Position(1,6);LCD_PrintString("o-- --o");
LCD_Position(2,0); LCD_PrintString(" Diode/LED .... ");
LCD_Position(3,0); LCD_PrintString(" Not Detected !! ");
Buzzer_Write(0);
CyDelay(200);
}
if (c<3850)
{
while( ADC_IsEndConversion(ADC_RETURN_STATUS)){}
c=ADC_GetResult16(0);
CyDelay(10);
LCD_ClearDisplay();
// Show Result on LCD //
LCD_Position(0,0);LCD_PrintString("* DIODE MODE *");
LCD_Position(1,6);LCD_PrintString("o--");
LCD_PutChar(LCD_CUSTOM_6);LCD_PutChar(LCD_CUSTOM_4);LCD_PrintString("--o");
LCD_Position(2,0); LCD_PrintString("Diode/LED Detected !");
LCD_Position(3,1); LCD_PrintString("V_fd = ");
int vfd = c/2; // in mV
LCD_PrintU32Number(vfd/1000);
if(vfd%1000>=100)LCD_PrintString(".");
else if(vfd%1000>=10)LCD_PrintString(".0");
else if(vfd%1000<10)LCD_PrintString(".00");
LCD_PrintU32Number(vfd%1000);
LCD_PrintString(" Volt");
Buzzer_Write(1);
CyDelay(10);
Buzzer_Write(0);
CyDelay(200);
}
CyDelay(20);
// mode exit if user press switch
if(LED_Read()==1){mode++;Buzzer_Write(0);}
}
}
//////////////////////
void ind_mode(void)
{
LCD_Position(0,0);
LCD_PrintString("* INDUCTANCE MODE *");
LCD_Position(1,6);
LCD_Position(1,6);
LCD_PrintString("o-");LCD_PutChar(LCD_CUSTOM_7);LCD_PutChar(LCD_CUSTOM_7);
LCD_PutChar(LCD_CUSTOM_7);LCD_PutChar(LCD_CUSTOM_7);LCD_PrintString("-o");
LCD_Position(2,0); LCD_PrintString(" Program for ");
LCD_Position(3,0); LCD_PrintString(" SINE Wave ");
CyDelay(100);
while(mode==3)
{
int i=0;
for(i=0;i<255;i=i+8)
{
IDAC_SetValue(sine_wave[i]); // feed from a lookuo table
}
if(LED_Read()==1) {mode++;}// EXIT COND
}
}
#include <project.h>
volatile uint32_t us_10=0; // 10 uSec variable
int current =0;
int voltage =0;
int resistance=0;
uint32_t IDAC_Val=0xff;
int c=4095;
int j=0; //use as loop counter
int mode =1;
CY_ISR(Timing_ISR_Handler)
{
us_10++;
Timer_ClearInterrupt(Timer_TC_INTERRUPT_MASK);
}
uint8_t sine_wave[256] = {
0x80, 0x83, 0x86, 0x89, 0x8C, 0x90, 0x93, 0x96,
0x99, 0x9C, 0x9F, 0xA2, 0xA5, 0xA8, 0xAB, 0xAE,
0xB1, 0xB3, 0xB6, 0xB9, 0xBC, 0xBF, 0xC1, 0xC4,
0xC7, 0xC9, 0xCC, 0xCE, 0xD1, 0xD3, 0xD5, 0xD8,
0xDA, 0xDC, 0xDE, 0xE0, 0xE2, 0xE4, 0xE6, 0xE8,
0xEA, 0xEB, 0xED, 0xEF, 0xF0, 0xF1, 0xF3, 0xF4,
0xF5, 0xF6, 0xF8, 0xF9, 0xFA, 0xFA, 0xFB, 0xFC,
0xFD, 0xFD, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFE, 0xFD,
0xFD, 0xFC, 0xFB, 0xFA, 0xFA, 0xF9, 0xF8, 0xF6,
0xF5, 0xF4, 0xF3, 0xF1, 0xF0, 0xEF, 0xED, 0xEB,
0xEA, 0xE8, 0xE6, 0xE4, 0xE2, 0xE0, 0xDE, 0xDC,
0xDA, 0xD8, 0xD5, 0xD3, 0xD1, 0xCE, 0xCC, 0xC9,
0xC7, 0xC4, 0xC1, 0xBF, 0xBC, 0xB9, 0xB6, 0xB3,
0xB1, 0xAE, 0xAB, 0xA8, 0xA5, 0xA2, 0x9F, 0x9C,
0x99, 0x96, 0x93, 0x90, 0x8C, 0x89, 0x86, 0x83,
0x80, 0x7D, 0x7A, 0x77, 0x74, 0x70, 0x6D, 0x6A,
0x67, 0x64, 0x61, 0x5E, 0x5B, 0x58, 0x55, 0x52,
0x4F, 0x4D, 0x4A, 0x47, 0x44, 0x41, 0x3F, 0x3C,
0x39, 0x37, 0x34, 0x32, 0x2F, 0x2D, 0x2B, 0x28,
0x26, 0x24, 0x22, 0x20, 0x1E, 0x1C, 0x1A, 0x18,
0x16, 0x15, 0x13, 0x11, 0x10, 0x0F, 0x0D, 0x0C,
0x0B, 0x0A, 0x08, 0x07, 0x06, 0x06, 0x05, 0x04,
0x03, 0x03, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x03,
0x03, 0x04, 0x05, 0x06, 0x06, 0x07, 0x08, 0x0A,
0x0B, 0x0C, 0x0D, 0x0F, 0x10, 0x11, 0x13, 0x15,
0x16, 0x18, 0x1A, 0x1C, 0x1E, 0x20, 0x22, 0x24,
0x26, 0x28, 0x2B, 0x2D, 0x2F, 0x32, 0x34, 0x37,
0x39, 0x3C, 0x3F, 0x41, 0x44, 0x47, 0x4A, 0x4D,
0x4F, 0x52, 0x55, 0x58, 0x5B, 0x5E, 0x61, 0x64,
0x67, 0x6A, 0x6D, 0x70, 0x74, 0x77, 0x7A, 0x7D
};
void measure_resistance(void);
void measure_continuity(void);
void measure_capacitance(void);
void measure_diode(void);
void measure_inductance(void);
void res_mode(void)
{
}
/////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////// MAIN LOOP /////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
int main()
{
LCD_Start();
ADC_Start();
IDAC_Start();
Timer_Start();
Timing_ISR_StartEx(Timing_ISR_Handler);
// CyGlobalIntEnable;
mode=1;
IDAC_SetValue(IDAC_Val);
ADC_StartConvert();
LCD_Position(1,0);LCD_PrintString(" ! PSoC Auto Range !");
LCD_Position(2,0);LCD_PrintString("*** LRC Meter ***");
CyDelay(2000);
LCD_ClearDisplay();
for(;;)
{
measure_capacitance();
measure_resistance();
measure_continuity();
measure_diode();
if (mode>4) {mode=1;}
} ///////////////////////// Forever for loop ends here /////////////////////////////////*/
} ///////////////////=========== main loop Ends Here ===============/////////////////////////
///////////////////////////// FUNCTIONS BODY /////////////////////////////
void measure_resistance()
{
IDAC_Start();
unsigned long R=0;
while (mode==1)
{
Buzzer_Write(0);
IDAC_Val=0xff;
c=4095;
while((IDAC_Val>0)&&(c>=4000))
{
IDAC_Val=IDAC_Val-0x01;
IDAC_SetValue(IDAC_Val);
CyDelay(3);
while( ADC_IsEndConversion(ADC_RETURN_STATUS)){}
c=ADC_GetResult16(0);
CyDelay(2);
}
if (c<4000)
{
IDAC_SetValue(IDAC_Val);
CyDelay(1);
current= IDAC_Val*1.2; // in uAmp
voltage=c*1000/2; // in uVolt
resistance = voltage/current; // Ohms Law to calculate resistanc
resistance = resistance - 148; // offsetting internal trace resistance of 150 ohms per trace
if (resistance<=0) {resistance = 0;} // omitting any negative value
if (resistance>5000) {resistance = resistance*1.05;} // soft correction to reduce error
LCD_ClearDisplay();
// 500K IS THE LIMIT FOR RESISTANCE
if (resistance<500000)
{
// Show Result on LCD //
LCD_Position(0,0); LCD_PrintString("* RESISTANCE MODE *");
LCD_Position(1,6);LCD_PrintString("o_");LCD_PutChar(LCD_CUSTOM_2);LCD_PutChar(LCD_CUSTOM_3);
LCD_PutChar(LCD_CUSTOM_2);LCD_PutChar(LCD_CUSTOM_3);LCD_PrintString("_o");
LCD_Position(2,5); LCD_PrintU32Number(resistance);
LCD_PrintString(" ");LCD_PutChar(LCD_CUSTOM_0);
LCD_Position(3,5);LCD_PrintU32Number(resistance/1000);
if(resistance%1000>=100)LCD_PrintString(".");
else if(resistance%1000>=10)LCD_PrintString(".0");
else if(resistance%1000<10)LCD_PrintString(".00");
LCD_PrintU32Number(resistance%1000);
LCD_PrintString(" k");
LCD_PutChar(LCD_CUSTOM_0);
CyDelay(100);
}
else
{
LCD_Position(0,0);LCD_PrintString("* RESISTANCE MODE *");
LCD_Position(1,6);LCD_PrintString("o_ _o");
LCD_Position(2,0); LCD_PrintString("No Resistor Detected");
LCD_Position(3,0); LCD_PrintString(" Connect Resistor !!");
CyDelay(100);
}
CyDelay(100);
// mode exit if user press switch
if(LED_Read()==1){mode++;}
}
}
}
void measure_capacitance()
{
while (mode==2)
{
// Timer_WritePeriod(10);
IDAC_Stop();
while( ADC_IsEndConversion(ADC_RETURN_STATUS)){}
c=ADC_GetResult16(0);
LCD_ClearDisplay();
LCD_Position(0,0);
LCD_PrintString("* CAPACITANCE MODE *");
LCD_Position(1,2);
LCD_PrintString("(+) o-- --o (-)");
IDAC_Start();
IDAC_Val=100;
IDAC_SetValue(IDAC_Val);// times 1.2 uA times CHARGE TIME is Q Coulomb charge
int k=0;
uint16 ADC_Level = 2048 ; // caps will charge through IDAC current upto this level
while(c<ADC_Level)
{
if(k==0) // One time loop
{
LCD_Position(0,0);LCD_PrintString("* CAPACITANCE MODE *");
LCD_Position(1,2);LCD_PrintString("(+) o--");LCD_PutChar(LCD_CUSTOM_6);
LCD_PutChar(LCD_CUSTOM_5);LCD_PrintString("--o (-)");
LCD_Position(2,0);LCD_PrintString(" Measuring.....");
k++;CyGlobalIntDisable; us_10=0;CyGlobalIntEnable;
}
// ADC is measuring voltage across capacitor
while( ADC_IsEndConversion(ADC_RETURN_STATUS)){}
c=ADC_GetResult16(0);
}
CyGlobalIntDisable; // disabling interrupt to stop updating time
IDAC_SetValue(0x00); // IDAC current is set 0
IDAC_Stop(); // IDAC is stopped
LCD_ClearDisplay();
// Using C = Q/V = I*t/V formula, Capacitance will be calculated and displayed
while(c>256)
{
LCD_Position(0,0); LCD_PrintString("* CAPACITANCE MODE *");
// Calculation Below //
// float Charge = IDAC_Val*1.2; // 1.2 uA is the step current
// uint32 Time = us_10/100; // microsec to milisec
// float Volt = ADC_Level/2.0;
// Approx Timing Correction for Execution Delay by adding 20% to calculated value (1.2 times)
double nFCaptemp = 1000*1.2*((IDAC_Val*1.2*us_10/100.0)/(ADC_Level/2.0));
uint32 nFCap = nFCaptemp;
uint32 Capacitance = nFCap/1000;
// Displaying Capacitacne on LCD //
LCD_Position(1,2);LCD_PrintString("(+) o-- --o (-)");
// LCD_PrintString("(+) o--");LCD_PutChar(LCD_CUSTOM_6);LCD_PutChar(LCD_CUSTOM_5);LCD_PrintString("--o (-)");
LCD_Position(2,7); LCD_PrintU32Number(Capacitance);LCD_PrintString(" uF ");
LCD_Position(3,7);; LCD_PrintU32Number(nFCap);LCD_PrintString(" nF ");
CyDelay(500);
// Checks for presence of Capacitance connected to Probe //
while( ADC_IsEndConversion(ADC_RETURN_STATUS)){}
c=ADC_GetResult16(0);
}
LCD_ClearDisplay();
// mode exit if user press switch
if(LED_Read()==1){mode++;}
}
}
void measure_continuity()
{
IDAC_Start();
LCD_ClearDisplay();
// Show Result on LCD //
LCD_Position(0,0);LCD_PrintString("* CONTINUITY MODE *");
LCD_Position(1,6);LCD_PrintString("o- -o");
LCD_Position(2,0); LCD_PrintString(" Continuity.... ");
LCD_Position(3,0); LCD_PrintString(" Not Detected !! ");
Buzzer_Write(0);
IDAC_Val=100;
IDAC_SetValue(IDAC_Val);
c=100;
CyDelay(1000);
while (mode==3)
{
if (c<50)
{
while( ADC_IsEndConversion(ADC_RETURN_STATUS)){}
c=ADC_GetResult16(0);
CyDelay(10);
LCD_ClearDisplay();
// Show Result on LCD //
LCD_Position(0,0); LCD_PrintString("* CONTINUITY MODE *");
LCD_Position(1,6);LCD_PrintString("o------o");
LCD_Position(2,0); LCD_PrintString(" Continuity.... ");
LCD_Position(3,0); LCD_PrintString(" Detected !! ");
Buzzer_Write(1);
CyDelay(20);
}
if (c>50)
{
while( ADC_IsEndConversion(ADC_RETURN_STATUS)){}
c=ADC_GetResult16(0);
CyDelay(10);
LCD_ClearDisplay();
// Show Result on LCD //
LCD_Position(0,0);LCD_PrintString("* CONTINUITY MODE *");
LCD_Position(1,6);LCD_PrintString("o- -o");
LCD_Position(2,0); LCD_PrintString(" Continuity.... ");
LCD_Position(3,0); LCD_PrintString(" Not Detected !! ");
Buzzer_Write(0);
CyDelay(20);
}
CyDelay(20);
// mode exit if user press switch
if(LED_Read()==1){mode++;Buzzer_Write(0);}
}
}
//////// diode ///////////////
void measure_diode()
{
IDAC_Start();
LCD_ClearDisplay();
// Show Result on LCD //
LCD_Position(0,0);LCD_PrintString("* DIODE MODE *");
LCD_Position(1,6);LCD_PrintString("o-- --o");
LCD_Position(2,0); LCD_PrintString(" Diode/LED .... ");
LCD_Position(3,0); LCD_PrintString(" Not Detected !! ");
Buzzer_Write(0);
IDAC_Val=255;
IDAC_SetValue(IDAC_Val);
c=100;
CyDelay(1000);
while (mode==4)
{
if (c>3850)
{
while( ADC_IsEndConversion(ADC_RETURN_STATUS)){}
c=ADC_GetResult16(0);
CyDelay(10);
LCD_ClearDisplay();
// Show Result on LCD //
LCD_Position(0,0);LCD_PrintString("* DIODE MODE *");
LCD_Position(1,6);LCD_PrintString("o-- --o");
LCD_Position(2,0); LCD_PrintString(" Diode/LED .... ");
LCD_Position(3,0); LCD_PrintString(" Not Detected !! ");
Buzzer_Write(0);
CyDelay(200);
}
if (c<3850)
{
while( ADC_IsEndConversion(ADC_RETURN_STATUS)){}
c=ADC_GetResult16(0);
CyDelay(10);
LCD_ClearDisplay();
// Show Result on LCD //
LCD_Position(0,0);LCD_PrintString("* DIODE MODE *");
LCD_Position(1,6);LCD_PrintString("o--");
LCD_PutChar(LCD_CUSTOM_6);LCD_PutChar(LCD_CUSTOM_4);LCD_PrintString("--o");
LCD_Position(2,0); LCD_PrintString("Diode/LED Detected !");
LCD_Position(3,1); LCD_PrintString("V_fd = ");
int vfd = c/2; // in mV
LCD_PrintU32Number(vfd/1000);
if(vfd%1000>=100)LCD_PrintString(".");
else if(vfd%1000>=10)LCD_PrintString(".0");
else if(vfd%1000<10)LCD_PrintString(".00");
LCD_PrintU32Number(vfd%1000);
LCD_PrintString(" Volt");
Buzzer_Write(1);
CyDelay(10);
Buzzer_Write(0);
CyDelay(200);
}
CyDelay(20);
// mode exit if user press switch
if(LED_Read()==1){mode++;Buzzer_Write(0);}
}
}
//////////////////////
void ind_mode(void)
{
LCD_Position(0,0);
LCD_PrintString("* INDUCTANCE MODE *");
LCD_Position(1,6);
LCD_Position(1,6);
LCD_PrintString("o-");LCD_PutChar(LCD_CUSTOM_7);LCD_PutChar(LCD_CUSTOM_7);
LCD_PutChar(LCD_CUSTOM_7);LCD_PutChar(LCD_CUSTOM_7);LCD_PrintString("-o");
LCD_Position(2,0); LCD_PrintString(" Program for ");
LCD_Position(3,0); LCD_PrintString(" SINE Wave ");
CyDelay(100);
while(mode==3)
{
int i=0;
for(i=0;i<255;i=i+8)
{
IDAC_SetValue(sine_wave[i]); // feed from a lookuo table
}
if(LED_Read()==1) {mode++;}// EXIT COND
}
}
#include <project.h>
volatile uint32_t us_10=0; // 10 uSec variable
int current =0;
int voltage =0;
int resistance=0;
uint32_t IDAC_Val=0xff;
int c=4095;
int j=0; //use as loop counter
int mode =1;
CY_ISR(Timing_ISR_Handler)
{
us_10++;
Timer_ClearInterrupt(Timer_TC_INTERRUPT_MASK);
}
uint8_t sine_wave[256] = {
0x80, 0x83, 0x86, 0x89, 0x8C, 0x90, 0x93, 0x96,
0x99, 0x9C, 0x9F, 0xA2, 0xA5, 0xA8, 0xAB, 0xAE,
0xB1, 0xB3, 0xB6, 0xB9, 0xBC, 0xBF, 0xC1, 0xC4,
0xC7, 0xC9, 0xCC, 0xCE, 0xD1, 0xD3, 0xD5, 0xD8,
0xDA, 0xDC, 0xDE, 0xE0, 0xE2, 0xE4, 0xE6, 0xE8,
0xEA, 0xEB, 0xED, 0xEF, 0xF0, 0xF1, 0xF3, 0xF4,
0xF5, 0xF6, 0xF8, 0xF9, 0xFA, 0xFA, 0xFB, 0xFC,
0xFD, 0xFD, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFE, 0xFD,
0xFD, 0xFC, 0xFB, 0xFA, 0xFA, 0xF9, 0xF8, 0xF6,
0xF5, 0xF4, 0xF3, 0xF1, 0xF0, 0xEF, 0xED, 0xEB,
0xEA, 0xE8, 0xE6, 0xE4, 0xE2, 0xE0, 0xDE, 0xDC,
0xDA, 0xD8, 0xD5, 0xD3, 0xD1, 0xCE, 0xCC, 0xC9,
0xC7, 0xC4, 0xC1, 0xBF, 0xBC, 0xB9, 0xB6, 0xB3,
0xB1, 0xAE, 0xAB, 0xA8, 0xA5, 0xA2, 0x9F, 0x9C,
0x99, 0x96, 0x93, 0x90, 0x8C, 0x89, 0x86, 0x83,
0x80, 0x7D, 0x7A, 0x77, 0x74, 0x70, 0x6D, 0x6A,
0x67, 0x64, 0x61, 0x5E, 0x5B, 0x58, 0x55, 0x52,
0x4F, 0x4D, 0x4A, 0x47, 0x44, 0x41, 0x3F, 0x3C,
0x39, 0x37, 0x34, 0x32, 0x2F, 0x2D, 0x2B, 0x28,
0x26, 0x24, 0x22, 0x20, 0x1E, 0x1C, 0x1A, 0x18,
0x16, 0x15, 0x13, 0x11, 0x10, 0x0F, 0x0D, 0x0C,
0x0B, 0x0A, 0x08, 0x07, 0x06, 0x06, 0x05, 0x04,
0x03, 0x03, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x03,
0x03, 0x04, 0x05, 0x06, 0x06, 0x07, 0x08, 0x0A,
0x0B, 0x0C, 0x0D, 0x0F, 0x10, 0x11, 0x13, 0x15,
0x16, 0x18, 0x1A, 0x1C, 0x1E, 0x20, 0x22, 0x24,
0x26, 0x28, 0x2B, 0x2D, 0x2F, 0x32, 0x34, 0x37,
0x39, 0x3C, 0x3F, 0x41, 0x44, 0x47, 0x4A, 0x4D,
0x4F, 0x52, 0x55, 0x58, 0x5B, 0x5E, 0x61, 0x64,
0x67, 0x6A, 0x6D, 0x70, 0x74, 0x77, 0x7A, 0x7D
};
void measure_resistance(void);
void measure_continuity(void);
void measure_capacitance(void);
void measure_diode(void);
void measure_inductance(void);
void res_mode(void)
{
}
/////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////// MAIN LOOP /////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
int main()
{
LCD_Start();
ADC_Start();
IDAC_Start();
Timer_Start();
Timing_ISR_StartEx(Timing_ISR_Handler);
// CyGlobalIntEnable;
mode=1;
IDAC_SetValue(IDAC_Val);
ADC_StartConvert();
LCD_Position(1,0);LCD_PrintString(" ! PSoC Auto Range !");
LCD_Position(2,0);LCD_PrintString("*** LRC Meter ***");
CyDelay(2000);
LCD_ClearDisplay();
for(;;)
{
measure_capacitance();
measure_resistance();
measure_continuity();
measure_diode();
if (mode>4) {mode=1;}
} ///////////////////////// Forever for loop ends here /////////////////////////////////*/
} ///////////////////=========== main loop Ends Here ===============/////////////////////////
///////////////////////////// FUNCTIONS BODY /////////////////////////////
void measure_resistance()
{
IDAC_Start();
unsigned long R=0;
while (mode==1)
{
Buzzer_Write(0);
IDAC_Val=0xff;
c=4095;
while((IDAC_Val>0)&&(c>=4000))
{
IDAC_Val=IDAC_Val-0x01;
IDAC_SetValue(IDAC_Val);
CyDelay(3);
while( ADC_IsEndConversion(ADC_RETURN_STATUS)){}
c=ADC_GetResult16(0);
CyDelay(2);
}
if (c<4000)
{
IDAC_SetValue(IDAC_Val);
CyDelay(1);
current= IDAC_Val*1.2; // in uAmp
voltage=c*1000/2; // in uVolt
resistance = voltage/current; // Ohms Law to calculate resistanc
resistance = resistance - 148; // offsetting internal trace resistance of 150 ohms per trace
if (resistance<=0) {resistance = 0;} // omitting any negative value
if (resistance>5000) {resistance = resistance*1.05;} // soft correction to reduce error
LCD_ClearDisplay();
// 500K IS THE LIMIT FOR RESISTANCE
if (resistance<500000)
{
// Show Result on LCD //
LCD_Position(0,0); LCD_PrintString("* RESISTANCE MODE *");
LCD_Position(1,6);LCD_PrintString("o_");LCD_PutChar(LCD_CUSTOM_2);LCD_PutChar(LCD_CUSTOM_3);
LCD_PutChar(LCD_CUSTOM_2);LCD_PutChar(LCD_CUSTOM_3);LCD_PrintString("_o");
LCD_Position(2,5); LCD_PrintU32Number(resistance);
LCD_PrintString(" ");LCD_PutChar(LCD_CUSTOM_0);
LCD_Position(3,5);LCD_PrintU32Number(resistance/1000);
if(resistance%1000>=100)LCD_PrintString(".");
else if(resistance%1000>=10)LCD_PrintString(".0");
else if(resistance%1000<10)LCD_PrintString(".00");
LCD_PrintU32Number(resistance%1000);
LCD_PrintString(" k");
LCD_PutChar(LCD_CUSTOM_0);
CyDelay(100);
}
else
{
LCD_Position(0,0);LCD_PrintString("* RESISTANCE MODE *");
LCD_Position(1,6);LCD_PrintString("o_ _o");
LCD_Position(2,0); LCD_PrintString("No Resistor Detected");
LCD_Position(3,0); LCD_PrintString(" Connect Resistor !!");
CyDelay(100);
}
CyDelay(100);
// mode exit if user press switch
if(LED_Read()==1){mode++;}
}
}
}
void measure_capacitance()
{
while (mode==2)
{
// Timer_WritePeriod(10);
IDAC_Stop();
while( ADC_IsEndConversion(ADC_RETURN_STATUS)){}
c=ADC_GetResult16(0);
LCD_ClearDisplay();
LCD_Position(0,0);
LCD_PrintString("* CAPACITANCE MODE *");
LCD_Position(1,2);
LCD_PrintString("(+) o-- --o (-)");
IDAC_Start();
IDAC_Val=100;
IDAC_SetValue(IDAC_Val);// times 1.2 uA times CHARGE TIME is Q Coulomb charge
int k=0;
uint16 ADC_Level = 2048 ; // caps will charge through IDAC current upto this level
while(c<ADC_Level)
{
if(k==0) // One time loop
{
LCD_Position(0,0);LCD_PrintString("* CAPACITANCE MODE *");
LCD_Position(1,2);LCD_PrintString("(+) o--");LCD_PutChar(LCD_CUSTOM_6);
LCD_PutChar(LCD_CUSTOM_5);LCD_PrintString("--o (-)");
LCD_Position(2,0);LCD_PrintString(" Measuring.....");
k++;CyGlobalIntDisable; us_10=0;CyGlobalIntEnable;
}
// ADC is measuring voltage across capacitor
while( ADC_IsEndConversion(ADC_RETURN_STATUS)){}
c=ADC_GetResult16(0);
}
CyGlobalIntDisable; // disabling interrupt to stop updating time
IDAC_SetValue(0x00); // IDAC current is set 0
IDAC_Stop(); // IDAC is stopped
LCD_ClearDisplay();
// Using C = Q/V = I*t/V formula, Capacitance will be calculated and displayed
while(c>256)
{
LCD_Position(0,0); LCD_PrintString("* CAPACITANCE MODE *");
// Calculation Below //
// float Charge = IDAC_Val*1.2; // 1.2 uA is the step current
// uint32 Time = us_10/100; // microsec to milisec
// float Volt = ADC_Level/2.0;
// Approx Timing Correction for Execution Delay by adding 20% to calculated value (1.2 times)
double nFCaptemp = 1000*1.2*((IDAC_Val*1.2*us_10/100.0)/(ADC_Level/2.0));
uint32 nFCap = nFCaptemp;
uint32 Capacitance = nFCap/1000;
// Displaying Capacitacne on LCD //
LCD_Position(1,2);LCD_PrintString("(+) o-- --o (-)");
// LCD_PrintString("(+) o--");LCD_PutChar(LCD_CUSTOM_6);LCD_PutChar(LCD_CUSTOM_5);LCD_PrintString("--o (-)");
LCD_Position(2,7); LCD_PrintU32Number(Capacitance);LCD_PrintString(" uF ");
LCD_Position(3,7);; LCD_PrintU32Number(nFCap);LCD_PrintString(" nF ");
CyDelay(500);
// Checks for presence of Capacitance connected to Probe //
while( ADC_IsEndConversion(ADC_RETURN_STATUS)){}
c=ADC_GetResult16(0);
}
LCD_ClearDisplay();
// mode exit if user press switch
if(LED_Read()==1){mode++;}
}
}
void measure_continuity()
{
IDAC_Start();
LCD_ClearDisplay();
// Show Result on LCD //
LCD_Position(0,0);LCD_PrintString("* CONTINUITY MODE *");
LCD_Position(1,6);LCD_PrintString("o- -o");
LCD_Position(2,0); LCD_PrintString(" Continuity.... ");
LCD_Position(3,0); LCD_PrintString(" Not Detected !! ");
Buzzer_Write(0);
IDAC_Val=100;
IDAC_SetValue(IDAC_Val);
c=100;
CyDelay(1000);
while (mode==3)
{
if (c<50)
{
while( ADC_IsEndConversion(ADC_RETURN_STATUS)){}
c=ADC_GetResult16(0);
CyDelay(10);
LCD_ClearDisplay();
// Show Result on LCD //
LCD_Position(0,0); LCD_PrintString("* CONTINUITY MODE *");
LCD_Position(1,6);LCD_PrintString("o------o");
LCD_Position(2,0); LCD_PrintString(" Continuity.... ");
LCD_Position(3,0); LCD_PrintString(" Detected !! ");
Buzzer_Write(1);
CyDelay(20);
}
if (c>50)
{
while( ADC_IsEndConversion(ADC_RETURN_STATUS)){}
c=ADC_GetResult16(0);
CyDelay(10);
LCD_ClearDisplay();
// Show Result on LCD //
LCD_Position(0,0);LCD_PrintString("* CONTINUITY MODE *");
LCD_Position(1,6);LCD_PrintString("o- -o");
LCD_Position(2,0); LCD_PrintString(" Continuity.... ");
LCD_Position(3,0); LCD_PrintString(" Not Detected !! ");
Buzzer_Write(0);
CyDelay(20);
}
CyDelay(20);
// mode exit if user press switch
if(LED_Read()==1){mode++;Buzzer_Write(0);}
}
}
//////// diode ///////////////
void measure_diode()
{
IDAC_Start();
LCD_ClearDisplay();
// Show Result on LCD //
LCD_Position(0,0);LCD_PrintString("* DIODE MODE *");
LCD_Position(1,6);LCD_PrintString("o-- --o");
LCD_Position(2,0); LCD_PrintString(" Diode/LED .... ");
LCD_Position(3,0); LCD_PrintString(" Not Detected !! ");
Buzzer_Write(0);
IDAC_Val=255;
IDAC_SetValue(IDAC_Val);
c=100;
CyDelay(1000);
while (mode==4)
{
if (c>3850)
{
while( ADC_IsEndConversion(ADC_RETURN_STATUS)){}
c=ADC_GetResult16(0);
CyDelay(10);
LCD_ClearDisplay();
// Show Result on LCD //
LCD_Position(0,0);LCD_PrintString("* DIODE MODE *");
LCD_Position(1,6);LCD_PrintString("o-- --o");
LCD_Position(2,0); LCD_PrintString(" Diode/LED .... ");
LCD_Position(3,0); LCD_PrintString(" Not Detected !! ");
Buzzer_Write(0);
CyDelay(200);
}
if (c<3850)
{
while( ADC_IsEndConversion(ADC_RETURN_STATUS)){}
c=ADC_GetResult16(0);
CyDelay(10);
LCD_ClearDisplay();
// Show Result on LCD //
LCD_Position(0,0);LCD_PrintString("* DIODE MODE *");
LCD_Position(1,6);LCD_PrintString("o--");
LCD_PutChar(LCD_CUSTOM_6);LCD_PutChar(LCD_CUSTOM_4);LCD_PrintString("--o");
LCD_Position(2,0); LCD_PrintString("Diode/LED Detected !");
LCD_Position(3,1); LCD_PrintString("V_fd = ");
int vfd = c/2; // in mV
LCD_PrintU32Number(vfd/1000);
if(vfd%1000>=100)LCD_PrintString(".");
else if(vfd%1000>=10)LCD_PrintString(".0");
else if(vfd%1000<10)LCD_PrintString(".00");
LCD_PrintU32Number(vfd%1000);
LCD_PrintString(" Volt");
Buzzer_Write(1);
CyDelay(10);
Buzzer_Write(0);
CyDelay(200);
}
CyDelay(20);
// mode exit if user press switch
if(LED_Read()==1){mode++;Buzzer_Write(0);}
}
}
//////////////////////
void ind_mode(void)
{
LCD_Position(0,0);
LCD_PrintString("* INDUCTANCE MODE *");
LCD_Position(1,6);
LCD_Position(1,6);
LCD_PrintString("o-");LCD_PutChar(LCD_CUSTOM_7);LCD_PutChar(LCD_CUSTOM_7);
LCD_PutChar(LCD_CUSTOM_7);LCD_PutChar(LCD_CUSTOM_7);LCD_PrintString("-o");
LCD_Position(2,0); LCD_PrintString(" Program for ");
LCD_Position(3,0); LCD_PrintString(" SINE Wave ");
CyDelay(100);
while(mode==3)
{
int i=0;
for(i=0;i<255;i=i+8)
{
IDAC_SetValue(sine_wave[i]); // feed from a lookuo table
}
if(LED_Read()==1) {mode++;}// EXIT COND
}
}
Comments