Sunday, June 12, 2016

BLINKING A LED

Circuit diagram includes connecting a LED with resistor in series in PORTB5, its digital 13 on Aruino.

Blink LED method 1

#define F_CPU 16000000

#include <avr/io.h>
#include <util/delay.h>

int main(void)
{
   
DDRB |= (1 << PORTB5);
    while (1)
    {
PORTB |= (1 << PORTB5);
_delay_ms(200);
PORTB &= ~(1<< PORTB5);
_delay_ms(100);

    }
}

Thursday, July 23, 2015

TERMS EXPLAINED IN CLASS D AMPLIFIERS

Class D amplifiers are one most used and popular amplifier due to efficiency, theoretically class d amplifiers are 100 percent efficient. But this cannot be achieved practically as no device is 100 percent efficient. Though class d amplifiers reach more than 90% of efficiency if designed very carefully.
Understanding class d amplifiers are very much simple if you are familiar with the Switch mode power supply or commonly called SMPS or switching supply.
Input for the class d amplifier is first modulated either using Pulse Width Modulation ie PWM or sigma Delta modulates. Order of modulation starts generally from two and can reach as higher as 5 or even higher.
Class d amplifier can either be half bridged which requires dual power supply or full bridge and can be powers with single power supply. The problem with full bridge is that it requires more hardware or switching MOSFET which decrease its efficiency.
Another thing that make the class d amplifiers better is bridge tied load configuration or bridging multiple amplifiers so that its output power can be doubled. In bridge tied load configuration two half bridge amplifiers as bridged so that its output is doubled and the power for this configuration should be dual Power supply.
What is happening in class d amp is the modulated PWM is turning on and off the MOSFET bridge. during this MOSFETs ate switched on alternately. But if two of the MOSFETs on high side is turned on a pop sound can be created which may be very annoying. Also if there is delay between the next switching sequence the there might be dead sound between the sound.

Tuesday, May 26, 2015

BROKEN YOUR AVR CHIP?

While working the avr for the first time it is always confusing while programing the fuse bits as wrong configuration of this can damage the chip or may be lock the chip so you cannot program it normally.

If your making a bare bone arduino or burning arduino boot loader the fuse bits if programmed wrong can lock the device. This often happens due to some of the following fuse bits.
A. First thing you are being greedy of that single reset pin to use it as gpio. But you will be programming it only once as after that fuse setting to use reset as gpio avr can't be programmed using ISP as ISP programming requires external reset operations . so you need to do the high voltage programming either serial or parallel.
For the he high voltage programming you can consult the avr data sheet where it is described crystal clear and also there are many tutorials available online for this problem.




Also choosing external clock source can also result avr to not work using ISP in this case high voltage programming can be used or a external TTL clock should be used for the programming.

Heres the line copied from datasheet of high voltage programming. 

The following algorithm puts the device in Parallel (High-voltage) Programming mode:

1. Set Prog_enable pins listed in Table 28-12 on page 290 to “0000”, RESET pin to 0V and
VCC to 0V.

2. Apply 4.5V - 5.5V between VCC and GND.
Ensure that VCC reaches at least 1.8V within the next 20μs.

3. Wait 20μs - 60μs, and apply 11.5V - 12.5V to RESET.

4. Keep the Prog_enable pins unchanged for at least 10μs after the High-voltage has been
applied to ensure the Prog_enable Signature has been latched.

5. Wait at least 300μs before giving any parallel programming commands.

6. Exit Programming mode by power the device down or by bringing RESET pin to 0V.

If the rise time of the VCC is unable to fulfill the requirements listed above, the following alternative
algorithm can be used.

1. Set Prog_enable pins listed in Table 28-12 on page 290 to “0000”, RESET pin to 0V and
VCC to 0V.

2. Apply 4.5V - 5.5V between VCC and GND.

3. Monitor VCC, and as soon as VCC reaches 0.9V - 1.1V, apply 11.5V - 12.5V to RESET.

4. Keep the Prog_enable pins unchanged for at least 10μs after the High-voltage has been
applied to ensure the Prog_enable Signature has been latched.

5. Wait until VCC actually reaches 4.5V - 5.5V before giving any parallel programming
commands.

6. Exit Programming mode by power the device down or by bringing RESET pin to 0V.



Monday, May 25, 2015

PIC vs AVR #30 #2

This is the second part of the pic and avr. One of the benefit of the avr is programming.

For the programming or firmware development avr gives AVR studio which is a very good IDE and most important for beginner is it's free. AVR studio gives most of the libraries for their micro controllers and also for the different boards made by ATMEL. 

Also one of the most important benefit that you get from AVR's 8 bit controllers is arduino. Arduino is a open source project. You can visit www.arduino.cc for more informations. Its based on AVR and most popular is ATMEGA328. You can use almost any other microcontrollers. 

