Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

right shift

Status
Not open for further replies.

poppy2008

New Member
dear friends i need one help,
i am new to c language, this is a part of one big program,,
using 10bit ADC, 8 bit MCU,vcc 3.3V,MY boss told me to study this program,almost i understand other codes,this portion the bitwise shift i understand but why we have to shift1,4,7,8 like that,and what is 15 in (Iin+15 )i could'nt understand this,
Iin is input current ,unsigned int ,this Iin is using for power calculation and SCI section. pls any one explain this portion,I'll be very grateful for your help
thank you.


Code:
Iin = RMS_Value;  // resolution :0.015625A
             if(Iin < 300)    //7A ,300*3.3/1023 = 0.9677v(mcu i/p) 
             {
              
                Itemp = RMS_Value>>1;  // 1 1000 0000
                Iin = Iin+Itemp;              // 300+480 = 
          
                Itemp = RMS_Value>>4; 
                Iin = Iin+Itemp;
          
                Itemp = RMS_Value>>7; 
                Iin = Iin+Itemp;      
                
                Itemp = RMS_Value>>8; 
                Iin = Iin+Itemp;
                
                Iin = Iin + 15;
             }
             else
             {
                Itemp = RMS_Value>>1; 
                Iin = Iin+Itemp;
                
                
                Itemp = RMS_Value>>3; 
                Iin = Iin+Itemp;
                
                Itemp = RMS_Value>>4; 
                Iin = Iin+Itemp;
                
                Itemp = RMS_Value>>5; 
                Iin = Iin+Itemp;
                
                Itemp = RMS_Value>>7; 
                Iin = Iin+Itemp;     
                
                Iin = Iin - 25;
             }
 
i understand this portion is used for calibration, can any one explain me how it works,
(or) can any one tell how to calibrate the 10 bit adc value ,
please
 
Last edited:
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top