Page 1 of 3
C Meter click
From MikroElektonika Documentation
C Meter click
C Meter click has circuitry for measuring the value of capacitors. The design is based on a NE-555
timer/square-wave generator. The chip is implemented in an astable multivibrator circuit with fixed
resistors and adjustable capacitors.
Features and usage notes
C Meter click has four different-sized plates for
placing SMD capacitors (covering standard SMD
packaging dimensions) as well as a socket for
inserting a thru hole resistor. Each plate is labeled
with package size in standard imperial
measurements:
1210 — 3.2mm x 2.5mm
1206 — 3.2 mm x 1.6 mm
0805 — 2.0 mm x x1.25 mm
Schematic also available in PDF (http://cdndocs.mikroe.com/images/d/dd/C_Meter_click_schem
0603 — 1.6 mm x 0.8 mm
The board outputs a square wave frequency through
the INT pin. Depending on the capacitor placed on the board, the value of this frequency changes. The
value of a capacitor can be inferred using a simple algorithm (shown in the Libstock code example).
Onboard screw terminals are placed to allow the click to be used with oscillator probes.
C Meter click is designed to use a 5V power supply, but can work with either 3.3V or 5V logic levels.
C Meter click
IC/Module NE-555 precision timer
(http://www.ti.com/lit/ds/symlink/ne555.pdf)
Interface
INT, RST
Power
5V (possible to use with 3.3V I/O)
supply
Website
Programming
This code snippet uses a preset calibration value and finds the capacitance of the capacitor for displaying on the TFT.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include
#include
#include "resources.h"
// C_Meter Click
sbit C_METER_RST
at GPIOC_ODR.B2;
sbit C_METER_INT
at GPIOD_ODR.B10;
// TFT module connections
unsigned int TFT_DataPort at GPIOE_ODR;
sbit TFT_RST at GPIOE_ODR.B8;
sbit TFT_RS at GPIOE_ODR.B12;
sbit TFT_CS at GPIOE_ODR.B15;
sbit TFT_RD at GPIOE_ODR.B10;
sbit TFT_WR at GPIOE_ODR.B11;
sbit TFT_BLED at GPIOE_ODR.B9;
void
void
void
void
system_setup( void );
setup_interrupt( void );
InitTimer2( void );
display_init( void );
uint32_t int_count = 0;
uint32_t timer_count_end = 0;
bool sec_flag = false;
void main()
{
//Local Declarations
char uart_text[ 40 ];
float c_cal = 0.0;
float t_meas = 0.0;
float c_meas = 0.0;
float final = 0.0;
float t_cal = 0.0;
system_setup();
setup_interrupt();
InitTimer2();
display_init();
t_cal = 1.0 / 23350.0;
www.mikroe.com/click/c-meter
(http://www.mikroe.com/click/c-meter)
Page 2 of 3
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
c_cal = t_cal / 77616.0;
int_count = 0;
while(1)
{
}
if( sec_flag )
{
//Measurment
t_meas = 1.0 / timer_count_end;
c_meas = t_meas / 77616.0;
final = fabs( c_cal - c_meas );
//Print out
FloatToStr( final, final_text );
TFT_Rectangle( 100, 100, 200, 120 );
TFT_Write_Text( final_text, 100, 100 );
TFT_Write_Text( " Farad", 190, 100 );
//Reset flags
sec_flag = false;
int_count = 0;
timer_count_end = 0;
}
}
void display_init( void )
{
TFT_Init_ILI9341_8bit( 320, 240 );
TFT_BLED = 1;
TFT_Set_Pen( CL_WHITE, 1 );
TFT_Set_Brush( 1, CL_WHITE, 0, 0, 0, 0 );
TFT_Set_Font( TFT_defaultFont, CL_BLACK, FO_HORIZONTAL );
TFT_Fill_Screen( CL_WHITE );
TFT_Set_Pen( CL_BLACK, 1 );
TFT_Line( 20, 46, 300, 46 );
TFT_Line( 20, 70, 300, 70 );
TFT_Line( 20, 220, 300, 220 );
TFT_Set_Pen( CL_WHITE, 1 );
TFT_Set_Font( &HandelGothic_BT21x22_Regular, CL_RED, FO_HORIZONTAL );
TFT_Write_Text( "C Meter click", 105, 14 );
TFT_Set_Font( &Tahoma15x16_Bold, CL_BLUE, FO_HORIZONTAL );
TFT_Write_Text( "C Meter", 135, 50 );
TFT_Set_Font( &Verdana12x13_Regular, CL_BLACK, FO_HORIZONTAL );
TFT_Write_Text( "EasyMx PRO v7 for STM32", 19, 223 );
TFT_Set_Font( &Verdana12x13_Regular, CL_RED, FO_HORIZONTAL );
TFT_Write_Text( "www.mikroe.com", 200, 223 );
TFT_Set_Font( &Tahoma15x16_Bold, CL_BLACK, FO_HORIZONTAL );
}
void system_setup( void )
{
//GPIO
GPIO_Digital_Output( &GPIOC_BASE, _GPIO_PINMASK_2 );
GPIO_Digital_Input( &GPIOD_BASE, _GPIO_PINMASK_10 );
//RST
//INT
//RST Toggle
C_METER_RST = 0;
Delay_ms(50);
C_METER_RST = 1;
//UART
UART1_Init( 9600 );
UART1_Write_Text( "UART Initialized\r\n" );
}
void setup_interrupt( void )
{
GPIO_Digital_Output(&GPIOE_BASE, _GPIO_PINMASK_HIGH);
GPIOE_ODR = 0xAAAA;
GPIO_Digital_Input(&GPIOD_BASE, _GPIO_PINMASK_10);
}
RCC_APB2ENR.AFIOEN = 1;
AFIO_EXTICR3 = 0x0300;
EXTI_FTSR = 0x00000400;
EXTI_IMR |= 0x00000400;
NVIC_IntEnable(IVT_INT_EXTI15_10);
EnableInterrupts();
//
//
//
//
//
//
// Enable digital output on PORTD
Enable clock for alternate pin functions
PD10 as External interrupt
Set interrupt on Rising edge
Set mask
Enable External interrupt
Enables the processor interrupt.
void ExtInt() iv IVT_INT_EXTI15_10 ics ICS_AUTO
{
EXTI_PR.B10 = 1;
// clear flag
int_count++;
}
void InitTimer2() //1 second
{
RCC_APB1ENR.TIM2EN = 1;
TIM2_CR1.CEN = 0;
TIM2_PSC = 1124;
TIM2_ARR = 63999;
NVIC_IntEnable(IVT_INT_TIM2);
TIM2_DIER.UIE = 1;
TIM2_CR1.CEN = 1;
}
void Timer2_interrupt() iv IVT_INT_TIM2
{
TIM2_SR.UIF = 0;
timer_count_end = int_count;
int_count = 0;
sec_flag = true;
}
Code examples that demonstrate the usage of C Meter click with MikroElektronika hardware, written for mikroC for ARM is available on Libstock
(http://libstock.mikroe.com/projects/view/1879/c-meter-click).
Resources
Page 3 of 3
- C Meter click example on Libstock (http://libstock.mikroe.com/projects/view/1879/c-meter-click)
- NE-555 vendor's data sheet (http://www.ti.com/lit/ds/symlink/ne555.pdf)
- mikroBUS standard specifications (http://download.mikroe.com/documents/standards/mikrobus/mikrobus-standard-specification-v200.pdf)
Retrieved from "http://docs.mikroe.com/index.php?title=C_Meter_click&oldid=601"
◾ This page was last modified on 1 August 2016, at 17:04.
◾ Content is available under Creative Commons Attribution unless otherwise noted.
http://docs.mikroe.com/index.php?title=C_Meter_click&printable=yes
8/8/2016