Showing posts with label electronics. Show all posts
Showing posts with label electronics. Show all posts

Saturday, August 29, 2020

EV battery size and cost

Being checking a bit on EVs now that Tesla is hot (I think >$2k/share is a joke, you read it here first :)). Still, the EV (which BTW were not invented by Tesla) are cool. Even Teslas are cool (just the stock price is a joke). Note: I am checking also FCEV (look super cool too). 

Anyhow, quick calculation from the offering on this site (they explain it really well so you just can read it there). A Tesla 5.3kWh (444 batteries as 74p6s) pack costs $1580 ($300/kWh) and is 68 x 28 x 7.5 cm. 10 of these packs would give you about 53kWh which is close to Model 3 smallest battery (50kWh) and can take you (if you believe the BS-EPA rating from Tesla) to 354Km. Would love to see you try that, Tesla fan ;) but still pretty good even if falls short of that (see bottom of this post). Assuming same "marketing" trickery, we can guess we can get about 275 km with that battery pack.

So, to summarize it, it takes about $57 and about 0.5 liter of volume per km of autonomy. 

Notice though that this is for the full Tesla module. In the same website we can check the price of the individual cells (Panasonic 18650): 200 cells (3Ah/cell, or ~2.3kWh) for $600. This is actually not much cheaper than just buying the Tesla module, about $1330 for the 444 cells on that module and you got everything else with it (cooling, assembly...), done on the Gigafactory.

So, what to do with this stupid battery? ;)

  • Awesome, I repeat, really awesome video of how to make an electric catamaran. Warning: if you watch it, you may not be able to avoid building one. You've been warned...
  • Or how about an eBike? :)
  • Or an eFoil?
  • Or an eWaterBike?
Seriously!

PS.: On the range (what I call BS-EPA), this video measures few cars in a real life scenario. The link should bring you straight into the results part. As summary:

  1. Nissan Leaf: 62kWh, 208 miles in the test, 87% of the EPA promised range (what I call the BS-EPA range).
  2. Jaguar I-Pace: 90kWh, 223, 76%
  3. Mercedes EQ: 80kWh, 194, 75% 
  4. Audi e-tron: 95kWh, 206, 81%
  5. Kia e-Niro: 64kWh, 255, 90%
  6. Tesla model 3 Long range: 75kWh, 270, 78% 

Based on #6, the real range would be 78% of 354km = 276km

Saturday, June 8, 2013

From ATX to bench power supply

Tons of these tutorials on the web. Here is one:
http://jumperone.com/2011/06/atx-power-supply-tutorial/
http://jumperone.com/2012/12/converting-atx-power-supply-to-bench-power-supply-faq/#Q3

Anyhow, this is just to say that if you don't put the load resistor, it can (and it did, on my case) blow up. In my case, I think it was an electrolytic cap... FYI, I blew it before I read anything. When it blew then I went looking for the reason... It is not that I was suicidal :) Anyhow, PSUs are so cheap that I don't feel like spending time fixing it.

Sunday, November 18, 2012

Filter design: From Matlab to C code

Note 1:  For this, I am using not only Matlab but the Signal Processing Toolbox. Got to study the other tools that Matlab has to deal with filters...
Note 2: I should write something like this but with some free tool out there... Anyhow, for the moment just use Matlab, as I have it available in my company...

Quick reading, it looks like there are couple of methods:
  1. A=ellip(specs) --> H=dfilt.df1(A) where A are the numerator and denominator coeff. This is kind of going analog to then move to digital.
  2. D=fdesign.bandpass(specs) --> H=design(D, ellip)
H is the object describing the digital filter (not exactly the coefficients, see more below). We will look in detail and extend the method 2 following Getting started with discrete time filters (dfilt) or fdesign objects.
1/ First got to get the object describing the specification of the filter we want. So, we use fdesign. Just type  "fdesign.bandpass" for a very simple syntax, or go to fdesign for more info.
In our case, we want to create a bandpass filter around 2.5KHz. So, we will do:

