Loading...
Showing posts with label PIC. Show all posts
Showing posts with label PIC. Show all posts

Sunday, November 1, 2020

AN7223 LM7001 PLL FM Stereo Tuner, JQ8400 USB MP3, Bluetooth Audio Player - 16F690

FM USB MP3 Player
Audio Player

This is my new project, 3 in 1 audio player that design for my amplifier. It built in FM radio, USB player and Bluetooth module. Also include a simple mixer with op-amp.

Bottom PCB
Bottom PCB

Top PCB
Top PCB

Side View
Side View

For tuner section I used AN7223 and TA7343 and for PLL here I used LM7001 low cost IC. JQ8400 used for USB function and it controlled by a PIC16F690 microcontroller. U can use any Bluetooth audio module for this. I used MH-M18 Bluetooth module for this.

JQ8400 Module
JQ8400 Module

Bluetooth Module
Bluetooth Module


Please read my previous post for detailed information about PLL FM tuner and jq8400. I wrote a small sample program for control this unit and u can modify it according to your need. Don’t use relay. Just connect I2C directly to R37 & R39.

Control Circuit
Control Circuit

Usage of usb command

// --------- commands ----------------- Write_Df(0x06,0,0); // mp3 next Write_Df(0x05,0,0); // mp3 prev Write_Df(0x02,0,0); // mp3 play Write_Df(0x03,0,0); // mp3 pause Write_Df(0x04,0,0); // mp3 stop Write_Df(0x21,0,0); // mp3 random Write_Df(0xA3,0,5); // mp3 ff 5s Write_Df(0xA2,0,5); // mp3 fr 5s write_Df(0x87,Cur_Tr>>8,Cur_Tr); // mp3 track play (max 9999)

Mikro c source code for Control circuit, source code for PLL FM, Hex file for jq8400 controller and PCB file and circuit are in download section. Hope you like it.


Thursday, August 6, 2020

JQ8400 MP3 Voice Module Microe C code

Previously I wrote a post about well-known voice module of DFPlayer Mini. Today I would like to write a post of advance chip, JQ8400. The main advantages of this chip are;
  • Inquiry of the file name
  • Inquiry of duration of the current audio
  • Inquiry of playback duration
  • Fast backward
  • Fast forward, etc.
jq8400 module
Jq8400 Module

JQ8400 module is a SOC solution that combines a 16bit MCU with an ADSP specialized in audio decoding. By using hardware decoding method, it ensures system stability, quality of sound, and small footprint matching requirements of embedded applications. For the flexibility of R&D, control commands can be sent via one-line mode or RS232 serial communication.
It adopts full duplex serial communication protocol: Baud rate 9600, 8-bit data, no parity and 1 stop bit.

Message Format

Starting Code + Command Code + Data Length + Data 1 – Data n + Checksum
  • Starting Code: fixed as “AA” (in hex)
  • Command Code: 01 – 26 (in hex)
  • Data Length: respective data bytes in commands; length=1 stands for command only, no data.
  • Checksum: The low byte of the sum of all the bytes before the checksum byte.
  • Data format: high 8-bit first, low 8-bit second.

Communication Mechanism

Default power-on state is idle and listening for commands from MCU as a guest The module will not initiate communication and a MCU must take initiative. The TTL level of the serial port is 3.3V. Use a 1K ohm resistor if connecting with a 5V MCU.

jq8400 module pin
Jq8400 Module Pin Details

Code

