analog out can not shows array value on the dac.

14 Dec 2012

In below code i have stored the sensed current in variable I_a,I_b in array form , I trying to show this waveform on the DAC (pin 18,analog out),but i did not get any waveform on the pin18. i can not understand why the pin 18 not showed any output. is this due to the limited RAM of the Mbed controller? if i want to see the array variables on the Pin 18 then, i need to use any other instruction to do this things.

#include"math.h"
#include"mbed.h"
AnalogIn Ia(p19);
AnalogIn Ib(p20);
DigitalOut led1(LED1);
AnalogOut Aout(p18);
Timer t;


main()
{double I_a[5],I_b[5],I_c[5],Ibeta[5],x=0.5774;

while(1)
{
 for(i=0;i<5;i++)
 {
    t.start();
    I_a[i]=Ia*66;
    I_b[i]=Ib*66;
    I_c= -(I_a+I_b);
    Ibeta[i] = (x*I_a[i])+(2*x*I_b[i]);
    
    led1=1;
    
    Aout = Ibeta[i]/66;
    t.stop();
    t.read();
   }}
}
14 Dec 2012

Here is 66 is multiplying factor.

14 Dec 2012

The AnalogOut object needs a float to be written to it. This might be the problem? Try using floats instead of doubles. Additionally the range should be from 0 to 1 so check your equations will give answers in this range.

14 Dec 2012

#include"mbed.h"
#include"math.h"
#include"mbed.h"
AnalogIn Ia(p19);
AnalogIn Ib(p20);
DigitalOut led1(LED1);
AnalogOut Aout(p18);
Timer t;
Serial pc(USBTX, USBRX);

//double x=0.5774;
int i;
main()
{
float I_a[5],I_b[5],I_c[5],Ibeta[5],x=0.5774;
while(1)
{
 
 for(i=0;i<5;i++)
 {
    
    t.start();
    I_a[i]=0;
    I_b[i]=0;
    //I_c= -(I_a+I_b);
    //Ibeta[i] = (x*I_a[i])+(2*x*I_b[i]);
    
    //y=Ibeta[i]/66;
    
    //led1=1;
    
    //Aout = Ibeta[i]/66;
    
    pc.printf("arrary is= %f ",I_a[i]);
    t.stop();
    t.read();
    pc.printf("value is = %f sec",t.read());

}}
}

thanks you martin for your replied

as you suggest, i am using the float datatype in places of double and tried above program.

in case of no any input of analog in it has to show me zero value but in actual case it will shows me some random values on the screen. does any modification in code required?

06 Feb 2013

it is possible i have done... Data type of the declare variables is important things. it is also cause of error in programs.