Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 24th May 2004, 04:36 PM   (permalink)
Default how to compare a two digital numbers ??

i'm using assembly to program PIC16f876 and i sued the A/D converter to convert an analog input into a 10 bits digital number .. now i want to generate an 8 bits digital output that represent the input number .. how can i do that ??
zika1212 is offline  
Old 24th May 2004, 05:29 PM   (permalink)
Default

You'd just right shift the whole 10 bits twice, discarding the two LSBs. That is, if you intend to use the whole scale. If you're measuring a signal that is always small, maybe you'd want to drop the 2 MSBs instead and limit your capabilities to 0-1.25V instead of 0-5V.
Oznog is offline  
Old 24th May 2004, 10:06 PM   (permalink)
Default

It's even easier than that, there's a bit in a register you can set that either right justifies or left justifies the 10 bit word, see my analogue tutorial (or the datasheet) for details. It's the ADFM bit in the ADCON1 register, by clearing it you get an 8 bit result in ADRESH.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Reply

Bookmarks

Thread Tools
Display Modes





All times are GMT. The time now is 05:50 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker