hear is my code for:
LTC1660 Eight Channel and
LTC2630 Single channel.
<>Code
- include "mbed.h"
DigitalOut myled1(LED1);
DigitalOut myled2(LED2);
DigitalOut myled3(LED3);
DigitalOut myled4(LED4);
SPI spi (p5, p6, p7); mosi, miso, sclk
DigitalOut LTC_1660_CS (p22);
DigitalOut LTC_1660_CLR (p21);
DigitalOut LTC_2630_CS (p23);
Serial pc(USBTX, USBRX);
AnalogIn Therm1(p15);
void LTC1660_Set_DAC_Value (char Channel, int Value);
void LTC2630_Set_DAC_Value (int Value);
void GetTemperatyre (void);
int main()
{
int Pattern = 22;
pc.baud(921600);
pc.format(8,Serial::None,1);
pc.printf ("\r\nIt Lives ..."); Serial pc(USBTX, USBRX);
set up LTC 1660 .. Vout = 0 ...
force LTC1660 ADC's Low ..
LTC_2630_CS = 1;
LTC_1660_CS = 1;
LTC_1660_CLR = 1; wait_ms (50);
LTC_1660_CLR = 0; wait_ms (50);
LTC_1660_CLR = 1; wait_ms (50);
LTC1660_Set_DAC_Value (2, 0);
LTC2630_Set_DAC_Value (0);
wait (0.5);
myled1 = 1;
while(1)
{
while (++Pattern < 1000) 40% of 3.3V = 1.32V, R sens = 1.65 Ohms (3R3 || 3R3)
{
LTC1660_Set_DAC_Value (2, Pattern);
LTC2630_Set_DAC_Value (Pattern);
wait_ms (5.0);
myled1 = 1;
myled4 = 0;
}
myled1 = 0;
myled2 = 1;
wait (2.50);
GetTemperatyre();
while (Pattern > 1)
{
LTC1660_Set_DAC_Value (2, Pattern);
LTC2630_Set_DAC_Value (Pattern);
wait_ms (5.0);
myled2 = 0;
myled3 = 1;
}
GetTemperatyre();
myled3 = 0;
myled4 = 1;
LTC1660_Set_DAC_Value (2, 0);
LTC2630_Set_DAC_Value (0);
LTC1660_Set_DAC_Value (2, 0);
LTC2630_Set_DAC_Value (0);
wait (1.50);
myled4 = 0;
wait (5.50);
myled2 = 0;
myled3 = 0;
myled4 = 0;
GetTemperatyre();
}
}
======================================================
void LTC1660_Set_DAC_Value (char Channel, int Value)
{
int OUT = 0;
check ranges ..
Channel &= 0x07;
Channel ++;
if (Value > 0x03ff) Value = 0x03ff ;
joine together ..
OUT = Channel;
OUT = OUT << 10;
OUT |= Value;
OUT = OUT << 2;
set all channels ..
OUT |= 0xf000;
send (as 2 bytes)
LTC_1660_CS = 0;
spi.write (OUT >> 0x08);
spi.write (OUT & 0xff);
LTC_1660_CS = 1;
}
=============================================================
void LTC2630_Set_DAC_Value (int Value)
{
int OUT = 0;
check ranges ..
if (Value > 0x03ff) Value = 0x03ff ;
joine together ..
OUT = Value;
OUT = OUT << 6;
send (as 2 bytes)
LTC_2630_CS = 0;
spi.write (0x30);
spi.write (OUT >> 0x08);
spi.write (OUT & 0xff);
LTC_2630_CS = 1;
}
=============================================================
void GetTemperatyre (void)
{
float T_ADC = Therm1.read();
float C, C3;
11.239x2 - 61.705x + 94.628
T_ADC = T_ADC * 3.3;
C = ((11.239 * (T_ADC*T_ADC)) - (61.705 * T_ADC)) + 94.628;
C3 =(-12.727*(T_ADC*T_ADC*T_ADC))+(69.111*(T_ADC*T_ADC))-(140.49*T_ADC)+123.77;
printf ("Temp ADC Value = %3.6f - %3.6f Deg C - Third Order .. %3.6f Deg C\r\n",T_ADC, C, C3);
}
<>
sorry cannot remember how to mark up code snippets
Hello Everyone
I am trying to setup and use an AD5666 SPI quad DAC chip. The datasheet is here http://www.analog.com/static/imported-files/data_sheets/AD5666.pdf
I have tried the program below and I get nothing out on any of the DAC channels. I dont see what I am doing wrong?? I tried changing the SPI mode to 0-3 with no change in results. Please take a look and offer any thoughts as I'm stumped for now.