DAC_LPC_1769_Real_Numbers

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DAC_LPC_1769_Real_Numbers

441 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lostman on Thu Apr 16 21:33:15 MST 2015
Dear All,

I have a few set of real numbers ranging from -0.04168 to 0.1257 which I need to send through DAC of lpc1769 and view it in CRO as an analog signal.[I have been able to use the DAC example(ramp generator) provided in the website and able to see the output in CRO]. I have also gathered from the other forums and user manual that only fixed point numbers with 10 bit resolution is possible in lpc1769.

I kindly request if you could give me a direction to represent the above range of numbers to send through 'DACR' register.

Thanking You for your valuable time


Labels (1)
0 Kudos
4 Replies

418 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lostman on Thu Apr 23 02:20:26 MST 2015
Thank you for the suggestion.
I have scaled up the values and it is like 10777,9218,7597,5938,4261,2592,953,-633,-2141,-11919,-23128 etc.
I have 100 such numbers and I have stored it in .txt file and tried to read from there (included stdio.h) and directed to DACR register. But I am not getting any values in CRO. Can you please tell me where was I wrong. Following is my code:
#include "LPC17xx.h"
#include "type.h"
#include "dac.h"
#include "stdio.h"
int main (void)
{
        FILE *myFile;
uint32_t numberArray[100];
        myFile = fopen("C:/Users/Admin/Documents/LPCXpresso_6.1.4_194/workspace1/dac/test.txt", "r");
        SystemInit();
        DACInit();
        while ( 1 )
{
for (i1 = 0; i1 < 100; i1++)
    {
        fscanf(myFile, "%d", &numberArray[i1]);
        LPC_DAC->DACR = numberArray[i1] <<6;
    }
}
}

When I try to print the values in numberArray
it prints as below:
268468160
268468164
268468168
268468172
268468176
268468180
268468184
268468188
268468192
268467796
268467800
268467804
268467808
0 Kudos

418 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by xianghuiwang on Fri Apr 17 17:58:03 MST 2015
you can always design your own protocol as for what represent negative or positive. You can for example use one of the bit in the integer domain to represent negative or positive.
regards,
0 Kudos

418 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lostman on Fri Apr 17 02:03:35 MST 2015
Thank you very much the suggestion.
I have a confusion of whether I can represent those negative values too(in 2's complement form)?
0 Kudos

418 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by xianghuiwang on Thu Apr 16 22:31:24 MST 2015
Hi,
I would suggest you scale up your real number to 10 bit integer and build your external hardware to scale them down to the level you want.
0 Kudos