connectivity
Member
Hello All,
I am planning to do a lock-in PID controller with Teensy 4.0 with the audio board (SGTL5000) and audio library.
This will be a relatively low frequency lock-in detector (between 1kHz to 10kHz) and PID controller (100 Hz to 1kHz, about 10x less bandwidth after low-pass).
-
The signal of interest goes into the ADC and is then mixed with a sine wave and a cosine wave separately ("local oscillators"). The two waves have the same frequency.
It then goes to a low-pass filter to remove the harmonics (lets call the signal S and C after low pass). The phase independent term R is sqrt(S^2 + C^2).
I have tested this lock-in detection part on Teensy 3.6 DAC output (without ADC and without the R calculation) by having an amplitude modulated sine mixing with the local oscillators and low-passing.
I can get the amplitude modulation signal out of the Teensy and it looks right scoped. The routing of the signals are done with the audio system design tool.
-
So the question now is how do I pipe the demodulated signals (S and C) into a PID controller ?
The signals seems to be "stuck" (sorry for lack of a better word) in the audio architecture way of doing things.
I want to use the PID controller to control the frequency and amplitude of the output - it is kind of to drive an object on resonance with constant amplitude. i.e. its a scaled local oscillator.
(side note, to get it on resonance, one drive the signal C to zero while changing the frequency/phase. To have constant amplitude, one would have drive S (or R) to the desired value)
Method One - Create a new audio object (following instructions here https://www.pjrc.com/teensy/td_libs_AudioNewObjects.html) to calculate R and write the PID in this audio object. This is not very ideal I guess, the audio cycle runs at 44kHz or so which is faster than what I really need.
Method Two - Create a new audio object to calculate R and some how "parse" it out of the audio library for use in Arduino main loop. Clearly my programming skills are not very good to understand how to do this.
Method Three - Create a new audio object to just serial output S and C and then do the processing on another teensy/device. This would probably work, but it runs at 44kHz as well and is not very efficient ( two teensy, connected by serial... )
Any suggestions would be appreciated.
I am planning to do a lock-in PID controller with Teensy 4.0 with the audio board (SGTL5000) and audio library.
This will be a relatively low frequency lock-in detector (between 1kHz to 10kHz) and PID controller (100 Hz to 1kHz, about 10x less bandwidth after low-pass).
-
The signal of interest goes into the ADC and is then mixed with a sine wave and a cosine wave separately ("local oscillators"). The two waves have the same frequency.
It then goes to a low-pass filter to remove the harmonics (lets call the signal S and C after low pass). The phase independent term R is sqrt(S^2 + C^2).
I have tested this lock-in detection part on Teensy 3.6 DAC output (without ADC and without the R calculation) by having an amplitude modulated sine mixing with the local oscillators and low-passing.
I can get the amplitude modulation signal out of the Teensy and it looks right scoped. The routing of the signals are done with the audio system design tool.
-
So the question now is how do I pipe the demodulated signals (S and C) into a PID controller ?
The signals seems to be "stuck" (sorry for lack of a better word) in the audio architecture way of doing things.
I want to use the PID controller to control the frequency and amplitude of the output - it is kind of to drive an object on resonance with constant amplitude. i.e. its a scaled local oscillator.
(side note, to get it on resonance, one drive the signal C to zero while changing the frequency/phase. To have constant amplitude, one would have drive S (or R) to the desired value)
Method One - Create a new audio object (following instructions here https://www.pjrc.com/teensy/td_libs_AudioNewObjects.html) to calculate R and write the PID in this audio object. This is not very ideal I guess, the audio cycle runs at 44kHz or so which is faster than what I really need.
Method Two - Create a new audio object to calculate R and some how "parse" it out of the audio library for use in Arduino main loop. Clearly my programming skills are not very good to understand how to do this.
Method Three - Create a new audio object to just serial output S and C and then do the processing on another teensy/device. This would probably work, but it runs at 44kHz as well and is not very efficient ( two teensy, connected by serial... )
Any suggestions would be appreciated.