Show Posts
Pages: 1 2 [3] 4 5 ... 171
31  Topics / Science and Measurement / Re: Filter library test on: May 18, 2014, 04:43:33 pm
Perhaps, TimerOne library could help.
32  Topics / Science and Measurement / Re: Filter library test on: May 18, 2014, 10:11:46 am
Quote
But also there nearly the same problem: 220Hz doesn’t pass but a frequency of 306Hz?!
Probably, your sampling rate isn't defined at 5 kHz, but vary above the spec.
Do you have a scope? If not, i could suggest to use your PC as a freq. meter, set one digital pin as output, and drive it high/low in the loop. Than using audacity or something else, use PC sound card to measure freq. Don't forget to attenuate a voltage from the pin with resistive divider, and put a DC blocking cap
33  Topics / Science and Measurement / Re: Filter library test on: May 16, 2014, 11:56:37 am
Quote
What do you think, it’s principally possible to use a filter and generate sine-waves simultaneously?
Sure, it's possible. 500 Hz is quite low freq.,
Quote
I did some tests and the filter didn’t work anymore.
It happenes, when two subfunction interfere with each other.
34  Topics / Science and Measurement / Re: Filter library test on: May 15, 2014, 08:55:45 am
Quote
Are the input signals correctly for filter computation?
Good question, you should subtract DC offset. Other things, declare data1 and data2 as signed. And you don't need time measurements anymore, otherwise you are reading input twice.
Code:
// int data1 = analogRead(analogPin);    <-- int, not unsigned int !
  data1 = analogRead(0) -512;       //Read Analog channels
  data2 = Filter.run(data1);   //Read the filtered signal
 
35  Topics / Science and Measurement / Re: Filter library test on: May 14, 2014, 11:28:52 am
Yea, coefficients looks o'k, except I didn't get
Quote
I used “long type” whit 8 bit. Without “-1 bit saturation save“.
36  Topics / Science and Measurement / Re: Filter library test on: May 14, 2014, 09:55:07 am
Quote
Or do you know other, maybe more accurate methods to test the filters?
I'd create a big array, 256 or 512 values to store results of the filtering. Like in your initial setup, you feed a sinewave, arduino filterring data and store them to an array. You printing results by request whenever you change input, or like to observe a process.

I checked a library, and author's copy has this:
Code:
  if(_order==2) {                                 //ripple -1dB
    _v[0] = _v[1];
    _v[1] = _v[2];
    long tmp = ((((data * 662828L) >>  4)         //= (    7.901529699e-2 * x)
      + ((_v[0] * -540791L) >> 1)                 //+( -0.5157387562*v[0])
      + (_v[1] * 628977L)                         //+(  1.1996775682*v[1])
      )+262144) >> 19;                            // round and downshift fixed point /524288

    _v[2]= (int)tmp;
    return (int)((
      (_v[0] + _v[2])
      +2 * _v[1]));                               // 2^
  }
As you can see, slow float math replaced by integer approximation.
You says:
Quote
Then I opened “SignalFilter.cpp” and substitute the Chebyshev Filter of 2nd Order with my new Filter code:
Code:
  if(_order==2) {                                 
         _v[0] = _v[1];
         _v[1] = _v[2];
_v[2] = (4.153748378268e-1 * data)
             + ( -0.4501779675 * _v[0])
             + ( -0.2113213838 * _v[1]);
         return
              (_v[0] + _v[2])
                 +2 * _v[1];
  }
  Is it code you are testing?
