Tuesday, August 17, 2010

Creating Minimum System Atmega8535

 What is the minimum system?

 The minimum system is a series of at least where the microcontroller chip can work. Atmega8535 microcontroller has dilengapi with internal oscillator, so no crystal or resonator is required external to the CPU clock source. However, this oscillator maximum 8Mhz so I suggest to keep using an external crystal.Internal oscillator by the manufacturer gives a chance 1 MHz, and to change it we need to change the settings of Fuse bits, for setting fuse bits need to be careful, because this setting is so vulnerable because if the wrong setting microcontroller can cause damage, I had corrupted a microcontroller.

Minimum System AVR is very simple where only connect AVCC to VCC and +5 V and GND and AGND to the ground and reset pin is not connected to anything . Chip will be reset if the voltage is zero or RST pins are forced to zero. This is the minimum system without using a crystal. For those who wear the above plus a series of crystal-crystal on pins XTAL1 and XTAL2.The following minimum system which uses a crystal (I recommend making the use of crystals)
Combination the above are the minimum system used to control the LEDs.The above circuit can use the live trace deeptrace, eagle, proteus, or other programs that you mastered. For those who are lazy to download the trace made by me, which I pake softrware deeptrace 2009, please download here
downloadernya can use a downloader that my previous post
 
 display the following minimum system in deeptrace
 For the prgram and the way I described in my program filling the next posting.

from  http://etekno.blogspot.com/2010/06/proyek-1-membuat-sistem-minimum.html

PWM Configuration for PIC16F877 microntroller

PWM can be used to control a motor driver or generate sound samples.


The register specifically used to configure PWM are the TRISC, PR2, CCP1CON, CCP2CON, CCPR1L, CCPR2L and T2CON registers. There are two PWM channels on the PIC16F877. These modules are coined CCP1 et CCP2. These modules are implemented on pins 16 and 17 of the PIC16F877. There are two ways to connect these pins to a L293D H-Bridge. I recommend to connect these to the L293D Chip Enable pins. PWM then controls the percentage of time the chip is enabled.

There are two parameters that affect the behavior of the PWM. The first one is the frequency of the pulses, the second is the length of these pulses. The length of the pulse is also called the duty cycle, e.g. the percentage of time the motor is enabled. In an ideal environment, if a motor normally exhibit 100 RPM, then it should do 25 RPM with a 25% duty cycle

It is important to experiment with these parameters to find the configuration that is right for your application because no two motors are the same. Some motors are better when the frequency is low (between 2 000-5 000 Hz). Other motors are best when the frequency is high, say between 15 000 and 20 000 Hz. Note that a low frequency (between 1 000 and 8 000 Hz) will produce an audible sound that can be very annoying. I have tested three robots with varying weight (500 g to 15 kg) and with different motors and have found that a frequency of 15 000 to 20 000 Hz gives good results. I have never seen any robot move with a duty cycle of less than 50%. If you want to do this, you have to find ways to control PWM in software, i.e. for a duty cycle of 25%, use a 50% duty cycle and turn PWM 50% of the time. Ideally, you will find motors that are not too fast at 50% and fast enough at 100%.

The TRISC register must be initialized so that RC1 et RC2 are identified as output ports (bits 1 and 2 of TRISC must be set to 0). CCP1CON and CCP2CON are used to configure CCP1 and CCP2 modules mode. A value of 12 configures these modules for PWM mode.

Timer2 is used by CCP1 and CCP2 modules for PWM purposes. Timer2 prescaler is configured using bits TCKPS0 et TCKPS1 of T2CON register (bits 0 and 1). A value of 0 for these two bits configures a prescaler of 1. Bit TMR2ON (bit 2) must be initialized to 1 to start Timer2.PR2 register controls the pulse frequency. The formula used to calculate the pulse period is:(PR2 + 1) * 4 * TOSC * (Timer2 prescaler value).Pulse frequency is 1 / period. If PR2 is equal to 255 and the PIC runs at 20 MHz, pulse frequency is 19.53 kHz with a Timer2 prescaler of 1, i.e. 1 / ((255 + 1) * 4 * 1 / 20 000 000 * 1).

The CCPR1L et CCPR2L registers configure the "duty cycle". The "duty cycle" is relative to PR2. If PR2 is 100 and CCPR1 is 50, then the "duty cycle" is effectively 50% (half of PR2).
CCS provides macros to configure these registers appropriately. Here is an example program that shows how to configure PWM with CCS:

demopwm.c

Graphic LCD

Done working on Graphic LCD (GLCD) interfacing with 89c51. Here is exapmle  asm file and hex code file.
And following are the connection pattern for GLCD and 89c51.
 

DC Motor Control with Microcontroller ATmega8535

