People keep posting code that has lots of blank lines. Why? It just causes me to scroll up/down in order to read it. I can understand one blank line separating routines for readabilities sake but every other line blank is just annoying.
Is it just me?
Mike.
Edit, this is in no way aimed at elec123. Sorry to use your code as an example.
P.S.
Here is what I mean.
Posted earlier,
My version,
Is it just me?
Mike.
Edit, this is in no way aimed at elec123. Sorry to use your code as an example.
P.S.
Here is what I mean.
Posted earlier,
Code:
void main(void);
void Initialize_ADC(void);
void main()
{
unsigned char dig_input;
unsigned char frank;
Initialize_ADC();
while(1)
{
//Read_ADC
ADGO = 1; //captures analogue voltage on pin.
frank = 0x10;
while(frank != 0x00)
{frank -= 1;}
while (ADGO)
{}
frank = 0xFF;
while(frank != 0x00)
{frank -= 1;}
dig_input = ADRESH; //defines the digital input.
if (dig_input<128)
{
CCPR1L = 0x00; //sets pwm to have duty cycle of zero.
CCP1CON = 0x00;
}
else
{
dig_input -= 128; //dig_input = dig_input-128
dig_input += dig_input; //multiplies dig_input by 2
CCPR1L = look1[dig_input];
CCP1CON = look2[dig_input];
}
}
};
void Initialize_ADC()
{
TRISA = 0x01;
TRISC = 0x00;
PORTC = 0x00;
PR2 = 0x18;
T2CON = 0x05;
ADCON0 = 0x80; //clear ADCON0 A2D starts sampling again.
//Set ADCON1
ADCON1 = 0x00; // clear ADCON1 register.//
ADCON1 = 0x02; // set PCFG1 bit i.e AN0 is analogue input.
ADON = 1;
};
My version,
Code:
void main(){
unsigned char dig_input;
unsigned int i;
Initialize_ADC();
While(1){
//Read_ADC
ADGO = 1; //captures analogue voltage on pin.
while (ADGO);
dig_input = ADRESH; //defines the digital input.
if (dig_input<128){ //if solar panel (Vin) to boost converter is less than 10V don't boost.
CCPR1L = 0x00; //sets pwm to have duty cycle of zero.
CCP1CON = 0xc0;
}
else{
dig_input -= 128; //dig_input = dig_input-128
dig_input += dig_input; //multiplies dig_input by 2
CCPR1L = look1[dig_input];
CCP1CON = look2[dig_input];
}
for(i=0;i<1000;i++);
}
}
Last edited: