basics of 8051 microcontroller

Status
Not open for further replies.
Hi

What microcontroller should I use to design a maximum power tracker? I have some experience with 8051 as is witnessed by this thread but have forgotten almost all the stuff. I was thinking of using PIC 16F877 but after reading Jon Wilder post above, I thought it would be a good idea to explore an alternative. I want to base the code on this flowchart. The block diagram of the system looks like this. You might also find this block diagram useful. Thank you.

Regards
PG
 

Attachments

  • 798361.fig.002.jpg
    31.8 KB · Views: 1,048
Last edited:
I have an excellent 8051 simulator! with lcd's and all sorts, but its on the broken laptop!!! let me try and hunt around the net for it! its really ace
 
Forgot to add it does ASM as well, you get keypads and led matrix, all sorts and works really well, I was going to use it to learn 8051 but I kind of jumped straight into hardware instead . I have downloaded it again though
 
POO you caught me with an old thread again!!! oh well it might help someone! can you please brnging back the dead without at least warning people!!! we dont charge by the thread FFS
 
Thank you, Little Ghostman.

I have used the simulator MCU 8051 IDE in the past. Yes, it's an old thread but I always try to keep similar content in the same thread. It also helps other members to help me in a better way because they can go through past posts, if they like to, to see what little bit I have already learned about the topic previously. In my view, you should have tried to help me with my most recent query rather than going for the queries which had already been answered. Moreover, You could have edited your post and added more content to a single post rather than generating four different posts. Please don't mind me. I'm just saying this as a friend.

Best wishes
PG
 
I dont think you can edit posts anymore after a set time, thats why I post many times, often I think of something ten mins later and cant edit the original post!
I understand why you put it all in the same thread, but most people including me feel STUPID replying to an old question! most times we forget to look at the date and just assume the question is new because the post is at the top.
Sorry I couldn't help more. By the way what did you think of the IDE simulator? I think considering how many chips it supports and all the external stuff it can sim, its great for a totally free program!
 
By the way what did you think of the IDE simulator? I think considering how many chips it supports and all the external stuff it can sim, its great for a totally free program!

I learned a lot using that simulator. It was great. I still remember that Ian Rogers suggested that simulator. Thanks.
 
Actually Jon Wilder beat me to it!!

I still use it... I am trying to get ASM / C tutorials into the articles section... Nearly done, so it comes in handy...
 
Hi

I have found this code which I believe can be tweaked to serve the purpose. Please note that I don't really understand the code and it has been few years when I did some basic C++. Please let me know what you think of it. You can also refer to post #22 above. Thanks.

Regards
PG
 
Better to post code in tags like this
Code:
#include <16f876.h>
#device *=16 ADC=10
#use delay(Clock=20000000)
#fuses XT, NOWDT, NOPROTECT, NOPUT, NOBROWNOUT,NOLVP
#define BATTERY_CHARGED 63
#define night_voltage 61

float mean_adc(byte channel) // Reads the adc port 30 times and gives the mean value
{

   int i,mean_total = 30;
   float mean = 0,mean1 = 0;

   set_adc_channel(channel);
   delay_us(100);
   for (i=1; i<=mean_total; i++)
   {
      mean =mean + read_adc();
  delay_us(100);
   mean1=(mean/mean_total);
   }
   return(mean1);
}
main()
{

   const byte current_channel = 0; // sets the channel one to read solar panel current
   const byte voltage_channel = 1; // set to read solar panel voltage
   const byte voltage_battery_channel=2;
   const byte current_battery_channel=4// set to read battery voltage

   float current; // initialising variables
   float battery_voltage;
   float voltage;
   float power_new = 0.0;
   float power_old= 0.0;
   long duty_change = 1;
   long pwm_value;
   setup_adc_ports(ALL_ANALOG); // setting up all port a as analog
   setup_adc(adc_clock_div_32);
   setup_ccp1(CCP_PWM);
   setup_timer_2(T2_DIV_BY_1, 99, 1);// pwm frequency 50KHz
   set_pwm1_duty(60)
   delay_ms(1000);

   while(TRUE) {
  
   current = mean_adc(current_channel);
   voltage = mean_adc(voltage_channel);
   battery_voltage=mean_adc(voltage_battery_channel);
   battery_current=mean_adc(current_battery_channel);
   power_new = current * voltage;
      if (battery_voltage > 517 || battery_current>670) // 517 corresponding to 14.4 battery voltage and 670 corresponding to 3A
     {
        set_pwm1_duty(0);
         output_high(battery_charged);
      }
      if (power_old >= power_new) {
         duty_change -= duty_change; // decrease duty cycle
               }
       else if (power_old<power_new)
       {
       duty_change += duty_change; // increase duty cycle
       }
      power_old = power_new;
      pwm_value =pwm_value+ duty_change;
      if (pwm_value > 160)// maximum duty cycle
      {
      pwm_value = 160;
      }
         else if (pwm_value< 36)  // duty cycle minimum
         {
         pwm_value = 36;
         }
     if (voltage<429)//429 CORRESPONDING TO 12V
     {
        pwm_value=0;
        out_high(night_voltage);
     }
      set_pwm1_duty(pwm_value);    
      delay_ms(1000);
   } // end of while
}   //end main
 
Well thats pic 16f code and your in the 8051 forum! so are you using a pic or a 8051? you are going to confuse me
 
Hi Little Ghostman

I'm going to use PIC. I posted it here because I had already made a related post above. Sorry for the confusion. Thanks.
 
Which pic? The one mentioned above? do you have the CCS compiler? Do you have a schematic? Are you going to make me ask 1000 questions first? lol
 
Thanks.

I can use the one mentioned in the code, i.e. PIC 16f876. This is the block diagram. You can also refer to post #22 above. Let me know if there is still some confusion. I can also get CCS compiler. Thank you.
 

Attachments

  • block_diagramjghddd.jpg
    49 KB · Views: 901
I dont use CCS, but yes it would probably do what you want regarding the block diagram. If you go hat route your question's may be better answered on the CCS forum, most here dont seem to use CCS although it dosnt look much different to most C compilers.
Anyway to answer your question, yes its ok based on the details given
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…