At mega 8535 microcontroller can use control dc motor that is on pin d where there have PWM control. DC motor can rotate because of the induction when the motor is connected to the DC voltage source. DC motor control with microcontroller if it is done more easily than without the microcontroller. We can change the direction of rotation of DC motor directly by changing the polarity of the voltage source. To change the speed of DC motors can be done by changing the size of a fox-voltage source. Control with a microcontroller as well as principled, but with an automated system. We do not have to change the cable from the motor to the battery if you want to change the direction of rotation, we just provide the logic 0 or 1 to the microcontroller is performed on the program in the microcontroller. To change the velocity is also easier because we simply use the existing PWM feature on the microcontroller. Maybe there are still many who do not know what PWM

PWM (Pulse Width Modulation) is a technique to get the effect of the analog signal from a digital signal to falter. PWM can be generated using only digital i / o which functioned as an output.



  In the example above the waves, the comparison between high signal (1) and low signal (0th) is the same. Above the wave is said to have 50% duty cycle. Duty cycle is the ratio between the width of high signal (1) the overall width of the cycle (cycle). If the PWM wave amplitude is 5 volts, then the average stress (as if to analog) that we get is 2.5 volts. Here's an example of wave PWM with duty cycle 10%, if the amplitude of wave 5 volts then we will get the average analog voltage 0.5 volts.



In  ATMEGA8535 have two way control PWM, the PWM can be generated from the first port input / output is enabled as output. The second is to utilize the facilities of the function of the PWM timer / counter which has been provided. With this facility, the timing of the process of high / low digital signal will not disrupt the sequence of other programs being executed by the processor. In addition, by using this facility to enter how many servings we lived on and off time period on a wave PWM registers. OCR1A, OCR1B and OCR2 is register a place set PWM duty cycle.
The following schematic DC Motor Control with Microcontroller ATmega8535 of my own, please trace itself, or if you want to please make my request in the comments section below ini. Click image to enlarge......




I separate the circuit into three main sections so that it is easy to understand and analyze our series, namely the minimum system, motor drivers, and motors (as a major expense). The minimum system the same as in my previous posting, the next part of the driver. in fact we can directly connect the microcontroller to the motor without a driver, this can be done if the motor that we use a small motor. we need a big motor for the drivers, these drivers can be made also with the MOSFET (often called the H-Bridge), we can use a more practical ie L298 driver ic, ni ijenis drivers able to control two motorcycles and also features the legs to control the PWM .
For our experiment we only use a single dc motor alone, here are photos from the series that I created.



For the program you can see below. Use the AVR Studio software (after AVR studio also install WinAVR is installed so that it AVRstudio supports the C language, because the standard AVRstudio using assembly language). To download your program can use the USB downloader downloader atapun series which has also been my post. The following program

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

#define    DDR_motor    DDRD    //DDR untuk Motor
#define    PORT_motor    PORTD    //PORT untuk Motor

#define en_ka         5        // Enable L298 untuk motor kanan
#define dirA_ka     2        // Direction A untuk motor kanan
#define dirB_ka     3        // Direction B untuk motor kanan
#define pwm_kanan    OCR1A

void delay_ms(int ms)
{for (int i=0;i<ms;i++){_delay_ms(1);}}

void maju(unsigned int pwm)
{
PORT_motor |=(1<<dirA_ka);        //motor maju
PORT_motor &=~(1<<dirB_ka);
pwm_kanan=pwm;                    //pwm motor kanan
}

void mundur(unsigned int pwm)
{
PORT_motor |=(1<<dirB_ka);        //motor maju
PORT_motor &=~(1<<dirA_ka);
pwm_kanan=pwm;                    //pwm motor kanan
}


int main (void)
{

DDR_motor=0xFF;
PORT_motor=0x00;


    TCCR1A= (1<<WGM11)|(1<<WGM10)|
            (1<<COM1A1)|(0<<COM1A0)|
            (1<<COM1B1)|(0<<COM1B0);
           
    TCCR1B= (0<<WGM13)|(1<<WGM12)|
            (0<<CS12)|(0<<CS11)|(1<<CS10);
    TCNT1=0x0000;
    OCR1A=0;
    OCR1B=0;
    sei( );


while(1)
{
mundur(1000);
delay_ms(5000);
maju(700);
delay_ms(3000);

}
}

see the main program, with a PWM motor will resign in 1000 over 5000ms (5 seconds) and then will forward denan PWM motor 700 for 3000ms (3 seconds). and the program will be repeated a maximum of motor-ulang.Kecepatan happen if we gave in 1000 and the minimum PWM value (motor stopped) if the PWM value of 0, see the main program, which is backward (1000) that mean the motor will spin backwards at top speed because the PWM is 1000

ISP Flash Microcontroller Programmer

Introduction

 This ISP Programmer can be used either for in-system programming or as a stand-alone spi programmer for Atmel ISP programmable devices. The programming interface is compatible to STK200 ISP programmer hardware so the users of STK200 can also use the software which can program both the 8051 and AVR series devices.

