Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

adc value*10

Status
Not open for further replies.

bee

Member
Hi
I have got the 8 bit value from the adc and need it to give me 10 readings over the 0 to 5 volt analog input. At the moment i am xoring it with known values but i need to read all the values upto each known value. I cant do this 255 times it would be to long surely.If anybody could point me in right direction

pic = 12f675
code = asm
programmer = new

Any help much appreciated

bee
 
Thanks be80be
I will read through this looks good, still looking for asm code examples
regards
bee
 
I am reading from 0 to 5 volts ie 0v to .5v would be one step then .5v to 1v and so on my code only reads at a certain value.

bee
 
You can use subwf to compare two 8 bit numbers. Throw away the result, and check the C flag in the STATUS register to see if one is lower than the other. The Z flag in the STATUS register will tell you if they are equal.
 
Something like this??

Code:
Main	movlw	.25
	movwf	Compare
	movlw	.1
	movwf	Value

Loop	call	Read_AD
	movf	ADRESH,W
	subwf	Compare,W
	btfsc	STATUS,C
	goto	Got_Val
	movlw	.25
	addwf	Compare,F
	incf	Value,F
	movf	Value,W
	xorlw	.11
	btfss	STATUS,Z
	goto	Loop
	goto	Main
	
Got_Val	----			;Value = result

There is an error in the above 250 ADC result you can fine tune it to your needs.
 
Last edited:
Thanks kchriste
Have you got a code snippet of this it would be easy for me to understand
what you are talking about

bee
 
Different example from Gayan's if his wasn't clear enough for you:
Code:
		movlw .25          ;Number to compare ADRESH to.
		subwf ADRESH, W
		btfss STATUS, C
		goto less          ;ADRESH less than 25
		;Skip to here if ADRESH greater than or equal to 25
 
Last edited:
Thanks a lot all you guys tried it tonight and it works very well reads all the values inbetween exactly what i wanted it was made simple thanks for your help.
Regards
bee
 
The pickit1 has some real good asm code for the 12f675 and it tells about using
analog its well wrote if you havn't looked at it you can find it here.

**broken link removed**
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top