43oh  # thomasss

Members

14

## Posts posted by thomasss

### MSP430G Series Got the QMathLib and IQMathLib from TI

Alright,

This works better:

```#include "msp430.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

#include <QmathLib.h>

_q12 _Q12div(_q12 A,_q12 ;
_q12 X = _Q12(1.0);
_q12 Y = _Q12(7.0);
_q12 alpha;

int main(void)
{
alpha = _Q12div(X ,Y);

return alpha;
}
```

That would be nice to have a small code like this for other functions though. Please post if you have been using other ones.

Thanks

### MSP430G Series Got the QMathLib and IQMathLib from TI

Guys,

I mean, they have a crazy example Signal_FFT but how is this supposed to help me understand the basic functions? Why don't they have a quick example to show how each function is working?

I am trying to just do a division: (how can this be so damn hard to do a DIVISION!) ( Don't get me wrong, I am really glad  they come up with this Qmath library, Thank TI, But please make it easier to understand)

Here is the code I tried:

```#include "msp430.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

#include <QmathLib.h>

int main(void)
{
_q12 f1 = _Q12(7.0);
_q12 f2 = _Q12(1.0);
_q12 f3 = _Q12div(f2, f1);

return 0;
}
```

I have a breakpoint just before "return 0;". When I run this f1 turn to be 0 and f2 turn to be 585. So 1/7=0.142857 and 1/7*2^12=585.14.

So f3 should be 585, not f2. And why f1 =0?

I also tried their code:

```#include "msp430.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

#include <QmathLib.h>

int main(void)
{
_q12 X, Y, Z;
X = _Q12(1.0);
Y = _Q12(7.0);
Z = _Q12div(X ,Y);

return 0;
}
```

CCS tell me there are errors in this code and don't even want to load the code in the msp430.

If someone has been able to make the Qmath library work, I would really appreciate some help as i spent 2 hours just trying to figure out how to do a division and it is still not working.

Thanks in advance for you help.

### floating point - Math - and Trigonometry with msp430g2553

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`

### floating point - Math - and Trigonometry with msp430g2553

Alright I like the idea of the look up table. You think the table may be too big to fit into the 16k of memory of the msp430 ?

I will have to do more testing on my input signals to see if they may vary in scale. If they don't vary too much I can generate my table on excel or something and input this into the msp430.

Is the look up operation time intensive or is it a fairly quick operation ?

### floating point - Math - and Trigonometry with msp430g2553

grahamf72, I looked at the library code that you uploaded on http://forum.43oh.com/topic/4291-energia-library-fixed-point-math/

Do you think it will compile on CCS ?

And would you have a code example by any chance to explain how you use the code ?

In fix16_trig.c the first line is #include <limits.h> but I can't find the limit.h file in the zip

Right now my code looks like this:

unsigned int getPosition() {
return  theta
}

I get the two values from the adc and I just added them to test that the adcs to dac transfer was good.

How would I include the code in here to use thefix16_atan2 function ?

Thank you so much guys

### floating point - Math - and Trigonometry with msp430g2553

Thank you grahamf72, 1/65536 resolution is plenty for what I need I think.

enl, thanks for the input. I am trying to recover the angle on the 4 quads yep. What other ways are you talking about ?

I think if I get the angle on -Pi/2...Pi/2 I think I can just do:

For Va < 0 and Vb < 0, subtract 180

### floating point - Math - and Trigonometry with msp430g2553

Hi Everyone,

Thanks all of you for your help. I didn't know about Energia but will look into it. Is it better than CCS ?

So if I understand well libfixmath is approximate math functions that only requires integers. Let's say I have the calculus atan(0.5)=~0.463 648 then you could find a function that do "atan"(500 000)=463 648.

am I right ?

Actually I have 2 ADC inputs (Va, Vb) and one DAC outputs (Vc) and I want to do Vc=Arctan(Va/Vb). Right now I only have a 10 bit adc so the resolution is limited to that. However the sensor has an accuracy of 0.0001. My future plan will be to switch to a 12 bit adc.

Is libfixmath powerful enough for this accuracy ? Should I just switch to the Tiva C Series instead ? Is it easier to use the Tiva C Series ?

So I have a signal Va=0..1024 , Vb=0..1024. It is the sine and the cosine of an angle. And I want to extract the angle Vc=0..1024.

What's the easy way to do this ?

Thanks again for your kind help

### floating point - Math - and Trigonometry with msp430g2553

Hi Everyone,

I have been looking for about an hour online and haven't been able to find the answers to these questions.

- Can I use floating point with the msp4302553 ? the watch expression on CCS don't seems to like floating point for sure.

- Can I use math.h to do trigonometry calculus on the msp430g2553 ?

Let me tell you guys what I am trying to do so that it is more clear:

I am scanning a signal with an ADC. I would like to do an atan() on the signal and output the signal with an DAC.

Right now I can scan the signal and send it to the DAC. This works well. But I can't get the trigonometric conversion to work.

Is it possible to do it? And if yes could I get a little help from you guys ?

Thomas

PS: I saw about these Qmath functions that came out recently but couldn't get it to work either

http://www.ti.com/tool/MSP430-iqmathLIB?DCMP=ep-mcu-msp-iqmath-en&HQS=ep-mcu-msp-iqmath-pr-sw2-en

### Convert 2 analog signals into 1 with the msp430

That's awesome! Thanks a lot robG!

I am going to try this code as soon as I can.

Thomas

### Convert 2 analog signals into 1 with the msp430

Hi guys,

How long don't you think it should take to do this for:

- someone who knows the msp430 really well ?

- A senor in undergrad study of computing ?

- A graduate student with average knowledge in computing ?

I need to know how long this is going to take me or I will try to get someone to do this.

Thomas

### Convert 2 analog signals into 1 with the msp430

Hi guys,

I know thats not going by the DAC would give us a better resolution in our sensors but our project is sponsored by NI and they want us to make a system they we could entirely connect to the myDAQ. Moreover I like the idea of using ADC-msp430-DAC because we would create a sensor that anyone could use later by just connecting it to their project.

That's the main reason I want to go more on getting the signal out by the DAC.

I don't know if I could use a Digital output of the myDAQ to do something like serial communication. That may be a way to explore.

### Convert 2 analog signals into 1 with the msp430

Hi guys,

Thanks a lot for your help, that's awesome!

I was actually wondering if I could get a better resolution for the ADC. If you guys say that I can use the F2013 which has a 16bit DAC, it's perfect.

RobG, I would love that you help me getting a better DAC. Do you think I could even find one that can go up to 16bits ?

touch, I didn't really understand the story of the CD4066. What do you mean by multiplex-scan the analog signal ?

Sorry if I am not that familiar with this vocably.

So up to now I have been working on getting more familiar with the launchpad.

Here is what I got inspired from:

I have been able to make the oscilloscope works:

Do you guys think could help me finding some part of code that I could use again for my problem ?

If my message is too spamy I am sorry.

Thanks again,

Thomas

### Convert 2 analog signals into 1 with the msp430

Hi RobG,

The output would represent the angular position of the axis. The relation between the angular position of the axis and the voltage output would be linear. 3.6V would represent a 360degree position, 1.8V would represent a 180degree position,...

There is 2 reasons why I want to convert back the signal to analog. The first reason is that it would make an angular position sensor easy to use because the output voltage would be a linear function of the angular position. The second reason is that we want to control our system with Labview after and we are using a myDAQ which as only 2 analog inputs. The problem is that we want the angular position of 2 axis. We have 4 analog signal from the sensors right now and we want to convert this into 2 to be able to use Labview.

Thomas

### Convert 2 analog signals into 1 with the msp430

Hi everyone,

I am working on a project for a robotic class and I am trying to convert 2 analog signals into 1. I was thinking about using the msp430 to do this but I am a mechanical guy so I am having a hard time. Let's say I am acquiring the 2 signals with 2 ADC channels, I do the operation on the 2 signals and output the result signal with the DAC. Do you guys think it's a good idea ?

My problem is also the accuracy of the resulting signal. The ADC is 10 or 12 bits as I have read and the DAC is only 8 bits. Is there an easy way of adding a better DAC to the msp430 ?

Here, I detail why I want to use the msp430 to do the operation on the 2 signals:

I am trying to make an angular position sensor with 2 hall effects sensors. If you rotate a magnet in front of a hall effect sensor you get a cosine curve. The problem is that if you rotate +30 let say or -30 the sensor would give you the same intensity so you actually don't know if you are turning left or right. If you place a 2nd sensor with a 90degree angle from the other one you get a sine curve. So my code is: You take the angle from the 1st sensor and if the second one is positive it means that you are turning right and negative means you are turning left. I hope you can understand this better by looking at the picture I attached

I apology for my poor English. I come from France.

Thanks for taking the time to read this,

Thomas ×
• Blog

• #### Activity

×
• Create New...