Rules | Recent posts | topic RSS | Search | Register  | Log in

Using ADC n PWM to light up the LED dimmer - need help


Goto page 1, 2, 3  Next
Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> Using ADC n PWM to light up the LED dimmer - need help
Author Message
jason1987



Joined: 22 Jun 2009
Posts: 69
Location: japan


Post22 Jun 2009 7:22   

i am doing ADC


i nid help in ADC n PWM.. my project is to make the LED dimmer using ADC n PWM.. isit possible?
Back to top
aanand_44



Joined: 25 Jul 2007
Posts: 24
Helped: 2
Location: India


Post22 Jun 2009 9:53   

Re: i am doing ADC


Hi,
It is possible. which controller you are going to use this project?

U can modify the your duty cycle wit reference to ADC value.

Give me details I'll give u solution.

Regards,
Anand.A
Back to top
jason1987



Joined: 22 Jun 2009
Posts: 69
Location: japan


Post22 Jun 2009 10:00   

Re: i am doing ADC


using ADC n PWM to light up the LED dimmer.. i using c8051f226dk.. give mi solution... erm i using microcontroller 8051 IC chip.. i gt the attachment help mi. and i attach to PDF file take a look


Sorry, but you need login in to view this attachment

Back to top
jason1987



Joined: 22 Jun 2009
Posts: 69
Location: japan


Post22 Jun 2009 10:06   

Re: i am doing ADC


i gt the board sample oso.. is attach to tis.. take a look ba.. i dunno anyting abt tis.. help


Sorry, but you need login in to view this attachment

Back to top
blueroomelectronics



Joined: 17 Sep 2006
Posts: 1681
Helped: 99
Location: Toronto, Canada


Post22 Jun 2009 12:40   

i am doing ADC


You want someone to write your homework code for you?
Back to top
jason1987



Joined: 22 Jun 2009
Posts: 69
Location: japan


Post22 Jun 2009 15:51   

Re: i am doing ADC


if possible give mi the code i will study myself or i ask some question..cos i have no idea... if possible if cannot den jus teach mi will do..

a)my procedures is develop firmware for ADC to acquire potentiometer setting
b)develop firmware for PWM generation
c)integrate ADC acquistion for PWM generation
d) develop current driver circuit for LED.. any idea? can help to slove?
Back to top
jason1987



Joined: 22 Jun 2009
Posts: 69
Location: japan


Post23 Jun 2009 3:37   

Re: i am doing ADC


can help mi? i jus wan some guide n i will learn myself.. jus give mi some hint will do.. den i learn myself.. i have a variable resister also and i dunno put where or connect where?

Added after 54 minutes:

can someone guide mi and give some hint.. i need urgent.. i need guide
Back to top
mfarooq1



Joined: 09 Jan 2009
Posts: 87
Helped: 4


Post23 Jun 2009 11:54   

Re: i am doing ADC


Hi
see the circuit in PDF and design in orcad. you can see the ADC connection with MCU and variable resistor. feel free to ask questions

Added after 58 seconds:

ADC circuit and Design in OrCad



Sorry, but you need login in to view this attachment

Back to top
jason1987



Joined: 22 Jun 2009
Posts: 69
Location: japan


Post23 Jun 2009 15:59   

Re: i am doing ADC


erm hw to do the program using ADC n PWM to generate the LEd dimmer? using c8051f226dk. hw does it wrk? tel mi more and the code i wanted dunno correct anot.. u have the datasheet rite? den can help mi? if possible i give u wat i have type and let u take a look?
Back to top
blueroomelectronics



Joined: 17 Sep 2006
Posts: 1681
Helped: 99
Location: Toronto, Canada


Post23 Jun 2009 17:54   

i am doing ADC


When's it due?
Back to top
jason1987



Joined: 22 Jun 2009
Posts: 69
Location: japan


Post23 Jun 2009 18:44   

Re: i am doing ADC


thank for replying mi. next week monday.. can help mi ma? i need it urgent because i have no idea what to do also.. cos first time handle this project.. thank.

best regard
Back to top
blueroomelectronics



Joined: 17 Sep 2006
Posts: 1681
Helped: 99
Location: Toronto, Canada


Post23 Jun 2009 20:20   

i am doing ADC


