Tuesday, October 29, 2013

Setting PWM to control speed fan

By using the L298 as a PWM driver to control the voltage on the motor or speed fan.

The PIC16F877A PWM Module:
16F877a includes two PWM modules included in the CCP1,CCP2 modules (CCP stands for Capture-Compare-PWM), and there are 3 steps for using those modules:

  1. Set the desired CCP module to PWM mode.
  2. Setup The TIMER2 module, which controls the frequency and the base of your PWM signal.
  3. Set your duty cycle, rely on the equations below to select it properly.
We'll be using CCS PIC-C compiler to explain those steps, if you have a question on using other compilers to set it, post a comment.
To set The CCP1 module to PWM mode, we'll use the code line:
setup_ccp1(CCP_PWM);
 and the first step is done.
Now setting up Timer2 module using PIC-C is a bit easy, use the code line: setup_timer_2(divider,preload,postscalar).
the divider and the preload values determines the frequency of the PWM signal by the following function:
Signal Frequency = (Crystal/4) / (divider * (preload+1))
The divider takes the values : T2_DIV_BY_1, T2_DIV_BY_4, T2_DIV_BY_16.
the preload is 8Bits and takes the values 0-255
So let us say we have 4MHz crystal and we set Timer2 like this:
setup_timer_2( T2_DIV_BY_1, 255, 1);
thus, our signal frequency is (4MHz/1)/(4 * 256) =  3.9KHz

Now the final step is to set your duty cycle using the function: set_pwm1_duty(duty_parameter);
to get the duty_parameter of your desired duty cycle, note the following:
the maximum value of duty_paramter (MAX) = ((preload+1)*4) -1
so in our case the maximum value is ((255+1)*4)-1 = 1023 and it represents a 100% duty cycle.
now if we need a duty cycle of 50% it would be 1023*0.5 = 512, and a duty cycle of 25% would be 1023*0.25 = 256, thus,

set_pwm1_duty(1023L); ---> 100% duty (Full Speed)
set_pwm1_duty(512L);  ----> 50% duty
set_pwm1_duty(256L);  ----> 25% duty
set_pwm1_duty(0);        ----> 0% duty (OFF)



So this is the program to control the PWM driver, from the value of the temperature it will convert the value to the PWM driver

#include <16f877a.h>
#device adc=10    // Set ADC resolution to 10Bit
#fuses XT,NOLVP,NOWDT,NOPROTECT
#use delay(clock=4000000)


#include "LCD.c"
#define LCD_DB4   PIN_D4
#define LCD_DB5   PIN_D5
#define LCD_DB6   PIN_D6
#define LCD_DB7   PIN_D7

#define LCD_E     PIN_D0
#define LCD_RS    PIN_D1
#define LCD_RW    PIN_D2
#define Wire1     PIN_B6

#define  LOAD1  PIN_B5
#define  LOAD3  PIN_B7

#define  THRES1 28.0     // load switching threshold in Celsius
#define  THRES2 36.0     // load switching in Celcius
#define  THRES3 42.0     // load switching in Celcius



int16 digital_reading,duty_cycle=1023;  // ADC resolution is 10Bit, an 8Bit integer is not enough to hold the reading
float temp;

