43oh

# Convert 2 analog signals into 1 with the msp430

## Recommended Posts

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

##### Share on other sites

Why would you want to convert back to analog and what would the output represent?

##### Share on other sites

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

##### Share on other sites

If you need a better DAC, try Microchip's MCP4822 or MCP4821. Low cost, 12bit, SPI, internal ref, dual or single channel. I can show you how to make them work with MSP430.

Other than that, you will have to bias your inputs, so the voltage on the input side is 0-Vcc. A simple math will take care of converting ADC values to what you will send to DAC.

##### Share on other sites

I think you could use something like the CD4066 to multiplex-scan the analog signal. the problem is it would half the horizontal resolution of your ADC I think. Take it with a grain of salt though, I'm not 100% sure.

##### Share on other sites

Quick side note: If you want a better ADC, use an MSP430F2013. It has the Sigma-16 16-bit ADC and should work in the Launchpad (haven't tried it, but I see no reason why it shouldn't...).

Cheers

TomKraut

##### Share on other sites

(I faintly remember I did, and it worked indeed.)

##### Share on other sites

I have used the F2013 with the launchpad. and the differential inputs are great, and the 16bit SDA has moe then enough resolution.

##### Share on other sites

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

##### Share on other sites

You could get the full resolution of all four analog readings by using serial communication between the Launchpad and LabView. That would also allow you to do the arctan(sin/cos) calculation on the PC rather than on the MSP430.

##### Share on other sites
You could get the full resolution of all four analog readings by using serial communication between the Launchpad and LabView. That would also allow you to do the arctan(sin/cos) calculation on the PC rather than on the MSP430.

That's a great idea! Since the F2013 doesn't have the USCI module, one would have to use software UART. Look into the Codevault section in the forums, there should be something there you can use. Also, the F2013 can be clocked by a high speed crystal, not just am active oscillator like the G2xxx usually used in the LaunchPad. This might help to achieve a higher baud rate than 9600. You can then use an USB-UART cable to connect the LaunchPad to the PC. There are ready-to-use cables from FTDI (expensive), or you can use an old cellphone data cable, there are tons of guides for converting one on the internet.

Cheers

TomKraut

##### Share on other sites

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.

##### Share on other sites

If you are looking for 16bit DAC, how about DAC8411, DAC8560, or DAC8551. 8411 uses Vcc as Vref, 8560 has an internal 2.5V reference.

##### Share on other sites

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.

s

Huh, Its my fault not yours, somehow I totally misread your post and thought you were trying to read two analog signals with 1 ADC, when in fact you were doing nothing of the such.

##### Share on other sites

Not being a student anymore, I wasn't able to download the myDAQ manual...

If it has a large enough sample buffer and sampling frequency for the digital I/Os you could use PWM to transfer the ADC values:

- Have the MSP periodically sample the four analog values

- put out PWM signals with a duty cycle equivalent to the analog values on four different pins

- sample the PWMs with your myDAQ for at least one full PWM period at at least twice the PWM clock

- transfer the samples to the PC

- count the high values -> that's your sampled voltage

If this is possible depends on the capabilities of the myDAQ. If it is, you won't need any additional hardware besides a LaunchPad; your sponsor might like that ;-)

Cheers

TomKraut

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
• Blog

• #### Activity

×
• Create New...