Perhaps you should try something simpler for your first project. Flashing an LED is good.
Back to top
jason1987



Joined: 22 Jun 2009
Posts: 69
Location: japan


Post24 Jun 2009 1:54   

Re: i am doing ADC


i alreadi start the flashing the LED wish can work. and now i wan go another steps which is going to do ADC but i don't have any idea about ADC.. so can give some guide? following is my PDF file name.. is my data sheet and kinda help mi abit. thank for replying mi..


Sorry, but you need login in to view this attachment

Back to top
jason1987



Joined: 22 Jun 2009
Posts: 69
Location: japan


Post30 Jun 2009 2:50   

Re: i am doing ADC


help help mi..
Back to top
blueroomelectronics



Joined: 17 Sep 2006
Posts: 1681
Helped: 99
Location: Toronto, Canada


Post30 Jun 2009 3:44   

Re: i am doing ADC


jason1987 wrote:
help help mi..


Sounds like a line from the Beatles song.

Your attached file C8051F2xx.pdf is nothing more than the datasheet.


Last edited by blueroomelectronics on 30 Jun 2009 3:47; edited 1 time in total
Back to top
jason1987



Joined: 22 Jun 2009
Posts: 69
Location: japan


Post30 Jun 2009 3:47   

Re: i am doing ADC


i am doing ADC and PWM to generate a LED dim.. anyone can help mi? urgent

what does the below code do?


#include<c8051f200.h>




//definitions
sbit LED = P2^4;


void adc_init(); //to initialize adc
void port_init(); //to initialize the ports

void main()
{

unsigned int index=0, total_period= (unsigned int) 255*256, on_time=0;
port_init();
adc_init();


// disable watchdog timer
WDTCN = 0xde;
WDTCN = 0xad;


{
ADBUSY = 0x01; //starts the adc conversion
while(ADCINT); //polling for ADCINT which tells us the end of conversion
ADCINT = 0x00;
on_time = ((unsigned int)ADC0H)*256;
for ( index = 0 ; index < total_period ; index++)
{
if (on_time--)
{
LED = 0x01; //switching on the LED

}

else
{
LED = 0x00; //switching off the LED
}
}
}
}

void adc_init ()

{
AMX0SL = 0x3f; // enable AMUX & configure for p3.7 as i/p pin
ADC0CF = 0x60; // set conversion clk at one sys clk and PGA at gain =1
ADC0CN = 0xC0; // ADC is enabled and ADBUSY=0 (changed here)
REF0CN = 0x03; // VDD is selected as Vref. Here are you using VDD for variable resistor also?
}
void port_init()
{
P3MODE = 0X7F; // Except the P3.7 pin all are configured as digital I/O
}
Back to top
blueroomelectronics



Joined: 17 Sep 2006
Posts: 1681
Helped: 99
Location: Toronto, Canada


Post30 Jun 2009 3:48   

i am doing ADC


Where did you get the code?

Try running it.

When's it due?
Back to top
jason1987



Joined: 22 Jun 2009
Posts: 69
Location: japan


Post30 Jun 2009 3:53   

Re: i am doing ADC


i run the code but nothing happen.. hw come? and i have connect mine variable resistor to the ADC input but nothing happen.. y? any idea? what does the code do?
Back to top
blueroomelectronics



Joined: 17 Sep 2006
Posts: 1681
Helped: 99
Location: Toronto, Canada


Post30 Jun 2009 4:09   

i am doing ADC


Where did you get the code from?
Back to top
jason1987



Joined: 22 Jun 2009
Posts: 69
Location: japan


Post30 Jun 2009 4:10   

Re: i am doing ADC


from my teacher.. i need to understand.. give some guide
Back to top
blueroomelectronics



Joined: 17 Sep 2006
Posts: 1681
Helped: 99
Location: Toronto, Canada


Post30 Jun 2009 4:12   

i am doing ADC


Then why not ask your teacher to explain it.
Back to top
jason1987



Joined: 22 Jun 2009
Posts: 69
Location: japan


Post30 Jun 2009 4:14   

Re: i am doing ADC


thank for the replying mi, if he will explain to mi den i post here for what?
Back to top
blueroomelectronics



Joined: 17 Sep 2006
Posts: 1681
Helped: 99
Location: Toronto, Canada


Post30 Jun 2009 4:19   