unsigned short df_wr[] = {0xAA,0,0,0,0,0};
void write_jq_cmd(char cmd, char data_h, char data_l, char len) //jq cmd data {   char m;
  Delay_ms(200);
       df_wr[1]= cmd;
       df_wr[2]= len;
       df_wr[3]= data_h;
       df_wr[4]= data_l;
       df_wr[5]= data_h + data_l + len + df_wr[1] + 0xAA;

    for (m=0; m<6; m++) {      Delay_ms(1);      if(len==0 && m==3) m=5; //(AA 02 00 AC) skip data_h data_l      if(len==1 && m==3) m=4; //(AA 18 01 03 C6) skip data_h      UART1_Write(df_wr[m]);  //aa, cmd, len, dh, dl, sm    }    Delay_ms(10); }

Usage

write_jq_cmd(0x02, 0,0, 0);      //Play write_jq_cmd(0x03, 0,0, 0);      //Pause write_jq_cmd(0x13, 0,27, 1);     //Set volume to 27 write_jq_cmd(0x07, 0x00,0xF4, 2); //Play 244th track write_jq_cmd(0x07, 0x01,0xF4, 2); //Play 500th track write_jq_cmd(0x23, 0x00,0x0A, 2); //FF 10 seconds


Tuesday, May 5, 2020

OProg - Open Source USB Programmer - 18F2550

Recently I found a programmer from internet. This programmer is completely free and open source. It used few components and working well. I make some changes to it. You can find the original one from here.

OPROG Prototype
Prototype

Advantages of this programmer are;
  • Completely free and Open Source (including firmware)
  • Programs PIC, dsPIC, ATMEL, EEPROM (I2C, SPI, MicroWire, OneWire, UNIO)
  • Can work as ICD debugger
  • USB 2.0 Full Speed interface
  • Self-powered
  • Doesn't need drivers
  • Hardware generated timings for maximum speed and reliability (writes an 18F2550 in 15s)
  • Open source control programs for Linux and Windows

OPROG diagram
Schematic

Main controller is PIC18F2550, and Supply directly get from PC USB port. HEX, PCB, Schematic and PC software can download from below. And for latest updates and full description please follow the Open Programmer site.


Sunday, April 19, 2020

7 Band Real Time Audio Spectrum Analyzer Circuit - 16F819 BA3834S

16F819 Audio Spectrum Analyzer
16F819 Audio Spectrum Analyzer

This is the new version of my previous spectrum analyzer. Used PIC16F819 microcontroller and BA3834 Band-pass filter for spectrum analyzer. It has two versions, BA3834S and BA3834F. Here i used BA3834S. BA3834 are 7-band, band-pass filter ICs that use microprocessor time division to produce serial output for spectrum analyzer displays. To minimize the number of attached components required and enable compact and reliable designs, all of the capacitors for the filters are on the chip. So we can build spectrum analyzer easily

16f819 analizer circuit
Analizer circuit

This circuit included 11 modes (9 patterns, off and random) and it shows which pattern currently running at start-up (S1, S2, etc.). In off mode it shows S0 on display and S+ for random mode. The pattern mode saved to Eeprom to run at next power up. In random mode it changes its pattern in every 3.5 minutes.
PCB, Circuit, and hex available in below

16f819 analizer
16f819 analizer pcb
16f819 analizer pcb


Saturday, February 2, 2019

Uart Controlled DF Player Mikroc Code - 16F628A

  The DFPlayer Mini MP3 Player is a small and low cost MP3 module with an simplified output directly to the speaker. The module can be used as a stand alone module with attached battery, speaker and push buttons or used in combination with a PIC, Arduino or any other with RX/TX capabilities. For this project, I would control the MP3 Player module with a microcontroller and RS232.
DF Player
DF Player

  The DF Player module has all the features which a MP3 player should have. Including advance equalizers, looping and shuffling functions. But here I will show you how to build a simple player with Play/Pause, Next/Preview and vol Up/Down functions. Later you can add more features.

DF Player Pin
DF Player Pin

Specifications:

  • Supported sampling rates (kHz): 8/11.025/12/16/22.05/24/32/44.1/48
  • 24 -bit DAC output, support for dynamic range 90dB , SNR support 85dB
  • Fully supports FAT16 , FAT32 file system, maximum support 32G of the TF card, support 32G of U disk, 64M bytes NORFLASH
  • A variety of control modes, I/O control mode, serial mode, AD button control mode
  • Audio data sorted by folder, supports up to 100 folders, every folder can hold up to 255 songs
  • 30 level adjustable volume
  • 6 -level EQ adjustable
Stand-alone Circuit
Stand-alone Circuit

Circuit:

DF Palyer Circuit
DF Palyer Circuit

In this circuit I used PIC16F628A and its configure to run using its internal oscillator. For sending commands to the PIC i used uart terminal that built in with Mikroc and u need a TTL converter module fo that. Rx pin of df player connected to the PIC's Tx and Rx pin of PIC connected to the TTL converter's Tx.
Rx pin of TTL converter connected to the df player's Tx (optional)

Uart TTL Module
Uart TTL Module
USB TTL Module
USB TTL Module

Connect circuit as above and plug usb or TF card.Then open uart terminal and enter commands as below..
r - Play, s - Pause, n - Next, p - Previous, u - Vol+, d - Vol-.

df palyer connection
Df palyer connection

Circuit in dot board
Circuit in dot board

Code:

This code was written by using mikroC PRO for PIC v6.

/**************************************************************************

DF Player
Copyright (C) 2019 Scorpionz

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.

>> Email: scorpionzblog@gmail.com
>> Blog : scopionz.blogspot.com

***************************************************************************/

char df_rd[10], dump, j, u_data;

void Write_Df_Data(char cmd, char data_H, char data_L) //------- df data ----
{
  char m = 0;
  char df_wr[] = {0x7E,0xFF,0x06,0,0,0,0,0xEF};
       df_wr[3]= cmd;
       df_wr[5]= data_H;
       df_wr[6]= data_L;

   Delay_ms(100);
   for (m=0; m<8; m++) UART1_Write(df_wr[m]);
   Delay_ms(300);
}


void interrupt() {   //-------- interrupt --------------------------------------

 if (PIR1.RCIF) {    //------- Usart interrupt ----------
      PIE1.RCIE = 0;
      u_data = UART1_Read();

    if(u_data==0x7E)  {    // check first byte 0x7E
      for (j=1; j<10; j++) { // read next 9 bytes 0xFF, 0x06, 0x03, 0x00, 0x00, 0x01, 0xFE, 0xF7, 0xEF
No:
        if(UART1_Data_Ready()) {    // Check, is data Ready..?
           df_rd[j] = UART1_Read();
           }
          else goto No;
        }
       
        delay_ms(50);
        if(UART1_Data_Ready()) dump = UART1_Read(); //remove duplicate data
      
        if(df_rd[9]==0xEF) { //check last byte 0xEF
         delay_ms(100);
         if(df_rd[3]==0x3C) Write_Df_Data(0x01,0,0); //play next song
         for (j=0; j<10; j++) df_rd[j]=0;            //clear read buffer
        }
      }
     
     else { //------ keyboard commands -------------
            if(u_data=='n') Write_Df_Data(0x01,0,0); //next
            if(u_data=='p') Write_Df_Data(0x02,0,0); //prev
            if(u_data=='u') Write_Df_Data(0x04,0,0); //vol+
            if(u_data=='d') Write_Df_Data(0x05,0,0); //vol-
            if(u_data=='r') Write_Df_Data(0x0D,0,0); //resume
            if(u_data=='s') Write_Df_Data(0x0E,0,0); //stop
           }
    PIE1.RCIE =1;
    PIR1.RCIF =0;
  }
}


void main()
{
 PCON.OSCF = 1;   //4MHz Internal OSC
 CMCON  |= 0x07;  //Disable Comparators

 INTCON.GIE=1;
 INTCON.PEIE=1;
 PIE1.RCIE=1;

 TRISA = 0x00;
 TRISB = 0xFE;  //Tx Rx
 PORTA = 0;
 PORTB = 0;

 Delay_Ms(3000);   // Df initialization 1.5 ~ 3Sec
 UART1_Init(9600);
}


Wednesday, January 2, 2019

Rotary Encoder Decoder Circuit - PIC12F683 Microcontroller

   Recently I need a rotary encoder circuit for my amplifier. So I searched the internet and test some circuits and codings I found. But nothing work for me. Some are worked but not accurate. So i decided to build my own.

What Is Rotary Encoder

Typical Rotary Encoder
Typical Rotary Encoder
   A rotary encoder is a special type of switch that converts the motion of the switch (clockwise or counterclockwise) into an output signal that can be used to determine what direction the knob is being rotated. There are many different types of rotary encoders which use different technologies and construction materials, however, today we’ll be looking specifically at quadrature rotary encoders which are the most common for general electronics. They're used in many applications such as the manual volume control or tuning on a car stereo.

   A quadrature rotary encoder is similar to a potentiometer, however, a rotary encoder doesn’t have limiting points in the rotation; it will rotate infinitely in either direction. Quadrature rotary encoders don’t output an absolute, fixed position, but rather have a number of increments per 360 degrees, and each increment consists of digital pulses known as ‘grey code’. Most encoders have detents which give tactile feedback every time they increment, however, you can also get smooth encoders without detents, usually with a higher number of steps per rotation.

How do They Work?

Quadrature Output Table
Quadrature Output Table
   It has three pins: A, C, and B. C is the common ground for A and B. A and B are the signal pins. When you rotate the knob, A and B come into contact with the common ground pin, in a particular order depending on the direction you are rotating the knob. When each pin comes into contact with the common ground, they produce a signal. These signals are shifted out of phase with each other as one pin connects before the other pin. This is called quadrature encoding. You need to listen to those pins and the way they pulse in order to determine the direction and number of steps.

The Circuit

   In my circuit I used PIC12F683 microcontroller. It configured to run using its internal oscillater at 8Mhz and internal pull up enable for GP1. And used few components. 0.47uf capacitor used to avoid noices making by rotary encoder. GP0 indicate rotation and GP4 and 5 indicate direction.

Rotary Encoder Circuit
Rotary Encoder Circuit

The Coding

   The code was written by using Mikroc Pro for pic.

/**************************************************************************

Rotary Encoder
Copyright (C) 2019 Scorpionz

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.

>> Email: scorpionzblog@gmail.com
>> Blog : scopionz.blogspot.com

***************************************************************************/

#define SW       GPIO.F1

void Interrupt()
{

INTCON.GIE = 0;   //Disable Global Interupt
  if(INTCON.INTF)  //RB0/INT External Interrupt Flag bit is set
    {
     if(SW) GPIO.F4=1;
     else   GPIO.F5=1;
     GPIO.F0=1;
     delay_ms(100);
     GPIO   = 0;
    }
INTCON.INTF = 0; //Clear RB0/INT External Interrupt Flag bit
INTCON.GIE = 1;  //Enable Global Interrupt
}

void main()
{
OSCCON = 0x75;
ADCON0 = 0x00;
CMCON0 = 0x07; // Disable Comparators
CMCON1 = 0x00;
ANSEL  = 0x00;

INTCON.GIE = 1; // Global Interrupt Enable
INTCON.INTE = 1; // RB0/INT External Interrupt Enable bit
OPTION_REG = 0b00111111; // wpu & int fall

TRISIO = 0b00000110;
WPU = 0b00000010;
GPIO   = 0b00000001;
delay_ms(500);
GPIO   = 0;
}

Saturday, November 4, 2017

DS3231 RTC Clock mikro C Demo Code - 16F648A


LCD Clock
LCD Clock

Introduction:

The DS323x is a low-cost, extremely accurate I²C real-time clock (RTC) with an integrated temperature-compensated crystal oscillator (TCXO) and crystal. The device incorporates a battery input, and maintains accurate timekeeping when main power to the device is interrupted. The integration of the crystal resonator enhances the long-term accuracy of the device as well as reduces the piece-part count in a manufacturing line. The DS323x is available in commercial and industrial temperature ranges, and is offered in a 16-pin, 300-mil SO package.

DS3231 Block Diagram
DS3231 Block Diagram
The RTC maintains seconds, minutes, hours, day, date, month, and year information. The date at the end of the month is automatically adjusted for months with fewer than 31 days, including corrections for leap year. The clock operates in either the 24-hour or 12-hour format with an active-low AM/PM indicator. Two programmable time-of-day alarms and a programmable square-wave output are provided. Address and data are transferred serially through an I²C bidirectional bus.

Most RTCs use an external 32kHz timing crystal that is used to keep time with low current draw. And that’s all well and good, but those crystals have slight drift, particularly when the temperature changes (the temperature changes the oscillation frequency very very very slightly but it does add up!) This RTC is in a beefy package because the crystal is inside the chip! And right next to the integrated crystal is a temperature sensor. That sensor compensates for the frequency changes by adding or removing clock ticks so that the timekeeping stays on schedule.

DS3231 module
DS3231 module

This is the finest RTC you can get, and now it in a compact, breadboard-friendly breakout. With a coin cell plugged into the back, you can get years of precision timekeeping, even when main power is lost. Great for data-logging and clocks, or anything where you need to really know the time.

The Circuit:

The circuit is very simple. It used PIC16F648A Pic micro, 16x2 LCD and DS3231 RTC module. The PIC used it's internal oscillator and run at 4MHz. Proteus and Hex file can download from the bottom of the page.

DS323x RTC Clock Circuit
DS323x RTC Clock Circuit


MikroC PRO Source Code:

/**************************************************************************

DS323x RTC Clock Demo
Copyright (C) 2017 Scorpionz

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.

>> Email: scorpionzblog@gmail.com
>> Blog : scopionz.blogspot.com

***************************************************************************/


// Software I2C connections
sbit Soft_I2C_Scl at RB2_bit;
sbit Soft_I2C_Sda at RB1_bit;
sbit Soft_I2C_Scl_Direction at TRISB2_bit;
sbit Soft_I2C_Sda_Direction at TRISB1_bit;
// End Software I2C connections

// LCD module connections
sbit LCD_RS at RB0_bit;
sbit LCD_EN at RB3_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;

sbit LCD_RS_Direction at TRISB0_bit;
sbit LCD_EN_Direction at TRISB3_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
// End LCD module connections

char seconds, minutes, hours, day, date, month, year, tem_l, tem_h; // Global variables

//--------------------- Reads time and date information from RTC (DS3231)
void Read_Time()
{
Soft_I2C_Start(); // Issue start signal
Soft_I2C_Write(0xD0); // Address DS3231, see DS3231 datasheet
Soft_I2C_Write(0); // Start from address 0
Soft_I2C_Start(); // Issue repeated start signal
Soft_I2C_Write(0xD1); // Address DS3231 for reading R/W=1

seconds = Bcd2Dec(Soft_I2C_Read(1)); // Read seconds byte
minutes = Bcd2Dec(Soft_I2C_Read(1)); // Read minutes byte
hours = Bcd2Dec(Soft_I2C_Read(1)); // Read hours byte
day = Bcd2Dec(Soft_I2C_Read(1)); // Read day byte
date = Bcd2Dec(Soft_I2C_Read(1)); // Read date byte
month = Bcd2Dec(Soft_I2C_Read(1)); // Read month byte
year = Bcd2Dec(Soft_I2C_Read(1)); // Read year byte

Bcd2Dec(Soft_I2C_Read(1)); // Alarm
Bcd2Dec(Soft_I2C_Read(1));
Bcd2Dec(Soft_I2C_Read(1));
Bcd2Dec(Soft_I2C_Read(1));
Bcd2Dec(Soft_I2C_Read(1));
Bcd2Dec(Soft_I2C_Read(1));
Bcd2Dec(Soft_I2C_Read(1));

Bcd2Dec(Soft_I2C_Read(1)); // Data
Bcd2Dec(Soft_I2C_Read(1));

Bcd2Dec(Soft_I2C_Read(1));

tem_h = Bcd2Dec(Soft_I2C_Read(1)); // Temp
tem_l = Bcd2Dec(Soft_I2C_Read(0));

Soft_I2C_Stop(); // Issue stop signal
}

void write_data(char address, char w_data)
{
Soft_I2C_Start(); // issue I2C start signal
Soft_I2C_Write(0xD0); // send byte via I2C (device address + W)
Soft_I2C_Write(address); // send byte (address of DS3231 location)
Soft_I2C_Write(w_data); // send data (data to be written)
Soft_I2C_Stop(); // issue I2C stop signal
delay_ms(50);
}

//-------------------- Output values to LCD
void Display_Time()
{
Lcd_Chr(2, 7, (hours / 10) + 48);
Lcd_Chr(2, 8, (hours % 10) + 48);
Lcd_Chr(2,10, (minutes / 10) + 48);
Lcd_Chr(2,11, (minutes % 10) + 48);
Lcd_Chr(2,13, (seconds / 10) + 48);
Lcd_Chr(2,14, (seconds % 10) + 48);

Lcd_Chr(2,16, (day % 10) + 48); // day
}

void Display_Date()
{
Lcd_Out(1,1,"Date: "); // Prepare and output static text on LCD
Lcd_Chr(1,9,'-');
Lcd_Chr(1,12,'-');
Lcd_Out(1,13,"20"); // start from year 2000

Lcd_Chr(1, 7, (date / 10) + 48);
Lcd_Chr(1, 8, (date % 10) + 48);
Lcd_Chr(1,10, (month / 10) + 48);
Lcd_Chr(1,11, (month % 10) + 48);
Lcd_Chr(1,15, (year / 10) + 48);
Lcd_Chr(1,16, (year % 10) + 48);
}
void Display_Temp()
{
Lcd_Out(1, 1,"Temp: +");
Lcd_Out(1,13,"ßC ");
Lcd_Chr(1,10,'.');

tem_l=tem_l*25;

Lcd_Chr(1, 8, ((tem_h & 127) / 10) + 48);
Lcd_Chr(1, 9, ((tem_h & 127) % 10) + 48);
Lcd_Chr(1, 11, (tem_l / 10) + 48);
Lcd_Chr(1, 12, (tem_l % 10) + 48);

if(tem_h & 128) Lcd_Chr(1, 7, '-');
}

//------------------ Performs project
void Init_Main()
{
PCON.OSCF = 1; //4MHz
CMCON |= 0x07; // Disable Comparators CMCON |= 7;
OPTION_REG = 0;

Soft_I2C_Init(); // Initialize Soft I2C communication
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear LCD display
Lcd_Cmd(_LCD_CURSOR_OFF); // Turn cursor off

Lcd_Out(1,3,".:Scorpionz:.");
Delay_ms(500);
Lcd_Out(2,1,"Ds3231 RTC Clock");
Delay_ms(1500);
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(2,1,"Time: ");
Lcd_Chr(2,9,':');
Lcd_Chr(2,12,':');

write_data(14,0x40); //SQWE output at 1 Hz
}

//----------------- Main procedure
void main() {
Delay_ms(500);

Init_Main(); // Perform initialization

while (1) { // Endless loop
Read_Time(); // Read time from RTC(DS3231)
Display_Time(); // Prepare and display on LCD
Display_Date(); Delay_ms(450);
Display_Temp();
Delay_ms(450);
}
}

Saturday, December 26, 2015

Multi Stage Simple Programmable Timer Circuit - 16F628A

255 Stages Simple Programmable Timer Circuit

Electronic delay timers are devices which are able to count and produce different time delay intervals as per the external settings. The elapsing of the set time is mostly indicated through an audible alarm to alert the user. Timers play an important role in our everyday life, whether it’s your cell phone, wall clock, TV/DVD sets, computers they are present everywhere.

Usually an ordinary electronic timer is able to produce single-shot delay intervals and setting up its initializing point becomes inaccessible. The present simple programmable timer circuit design eliminates this drawback.

Simple Programmable Timer Circuit - 16F628
Simple Programmable Timer Circuit

This is a one of the simple circuit of programmable timer circuit. The time range of this timer is 1 second to 255 hours. The delay time can be change by dip switches. The whole circuit of programmable timer is build using cheap PIC16F628A microcontroller and few passive components.

Circuit Operation

After power applied, the START led will turn on and you need to configure the delay time, timer mode and repeat mode. The delay time of this circuit can change by using dip switches. Those dip switches are represent 8-bit binary number and that number use to set delay time. When the delay time over, RLY ON led will turn on.

Eg:
If you need to set delay time to 150 then, dip switch configuration is 10010110 (RB0-RB7).
1 = Off and 0 = On

When you pressed the START button, START led will begin to blink and you can observe timer status by that.

Time Mode

This circuit can operate in 3 different time modes (Seconds, Minutes and Hours). Those modes can select from MODE buttons.

  1. If both PORTA.F6 and PORTA.F7 are low or high, then circuit is running in seconds’ mode (0 – 255 seconds)
  2. If PORTA.F6 high and PORTA.F7 low, then the circuit is running in minutes’ mode (0 – 255 minutes)
  3. If PORTA.F6 low and PORTA.F7 high, then the circuit is running in hours’ mode (0 – 255 hour)

Repeat Mode

If PORTA.F1 is low then repeat mode will turn on. The circuit running continuously and RLY ON led will turn on and off repeatedly.

To control heavy load, remove RLY ON led and connect 5v relay through NPN transistor. Then connect you device across the relay. Supply voltage for this circuit is 5v and use voltage regulator ic such as LM7805, if you use voltage above that.

Thursday, November 26, 2015

Simple and Accurate LC Meter Circuit - 16F690

Simple and Accurate LC Meter - 16F690
Digital LC Meter

A LCR meter [Inductance (L), Capacitance (C), and Resistance (R)] is a piece of electronic test equipment used to measure the inductance, capacitance and, resistance of a component. Inductance is the property of an electrical circuit causing voltage to be generated proportional to the rate of change in current in a circuit. In Electronics, capacitance is the ability of a body to hold an electrical charge. Capacitance is also a measure of the amount of electrical energy stored (or separated) for a given electric potential. The electrical resistance of an electrical element measures its opposition to the passage of an electric current. The meter reads L, C and R directly with no human calculation required.

Recently I found this LC meter project on internet and I was looking for that kind of project. Therefore, I build. Amazing it is work! Also the accuracy of this LC meter is great and it is very easy to build. So that, I post it here, because I think it is useful to you. You can visit original post from using this link: LMC3

The data below were determined based on theoretical calculations, the scale and the display automatically change.

Min Max Resolution Accuracy
Non Polar Condenser 1pF 1nF 0.1pF 1%

1nF 100nF 1pF  1%

100nF 1uF  1nF 2.5%
Electrolytic Capacitor 100nF 100,000uF 1nF 5%
Inductor 10nH 20H 10nH 5%
Resistance 1mΩ 0.5Ω 1mΩ 5% 
Inductance 0.5Ω 30Ω 10mΩ 10%
Specifications of the LC Meter


Simple and Accurate LC Meter Circuit
LC Meter Diagram


LC Switch:
The purpose of this is, switch between inductance and capacitance mode. When you turn on the LC meter, you should set it to C mode.

Calibration Switch:
You can calibrate LC meter by pressing this. See Calibration for more details.

LC Meter Calibration

You have 3 modes to calibrate. When the process is completed, calibrated values are saving to the microcontroller’s internal EEPROM, so of course they are available after the re-start.

C Calibration
  1. Switch on
  2. Switch L/C switch to C position
  3. Leave the test probes freely. Do not even touch it
  4. Press and hold the CALIB button until the message Switch to meas. Then release the button
  5. Wait for the appearance of 0.00 pF
L Calibration
  1. Switch on
  2. Switch to the L position
  3. Connect L/C probe and GND probe together
  4. Press and hold the CALIB button until the message Switch to meas. Then release the button
  5. Wait for the appearance of 0.00 uH
ESR Calibration
  1. Switch on
  2. Switch to the C position
  3. Connect LE probe and GND probe together
  4. Press and hold the CALIB button until the message Switch to meas. Then release the button
  5. Note the value shown on the screen
Calibration Values
  • F0 = 499.9k
  • Fcal = 355.9k
  • Re = 180Ω
  • Uesr0 = 58.3mV
  • Fesr = 83.6k
  • Rx = 0mΩ [-5mΩ to 5mΩ]

Critical Components

All the below resistors are 1%.
(In my circuit, I used normal resistors and those are measured using digital multimeter)

  • 47Ω - R11
  • 47kΩ - R8
  • 100kΩ - R3-R5
  • 1nF - C8, C11 (Polypropylene or Polyester)
  • 33nF - C10 (Polypropylene 275V AC)
  • 10uF - C7, C9 (Tantalum)
  • 100uH - L1 (Low-loss DC resistance of 0.3-0.4Ω)

Testing


Simple and Accurate LC Meter Circuit - 16F690 test c
check 22pF ceramic capacitor

Simple and Accurate LC Meter Circuit - 16F690 test e
check 100uF electrolytic capacitor

Simple and Accurate LC Meter Circuit - 16F690 test l
check 100uH inductor

I was unable to find a reed relay, so I put 5v ordinary relay temporarily. In addition, my PCB designed for the TL2285 switches. But, I bought TL2230 by mistake :)

