thomasss 0 Posted April 29, 2014 Author Share Posted April 29, 2014 Hi everyone, Let me follow up with my results: (I finally got the time to write this post) First let me thanks everyone who has been helping in the previous messages and particularly enl for the very detailed last two msg. I finally decided to use a table with 1024 values (or every values of the ADC) (my code size was no more than 2782 bytes so I was fine with this) (I understand you can go to better accuracy but I was trying to make the all thing work before going into improving accuracy) Also I am using a MCP4822 (DAC) which have 12bit resolution. The sine and cosine were centered at 1.8V and amplitude peak to peak was 3.6V. How to (easily) construct the table: 1 - use excel: 0-1024 adc cos(x) acos(cos(x)) scaling for DAC 0-Pi A B=1-2/1023*A C=ACOS( D=C*4095/2/PI() E=Round(D) F=DectoHex(E)0 1 0 0 0 01 0.998044966 0.062540732 40.76026482 41 292 0.996089932 0.088460377 57.65312148 58 3A3 0.994134897 0.108359078 70.62189026 71 47 Quote Link to post Share on other sites
enl 227 Posted April 29, 2014 Share Posted April 29, 2014 In the last few weeks, the option of the QMath lib from TI has become available for the G-series and other low end MSP430. Disclaimer: I have not used it, but the docs and benchmark numbers look good The function that covers your application is _QNatan2 (or IQnatan2) for angle output, or _QNatan2PU (or IQNatan2) for cycles per unit output. The benchmark numbers look good, but are not int he ballpark of table lookup. If the amplitudes are not fixed, then this is likely your best option. Code size up a bit, but not as much as with floating point, and no table needed. See: http://forum.43oh.com/topic/5366-iqmathlib-for-ccs/ Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.