You can collect the output of a commandlet or whole pipeline into a variable
$a = (gci 0.txt)
and then invoke methods of $a
$a.Name
or you can omit the variable
(gci 0.txt).Name
Anti-nuisance lawsuit warning: The purpose of these notes is to remind me, Zoegond, of stuff or to help me work stuff out. They may contain mistakes.
Quick
- ($a, $b....) = unpack("A2A7...", $packed)
- push( array, list )
Monday, February 28, 2011
Powershell get-content
get-content (when applied to a file) returns a collection of objects, each of which is a line from the file.
Thursday, February 24, 2011
Batch variable substring
The batch variable substring syntax only works with environment-style variables, ie ones that are substituted thus %var% .
It doesn't work with command line parameters (and I assume not for FOR placeholders either).
It doesn't work with command line parameters (and I assume not for FOR placeholders either).
Wednesday, February 23, 2011
SQL Server extended properties
fn_listextendedproperty is very particular about which arguments can be left out. Or rather it isn't particular, it just returns no output if it doesn't like your invocation.
The only 'wildcard' invocation I've managed to make work is
select * from fn_listextendedproperty('MS_Description', 'schema', 'dbo', 'table', 'thetable', 'column', default )
Putting default in anywhere else - even if the defaults are the final items in the list, as specified in the documentation - leads to no results.
The only 'wildcard' invocation I've managed to make work is
select * from fn_listextendedproperty('MS_Description', 'schema', 'dbo', 'table', 'thetable', 'column', default )
Putting default in anywhere else - even if the defaults are the final items in the list, as specified in the documentation - leads to no results.
sqlite identity
For a sqlite field to work as an identity field it has to be precisely integer primary key (not int...) .
sqlite command shell
The sqlite command shell can't cope with a comment in between the closing semicolon of a command and the next command. Eg you must say
select * from blah;
/*
a comment
*/
;
.exit
select * from blah;
/*
a comment
*/
;
.exit
Monday, February 14, 2011
Circuit analysis with transistors (BJT)
(Notes on http://www.ittc.ku.edu/~jstiles/312/handouts/Steps%20for%20DC%20Analysis%20of%20BJT%20Circuits.pdf)
1. Assume operating mode (Active, Saturated, Cutoff)
2. Enforce appropriate equalities:
A - Vbe = 0.7, Ic = beta * Ib
S - Vbe = 0.7, Vcb = -0.5 (so Vce = 0.2)
C - Ib = Ic = Ie = 0
Also Vce = Vcb + Vbe in all modes
3. Analyse
A - Ic = beta * Ib, Ie = Ic + Ib, Vce = Vcb + 0.7. Find one i and one of Vce, Vcb
S - Find two of Ic, Ib, Ie using the three voltages (which are all known)
C - Find two of Vbe, Vce, Vcb
4. Check inequalities
A - Vcb > 0 or Vce > 0.7; Ib > 0 (or Ic or Ie > 0)
S - Ic < beta * Ib; Ib and Ic and Ie all > 0
C - Vbe < 0, Vcb > 0
5. If any of the inequalities are not present, the assumption was wrong. Start again with a different one.
1. Assume operating mode (Active, Saturated, Cutoff)
2. Enforce appropriate equalities:
A - Vbe = 0.7, Ic = beta * Ib
S - Vbe = 0.7, Vcb = -0.5 (so Vce = 0.2)
C - Ib = Ic = Ie = 0
Also Vce = Vcb + Vbe in all modes
3. Analyse
A - Ic = beta * Ib, Ie = Ic + Ib, Vce = Vcb + 0.7. Find one i and one of Vce, Vcb
S - Find two of Ic, Ib, Ie using the three voltages (which are all known)
C - Find two of Vbe, Vce, Vcb
4. Check inequalities
A - Vcb > 0 or Vce > 0.7; Ib > 0 (or Ic or Ie > 0)
S - Ic < beta * Ib; Ib and Ic and Ie all > 0
C - Vbe < 0, Vcb > 0
5. If any of the inequalities are not present, the assumption was wrong. Start again with a different one.
Sunday, February 13, 2011
Transistors
When trying to work out collector and emitter voltages start with the base current Ib.
The transistor will try to make Ic equal to Ib * beta. This means that if there is a collector resistor Rc then Vc will be pulled down to whatever level makes the voltage drop across Rc produce the desired current. That level cannot be less than 0 - if it is, then Vc ~ 0 and Ic/Ib < beta (saturation).
If there is no Rc then Vc will be Vcc, it seems. But this does not mean Ic = 0; the collector works like a current sink (a hypothetical thing that absorbs current without obeying Ohm's Law).
Similarly, Ve will be whatever level results in the desired current (Ib + Ic) through the emitter resistor. Bear in mind that BE works like a diode, so if it is forward biased then Vb - Ve = 0.6 V. (And this also means that it will break down if reverse biased by too great a difference)
Btw there's nothing magic about the -4.4/-5V cutoff in the Art of Electronics emitter follower example. The figure is -5V because that is Ve when Ic = 0; Ve is -5V in that situation because the emitter is between two resistors of equal value. Beyond the load resistor is 0V and beyond the emitter resistor is -10V, so Ve is halfway between in accordance with the voltage divider principle. If for example Re is only half the value of RL, then the figure is -6.67V.
The transistor will try to make Ic equal to Ib * beta. This means that if there is a collector resistor Rc then Vc will be pulled down to whatever level makes the voltage drop across Rc produce the desired current. That level cannot be less than 0 - if it is, then Vc ~ 0 and Ic/Ib < beta (saturation).
If there is no Rc then Vc will be Vcc, it seems. But this does not mean Ic = 0; the collector works like a current sink (a hypothetical thing that absorbs current without obeying Ohm's Law).
Similarly, Ve will be whatever level results in the desired current (Ib + Ic) through the emitter resistor. Bear in mind that BE works like a diode, so if it is forward biased then Vb - Ve = 0.6 V. (And this also means that it will break down if reverse biased by too great a difference)
Btw there's nothing magic about the -4.4/-5V cutoff in the Art of Electronics emitter follower example. The figure is -5V because that is Ve when Ic = 0; Ve is -5V in that situation because the emitter is between two resistors of equal value. Beyond the load resistor is 0V and beyond the emitter resistor is -10V, so Ve is halfway between in accordance with the voltage divider principle. If for example Re is only half the value of RL, then the figure is -6.67V.
Friday, February 11, 2011
Pull-up resistor
So if there is a pull-up resistor between a pin and 5V, how is that keeping the pin at 5V? Surely there is a voltage drop across the resistor?
Well apparently there is, but it is very very small because the resistor value would be chosen to be small compared to the impedance of the device the pin belongs to. It's like any voltage divider, Vpu = Vcc * (Rpu / (Rpu + Rdevice)). Where Rpu << Rdevice, Vpu ~ 0.
Well apparently there is, but it is very very small because the resistor value would be chosen to be small compared to the impedance of the device the pin belongs to. It's like any voltage divider, Vpu = Vcc * (Rpu / (Rpu + Rdevice)). Where Rpu << Rdevice, Vpu ~ 0.
Friday, February 4, 2011
SQL case
The short form of case -
case field when x then y when z then w else v end
appears to do a comparison with =. This means that a clause 'when null then...' will always be false, for the usual reason that any expression (other than is) involving null returns null.
Where null is one of the switch values, you must use the long form
case when field = x then y when field is null then w else v end
case field when x then y when z then w else v end
appears to do a comparison with =. This means that a clause 'when null then...' will always be false, for the usual reason that any expression (other than is) involving null returns null.
Where null is one of the switch values, you must use the long form
case when field = x then y when field is null then w else v end
Thursday, February 3, 2011
Capacitors in series
The voltage across capacitors in series is inversely proportional to their capacitance.
This is because:
- they are all partaking of the same current, so charge is evenly distributed between them.
- Q=CV so C=Q/V so capacitance = charge / voltage
- so farads can be thought of as 'coulombs per volt'
- so if two capacitors in series each hold 2C of charge, and cap A is rated 1F and cap B is rated 2F, the 2C in A keep its terminals 2V apart, but the 2C in B only keeps its terminals 1V apart.
- cap A, rated with half the capacitance of B, thus has twice the voltage across it. TICK
Thanks again to Grob for pointing this out where Cook, and Art of Electronics, didn't.
(I understand capacitance better if I think of it as 'charge sensitivity'. Higher capacitance means lower voltage between the terminals after being filled with the same amount of charge.)
This is because:
- they are all partaking of the same current, so charge is evenly distributed between them.
- Q=CV so C=Q/V so capacitance = charge / voltage
- so farads can be thought of as 'coulombs per volt'
- so if two capacitors in series each hold 2C of charge, and cap A is rated 1F and cap B is rated 2F, the 2C in A keep its terminals 2V apart, but the 2C in B only keeps its terminals 1V apart.
- cap A, rated with half the capacitance of B, thus has twice the voltage across it. TICK
Thanks again to Grob for pointing this out where Cook, and Art of Electronics, didn't.
(I understand capacitance better if I think of it as 'charge sensitivity'. Higher capacitance means lower voltage between the terminals after being filled with the same amount of charge.)
AC voltage
When an AC source is stated as being a particular voltage (eg 240V) that is usually an RMS value ( 1 / sqrt(2) * peak).
So peak voltage of the '240V' AC source is 339V, and the voltage at any given time varies between 339V and -339V.
And don't forget that all voltages are a statement of potential difference between 2 points, in this case the two terminals of the source.
So if we are giving the voltage in terms of the difference between the brown 'Live' wire and the blue 'Neutral' one, at positive peak brown is at +339V with respect to blue. (brown 339V, blue 0V)
1/4 cycle later brown is at 0V with respect to blue. (brown 0V, blue 0V)
And after another 1/4 cycle brown is at -339V with respect to blue. (brown -339V, blue 0V)
The absolute potential difference between the two terminals varies between 0 and 339 volts and its root mean square value is 240V, which is where we started.
Thanks to Grob: Basic Electronics for finally explaining this one in a way I could grasp.
(Incidentally although the difference between the two terminals says nothing about the difference between either and any other point, in a domestic wiring situation you would expect a 240V RMS reading between either terminal and the earth wire).
So peak voltage of the '240V' AC source is 339V, and the voltage at any given time varies between 339V and -339V.
And don't forget that all voltages are a statement of potential difference between 2 points, in this case the two terminals of the source.
So if we are giving the voltage in terms of the difference between the brown 'Live' wire and the blue 'Neutral' one, at positive peak brown is at +339V with respect to blue. (brown 339V, blue 0V)
1/4 cycle later brown is at 0V with respect to blue. (brown 0V, blue 0V)
And after another 1/4 cycle brown is at -339V with respect to blue. (brown -339V, blue 0V)
The absolute potential difference between the two terminals varies between 0 and 339 volts and its root mean square value is 240V, which is where we started.
Thanks to Grob: Basic Electronics for finally explaining this one in a way I could grasp.
(Incidentally although the difference between the two terminals says nothing about the difference between either and any other point, in a domestic wiring situation you would expect a 240V RMS reading between either terminal and the earth wire).
Subscribe to:
Comments (Atom)