If the back-light brightness is low, you can increase back-light brightness by decreasing the value of the resistor R2 to 470Ω - 1k. You can change display contrast by adjusting 10k preset.
For PCB, Schematic and hex file, click download button.

You need to discharge capacitors properly before measuring.

Monday, November 23, 2015

MikroC Programming Guide

PIC Microcontrollers - Programming in C
Microcontroller Programmer

The purpose of this post is to provide basic information that one needs to know in order to be able to use microcontrollers successfully in practice. This post, therefore, doesn’t contain any super interesting program or device schematic with amazing solutions. Instead, the following examples are better proof that program writing is neither a privilege nor a talent issue, but the ability of simply putting puzzle pieces together using directives. Rest assured that design and development of devices mainly consists of the ‘test-correct-repeat’ work. Of course, the more you are in it, the more complicated it gets since the puzzle pieces are put together by both children and first-class architects.

Copyright © 1998–2012. MikroElektronika. All rights reserved. All trade and/or services marks mentioned are the property of their respective owners.

4.0 TABLE OF CONTENTS

Wednesday, November 18, 2015

Programmable Digital Seven Segment Timer Circuit - 16F628

Programmable Digital Timer Circuit
Seven Segment Timer


A timer is a specialized type of clock for measuring time intervals. By function, timers can be categorized to two main types. Those are Counts upwards and counts downward.

