MIKROE-2376

C Meter click
C Meter click
IC/Module NE-555 precision timer
(http://www.ti.com/lit/ds/symlink/ne555.pdf)
Interface INT, RST
Power
supply
5V (possible to use with 3.3V I/O)
Website www.mikroe.com/click/c-meter
(http://www.mikroe.com/click/c-meter)
Schematic also available in PDF (http://cdn-
docs.mikroe.com/images/d/dd/C_Meter_click_schem
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
C Meter click
From MikroElektonika Documentation
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
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.
Programming
This code snippet uses a preset calibration value and finds the capacitance of the capacitor for displaying on the TFT.
#include <stdint.h>
#include <stdbool.h>
#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 system_setup( void );
void setup_interrupt( void );
void InitTimer2( void );
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;
Page 1 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
1
00
1
01
1
02
1
03
1
04
1
05
1
06
1
07
1
08
1
09
1
10
1
11
1
12
1
13
1
14
1
15
1
16
1
17
1
18
1
19
1
20
1
21
1
22
1
23
1
24
1
25
1
26
1
27
1
28
1
29
1
30
1
31
1
32
1
33
1
34
1
35
1
36
1
37
1
38
1
39
1
40
1
41
1
42
1
43
1
44
1
45
1
46
1
47
1
48
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 ); //RST
GPIO_Digital_Input( &GPIOD_BASE, _GPIO_PINMASK_10 ); //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); //
Enable digital output on PORTD
GPIOE_ODR = 0xAAAA;
GPIO_Digital_Input(&GPIOD_BASE, _GPIO_PINMASK_10);
RCC_APB2ENR.AFIOEN =1; // Enable clock for alternate pin functions
AFIO_EXTICR3 = 0x0300; // PD10 as External interrupt
EXTI_FTSR = 0x00000400; // Set interrupt on Rising edge
EXTI_IMR |= 0x00000400; // Set mask
NVIC_IntEnable(IVT_INT_EXTI15_10); // Enable External interrupt
EnableInterrupts(); // 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 2 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.
Page 3 of 3
8
/
8
/
201
6
http://docs.mikroe.com/index.php?title=C_Meter_click&printable=yes

MIKROE-2376

Mfr. #:
Manufacturer:
Mikroe
Description:
Daughter Cards & OEM Boards C Meter click
Lifecycle:
New from this manufacturer.
Delivery:
DHL FedEx Ups TNT EMS
Payment:
T/T Paypal Visa MoneyGram Western Union

Products related to this Datasheet