Discussion in "Project Help" started by    firoz3321    Jan 7, 2010.
Thu Sep 29 2011, 09:42 pm
@Sir Majoka,
Sir, i do have a question about this link,http://www.8052.com/users/AT89S52InSystemProg/,it says in there that i must burn the firmware into an AT89C2051 and i will need a conventional parallel Programmer to Program it). This parallel programmer involves another circuit sir?And do i need another programmer software which is different from the AT89SXX ISP Flash Programmer Software to burn this so called firmware?
And i also consider this simple programmer which i got from one of the links you have provided. http://chaokhun.kmitl.ac.th/~kswichit/tahan/boards51/Board%20S51.htm. Could i use this sir for making the greenbee project?
Thanks for the future response about this matter sir!Sorry for the series of long questions ..
More Power to you sir majoka!

Thu Sep 29 2011, 11:37 pm

http://chaokhun.kmitl.ac.th/~kswichit/tahan/boards51/Board%20S51.htm


this is a test board for initial stage u can also make it but u need as well as programmer that is also in the link that is of parallel port
http://www.8052.com/users/AT89S52InSystemProg/

in this circuit AT89C2051 is used u need a programmer for that i suppose that u has programmer in university by using that u burn and after that it will burn the other chips
Fri Sep 30 2011, 02:34 pm
I think its easier to use AVR controler like ATmega8 for this project.
Even the programmer is easy to make.
Fri Sep 30 2011, 03:55 pm
@ firoz3321
PIC ,AVR or any brand that is available in local market that can be used
AVR are costly so less people use that
Fri Sep 30 2011, 03:59 pm
but ATmega8 has internal ADC too so it solves many connection issues. Because i have done GreenBee i see it easy on AVR than on 89C , also the cost is approx 80 INR variation.

at the time of my project i was not aware of the ATmega8, but now i have done a few on this so i feel we can easily have the programmers too.

i completely relied on my college KITS for programming , because i didnt have the programmer with me then.
Fri Sep 30 2011, 04:05 pm
@ firoz3321
yes AVR programmers are small in size and AVR are fast controllers
PIC can also be used it also has internal adc as well as other peripherals as AVR has
Fri Sep 30 2011, 04:05 pm
I personally never worked on PIC
Fri Sep 30 2011, 04:11 pm
@ firoz3321
if u worked on AVR then it means u worked on PIC
all controllers logically are same logic is same almost timer, counters are same
Sat Oct 01 2011, 12:39 pm
I wrote the following code from scratch for AVR controller last night.
I knw its still incomplete, can someone please let me knw WHAT am I missing ?
Does this code even work ?

I am a beginner and not good with coding, but just wrote this for time pass. please suggest the MISSING PARTS. and MISTAKES in the code SO FAR

// I chose GreenBee and transformed it to GreenBee_v2 which was my firt project on microcontrollers
// Today I have once again started this project from scratch using ATmega Controller as GreenBee_v3


#include <stdio.h>

#include <avr/io.h>

#include <math.h>

#include <util/delay.h>


void UART_INIT(void);
void ADC_INIT(void);
void  temp_read(void);
void  humid_read(void);
void  moist_read(void);
void  lumus_read(void);


#define reference_voltage 5						// Reference External 5 Volts

#define Light1_ON	(PORTB|=0b00000001); 		// Light Intensity Dependent
#define Light1_OFF	(PORTB&=0b11111110);


#define Light2_ON	(PORTB|=0b00000010);		// Temperature Dependent
#define Light2_OFF	(PORTB&=0b11111101);


#define Pump_ON		(PORTB|=0b00000100);		// SoilMoisture Dependent 
#define Pump_OFF	(PORTB&=0b11111011);


#define Cooler_ON	(PORTB|=0b00001000);		// Temperature Dependent
#define Cooler_OFF	(PORTB&=0b11110111);


#define Sprayer_ON	(PORTB|=0b00010000);		// Humidity Dependent
#define Sprayer_OFF	(PORTB&=0b11101111);


#define Buzzer_ON	(PORTB|=0b00100000);		// Buzzer beyond Threshold
#define Buzzer_OFF	(PORTB&=0b11011111);


//******************************CHANGE THE BELOW THRESHOLD VALUES ACCORDINGLY******************************
#define temp_treshold  40
#define humid_treshold 30
#define moist_treshold 30
#define light_treshold 30
//******************************CHANGE THE ABOVE THRESHOLD VALUES ACCORDINGLY******************************


//******************************CHANGE THE BELOW MULTIPLIER VALUES ACCORDINGLY******************************
#define temp_multiple  100						// 100 according to LM35 Datasheet assuming GAIN = 1
#define humid_multiple 30						// This will later change acordingly
#define moist_multiple 30						// This will later change acordingly
#define light_multiple 30						// This will later change acordingly
//******************************CHANGE THE ABOVE MULTIPLIER VALUES ACCORDINGLY******************************


