Hello,
Congratulations for the forum!
Excuse me for the bad english. I little use Google translate

My task is to program with Matlab this National Instrument module http://sine.ni.com/nips/cds/view/p/lang/en/nid/202597 (using the "Data Acquisition Toolbox").
It have to download data from the accelerometer sensor ADXL330, which generally earns 3 offset voltages in the middle of its supply voltage and measure the acceleration in the range + / - 3g
At this stage of the project, my problem is as follows:
I have two boards ready: the first is the accelerometer with three issues AD694 for x, y and z axes, ie the circuit board with 4-20mA outputs.
Second board with resistors groups convert current into voltage. Then multiplexer 4052 switches, these three voltages (for x, y, z axes) with a certain frequency.
This chip is: http://www.datasheetcatalog.org/datasheet/philips/HEF4052BN.pdf
Indeed, National Instuments DAQ must read this three voltages switched on 1 wire (ie the output of the multiplexer).
The code for driving the multiplexer is:
------------------- ------------------- ------------ -------
function mux_control
dio = digitalio ( 'nidaq', 'Dev1');
addline (dio, 0:1, 'out', ( 'line1', 'line2'));
while (1)
putvalue (dio.Line (1:2), [0 0]);
pause (0.001)
putvalue (dio.Line (1:2), [0 1]);
pause (0.001)
putvalue (dio.Line (1:2), [1 0]);
pause (0.001)
putvalue (dio.Line (1:2), [1 1]);
pause (0.001)
end
delete (dio)
clear dio
end
------------------- ------------------- ------------ -------
Small problem is that even if you add zeros after the decimal point switching frequency of the digital output of the DAQ is not more than 35-70Hz.
pause (0.001) => 1000hz, but is not so!
Accelerometer will be mounted on the wall in the laboratory and measured vibration (earthquake). The output should be 3D graphics, which is visible wavelength (or something like that:))
In principle, measuring the frequency vibration need around 100-200Hz.
The code of the program for the analog inputs of the NI DAQ is the following:
- Is now set to work with winsound microfone:)
--------- ---------- ------------------- --------- --- -------
function ACC_RT
daqhwinfo
AI = analoginput ( 'winsound');
% AI = analoginput ( 'nidaq', 'Dev1');
chan = addchannel (AI, 1);
% Chan = addchannel (AI, 0);% For NI
duration = 10;
set (AI, 'SampleRate', 8000); %<--- 8000 for winsound; max 200 for NI-DAQ
ActualRate = get (AI, 'SampleRate');
set (AI, 'SamplesPerTrigger', duration * ActualRate)
% set (AI, 'InputType', 'SingleEnded')% only for NI-DAQ
% Set (ai, 'TriggerRepeat', 3)
set (AI, 'LogFileName', 'ACC_log.daq')
set (AI, 'LoggingMode', 'Disk & Memory')
% Set (chan, 'SensorRange', [-1 1])
% Set (chan, 'InputRange', [-1 1])
% Set (chan, 'UnitsRange', [-50 50])
% Set (chan, 'Units', 'g''s (1g = 9.80 m / s / s)')
preview = duration * ActualRate/100;
%%
subplot (211)
set (gcf, 'doublebuffer', 'on')
P = plot (zeros (preview, 1)); grid on% ylim ([-1 1]);
title ( 'Preview Data')
xlabel ( 'Samples')
ylabel ( 'Signal Level (Volts)')
%%
start (AI)
% Disp (ActualRate)
% Disp (preview)
% Disp (duration * ActualRate)
%% Realtime UPDATE data
while AI.SamplesAcquired <preview% checking whether we are trying to represent more than the samples taken
end
while AI.SamplesAcquired <duration * ActualRate% while equality is true plot-a update-ca is constant
data = peekdata (AI, preview, 'double');% double po default
set (P, 'ydata', data)
drawnow
end
%%
% Extract all the acquired data from the engine, and plot the data.
data = getdata (AI);
subplot (212),
%%
plot (data), grid on
title ( 'All Acquired Data')
xlabel ( 'Samples')
ylabel ( 'Signal level (volts)')
delete (AI)
clear AI
end
--------- ---------- ------------------- --------- --- -------
The big problem for me is how for each switching of multiplexer for X, Y and Z to read this voltage with NI-DAQ board and to depict graphically?
Not necessarily have real-time data!
We will left the system all night to record the data in the file 'ACC_log.daq'.
I am interested in how to acquare this three voltages and store them into a matrix with three columns ..
May I asked too many questions, but just my time is limited to February 2010 ... by then the project should be ready
Thanks in advance!
I have all the electrical circuits ..