void main()
{
   /* ADC Initialization */
   setup_adc(ADC_CLOCK_INTERNAL); // initialize ADC with a sampling rate of Crystal/4 MHz
   setup_adc_ports(RA0_ANALOG);   // set PIN_A0 as analog input channel
   set_adc_channel(0);            // point ADC to channel 0 for ADC reading
   delay_ms(1);                   // ADC module is slow, needs some time to adjust.
   
   /* Peripherals Configurations */
   lcd_init();                   // Turn LCD ON, along with other initialization commands
   output_low(LOAD1);             // the load is initially OFF
   lcd_gotoxy(1,1);              // point LCD cursor to col1 row1
   lcd_putc("Temperature is:");  // print on LCD
  
    /* PWM Configurations */
   setup_timer_2(T2_DIV_BY_1,255,1); // Set PWM frequency
   setup_ccp1(CCP_PWM); // Configure CCP1 to PWM mode
   set_pwm1_duty(1023L); // default duty cycle = 100% (Full Speed)
  
  
   while(1) // infinite loop
   {
      digital_reading = read_adc();    // capture current temperature reading
      delay_us(100);                   // 0.1ms delay for ADC stabilization
      temp = digital_reading * 0.4883; // convert reading to Celsius
      lcd_gotoxy(1,2);                 // point LCD cursor to col1 row2
      printf(lcd_putc,"%2.1f C",temp); // print value on LCD
    
      
        
      
         if((temp>=THRES1)&&(temp<THRES2));
            {
               output_toggle(Wire1);
               duty_cycle=437.5; // increase the duty cycle(70%)
               set_pwm1_duty(duty_cycle); // set the duty cycle
            }
        
        
         if ((temp>=THRES2)&&(temp<=THRES3));
            {
               output_toggle(Wire1);
               duty_cycle=531.25; // increase the duty cycle(850%)
               set_pwm1_duty(duty_cycle); // set the duty cycle
            } 
        
        
         if (temp>THRES3);
            {
               output_toggle(Wire1);
               duty_cycle=625; // increase the duty cycle(100%)
               set_pwm1_duty(duty_cycle); // set the duty cycle
            }  
              
         delay_ms(100);
        
           // 1 second delay between readings
          
        
   }



however my program cant work because it cant match to the PWM program.

 

Monday, October 7, 2013

Completed Circuit for my project

So this is the circuit that i use PROTEUS (ISIS) to assemble my completed circuit.

There have 3 main source to control the level of speed fan depend on the temperature, here is the statement for the temperature and voltage to the speed fan.

1. when temperature is 28C ~ 35C = 5volt to the speed fan
2. when temperature is 36C ~ 42C = 9volt to the speed fan
3 when temperature is more than 42 = 12volt to the speed fan

Friday, July 12, 2013

Change The Voltage Source

By using the relay, i can change the voltage from 5 volt DC to the 12 volt DC for the DC fan motor.

to fulfill my requirement system when
# Temperature ( 27 - 30 ) the fan must 5 volt supply.
# Temperature ( 31 above ) the fan operate at fully power.

so my system will change automatically depend on the temperature that provide by the battey.

Wednesday, June 26, 2013

How to connect the ardruino port to the ATMEL IC

With this I can connect the IC ATMEL to the Ardruino set. So I can sent or burn Ardruino program into the ATMEL IC. I use the ATMEL IC model ATMEGA 328P.

1. To connect the project, the first thing student should know is pin of the IC atmel. Each of the pin consist their own data transfer.





2. So here is the circuit with the component and also the pin that have be used.
 -10k ohm resistance
 - Reset pin (use to reboot)
 - external clock 
 - 22 pf capacitors (2 units)


  • pin 7 (VCC supply voltage)
  •  pin 8 (GND)
  • pin 21 AREF (analog reference pin for ADC)
  • pin 20 AVcc (supply voltage for ADC conveter)
  • pin 9 and 10 (external clock 16MHz)

Tuesday, June 25, 2013

Make a Circuit for Power Supply

Actually it use a breadboard to connect all the wiring because if have any problem it can be fix it directly.

 1. Add the POWER and GROUND for the circuit.







2. Connect the POWER and GROUND to the each rail of the board so it can be share for the other wire.




3. Add the voltage regulator model 7805 to maintain the voltage is 5volt for the circuit. So the output will be 5volt constantly. Also put the 10uF capacitor at the IN of the voltage regulator and the OUT (ground) voltage regulator. This capacitor will maintain the voltage the come out.

Monday, June 24, 2013

chip program with ardruino

Try to program ATMEL IC with ardruino set. So the first thing is how to set up the board.

1. Basic part for board setting
 - breadbord
 -2 AWG wire
 -7805 Voltage regulator
 -2 LEDs
 -2 220 Ohm resistors
 -1 10k Ohm resistor
 -2 10 uF capacitors
 -16 MHz clock crystal
 -2 22 pF capacitors
 -small momentary normally open ("off") button, i.e. Omron type B3F

so this is the basic part so the circuit must be complete done.

 

Monday, May 27, 2013

study how to control dc fan based on temperature

Here is a simple circuit based on two transistors that can be used to control the speed of a 12 V DC fan depending on the temperature.A thermistor (R1) is used to sense the temperature.

When the temperature increases the base current of Q1 (BC 547) increases which in turn decreases the collector voltage of the same transistor. Since the collector of Q1 is coupled to the base of Q2 (BD 140), the decrease in collector voltage of Q1 forward biases the Q2 more and so do the speed of the motor. Also, the brightness of the LED will be proportional to the speed of the motor.
 
how ever i have a problem. i have to use IC (PIC 16F877A) to upload my program. so i have to find another solution.

Sunday, May 26, 2013

Chevrolet Volt Battery at Ideal Temperature

Every battery has a temperature sweet spot where it provides the optimal blend of power output, energy capacity and long life and we keep the Volt right on that target,” said Bill Wallace, General Motors director of Global Battery Systems.  Batteries that are too cold are reluctant to release electrons while batteries that run too hot can see a significantly shorter life.
The Volt’s T-shaped battery pack consists of 288 individual cells arranged into nine modules. Plastic frames hold pairs of lithium-ion cells that sandwich an aluminum cooling fin. The design and construction of that aluminum plate is critical to ensuring an even temperature distribution with no hot or cool spots across the flat, rectangular cell. The battery pack has its own cooling circuit that is similar to, but independent from, the engine cooling system.
The Dana Corp-manufactured cooling fin consists of two lightweight aluminum plates joined by a proprietary clean nickel-brazing process. The carefully designed grooves stamped into the plates form channels that allow battery coolant that is pumped through the pack to flow over the entire cell surface.
“Three different systems are used to regulate the temperature of the coolant,” said Wallace. “When the Volt is plugged in and charging in cold weather, an electric heater at the front of the battery pack is used to warm the coolant and pre-heat the battery. During normal operations, the coolant is passed through a heat exchanger at the front of the car, while a chiller in the air conditioning circuit can be used to dissipate heat from the battery when temperatures really climb.”
The management system monitors feedback from 16 thermal sensors arranged throughout the battery pack to maintain a spread of no more than 2 degrees centigrade from the optimal temperature across the pack.
Getting the battery temperature just right was a product of lessons learned from the EV1 and 15 years of testing fuel cell stacks. GM engineers and researchers learned a lot about how to circulate coolant to maintain an even temperature distribution. Those learnings went straight into the cooling system of the Volt battery.


reference
http://media.gm.com/product/public/us/en/FuelEfficiency/home/intro.detail.html/content/Pages/news/us/en/2011/Feb/0214_battery.html

DC motor speed control using PWM using PIC16F876

Schematic DC motor speed control
for this system i try the program inside the pic compiler but it is not work.
so i have to find another solution how to control the DC motor using PWM method