sean2k5
Newbie level 2
- Joined
- Jan 5, 2013
- Messages
- 2
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,300
well my code to get pretend voltage from a 10k pot works great sometimes but others it will show random things even sometimes on the wrong line
im using mikroC and a pic 18f4550
what i thing is wrong is FloatToStr because if i remove that part of the code everything is great
please help me and thank you
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
int raw ;
float convert;
float volts ;
char strDisplay;
void main(){
OSCCON = 0x72; // OSCOLATOR
ADCON1 = 0x0E; // all pins digital but AN0
CMCON |=0x07; // Disable comparators
TRISA.F0 = 1; // Switch Location set to in
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Cmd(_LCD_CLEAR);
while (1){
raw = ADC_Read(0);
convert = raw * 0.0048875855327468;
volts = convert * 4.0;
FloatToStr(volts, strDisplay);
Lcd_Out(1, 1, "Pretend Volts is");
Lcd_Out(2, 2, strDisplay);
Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);
}
}
im using mikroC and a pic 18f4550
what i thing is wrong is FloatToStr because if i remove that part of the code everything is great
please help me and thank you
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
int raw ;
float convert;
float volts ;
char strDisplay;
void main(){
OSCCON = 0x72; // OSCOLATOR
ADCON1 = 0x0E; // all pins digital but AN0
CMCON |=0x07; // Disable comparators
TRISA.F0 = 1; // Switch Location set to in
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Cmd(_LCD_CLEAR);
while (1){
raw = ADC_Read(0);
convert = raw * 0.0048875855327468;
volts = convert * 4.0;
FloatToStr(volts, strDisplay);
Lcd_Out(1, 1, "Pretend Volts is");
Lcd_Out(2, 2, strDisplay);
Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);
}
}