424,952 Members | 1,665 Online
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

# How would I determine the number of machine instructions needed to run a main loop?

 P: n/a I am determining the necessary processor throughput based on the amount of time a particular processor would take to handle the main loop in my code. If it is relevant, I am deliberating between using an Arduino MCU (16 MHz, 8-bit, 16 MIPS) and a Maple MCU (72 MHz, 32-bit). I know that, worst case scenario, the processor will have 12 milliseconds to run through the loop. The below code is the "higher level" variant and calls some external codes. Expand|Select|Wrap|Line Numbers void loop() {   potValue = analogRead(potPin);   int servoPulse = map(potValue, 0, 1023, 600, 1500); //Maps pulse in microseconds   servo.writeMicroseconds(servoPulse);   //int valveDegrees = servo.read(); //Reads the degrees the air manifold valve is open   pressureValue = analogRead(pressurePin);   int MAP = map(pressureValue, 40.92, 1002.54, 20, 250); //Maps pressure in kPa   tempValue = analogRead(tempPin);   int MAT = map(tempValue, 0, 1023, 0, 500); //Maps temp in K- values require confirmation    //   pulseDelay = 1000*(((.79*2*14.01+.21*2*16)*7920*.148*.6)/(.0821*14.9*101.325*20))*(MAP/MAT);   sparkDelay = 215.94214021463*(timeNew-timeOld)-pulseDelay+corr; //Delay before spark fires (should the pulse calculations be at the beginning or end?) }   This code is a little more "lower level" and incorporates fewer external calls. Expand|Select|Wrap|Line Numbers void loop() {   pressureValue = analogRead(A2);   int MAP = (pressureValue-40.92)*(230/961.62)+20;   tempValue = analogRead(A4);   int MAT = tempValue*(500/1023); //Maps temp in K- values require confirmation    potValue = analogRead(A0);   int servoPulse = potValue*(900/1023)+600; //Maps pulse in microseconds   //   pulseDelay = ((28.85*7920*148*.6)/(.0821*15*101.325*20))*(MAP/MAT); //Stoichiometric calculation for fuel injection timing- requires C, D, and F- simplify the number once found (allow for lean mix)   sparkDelay = 215.94214021463*(timeNew-timeOld)-pulseDelay+corr; //Delay before spark fires (should the pulse calculations be at the beginning or end?)   if (servoTimer<=(millis()-20)) {     PORTB=B00000001;     delayMicroseconds(servoPulse);     PORTB=B00000000;     servoTimer=millis();   } }   I really appreciate the help, thanks! -Hari Ganti Oct 20 '10 #1