37  Using Arduino / Sensors / Re: iir_filter on: May 12, 2014, 04:27:55 pm
This part isn't correct:
Code:
float filter( float x) {
  float v[6];
  for(int i=0; i <= 5; i++)
v[i]=0.0;
You declare new array each time when you passing new value, so all history is lost. I think you should declare v[6] as global and remove "for" initializing loop.
38  Using Arduino / General Electronics / Re: Charging circuit verification on: May 10, 2014, 10:48:23 pm
Data sheet says it has PGA = 20x, may be enough.
Quote
18.7.2
Unipolar Differential Conversion
If differential channels and an unipolar input mode are used, the result is
              ( V POS – V NEG ) ⋅ 1024
ADC = ------------------------- ⋅ GAIN
                       V REF
39  Using Arduino / General Electronics / Re: Charging circuit verification on: May 10, 2014, 09:41:43 pm
PGA is programmable Gain Amplifier.
Quote
Could I set internal voltage ref and yet leave the resistor on the side it is currently? Since I am only looking at the difference between the two voltages?
No, as it shown on your circuits there is about 5V at voltage divider outputs, and ref. voltage can't be lower than that.
BTW, what part number of ATTINY you gonna to use? Look in data sheet, if it supports differential mode and PGA. Something to think, otherway 10 OHm resistors may be an answer.
40  Using Arduino / General Electronics / Re: Charging circuit verification on: May 10, 2014, 09:04:27 pm
Quote
If the resistance is 0.1 ohms and the current is 0.1A the voltage drop would be .01V correct?
Opps, right, I thought it's 1 OHm. Probably, you should make it 1 ? Moving resistor to gnd path, you may select internal voltage reference of the ADC , and get 5x ( or 2x) better accuracy. I'm not ready to comment on ATTINY  ADC internals, if there is a PGA?
41  Using Arduino / Sensors / Re: got laser displacement sensor? on: May 10, 2014, 08:20:17 pm
Why not IR?
https://www.sparkfun.com/categories/84
42  Using Arduino / General Electronics / Re: Charging circuit verification on: May 10, 2014, 08:13:29 pm
O'K, I see, and you choose 2.45V per cell?
Using high side current sensor, you 'd have only 0.1V drop across a resistor, plus after voltage divider it diminishes to  about 1/3, and after all 30 mV at analog inputs difference 'd be present. That accounted to 6 "tick" of the ADC w/o voltage amplifier. I think it's better to transfer current sensing resistor down into source path of the mosfet. As 0.1V voltage loss 'd not make much difference, same time current control loop 'd looks locked and more accurate.
43  Using Arduino / General Electronics / Re: Charging circuit verification on: May 10, 2014, 07:46:18 pm
Quote
So from my understanding form a code perspective all I need to do is set PWM value such mosfet sees 4V at gate such that current is limited to .1A. And taking the datasheets average value of charge voltage for cycle use for 6 cell battery is how I came up with 14.7V so it would seem that's correct.
No, there are a lot of variables, temperature, mosfet threshold voltage, battery state, you can't control a current by setting specific voltage. Better to measure current itself, and adjust voltage accordingly to keep 0.1A. Charging chart shows 13.8 V  as max voltage and they recommend constant current / constant voltage as a method of charging. It looks like it takes only 7 hours for fully discharged battery to get up to 13.8 V ( current exact 0.1A) and after that current drops but voltage stays 13.8 V, if it's me I wouldn't reinvent a wheel and follow their recommendations
44  Using Arduino / General Electronics / Re: Charging circuit verification on: May 10, 2014, 06:10:57 pm
Depends on  battery, wiki says:
Quote
Open-circuit (quiescent) at full charge: 2.10 V
Open-circuit at full discharge: 1.95 V
Loaded at full discharge: 1.75 V
Continuous-preservation (float) charging: 2.23 V for gelled electrolyte; 2.25 V for AGM (absorbed glass mat) and 2.32 V for flooded cells
All voltages are at 20 °C (68 °F), and must (for a 6 cell battery) be adjusted by −0.0235 V/°C for temperature changes.
Float voltage recommendations vary among manufacturers.
Precise float voltage (±0.05 V) is critical to longevity; insufficient voltage (causes sulfation) is almost as detrimental as excessive voltage (causing corrosion and electrolyte loss)
Typical (daily) charging: 2.37–2.4 V (depending on temperature and manufacturer's recommendation)
Equalization charging (for flooded lead acids): 2.5 V for no more than 2 hours.[citation needed] Battery temperature must be absolutely monitored.
Gassing threshold: 2.4 V

http://en.wikipedia.org/wiki/Lead–acid_battery
45  Using Arduino / General Electronics / Re: Charging circuit verification on: May 10, 2014, 04:31:32 pm
Quote
1. set ctrl pin(pwm) such that current into battery is always limited to max charging current on battery spec (should this current be at 14.7 V?)
Does it mean you gonna to regulate charging current using PWM? 
What is approx. max current? IRF510 isn't logic level, and at +5 V Gate could pass a few amps, have you verified with data sheet?
You aware, that smoothing out PWM (1k and 10 uF) you gonna dissipate significant amount of power on transistor?
Quote
2. as voltage come towards 14.7 the current will start to drop inherintely as battery resistance rises (is this correct)
3. once current is low enough light up LED to indicate charge complete
2. Isn't correct, battery resistance lowers.
Pages: 1 2 [3] 4 5 ... 171