Guido Cargnino Wins the CC Code Challenge (Week 25)

We have a winner of last week’s CC Weekly Code Challenge, sponsored by IAR Systems! We posted a code snippet with an error and challenged the engineering community to find the mistake!

Congratulations to Guido Cargnino of Grugliasco, Turin, Italy  for winning the CC Weekly Code Challenge for Week 25! Guido will receive an Elektor 2012 & 2011 Archive DVD.

Guido’s correct answer was randomly selected from the pool of responses that correctly identified an error in the code. Guido answered:

Line #14: *p and *q must be used.

2013_code_challenge_25_answer

You can see the complete list of weekly winners and code challenges here.

What is the CC Weekly Code Challenge?
Each week, Circuit Cellar’s technical editors purposely insert an error in a snippet of code. It could be a semantic error, a syntax error, a design error, a spelling error, or another bug the editors slip in. You are challenged to find the error.Once the submission deadline passes, Circuit Cellar will randomly select one winner from the group of respondents who submit the correct answer.

Inspired? Want to try this week’s challenge? Get started!

Submission Deadline: The deadline for each week’s challenge is Sunday, 12 PM EST. Refer to the Rules, Terms & Conditions for information about eligibility and prizes.

John Safrit Wins the CC Code Challenge (Week 24)

We have a winner of last week’s CC Weekly Code Challenge, sponsored by IAR Systems! We posted a code snippet with an error and challenged the engineering community to find the mistake!

Congratulations to John Safrit of Mebane, North Carolina, United States  for winning the CC Weekly Code Challenge for Week 24! John will receive a CC T-shirt and a one-year subscription to Circuit Cellar.

John’s correct answer was randomly selected from the pool of responses that correctly identified an error in the code. John answered:

Line#22: need to terminate space string, add: space[d]=’';

2013_code_challenge_24_answer

You can see the complete list of weekly winners and code challenges here.

What is the CC Weekly Code Challenge?
Each week, Circuit Cellar’s technical editors purposely insert an error in a snippet of code. It could be a semantic error, a syntax error, a design error, a spelling error, or another bug the editors slip in. You are challenged to find the error.Once the submission deadline passes, Circuit Cellar will randomly select one winner from the group of respondents who submit the correct answer.

Inspired? Want to try this week’s challenge? Get started!

Submission Deadline: The deadline for each week’s challenge is Sunday, 12 PM EST. Refer to the Rules, Terms & Conditions for information about eligibility and prizes.

Issue 280: EQ Answers

PROBLEM 1
What is the key difference between the following two C functions?

#define VOLTS_FULL_SCALE 5.000
#define KPA_PER_VOLT 100.0
#define KPA_THRESHOLD 200.0

/* adc_reading is a value between 0 and 1
 */
bool test_pressure (float adc_reading)
{
  float voltage = adc_reading * VOLTS_FULL_SCALE;
  float pressure = voltage * KPA_PER_VOLT;

  return pressure > KPA_THRESHOLD;
}

bool test_pressure2 (float adc_reading)
{
  float voltage_threshold = KPA_THRESHOLD / KPA_PER_VOLT;
  float adc_threshold = voltage_threshold / VOLTS_FULL_SCALE;

  return adc_reading > adc_threshold;
}

ANSWER 1
The first function, test_pressure(), converts the ADC reading to engineering units before making the threshold comparison. This is a direct, obvious way to implement such a function.

The second function, test_pressure2(), converts the threshold value to an equivalent ADC reading, so that the two can be compared directly.

The key difference is in performance. The first function requires that arithmetic be done on each reading before making the comparison. However, the calculations in the second function can all be performed at compile time, which means that the only run-time operation is the comparison itself.

PROBLEM 2
How many NAND gates would it take to implement the following translation table? There are five inputs and eight outputs. You may consider an inverter to be a one-input NAND gate.

Inputs Outputs
A B C D E   F G H I J K L M
1 1 1 1 1 0 0 0 0 1 1 1 1
0 1 1 1 1 0 0 0 0 0 0 1 1
0 0 1 1 1 0 0 0 0 0 0 0 0
0 0 0 1 1 1 0 0 0 0 0 1 1
0 0 0 0 1 1 0 0 0 1 1 1 1

 