Timers originally designed to fulfill a need in industry for a means of keeping time on certain devices. Originally, these timers were mechanical devices and used clockwork mechanisms as a means of keeping a regular time. The invention of two electromechanical timer designs allowed for more precise time measurement. The first uses the principle of heat expansion to increase the temperature of a metal finger made of two different metals with differing rates of thermal expansion. As electric current flows through the metal, it begins to heat and one side expands more quickly than the other does, which in turn, moves the electrical contact away from an electrical switch contact. The second uses a small AC motor, which turns at a predetermined rate due to the application of an alternating current.

Finally, digital timers invented. Digital logic circuits are now so cheap that it has become a better investment to buy a digital timer than a mechanical or electromechanical timer. Individual timers implemented with single chip circuits.

This is a very simple adjustable digital timer circuit based on the PIC16F628A microcontroller and it can be programmed to schedule the on and off operation of an electrical appliance. This timer consists of three parts: power supply, control circuit and display. Working voltage of the circuit is 5v - 12v. It depends on the relay voltage. If you use 5v relay then you can omitted the LM7805 regulator IC and apply 5v directly. Otherwise, you have to use regulator IC and apply suitable voltage according to the relay voltage. The schematic is very simple and accurate of the circuit is very good. PIC use its internal oscillator.

Programmable Digital SSD Timer Circuit - PIC16F628A
Programmable Digital Timer Schematic