For the beginners who are not so into the hardware of microcontroller thing and also with the hardware or internal things of the controller. Arduino make programming so easy that any can interface any hardware to it.

PIC on the other hand also provide their own IDE, MPLAB X , it uses a separate compiler. The bad thing is its not free. There's also a free version which does all the job done for the beginner but what the free version is not giving us is maximum code optimization . Paid version of MPLAB  gives the maximum optimization which is more that 50 % of the code size of the free version. 

PIC also provide some of the libraries for its users , also MIKRO C gives some simple programming interface for the PIC which is the third party PIC IDE. 

These are some of the things to compare between the PIC and AVR. Further on its on you to choose between PIC or AVR. 

Saturday, May 23, 2015

PIC VS AVR MICROCONTROLLER #29 #1

For the starters it is always the question in mind whether to use PIC microcontroller or AVR microcontroller. PIC manufacutred by MICROCHIP and AVR by ATMEL is beginner level 8 bit micorcontrollers which every beginner use.

If your starting a project or starting to learn some more on controllers which to follow. I list out some of my points on both controllers their pros and cons.

Moving on to PIC ,  PIC's 8 bit series 16F and 18F are the most popular one. These PIC controllers are available in package like SSOP,SOIC,DIP,QFN,QFP. 

If your project is power sensitive PIC is the best. PIC's nanoWatt XLP series have very low power. They in even go to micro Ampere current range when in Deep Sleep. Though AVRs got the power control like sleep, stand by modes but PIC is better than AVR in this matter.

Other benefit that PICs got is PIC has more features in chip than AVR. They have more peripheral fetures and control than AVR . PICS got many standard like ECAN, more CCP and ECCP channels and controls more AD converter channels than AVR. 

Its not like AVR got no such feature AVR's also got the same feature but AVR's got less flexibility in these things. 

Thing in which AVR dominates PIC is in my case TIMERS, In AVR timers got more controls than in PIC. Handling timers in AVR is always easy than PIC.

In term of cost both are same , but some PICs are cheaper in compared to AVR. 


Friday, November 28, 2014

CHOOSING AND DRIVING A MOSFET #1 #28

MOSFETS are some what confusing than the Bipolar Juntion Transistors BJT or simply transistors. MOSFETS (Metal Oxide Semiconductor Field Effect Transistors) are voltage controlled current source (VCCS) while BJT are current controlled current source. One of the well known relation for the transistor is Ic = B Ib. Where  B is beta or Hfe current gain of the transistor and is usually >10 for high power transistors and >100 for small signal transistors. 
So controlling the current flowing in the Base of the transistor one can control the output current flowing from the collector to emitter or from emiter  to collector in case of NPN and PNP transistors. 
High power transistors require more silicon space in comapre to the same space with the MOSFETS.



In case of Mosfets, they are of N channel and of P channel. Both have its own advantages and dis advantages. But the common of the Mosfets are that both the Mosfets only start conduction when the voltage in its GATE terminal exceeds some voltage level than that of the voltage level in source, which is called Vgs = Vth = Gate threshold voltage. Understanding this voltage level is very important for the design withe Mosfets. Vgs voltage from gate to source is position in the case of the N channel but for the P channel its in negative. But it is still easy to drive the gate of the Mosfets.



N channel have some advantages as they have electrons as their carrier and they have more mobility so the N channel mosfets have very low ON resistance called Rds than the P channel mosfet with same size of die or silicon and this reason need of more silicon space also make P channel mosfet more expensive. 

Wednesday, November 5, 2014

SVN VERSION CONTROL IN ALTIUM #27

Version control in makes any project very easy to manage and work with different versions of the same projects and makes modifications and make easy management of all the versions and storing of all the versions.
In Altium, it has got its own version control and also SVN external version control.

THIS TUTORIAL IS ONLY FOR THE VERSION CONTROL OF THE PROJECTS IN LOCAL COMPUTER ONLY.

Step 1: Make new PCB project.




Step 2: Then go to preferences of ALTIUM  and navigate to Data Management and Version Control
and check the User external Suberversion Radio button and check on SVN-Suberversion check box. Or click on Auto Detect.


Step 3: Now click on Design Repositories and click on Create New and Click on SVN.


Step 4: Name Repository some name like "MyRepo" and in location choose the folder where you work. Mine is "altiumrepo". Then Hit OK.
The status will be green if everythings OK.


Step 5: Now on project right click and choose version control and add project to version control.


Step 6: Choose the Repo and Hit OK.



Now we can comit the project or inidivual file from the same menu by right clicking it . For check out go to storage manager and right click and click on revert on specified file or project.