Phase Sensitive Detection (Lock-in) help
hi all,
please bare me, i'm quite new arduino , electrical set ups in general i'm mechanical engineer , trying of out first time.
i'm working on project implement phase sensitive detection (psd) in arduino. have sensor set signal. i'm using photoresistor record intensity of light led. simulate random noise set led next sensor , have programmed blink randomly.
now onto meat of project: in order implement there couple things don't know how do.
the first need generate reference signal used multiply sensor signal.
i need signal @ same frequency modulations of source signal. ideally sinusoidal reference opposed square one. can let me know how can done in arduino? i'm using uno if makes difference.
the second need multiply reference signal sensor signal. i'm not sure how either. can done on board electrical components (relatively) easily?
and need send multiplied signal through low pass filter. understand idea of how resistors , capacitors unsure of values should use filter signal.
any further tips or pointers (or corrections on process) on how welcome!
if useful, here current code. modulate "source" led, cause random blinking in "noise" led, , sends me sensor output of combined light intensity.
thank you!
please bare me, i'm quite new arduino , electrical set ups in general i'm mechanical engineer , trying of out first time.
i'm working on project implement phase sensitive detection (psd) in arduino. have sensor set signal. i'm using photoresistor record intensity of light led. simulate random noise set led next sensor , have programmed blink randomly.
now onto meat of project: in order implement there couple things don't know how do.
the first need generate reference signal used multiply sensor signal.
i need signal @ same frequency modulations of source signal. ideally sinusoidal reference opposed square one. can let me know how can done in arduino? i'm using uno if makes difference.
the second need multiply reference signal sensor signal. i'm not sure how either. can done on board electrical components (relatively) easily?
and need send multiplied signal through low pass filter. understand idea of how resistors , capacitors unsure of values should use filter signal.
any further tips or pointers (or corrections on process) on how welcome!
if useful, here current code. modulate "source" led, cause random blinking in "noise" led, , sends me sensor output of combined light intensity.
code: [select]
int signl = 2; // number of led pin
int noise = 3;
int sensordrive = 13;
int sensorread = a0;
int signlstate = low;// ledstate used set led
int noisestate = low;
unsigned long previoussigmillis = 0; // store last time signal updated
unsigned long previousnoisemillis = 0; // store last time noise updated
unsigned long previoussensormillis = 0;
long ontime = 250; // milliseconds of on-time
long offtime = 250; // milliseconds of off-time
long randnumber = 0; // noise freq
long interval = 10; // sampling freq
int sensorvalue = 0; // variable to store value coming from sensor
void setup()
{
serial.begin(9600);
// set digital pin output:
pinmode(signl, output);
pinmode(noise, output);
pinmode(sensordrive, output);
}
void loop()
{
// check see if it's time change state of led
unsigned long currentmillis = millis();
//------------------------------------------------------------------------------
//-------------------------------------signal-----------------------------------
//------------------------------------------------------------------------------
if((signlstate == high) && (currentmillis - previoussigmillis >= ontime))
{
signlstate = low; // turn off
previoussigmillis = currentmillis; // remember time
digitalwrite(signl, signlstate); // update actual led
}
else if ((signlstate == low) && (currentmillis - previoussigmillis >= offtime))
{
signlstate = high; // turn on
previoussigmillis = currentmillis; // remember time
digitalwrite(signl, signlstate); // update actual led
}
//------------------------------------------------------------------------------
//-------------------------------------noise-----------------------------------
//------------------------------------------------------------------------------
if((noisestate == high) && (currentmillis - previousnoisemillis >= randnumber))
{
noisestate = low; // turn off
previousnoisemillis = currentmillis; // remember time
digitalwrite(noise, noisestate); // update actual led
randnumber = random(0,250);
}
else if ((noisestate == low) && (currentmillis - previousnoisemillis >= randnumber))
{
noisestate = high; // turn on
previousnoisemillis = currentmillis; // remember time
digitalwrite(noise, noisestate); // update actual led
randnumber = random(0,250);
}
//------------------------------------------------------------------------------
//-------------------------------------sensor-----------------------------------
//------------------------------------------------------------------------------
sensorvalue = analogread(sensorread);
if(currentmillis - previoussensormillis >= interval)
{
serial.println(sensorvalue, dec);
previoussensormillis = currentmillis; // remember time
}
}
thank you!
quote
ideally sinusoidal reference opposed square one.trig functions available in arduino c/c++:
code: [select]
vref = a*sin(2*pi*f*t+phi)+offset;
where vref simulated reference voltage, amplitude,f=frequency in hz, t=time in seconds, phi phase factor in radians , offset may or may not required.
to multiply values of 2 signals @ point in time, example result of analogread() , vref above simple as:
code: [select]
sensorvalue = analogread(sensorread);
product = vref*sensorvalue;
beware of integer overflow if use int variables. maximum 32767.
this has been done many times, more detailed information, google "arduino lock in amplifier" or "arduino phase locked loop".
Arduino Forum > Using Arduino > Project Guidance > Phase Sensitive Detection (Lock-in) help
arduino
Comments
Post a Comment