i am doing ADC


The comments in the code tell what the code is doing.

Your teacher gave this to you to debug so you could learn to program.

Do you not know how to program in C ?
Back to top
Google
AdSense
Google Adsense




Post30 Jun 2009 4:19   

Ads




Back to top
jason1987



Joined: 22 Jun 2009
Posts: 69
Location: japan


Post30 Jun 2009 4:22   

Re: i am doing ADC


i dunno hw to program in C.. and i have a hex file.. how to download to the board using silicon software? what kind of result if i download the code to ther board? and kinda tell mi the code what he is doin?

#include<c8051f200.h>




//definitions
sbit LED = P2^4;


void adc_init(); //to initialize adc
void port_init(); //to initialize the ports

void main()
{

unsigned int index=0, total_period= (unsigned int) 255*256, on_time=0;
port_init();
adc_init();


// disable watchdog timer
WDTCN = 0xde;
WDTCN = 0xad;


{
ADBUSY = 0x01; //starts the adc conversion
while(ADCINT); //polling for ADCINT which tells us the end of conversion
ADCINT = 0x00;
on_time = ((unsigned int)ADC0H)*256;
for ( index = 0 ; index < total_period ; index++)
{
if (on_time--)
{
LED = 0x01; //switching on the LED

}

else
{
LED = 0x00; //switching off the LED
}
}
}
}

void adc_init ()

{
AMX0SL = 0x3f; // enable AMUX & configure for p3.7 as i/p pin
ADC0CF = 0x60; // set conversion clk at one sys clk and PGA at gain =1
ADC0CN = 0xC0; // ADC is enabled and ADBUSY=0 (changed here)
REF0CN = 0x03; // VDD is selected as Vref. Here are you using VDD for variable resistor also?
}
void port_init()
{
P3MODE = 0X7F; // Except the P3.7 pin all are configured as digital I/O
}
Back to top
blueroomelectronics



Joined: 17 Sep 2006
Posts: 1681
Helped: 99
Location: Toronto, Canada


Post30 Jun 2009 4:27   

i am doing ADC


You have to compile the code first. Makes no sense your teacher would expect you to be able to understand the code if you can't program in C

I recommend a getting a book on C

PS what does "mi" mean?
Back to top
jason1987



Joined: 22 Jun 2009
Posts: 69
Location: japan


Post30 Jun 2009 4:29   

Re: i am doing ADC


but do u noe what the code is doing anot? if i have the book i wont be posting here
Back to top
blueroomelectronics



Joined: 17 Sep 2006
Posts: 1681
Helped: 99
Location: Toronto, Canada


Post30 Jun 2009 4:33   

Re: i am doing ADC


jason1987 wrote:
but do u noe what the code is doing anot? if i have the book i wont be posting here



Sorry I don't understand your question?

As for the book why do you want to post it? I don't need a C book I have a couple.
Back to top
jason1987



Joined: 22 Jun 2009
Posts: 69
Location: japan


Post30 Jun 2009 4:38   

Re: i am doing ADC


i don't undestand the code that why i post here for help.. i don't have the book tat why if u know try to help mi.. thank
Back to top
blueroomelectronics



Joined: 17 Sep 2006
Posts: 1681
Helped: 99
Location: Toronto, Canada


Post30 Jun 2009 4:47   

i am doing ADC


Try Google for C tutorials. The code is pretty straight forward. Don't bother with C# tutorials just look for ANSI C
Back to top
jason1987



Joined: 22 Jun 2009
Posts: 69
Location: japan


Post30 Jun 2009 5:35   

Re: i am doing ADC


give mi the link
Back to top
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> Using ADC n PWM to light up the LED dimmer - need help
Page 1 of 3 All times are GMT + 1 Hour
Goto page 1, 2, 3  Next
Similar topics:
Light dimmer/brightner- need circuit to gradually bright,dim (2)
Programmable Message LED Light-UP Handheld Personal Fan (2)
Light up led source code - what went wrong ? (9)
Help Needed... Light dimmer (1)
Need help. led light circuit with output at on/off (4)
Using 8051 to control PWM, ADC, DAC, Memory, Sensor (12)
LED driver using PWM???? (2)
problem with counter using led matrix... why not light on? (2)
Light dimmer.... (8)
Light Dimmer (2)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS