Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.
/**
* Zero-Latency Exponential Moving Average.
*/
float zlema(float* vals, int numVals, int currentSample)
{
static float factor = 0;
static int lag = 0;
static float lastema = 0;
float ema;
if(currentSample <= 1)
{
ema = vals[0];
factor = 2.0 / (((float) numVals) + 1.0);
lag = (numVals - 1) / 2;
}
else
{
ema = (factor * ((2.0 * vals[0]) - vals[lag])) +
((1.0 - factor) * lastema);
lastema = ema;
}
return ema;
}
...
static long cs0 = 0;
for(int cnt = NUM_AVERAGE_VALS - 1; cnt > 0; cnt--)
{
m_arrAct0AverageVals[cnt] = m_arrAct0AverageVals[cnt-1];
}
m_arrAct0AverageVals[0] = lPos;
float lPosNew = zlema(m_arrAct0AverageVals, NUM_AVERAGE_VALS, cs0);
cs0++;
...
Would be extremely grateful if someone with a better understanding of the math could please sanity check this for me to see if I've got anything slightly wrong?Add your voice to the tech community where 5M+ people just like you are talking about what matters.
float y[NUM_VALS -1];
float dy;
float A;
y[0] = 0;
for (int cnt = 1; cnt < NUM_VALS; cnt++){
dy = (u[cnt] - y[cnt-1])/A;
y[cnt] = y[cnt-1] + dy;
}
function NextOutput(float input,float A){
static float dy = 0;
static float y = 0;
dy = (input - y)/A;
y = y + dy;
return y;
}
Copy-of-Low-Pass-Filter.xls
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.