10 years, 8 months ago.

mbed NXP LPC1768: questions about using of AnalogIn and AnalogOut

Hello everybody,

I want to buy the mbed NXP LPC1768 in order to use it for a specific application. In short, I need to read an analogic voltage ("setpoint" ==> see just below), to treat it and after to write an analogic output voltage ("temp" ==> see just below). The body of the code is the following:

  1. include "mbed.h"
  2. include <AnalogIn.h>
  3. include <AnalogOut.h>

void Init(); void Application();

float setpoint, temp, setpoint_in, temp_out; + other variables

*************** Main() - Main Routine *************** void main() { Init(); Initialize the mbed NXP LPC1768

while(1) Loop Forever {Application();} }

*************** Init - Initialization Routine *************** void Init() { AnalogIn setpoint_in(p15); AnalogOut temp_out(p18); + initialization of other stuff return; } void PID() { setpoint = setpoint_in.read(); + computation using "setpoint" in order to calcul "temp" temp_out=write(temp); return; }

My questions are the following:

- what are the impedances of analogic input and output I'm using of the card mbed NXP LPC1768 ?

- Are AnalogIn.h and AnalogIn.h compatible with the card I want to use? I took this from:

- If it's compatible, I saw something strange: it's written on the websites just above that the functons read() and write() convert the signal with 16 bits of precision, but ADC of the card is 12 bits precision and DAC is 10 bits precision, so I don't understand why it's possible to obtain 16 bits precision using the functions read() and write() ?

- For the specific task I want to achieve, the output voltage "tmp_out" need to be filtered with an integrator followed by a low pass filter of second order. I suppose that "temp_out=write(temp);" take the digital signal "temp" and convert it into the analogic signal "temp_out" with the DAC of the card, without any filtering after the DAC? If it's like that, is it possible with the card itself to put an integrator followed by a low pass filter of second order, or do I have to construct these things by myself with electronic components and put them after the output of the card?

Thank you very much in advance for your answer,

Quentin

2 Answers

10 years, 8 months ago.

Hi, Quentin

Quote:

- what are the impedances of analogic input and output I'm using of the card mbed NXP LPC1768 ?

Better check the datasheet

p.65 table 20, parameter Ri1 = 2kOhm to 5kOhm [...] varies with temperature, input voltage, and process [...].

p.65 table 21, parameter RL load resistance min 1kOhm

So, depending on your signal, it may require conditioning.

Quote:

- Are AnalogIn.h and AnalogIn.h compatible with the card I want to use?

You meant AnalogOut.h ;-) Yes, they are made for this type of controller.

Quote:

If it's compatible, I saw something strange: it's written on the websites just above that the functons read() and write() convert the signal with 16 bits of precision, but ADC of the card is 12 bits precision and DAC is 10 bits precision, so I don't understand why it's possible to obtain 16 bits precision using the functions read() and write() ?

Both read() and write() uses a float type value ranging from 0 to 1, which does not mean automatically that the precision beats a 12bits value for input and a 10bits value for output. They will remain in 0..4095 range for input (see AnalogIn's read_u16()) and 0..1023 range for output (AnalogOut's write_u16())

Quote:

I suppose that "temp_out=write(temp);" take the digital signal "temp" and convert it into the analogic signal "temp_out" with the DAC of the card, without any filtering after the DAC?

Correct.

Quote:

is it possible with the card itself to put an integrator followed by a low pass filter of second order,

No.

Quote:

or do I have to construct these things by myself with electronic components and put them after the output of the card?

That depends on your output needs. DAC also may need signal conditioning.

Regards.

Accepted Answer

Thank you very much for your answer Gyozo :)

posted by Atchoum V 27 Aug 2013
10 years, 8 months ago.

Please use <<code>> and <</code>> around your code.

Quote:

- what are the impedances of analogic input and output I'm using of the card mbed NXP LPC1768 ?

15pF for analogIn, but important one is 7.5kOhm max output impedance of whatever you connect to it. I think AnalogOut may drive 1kOhm or larger impedances, but not really clear from the datasheet (http://www.nxp.com/documents/data_sheet/LPC1769_68_67_66_65_64_63.pdf).

Quote:

- Are AnalogIn.h and AnalogIn.h compatible with the card I want to use? I took this from:

You mean just the mbed LPC1768 board? Yeah works with that.

Quote:

- If it's compatible, I saw something strange:

The 'raw' functions use 16-bit unsigned values. That is because other microcontrollers may have more accuracy. But the ones you mention are what the LPC1768 can do.

Quote:

- For the specific task I want to achieve, the output voltage "tmp_out" need to be filtered with an integrator followed by a low pass filter of second order. I suppose that "temp_out=write(temp);" take the digital signal "temp" and convert it into the analogic signal "temp_out" with the DAC of the card

There seem to be some errors in your code, but without formatting that ish ard to see. You need to write a bit different to AnalogOut, see also the documentation you linked earlier.

And yeah the mbed can easily do integration/low pass filtering. You do need to make sure the signal stays within the boundaries the DAC can output.

Thank you very much for your answer Erik. For the integrator and the filter, maybe I wrote something not really clear. I know that it's possible to do these king of things on the digital signal treated inside the program, but I wanted to speak about the analogic signal, after the DAC (to eliminate abrupt voltage jumps due to the digital-to-analogic conversion). And maybe it's not possible to do this with the card, like Gyozo said in his post just below?

posted by Atchoum V 27 Aug 2013

Ah yeah if you want to do it in the analog domain you will indeed have to add your own hardware for that. Especially if you integrate it anyway however, but also if not, there is a good chance those bumps will have no effect on whatever is behind it.

posted by Erik - 27 Aug 2013