Heys guys,just writing some code to display an analog signal on a lcd,below I've wrote some code to take in analog signal and display its result on port 2.So now I guess instead of display it on port 2 I want display it on the lcd.So just wondering can I manipulate the signal going into AD0DAT1 register in order to display it on the lcd?
# include <REG935.H> void main() { P2M1=0x00; //output P2M2=0x00; P1M1=0x00; //lcd P1M2=0x00; P0M1=0xFF; //set as input for analog signal P0M2=0x00; ADINS=0x02; //set ad01(P0.0) for sampling ADCON0=0X04; //ADC channel 0 enabled ADMODB=0x40; //sets to divide by 3,for accuracy ADMODA=0x02; //fixed channel,continous conversion,until terminated by user while(1) { ADCON0 |= 0x01; //start conversion,immediate start mode while((ADCON0 & 0x08) == 0); //wait for end of conversion ADCON0 &= 0xF7; //clear EOC flag P2 = AD0DAT1; //output result on to port 2 } }
What does your spider senses tell you?
Doesn't the type of LCD and the way it is interfaced drastically change what code you need to present information on it? How are we expected to know what hardware you have? or if you have a text panel where you want to display the ADC value as digits (0.15V) or maybe a graphical panel where you want to plot the ADC value as a curve over time? Or maybe just let the ADC value control the length of a bar on the display?
Well I thought I could just simulate it first using the development board peripheral in the keil environment without using any hardware.
You are still ignoring the issue. What kind of LCD? Connected how?
Simulating? All depends on how believable the simulation is expected to be. Just print to a serial port is a very low-quality simulation. Having something that behaves identical to the real LCD, requiring identical source code is the high-quality way of simulating. There exists a plugin module that behaves like one kind of LCD and that can be interfaced with the debugger. Applicable? That very much depends on what real LCD you planned to use.
The LCD I would be using would be a 16x2 alphanumeric,I will upload a picture of how I'm connecting it soon hopefully
The link below is currently how I'm trying to simulate the lcd in code http://omg.wthax.org/lcd.jpg
So how do you intend to display the analogue value: as a bargraph? as a numeric sample value? or what??
As a numeric value
So it's just a question of displaying a numeric value on a text display.
Where, exactly, are you stuck with this?
No its more a case I want to display the analog value I'm sampling on the lcd. But in order to do this I think I may have to convert the value to ASCII in order to display it on the lcd.
Of course you will - it's a text display!
The source of the number is irrelevant.
im stuck at a similar point, as any one got any useful info, like how to convert it to ASCII
Any decent 'C' textbook will describe the functions available in the standard 'C' library...
You can then check specific implementation details in the Keil manuals:
http://www.keil.com/support/man/docs/c51/c51_library.htm