ANSWER 2
First of all, note that there are really only four inputs and three unique outputs for this function, since input E is always 1 and outputs GHI are always 0. The only real outputs are F, plus the groups JK and LM.

Since the other 27 input combinations haven’t been specified, we can take the output values associated with all of them as “don’t care.”

The output F is simply the inversion of input C.

The output JK is high only when A is high or D is low.

The output LM is high except when B is low and C is high.

Therefore, the entire function can be realized with a total of five gates:

eq0641_fig1

PROBLEM 3
Quick history quiz: Who were the three companies who collaborated to create the initial standard for the Ethernet LAN?

ANSWER 3
The original 10-Mbps Ethernet standard was jointly developed by Digital Equipment Corp. (DEC), Intel, and Xerox. It was released in November 1980, and was commonly referred to as “DIX Ethernet.”

PROBLEM 4
What was the name of the wireless network protocol on which Ethernet was based? Where was it developed?

ANSWER 4
The multiple access with collision detection protocol that Ethernet uses was based on a radio protocol developed at the University of Hawaii. It was known as the “ALOHA protocol.”

Electrical Engineering Crossword (Issue 281)

The answers to Circuit Cellar’s December electronics engineering crossword puzzle are now available.

281-Crossword-key

Across

4. VENNDIAGRAM—Represents many relation possibilities [two words]
5. PERSISTRON—Produces a persistent display
9. CODOMAIN—A set that includes attainable values
12. HOMOPOLAR—Electrically symmetrical
13. TRUTHTABLE—Determines a complicated statement’s validity [two words]
17. POWERCAPPING—Controls either the instant or the average power consumption [two words]
18. MAGNETRON—The first form, invented in 1920, was a split-anode type
19. MAGNETICFLUX—F
20. TURINGCOMPLETE—The Z3 functional program-controlled computer, for example [two words]

Down

1. CHAOSCOMPUTERCLUB—Well-known European hacker association [three words]
2. LOGICLEVEL—When binary, it is high and low [two words]
3. LINEARINTERPOLATION—A simple, but inaccurate, way to convert A/D values into engineering units [two words]
6. SYNCHRONOUSCIRCUIT—A clock signal ensures this device’s parts are in parallel [two words]
7. BOARDBRINGUP—Design validation process [three words]
8. HORNERSRULE—An algorithm for any polynomial order [two words]
10. MEALY—This machine’s current state and inputs dictate its output values
11. SQUAREWAVE—It is produced by a binary logic device [two words]
14. THEREMIN—Its electronic signals can be amplified and sent to a loudspeaker
15. ABAMPERE—10 A
16. SCOPEPROBE—Connects test equipment to a DUT [two words]

Rob Tholl Wins the CC Code Challenge (Week 23)

We have a winner of last week’s CC Weekly Code Challenge, sponsored by IAR Systems! We posted a code snippet with an error and challenged the engineering community to find the mistake!

Congratulations to Rob Tholl of Calgary, Alberta, Canada for winning the CC Weekly Code Challenge for Week 23! Rob will receive a CCGold Issues Archive.

Rob’s correct answer was randomly selected from the pool of responses that correctly identified an error in the code. Rob answered:

Line 14: need &array[c] to write to the proper memory location

2013_code_challenge_23_answer

You can see the complete list of weekly winners and code challenges here.

What is the CC Weekly Code Challenge?
Each week, Circuit Cellar’s technical editors purposely insert an error in a snippet of code. It could be a semantic error, a syntax error, a design error, a spelling error, or another bug the editors slip in. You are challenged to find the error.Once the submission deadline passes, Circuit Cellar will randomly select one winner from the group of respondents who submit the correct answer.

Inspired? Want to try this week’s challenge? Get started!

Submission Deadline: The deadline for each week’s challenge is Sunday, 12 PM EST. Refer to the Rules, Terms & Conditions for information about eligibility and prizes.