WR Home      Topic Home      Chapter:  1  2  3  4 
<Previous Next>

Chapter 04

Developing a Utility Library for the Propeller PCB

Page 11

Questions

onSeq

Q16 FINAL TEST 1 Suppose if the Propeller is rotating at a constant speed of RPM = 1200
It will make 20 number of turns in a second (1200/60 = 20)
and to move one degree it will take 137.888889 micro seconds
Assume that time taken to execute the LOOPING instructions is negligible and delays are exact.
What pattern the following code displays/renders:


float D = 137.888889;

unsigned int onSequenceEVEN = 0x5555; // 0101 0101 0101 0101 EVEN LEDs are ON
unsigned int onSequenceODD  = 0xAAAA; // 1010 1010 1010 1010 ODD  LEDs are ON
int main()
{
	int i;
	while(1)
	{
		for(i=0; i< 90; i++) 
		{	switch_LEDs(onSequenceEVEN, RED); 
			myDelay(D);
		}

		for(i=0; i< 90; i++) 
		{	switch_LEDs(onSequenceEVEN, BLUE); 
			myDelay(D);
		}

		for(i=0; i< 90; i++) 
		{	switch_LEDs(onSequenceODD, RED); 
			myDelay(D);
		}

		for(i=0; i< 90; i++) 
		{	switch_LEDs(onSequenceODD, BLUE); 
			myDelay(D);
		}

	} // while(1)
} // main()

Imagine: DISCUSS: What do you see ? Scroll below to check your answer
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
HINT:
When Even numbered LEDs are in First quadrant, then ODD numbered LEDs are in opposite (Third) quadrant.
When Even numbered LEDs are in Second quadrant, then ODD numbered LEDs are in opposite (Forth) quadrant.
When Even numbered LEDs are in Third quadrant, then ODD numbered LEDs are in opposite (First) quadrant.
When Even numbered LEDs are in Forth quadrant, then ODD numbered LEDs are in opposite (Second) quadrant.
ODD EVEN

Explanation followed by Answer:
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
The Tip of the propeller PCB is denoted by a RED dot (circle)

for(i=0; i< 90; i++) 
{	switch_LEDs(onSequenceEVEN, RED); 
	myDelay(D);
}
    

For 90° First quadrant has all EVEN LEDs as RED
ODD LEDs (which are physicaly in the Third quadrant at the same time instant) are OFF

persistence

for(i=0; i< 90; i++) 
{	switch_LEDs(onSequenceEVEN, BLUE); 
	myDelay(D);
}

For 90° Second quadrant has all EVEN LEDs as BLUE
ODD LEDs (which are physicaly in the Forth quadrant at the same time instant) are OFF

persistence

for(i=0; i< 90; i++) 
{	switch_LEDs(onSequenceODD, RED); 
	myDelay(D);
}

For 90° THIRD quadrant has all EVEN LEDs as OFF
ODD LEDs (which are physicaly in the First quadrant at the same time instant) are RED

persistence

for(i=0; i< 90; i++) 
{	switch_LEDs(onSequenceODD, BLUE); 
	myDelay(D);
}

For 90° FORTH quadrant has all EVEN LEDs as OFF
ODD LEDs (which are physicaly in the Second quadrant at the same time instant) are BLUE

persistence


And finally due to persistence of vision:

Answer




WR Home      Topic Home      Chapter:  1  2  3  4 
<Previous Next>