witches »   HW-20: Arduino - Motor Speed.problem Arduino - Measuring Motor Speed Arduino sketch with corresponding line numbers...

90.2K

Verified Solution

Question

Electrical Engineering

witches »


 


HW-20: Arduino - Motor Speed.problem


Arduino - Measuring Motor Speed

Arduino sketch with corresponding line numbers percoding line.
Match line # 1 through #17 with the corresponding instructionpurpose.
_____________________________________________________________________

1.   int count = 0;
     float f = 0;
     float PPR = 500;
     float RPM= 0;

2.   void setup()
3.      pinMode(2,INPUT);
4.     attachInterrupt(0,freq,RISING);
5.      Serial.begin(9600);

6.    void loop()
      {
7.      count=0;
8.      delay(100);
9.      f=10*count;
10.    RPM=f/PPR;
11.    Serial.print(count);
12.    Serial.print(\" Pulses/100ms\");
13.    Serial.print(\"\t\");
14.    Serial.print(f);
15.    Serial.println(\" Hz\");
       }

16.   void freq()
        { 
17.      count=count++; 
        }

 1 2 3 4 5  Establish inputs andoutputs 
 1 2 3 4 5  DeclareVariables 
 1 2 3 4 5  Establish outputcommunications with the monitor 
 1 2 3 4 5  Declare digitalinput pin 
 1 2 3 4 5  Establish interruptdigital input pin, name and mode 
 Tries 0/2
 6 7 8 9 10  Establish initialcount value within the running program loop 
 6 7 8 9 10  Infinite loop -running program 
 6 7 8 9 10  Calculaterevolutions per minute 
 6 7 8 9 10  Calculatefreqency 
 6 7 8 9 10  Delay 100 ms whilecounting interrupt pulses 
 Tries 0/2
 11 12 13 14 15  Print text\"Pulses/100ms\" to monitor 
 11 12 13 14 15  Print countvalue to monitor 
 11 12 13 14 15  Print text \"Hz\" to monitor then line feed 
 11 12 13 14 15  Print frequencyvalue to monitor 
 11 12 13 14 15  Print tabspacing to monitor 
 Tries 0/2
 16 17  Interrupt subroutine 
 16 17  Add one to the count which isaccumulating the number of pulses in 100ms 
 Tries 0/2

Answer & Explanation Solved by verified expert
4.1 Ratings (554 Votes)
1int count 0 float f 0 float PPR 500 float RPM 0 Declare Variables 2 void setup Establish output communications with the monitor 3pinMode2INPUT Establish inputs and outputs    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students