Hardware
Figure 1 shows the circuit diagram of the in-system programmer interface, the power to the interface is provided by the target system. The 74HCT541 ic isolate and buffer the parallel port signals. It is necessary to use the HCT type ic in order to make sure the programmer should also work with 3V type parallel port.

                Figure 1: Circuit Diagram of the ISP Programmer Interface
Figure 2 shows the circuit diagram of the stand-alone spi programmer, the power to the interface is provided by the PC USB port which can supply a max of 100mA current. Get a cheap USB cable, cut the cable other end connector and attach a crimp shell connector to this end, red wire is 5V and black is 0V.

The printer port buffer interface is same as shown in figure 1. For the u-controller a 40 pin ZIF socket can be used.

This programmer circuit can be use to program the 89S series devices and the AVR series devices which are pin compatible to 8051, like 90S8515. For other AVR series devices the user can make an adapter board for 20, 28 and 40 pin devices. The pin numbers shown in brackets correspond to PC parallel port connector.

                    Figure 2: Circuit Diagram of the SPI Programmer


Software
The ISP-30a.zip file contains the main program and the i/o port driver. Place all files in the same folder.
The main screen view of the program is shown in figure 3.

Also make sure do not program the RSTDISBL fuse in ATmega8, ATtiny26 and ATtiny2313 otherwise further spi programming is disable and you will need a parallel programmer to enable the spi programming. For the fuses setting consult the datasheet of the respective device.

For the auto hardware detection it is necessary to short pin 2 and 12 of DB25 connector, otherwise the software uses the default parallel port i.e. LPT1.

Following are the main features of this software,

Read and write the Intel Hex file
Read signature, lock and fuse bits
Clear and Fill memory buffer
Verify with memory buffer
Reload current Hex file
Display buffer checksum
Program selected lock bits & fuses
Auto detection of hardware


Note:
The memory buffer contains both the code data and the eeprom data for the devices which have eeprom memory. The eeprom memory address in buffer is started after the code memory, so it is necessary the hex file should contains the eeprom start address after the end of code memory last address i.e. for 90S2313 the start address for eeprom memory is 0x800.

The software does not provide the erase command because this function is performed automatically during device programming. If you are required to erase the controller, first use the clear buffer command then program the controller, this will erase the controller and also set the AVR device fuses to default setting.
Download
ISP-Flash Programmer Software ISP-30a.zip


                  Figure 3: Main screen of the program ISP-Pgm Ver 3.0a

LT1300 Solar Powered Power Supply

This architecture was generated as allotment of a alien acclimate base project. One of the requirements of the architecture is that it accept a solar-powered accumulation with rechargeable batteries. This architecture is based on a photovoltaic arrangement accessible from Radio Shack alleged a BatterySAVER (part cardinal 980-1045). It was advised to allegation your car array during the day. They allegedly aren't actual accepted because you can aces them up for $15. The affidavit claims an achievement of 1 watt but I begin that at apex in Atlanta, the ability was a little les than bisected a watt. Maybe at the equator during the autumnal equinox...




 LT1300 Solar Powered Power Supply
 LT1300 Solar Powered Power Supply 

 
For my application, the boilerplate cesspool off the batteries would is abundant abate than the charging accepted (50mA). If your appliance has college boilerplate accepted requirements, again R1 will charge to be adapted accordingly:

R1=64mV/(50mA+Average Amount Current)

Don't try to cull too abundant accepted admitting because the solar console can alone accommodate 500mW and the batteries charge 40% of that. That leaves 300mW for your load.

The architecture is based on four anatomic blocks: 1) a 50mA accepted antecedent apprenticed by the solar cells, 2) three AAA NiCAD batteries with a 500mAHr capacity, 3) a 5V, 400mA switch mode regulator, and 4) a low dropout 3.3V 150mA beeline regulator. If you accept no charge for 3.3V again U3 and C4 can be eliminated. If you alone charge 3.3V again U3 and C4 can be alone and pin 2 of U2 can be affiliated to arena - this will catechumen U2 to a 3.3V switch mode regulator.

All the capacitors on the switch mode ability accumulation should be tantalum with C2 actuality affiliated anon to pins 6 and 8 if possible.

Servo Light Dimmer

What, the of a dimmer,you may ask ?Well, then a concise answer would be that it:

  • Reduces power consumption(and bills)
  • Increases life of lamps by switching them
  • Allows the same lamp to serve as a ten-watt night lamp or a two hundred watt control illumination lamp.
And this is exactly what this dimmer does.One plus point is that it has a power handling capacity exceeding 1600 watts, far exceeding the ordinary 300 watt types.
Any type of 400 PIV, 8 ampere triac may be used in the circuit VR1 provides illumination control.R2,R3 and C1 set the minimum brightness level which can however be altered.

The LED and R1 are optional,They serve the purpose of pilot monitoring.The triac must be heavily heatsinked to prevent any damage.
A suitable front panel etch-on is shown in figure.The same can either be photocopied or xeroxed on self adhesive panel plates.




The dimmer -an excellent power saver(and bill reducer)
Figure : Front panel etch-on for the dimmer