During the experiment potentiometer is arranged in a manner that makes it possible for ADC to be carried out. Values obtained from ADC are changed to digital. This is then transferred to LCD to be displayed.
Various codes were developed to aid in the experiment. They include:
Put the code here
Variable ‘adc_value’ refers to the value of the adc returned by the function ‘read_adc()’. POT means 0x48 representing the pot in the ADCON0 which is sent to variable ‘setup adc’. This helps in setting up the adc and starting the ADC as it sets ADON=1. Meanwhile, loop 1 wehich is the fuction read adc reads values for adc. The return is stored in variable ‘adc value’. It is in the function that variables are defined while GO=1 is positioned to begin conversion. Till the conversion is over, GO==1 plays a major role.
Once the changing/convertion is over num is where the obtained data is transferred to. It is then taken back to the main function. The value adc is transferred to LCD to be displayed. After this, the whole systems/the program goes back to the main function performing similar operations of constantly reading adc values.
Result & Conclusion: It is established that the entire program was free from errors. Additionally the program was put into test through developmental boards. The exercised generated a program that was capable of setting up adc, reading data from the adc values, converting them to digital and showing the results through LCD. This can be seen in the figure shown below;
TAKE THE PICTURE OF THE LCD AND PUT IT HERE AKHI
In conclusion, the experiment was a success in teaching how to go about setting up of adc as well as using microcontroller in taking readings from potentiometer as well as displaying it via LCD.
Introduction: the experiment entails calibration of ADC. This is done by taking records of varying outputs of potentiometer. For instance at 0 Volt adc value which corresponds with it is recorded. From the outcome atable is generated which in turn help in obtaining adc. A formula for adc resolution is input voltage/digital ouput of adc. For instance at 5 volts at 1023 maximum digital out put; adc resolution is 5/1023=0.0048875
Conclusion: it is established that differing values of results from potentiometer, the corresponding ADC values after measuring and tabulation shows that adc resolution is 0.0048875.
Introduction: the experiment is carried out like in experiment 1. And data is shown via LCD. However, instead of convering the data into digital, it is changed into analog value then showed via LCD. Conversion of adc value to the equivalent voltage was done by use of the formula; Analog=(adc_value/100) * (493.1034/10);
Major codes of the program:
In order to show the values obtained (voltage) through LCD ‘analog’ as a variable is transferred into the function labelled ‘display_voltage_value’. It is worth noting that this conitunes while the code enclosed in loop 1.
Result and Conclusion: The experiment entailed modification of experiment 1 in order to depict voltage read from the potentiometer on the LCD. The whole exercise worked without errors and attained it objectives of showing adc values and voltage on LCD
Introduction: Resistors that depend on light do generate electric volt once an incident light fall on the resistor. LDR is linked to developmental board. It is worth to note that the set up of the program is similar to that in experiment 1. Nonetheless, it is different in terms of initialization of ADCON0 register. For this experiment ADCON0 is set at 0x80. ADC is switched on by utilizing ADON=1
Following is the main code:
The rest of the processe is similar as that carried previously in loop 1. The function adc reads the values adc from LDC. It eventually takes back the value to the program where adc value is stored. The program is distinct from the previous one as adc values are sent to PORTB lighting up LEDs representing adc values from LDR. This happens continuously since it is enclosed in loop 1.
Result and Conclusion: the experiment used LDR in accepting outputs as well as performing conversion of adc values to be shown in LEDs of the PORTB. The program was free of error and worked well in attaining the objectives. To establish that the program was working, it was observed that with varying fall of incident light on the resistor, there were varying values on LEDs.
Various appliances that are analog need to be interfaced to a microcontroller for us to make calculations. In order to attain this, there is need of converting analog data into digital through adc conversion. A greater foundation is on use of adc program by help of LDR and potentiometer.