» Home

» Products

» Interfaces

» Lab

» Downloads

» Buy It

» Contact

» Links

|
» Lab » Digital Volt Meter via IrTx
|
| Project: | Digital Volt Meter via IrTx |
| Source Code: | PIC Assembler |
| PIC: | 16F628 |
| Interface: | IrTx |
| Author: | Ravi Deo |
| Last Updated: | 7th April 2005 |
|
Project Description:
This sample PIC project demonstrates how to use a PIC 12F675 with SirPic, to implement
a simple 5 volt digital voltmeter (using the ADC converter).
DVM via IrTx
: Zip file containing ASM and HEX files (approx 4KB).
Hardware Schematic:
Note, that this project assumes the internal 4MHz clock has been calibrated, hence no need for an external 4MHz crystal.
The PIC internal 4MHz clock was pre-calibrated by the manufacturer (OSCAL calibration).
If your PIC is not calibrated, you can modify the code/configuration to use an external 4MHz crystal.

This project makes use of the 12F675's 10 bit ADC channel for sampling the voltage.
The ADC converts the analogue voltage to a 10 bit digital value.
For simplicity we use the 8 most siginifcant bits in ADRESH.
As we wish to only display the voltage reading to two decimal places:
5V/255 = 0.0196078431
However 255*0.01960=4.99V, so we use 0.01964 instead (255*0.01964=5.00V).
The Mul8x16 routine from PicList was used to multiply the 8 bit ADC value with 1964 (16-bit value).
The resulting 24 bit value is displayed up to 2 decimal digits (with decimal point character).
Display output from the PIC is transmitted via the IrTx interface to SirPic running on the Palm.
The code comprises of the following subroutines:
InitPic: Initialises the PIC device
MainLoop: Main loop which refreshes the current voltage reading.
GetADC: Gets the current 8 bit ADC value.
Banner: Displays the project title and version at startup.
Mul16x8: Multiples 8 bit ADC value with 16-bit 1964 value.
ShowDigit: Displays a digit
bcd2a: Converts BCD to ASCII
b2bcd: Converts 32-bit Binary to BCD
TxChIr: Standard SirPic subroutine to transmit char via Infra-Red
SpWaitDelay: Standard SirPic delay routine used by above
SirPic Communication and Options settings should be configured as shown below (Note Text mode):

On starting the SirPic log session, you should see voltage readings being captured.
SirPic IrTx DVM v1.0
2.53V
2.53V
2.53V
Try varying the voltage via the potentiometer (variable resistor) and observe the voltage reading.
|
|