CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Help me control brightness Led using PWM module
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Oct 27, 2010 3:51 pm     Reply with quote

I don't have Proteus. I don't know very much about it.
matheuslps



Joined: 29 Sep 2010
Posts: 73
Location: Brazil

View user's profile Send private message MSN Messenger

PostPosted: Wed Oct 27, 2010 6:42 pm     Reply with quote

Sure you can simulate with Proteus.

Most of the codes works fine.

bye
alex_ccs



Joined: 27 Oct 2010
Posts: 3

View user's profile Send private message

PostPosted: Thu Oct 28, 2010 9:43 am     Reply with quote

Thanks both.
I have simulate on Proteus but nothing happen.
matheuslps



Joined: 29 Sep 2010
Posts: 73
Location: Brazil

View user's profile Send private message MSN Messenger

PostPosted: Thu Oct 28, 2010 12:43 pm     Reply with quote

Please post your circuit and your code.

I will simulate it for you.

EDIT:

Done:

Circuit:

http://img7.imageshack.us/img7/6990/adclcd.png

Code:

Code:
#include <16F877A.h>
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES XT                       //Crystal osc <= 4mhz
#FUSES PUT                      //Power Up Timer
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES BROWNOUT                 //Reset when brownout detected
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD                    //No EE protection

#use delay(clock=4000000)

#include <LCD.C>


void main()
{
   int8 q;
   float p;
   
   setup_ccp1(CCP_PWM);


   setup_timer_2(T2_DIV_BY_16, 255, 1);

   setup_adc_ports(AN0);                                   //Analogic channel 0
   setup_adc(ADC_CLOCK_INTERNAL);    //internal clock

   lcd_init();   
   
   set_adc_channel(0);           //enable channel 0
   delay_us(20);
   
   while (TRUE)
   {     
      q = read_adc();                  //read channel 0
      p=0.392*q;
      printf (lcd_putc, "\fADC = %4u \n%4.2f percent", q, p);
      set_pwm1_duty(q);
      delay_ms(100);
   }
}
     
     


bye
alex_ccs



Joined: 27 Oct 2010
Posts: 3

View user's profile Send private message

PostPosted: Wed Nov 03, 2010 10:54 am     Reply with quote

Thank you for your help matheuslps.

http://img529.imageshack.us/img529/5412/pwm1.jpg
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

proteus ....
PostPosted: Thu Jul 21, 2011 3:50 pm     Reply with quote

You can simulate quite a few pic situations with Proteus

But - after having it suggested to me
and trying it exactly ONCE - i will NEVER touch it again.

If you want to know how a program really works - you should make the effort to build the actual hardware and do it for REAL.

Proteus simulated pic code is NOT a basis for a working product that i would ever rely on.
For school class maybe -
but not in the world of designs that HAVE to work.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group