Ok you are right it is not addition but I mean
the 10 bits 1024 represents a position from a potmeter
in order not to change the fysical position i would like to add or substract an offset
but finnaly need to keep the 10bit resolution for further calculation
But I dont now how to do that
any help welcome
Ok, I think I understand it now. You want to move the physical position of the pot in code.
You will be able to offset the reading. But the part that you've discarded due to the offset will be lost, so you cannot expect the full 10bits once you do this.
JF
Hi, RF
Could you be more precise about what you want to do ...
The physical position of WHAT ???
i.e. read a pot with ADC , and from this reading show the pot angle, then place a servomotor's arm ... or what ???
Skimask's answer is one of the numerous possibilities ... consider it !!!
Alain
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Hi Alain and others
Well I read a potmeter or other position encoder which is 10bit for full resolution
or equal to 1 single turn
Later I will convert this to Degrees (which is no problem)
But i would like to keep the maximum resolution to 10bit
but shift in the software the actual position instead of moving the potmeter mechanicaly
example
0 deg = 0V, 5V = to 360 (1024) or 10bit
imagine that the true 0 degree is at a value of 120 (decimal) and I dont want to move
the mechanical position of the potmeter but would like to see 0 as a decimal value
SO i would like to implement an offset of 120 decimal
whitout touching the 1024 10bit resolution for 1 revolution
I hope this is more clear
Walter
So why not ADD an offset of 120 (using your example)...
That way zero will be in reality -120, 120 will be zero, and 240 is actually +120 ???
This way you will never go below zero, because zero is your REAL reference point, and your offset value is actually your mechanical zero.
Simple maths prior to displaying the figures will have it display whatever you want it to display.
thank you melanie
Well this is what i want to do and would show on the display:
I read the Real position from the encoder as a 10bit word (0-1024) as the encoder is absolute
i might want to add or substract an offset so that how the encoder mechanicly is fixed
i still can correct it by the offset but need to keep 1024 as resolution for 1 revolution
So i want to display or have new variables with:
the position +/- it's offset but between 0 and 1024
Conversion of the position +/- offset to 0 - 360 deg (keep the 10bit resolution)
I dont see how I can do that
Can you point me out ?
Hi Melani and others
Well the problem is as followed:
The application which is reading the encoder via a serial port expects a 10bit value
where 0 is 0 and 1024 is 1 resolution (or 360deg)
So this application does the mathematics for conversion
So the meaning of my offset value is to avoid that i have to move the encoder physicaly to its true zero point
So i would like to keep the resolution of 1024 but shift it around (if i may call it shifting)
in a way that i will keep a 10bit value
I dont see how to do that
maybe you might have some help
Thanks in advance
Walter
Either we're not getting it (not likely) or you're not getting it (more likely)...
If you're converted/offset value is out of range after the calculations, then put it back in range.
Example...
You had read 300 degrees, now you add an offset of 100 degrees, that gives you 400 degrees, well, that's no good, 'cause 400 degrees is out of range, but we both know 400 degrees is actually 40 degrees past 360 degrees, so subtract 360.
Further example...
You had 10 degrees, now you need to offset that by -50 degrees, which will give you -40 degrees, again, that's no good because -40 degrees isn't in the range of 0 to 359 degrees, so add 360 degrees to -40 will give you 320 degrees which is the answer you want.
Yes, the examples above are in degrees. If 360 degrees = 1024 counts, then add or subtract 1024 counts from any answer that's out of range.
If value => 1024 and value < 64512 then subtract 1024...
If value => 64512, then add 1024...
Question for you...Where did I get that value of 64512?
Here's another thread talking all about this same sort of thing...
http://www.picbasic.co.uk/forum/show...highlight=wind
Bookmarks