CURRENT ISSUE
Contests
Test your eq
|
|
Issue #220 November 2008
Problem 1—One way to form a simple DAC is to set up an R-2R resistor ladder, with each leg driven by a digital gate that has a totem-pole output. How does the output impedance of such a converter vary with the digital value being applied to it?
(This material first appeared in David Tweed’s article, “Digital Processing in an Analog World, Part 2: Technology Choices,” Circuit Cellar 100, 1998.)

Problem 2—What does the following script do? Is there a way to write it more compactly?
#!/usr/bin/perl
open(TOKENS, "<tokens.txt");
open(INFILE, "<infile.txt");
open(OUTIFLE, ">outfile.txt");
$magicstring = "MAGICTOKEN";
@tokens = <TOKENS>;
chomp(@tokens);
close(TOKENS);
while($inline = <INFILE>)
{
while ($inline =~ /$magicstring/ )
{
$token = shift(@tokens);
$inline =~ s/$magicstring/$token/;
}
print OUTFILE $inline;
}
Problem 3—How do you detect an overflow condition when doing 2’s-complement (signed) arithmetic such as addition and subtraction on a microprocessor?
Answer
Problem 4—Carl has a well that’s located 200' from his house, and a nonmetallic conduit carries power out to equipment in the well. The power line is protected by a GFCI at the house end.
Occasionally (several times a year), when a thunderstorm passes nearby, when lightning strikes maybe several miles away, the GFCI opens the circuit. If it is reset, it then keeps working for months until possibly another storm passes by.
What’s going on, and how can it be remedied?
Answer
|