There are two versions of hex file are available. Those are "4dg_tmr_min.hex" and "4dg_tmr_hr.hex". The first file for the minute timer. It display minutes and seconds. Adjustable time is 1 second to 60 minutes. Other hex file for hourly timer and its adjustable time is 1 minute to 24 hours. This will display hours and minutes on the seven segments.

Configuration

If the time runs too fast or too slow, you can able to adjust the speed by changing the value of Eeprom address 0. Default value is 44 (0x2c). Typical value is 59 (0x3B). Maximum is 255 (0xFF). In repeat mode delay time before restart the timer, determine by value of Eeprom address 3. Default value is 10 (0x0A). Maximum is 255 (0xFF). See below picture for more details.

Programmable Digital Timer Circuit configuration
Eeprom Configuration

Operation of the timer

This circuit uses 5 push buttons to control the their functions.
  • START/PAUSE: When the timer is on, the device is in pause condition even the switch was in closed position. Pressing this button, you can switch between the start and pause timer.
  • FOR/BACKWARD: This allows you to select counter mode. Either upwards or count down.
  • REPEAT: When the timer reaches 00:00, it starts again from previous value you set.
  • LEFT/RIGHT: This allows you to change values on display. The selected digit is incremented by pressing those buttons and values on the display are stored to the Eeprom.

Now connect device you want to operate, through the relay. Set the desired time using left and right buttons and press start. When the timer reaches 00:00, relay will activate.

 

on line

Labels

Recent comment

Visitors

Free counters!
Copyright © 2012 - Scorpionz™.,All rights reserved | Powered by Blogger