>> D=fdesign.bandpass(2000,2200,2800,3000,40,1,40,44100)
And we get:
D =
               Response: 'Bandpass'                     
          Specification: 'Fst1,Fp1,Fp2,Fst2,Ast1,Ap,Ast2'
            Description: {7x1 cell}                     
    NormalizedFrequency: false                          
                     Fs: 44100                          
                 Fstop1: 2000                           
                 Fpass1: 2200                           
                 Fpass2: 2800                           
                 Fstop2: 3000                           
                 Astop1: 40                             
                  Apass: 1                              
                 Astop2: 40

2/ To get the real design, we use:
>> h=design(D,'ellip')
And get:
h =
         FilterStructure: 'Direct-Form II, Second-Order Sections'
              Arithmetic: 'double'                              
               sosMatrix: [4x6 double]                          
             ScaleValues: [5x1 double]                          
     OptimizeScaleValues: true                                  
        PersistentMemory: false
For help, type designmethods(h) to get a list of filters.

3/ At this moment, we may actually like a different structure. Notice it used the default one (direct form II)


but we may want the more standard one. I am going to use direct form I as it is easier for me to identify what output number below matches what coefficient (notice that I am learning while doing this), so, it'll be easier to program:

Note: notice the error on the - sign in the added of b(nb) path.

So, we do:
>> h1  = convert(h,'df1')

h1 =

     FilterStructure: 'Direct-Form I'
          Arithmetic: 'double'      
           Numerator: [1x9 double]  
         Denominator: [1x9 double]  
    PersistentMemory: false

To see what we get, we can do:
>> info(h1)
Discrete-Time IIR Filter (real)   
-------------------------------   
Filter Structure    : Direct-Form I
Numerator Length    : 9           
Denominator Length  : 9           
Stable              : Yes         
Linear Phase        : No

4/ At this point, if we want to see what we got, it is as simple as using the Filter Visualization Tool:
hfvt=fvtool(h1);


5/ To get the coefficients, use:
num = get(h1,'Numerator');
den = get(h1,'Denominator');

In our case:
num =     0.0099   -0.0729    0.2418   -0.4681    0.5789   -0.4681  0.2418   -0.0729    0.0099
den =     1.0000   -7.4222   24.5776  -47.3746   58.1077  -46.4331  23.6104   -6.9884    0.9229

Where numerator and denominator are (when a0=1, like in our case):


In this kind of structure

Notice that a0 in Matlab is den(1) as the index starts at 1. So, we create in Matlab a piece of code that will do this (equivalent to running y=filter(h1,rx)):

rx2=[zeros(length(num)-1,1);rx];
y=zeros(length(rx)+length(num)-1,1);
for R=length(num):length(rx2)
    data=0;
    for N=1:length(num)
        data=data+rx2(R-N+1)*num(N);
    end
    for D=1:(length(den)-1)
        data=data-y(R-D)*den(D+1);
    end
    y(R)=data/den(1);
end

Translating this into C is straightforward. Notice that the initialization is important. I.e., getting both, input and output past values equal to zero. We can do that adding those in front of our sequences/arrays, or, just make zero the first set of values on those arrays. Of course, this is just for test and assuming you don't care about that data being lost... Either way, you get the point :)
 
The plot on the left is the result using "filter" while the one on the right is the one from the "C" code.


Other useful information:

For an automatic way to do it: Forum describing how to do it
From Simulink to C
From Matlab to HDL
Real Time Workshop Embedded Coder

Matlab filter design
Designing Low Pass FIR filters
FDATool

To use your filter (DUH!): y=filter(num,den,x);
To see the impulse response of your filter use [h,t] = impz(num,den) and plot(t,h)
To check if it is stable: isstable(h) - Note: I didn't get it to work where I can check it with filter running in a given precision

Nice write up on filter theory: http://www.mikroe.com/chapters/view/73/chapter-3-iir-filters/
And another one...
And one more!