int input_volt =0;
int luminance  =0;
int humidity   =0;
int moisture   =0;
int temperature=0;

    static int uart_putchar(char c, FILE *stream);

    static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar, NULL,
                                             _FDEV_SETUP_WRITE);

    static int
    uart_putchar(char c, FILE *stream)
    {

      if (c == '\n')
        uart_putchar('\r', stream);
      loop_until_bit_is_set(UCSRA, UDRE);
      UDR = c;
      return 0;
    }

//Main 

int main (void)
{
  DDRB=0xff;
  PORTB=0x00;
  DDRC=0x00;
  PORTC=0x00;
  DDRD=0xFE;
  PORTD=0x00;
  ADC_INIT();
  UART_INIT();

  stdout = &mystdout;
  printf("\nWelcome to GreenBeev3 by Feroze Mohamed, started from Scratch using AVR controller\n");
  
  while(1)
  { 
    temp_read();
  	moist_read();
  	humid_read();
  	lumus_read();

	if(temperature<=temp_treshold)		// use flags for repeating actions like buzzer
		{
			Cooler_OFF;
			Light2_ON;
		}

	if(temperature>
temp_treshold)
		{
			Cooler_ON;
			Light2_OFF;
		}

	if(moisture<=moist_treshold)
		{
			Pump_ON;
		}
	if(moisture>
moist_treshold)
		{
			Pump_OFF;
		}


	if(humidity<=humid_treshold)
		{
			Sprayer_ON;
		}	
	
	if(humidity>
humid_treshold)
		{
			Sprayer_OFF;
		}


	if(luminance<=light_treshold)
		{
			Light1_ON
		}
	if(luminance>
light_treshold)
		{
			Light1_OFF
		}

    _delay_ms(10000);				// 10 sec delay
  }

}


//ADC
void ADC_INIT(void)
{
  ADCSRA = (1<<ADSC) | (1<<ADPS2) | (1<<ADPS1) | (1<<ADPS0);
  ADMUX = 0x00;
}

unsigned int ADC_READ(char channel)
{ 
  float float_value=0;

  ADMUX|= channel & 0x07;			// Making sure Only MUX bits are variable

  ADCSRA|= (1<<ADSC); 				// Set ADSC bit HIGH i.e., Start Conversion

  loop_until_bit_is_set(ADCSRA,ADIF); // wait till ADIF is high also can use this while !(ADCSRA&(1<<ADIF));

  float_value = (ADC) * (reference_voltage) / (1024); // ADC is 10 bit so 2 power 10 = 1024
 
  input_volt = float_value;

  return input_volt;

}

//UART
void UART_INIT(void)
{
 
  UCSRB = 0x18;
  UCSRC = 0x86;
  UBRRL = 0x33;

}

//********SENSORS********

		//Sensor: TEMPERATURE
void  temp_read(void)
{
  printf("\nReading Temperature...");
  ADC_READ(0);
  temperature = input_volt * temp_multiple;  	
  printf("\nTemperature = %d",temperature);
}

		//Sensor: SOIL MOISTURE
void  moist_read(void)
{
  printf("\nReading Moisture...");
  ADC_READ(1);
  moisture = input_volt * moist_multiple;  	
  printf("\nMoisture = %d",moisture);
}

		//Sensor: HUMIDITY
void  humid_read(void)
{
  printf("\nReading Humidity...");
  ADC_READ(2);
  humidity = input_volt * humid_multiple;  	
  printf("\nHumidity = %d",humidity);
}

		//Sensor: LIGHT
void  lumus_read(void)
{
  printf("\nReading Light Intensity...");ADC_READ(3);
  luminance = input_volt * light_multiple;  	
  printf("\nLight Intensity = %d",luminance);
}

 


[ Edited Sat Oct 01 2011, 01:35 pm ]
Sun Oct 02 2011, 01:10 am
@ firoz3321
is it working and u want to ask for improvement in coding or ur getting error or problem in that sense u want to ask

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Richardgar
Sat Apr 20 2024, 11:05 am
AntoniaRoons
Fri Apr 19 2024, 09:59 pm
carpinteyrowrl
Fri Apr 19 2024, 02:51 pm
DonaldJAX
Fri Apr 19 2024, 01:08 pm
Lewisuhakeply
Thu Apr 18 2024, 06:00 pm
Darrellciz
Thu Apr 18 2024, 11:07 am
Charlessber
Thu Apr 18 2024, 09:29 am
BartonSem
Thu Apr 18 2024, 04:56 am