By deliberate do you mean 8bits, 12 bits, 19bits??? Are you just wanting to know what was implicitly set (by default) that makes this 16 bit? What is your ultimate goal?
bcf
By deliberate do you mean 8bits, 12 bits, 19bits??? Are you just wanting to know what was implicitly set (by default) that makes this 16 bit? What is your ultimate goal?
bcf
Thank you for your question.
Exactly, I want to know how it subdivides in 1024 steps. Then it should be easy to change it to the desired value.
well i certainely miss something here but, 1024 steps it's 10Bit. you said you want Increase your actual 16Bit resolution.. euh... i'm i wrong or what.
By the way, why using the comparator when a real ADC give you already 10Bit resolution without headache, need few lines of code and no big additional hardware?
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
These lines checks for 1024 passes through the loop and stops if reached.
andlw 0x04 ; Are we done? (We're done when bit2 of
btfsc STATUS,Z ; the high order byte overflows to 1).
All you need to do is change ....
andlw 0x04
..... to .......
andlw 0x02 for 512(9 bits)
andlw 0x08 for 2048(11 bits)
andlw 0x10 for 4096(12 bits)
andlw 0x20 for 8192(13 bits)
andlw 0x40 for 16384(14 bits)
andlw 0x80 for 32768(15 bits)
If you need better resolution it can be done, but needs more changing in the code.
/Ingvar
Thank you so far.
In my current application, I need around 750 steps. Surely I could use 1024 steps right now.
I want to change it to the number of steps wanted, but I have not understood the relation yet.
Please explain the math behind your examples.
Last edited by selbstdual; - 15th September 2006 at 01:42.
The code checks if bit 2 of the high byte of the wordsized variable "counter" is set. If it is, the program has looped around 1024 times, if not it keeps looping.
There is really no math involved, 1024dec = 0400hex = 0000010000000000bin.
You don't want to check for anything more complicated than if a single bit is being set or cleared. That would slow the ADconversion down, not something you want to do. I'm not saying it can't be done, just that it wouldn't be very easy. Especially if you don't know assembler and i get the impression that you don't.
My advice is that you stick with 10 bits(1024) and when the conversion is complete you scale the result to your desired value. That can be done in various ways. Here's a few..... all will scale to 752.
Dummy = ADresult * 752
ScaledResult DIV32 1024
ScaledResult = ADresult */ 188 '752/1024*256=188
ScaledResult = ADresult ** 48128 '752/1024*65536=48128
/Ingvar
What about using
Code:andlw 0x2F0 ; Are we done? (We're done when bit2 of btfsc STATUS,Z ; the high order byte overflows to 1).
Bookmarks