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

Chapter 04

Developing a Utility Library for the Propeller PCB

Page 7

Questions

onSeq
Q12 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 instructions is negligible.
What pattern the following code displays/renders:

//                  BGR
#define BLACK         0
#define RED           1
#define GREEN         2
#define YELLOW        3
#define BLUE          4
#define MAGENTA       5
#define CYAN          6
#define WHITE         7

float D = 137.888889;

unsigned int onSequence = 0x5555; // 0101 0101 0101 0101 Even LEDs are ON

int main()
{
	while(1)
	{
		switch_LEDs(onSequence, RED); 
		myDelay(D * 180);

		switch_LEDs(onSequence, BLUE); 
		myDelay(D * 180);

	}
}


Imagine: What do you see ? Scroll below to check your answer
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
To move one degree it will take 137.888889 micro seconds
To move one degree it will take D amount of time
To move one 180 degree it will take D x 180 amount of time
Since onSequence = 0x5555; // 0101 0101 0101 0101 Even LEDs are ON in RED for 180° and
for next 180° the same LEDs are ON in BLUE color.

Answer




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