Go Down

Topic: High speed read of bipolar signal, -> ADC (LTC1605) (Read 2 times) previous topic - next topic

SuperR

Feb 07, 2013, 04:23 pm Last Edit: Feb 24, 2013, 10:55 am by SuperR Reason: 1
Hi,

I am starting experiments on a setup next week and was interested in using a standalone Arduino application next to the (overkill) Matlab dSpace interface. I really like Matlab and Simulink, but I am intrigued by the idea of implementing a control loop within the Atmega 328P.

Here's the setup;
Reference input, an audio signal, so both positive and negative voltages
Sensor output, an accelerometer, putting out both positive and negative voltages

Once I find a control loop, say, just an error times a transferfunction, it would be nice to implement it in an Arduino environment

Here's the issue;
I want a "sample 2 inputs -> substrackt -> run filter-> output"-time of say 1/10000 s = 100 us
Assume the filter to be quite "filled with dynamics". So no simple 1 zero 2 poles transfer function.

Do any of you have experience with similar implementations? I am not sure whether the Atmega can do this at ease or if it is impossible.

I read about implementing Simulink code on an Arduino. That would be awesome, but then again, I am not sure the (calculation)speed is high enough for my goals.

If it's impossible to do, so be it. However, if with little modifications something like this can be accomplished, that would be great!

http://www.mathworks.com/matlabcentral/fileexchange/35639
http://arduino.cc/forum/index.php/topic,6549.0.html
https://sites.google.com/site/measuringstuff/the-arduino#TOC-Sample-Rates


robtillaart

\Can you give a glimpse of the complexity of the code you want to implement?
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

SuperR

Something like this is the discretized transfer function;

>> c2d(C,0.0001)

Transfer function:

                                                                                   
7.716 z^7 - 37.57 z^6 + 73.23 z^5 - 71.39 z^4 + 34.81 z^3 - 6.785 z^2 - 0.001332 z
                                                                                   
                                                                       - 1.96e-008 
                                                                                   
-------------------------------------------------------------------------------------
                                                                                     
z^7 - 3.882 z^6 + 5.648 z^5 - 3.652 z^4 + 0.8852 z^3 - 1.632e-005 z^2 + 1.002e-010 z
                                                                                     
                                                                     - 2.053e-016 

robtillaart


such a formula can be calculated quite well with an Arduino.

float x1 = ((((((7.716 * z - 37.57) * z + 73.23) * z  - 71.39) * z + 34.81) * z - 6.785) * z - 0.001332) * z - 1.96e-008 

This trick brings it down to 14 "simple" float operations instead of using power

Main problem might be that the Arduino only supports 32bit IEEE754 floats with ~7 significant digits.

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

dc42

If you need to sample 2 inputs, you face an immediate problem which is that the Arduino in its default configuration takes about 100us to do a single ADC conversion. If you can tolerate reducing the number of bits resolution below 10, then you can increase the ADC clock frequency and achieve faster conversion times.

You will need to write the code something like this so that you are not waiting on the ADC conversions:

Start conversion of input A
Do half of the maths on the previous pair of samples
Wait for conversion to complete
Read the result of the conversion of input A
Start conversion of input B
Do the remaining half of the maths on the previous pair of samples
Wait for conversion to complete
Read the result of the conversion of input B
Repeat from start

What I don't know is whether you can do the maths fast enough on an Arduino, but you can measure that yourself.

You will be sampling the inputs at slight different times (maybe 50us apart). If that isn't acceptable, you will have to use an external ADC chip with faster conversion time.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Go Up