Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In \"C\" Programming Language In this Homework, information from a number files

ID: 3765954 • Letter: I

Question

In "C" Programming Language In this Homework, information from a number files (N) is combined to obtain a number of statistical parameters. Each file contains information about the power consumption of a sensor. Based on used, each sensor is likely to consume a different amount of power (Pi). The frequency of measurement (Ti) may be different too. 2. Input Parameters The variables for this project are: a. Number of sensors( N ): Determines the number of input files b. File location: A local directory/folder where the files are located. Each file will be named: sensor_0.txt, sensor_1.txt, …, sensor_(N-1).txt c. Time Interval(TI): Two values (Start Time (ST) and End Time (ET)) used to obtain the statistical parameters. d. Integration Method (IM): Midpoint(M) or Trapezoidal(T). e. Sample Rate (SR): A single value. SR will determine the number of “rectangles” used for the integration methods M or T. It determines how often the average is obtained. 3. Input Files The filename includes the sensor number: sensor_ .txt. For example sensor_0.txt is the file that contains the data collected by sensor with id 0. Files have the following format: For example: 4534 97.5 mW 4554 97.4 mW 4574 97.6 mW Notice: that each sensor may have a different sample rate (e.g. time in between measurements). We consider the time_stamp as an integer. 4. Statistical Values (Parameters of interest ) Assuming that N represents the number of sensors used to monitor power consumption; The program should: a) Read the files from a given location and load the information using either parallel arrays or an array of structures b) For each sensor i. The average power consumed from Start Time (ST) to End Time (ET). ii. Min and Max amount of power consumed iii. Total power consumed. This is obtained by finding the integral from ST to ET c) As an average (all the sensors) for a given SR: i. The average power consumption. ii. Min and Max amount of power consumed iii. Total Power Consumed. Notice: if no data is available for a given point, you can use linear interpolation d) The time when the power consumption was minimum/maximum and the sensor that was consuming the minimum/maximum Notice: If no data is available use linear interpolation. 5. Output Examples The program should display 1) A menu with the following options a) Enter the number of sensors b) Enter file location c) Time interval st and et d) Sample Rate e) Get statistical values f) Exit 2) Options a) to d), can be chosen any time. However once option e) is chosen the program should test whether or not all the required parameters were already given a. If there is a missing parameter, a message should be displayed indicating the input value that has not been defined b. After entering valid parameters (i.e. a) to d) values are given), a table with the statistical parameters should be displayed. For example: Sensor ID Average Min Max Total 0 23.4 15.4 31.4 2058.7 1 22.6 21.4 23.8 2154.2 N-1 25.1 25.1 25.1 2097.8 AVG 24.6 23.9 25.3 2103.6 The power consumption was minimum at time 55(18.5) reported by sensor 0, and maximum at time 67(29.4) reported by sensor 2.

Explanation / Answer

#include "dev/button-sensor.h"

#include "dev/leds.h"

#include <stdio.h>

#include <avr/sleep.h>

void main()

{

DDRB &= ~0x20; /* make B5 an input */

PORTB &= ~0x20; /* disable pull-up */

if(PINB & 0x20)

{

/* iRobot Create power is on */

}

else

{

/* iRobot Create power is off */

}

DDRD |= 0x80; /* make D7 an output */

if(!(PINB & 0x20)) /* if power is off */

{

PORTD &= ~0x80; /* set D7 low */

delay(100); /* delay so new state is seen by Create */

PORTD |= 0x80; /* set D7 high to turn power on */

delay(100); /* delay so new state is seen by Create */

}

delay(2000); /* Wait for Create’s bootloader to run */

if(PINB & 0x20) /* if power is on */

{

PORTD &= ~0x80; /* set D7 low */

delay(100); /* delay so new state is seen by Create */

PORTD |= 0x80; /* set D7 high to turn power off */

delay(100); /* delay so new state is seen Create */

}

void powerOff(void)

{

// If Create’s power is on, turn it off using D7

if(PINB & 0x20)

{

PORTD &= ~0x80;

delay10ms(50); // Delay in this state

PORTD |= 0x80; // Low to high transition to toggle power

delay10ms(10);

PORTD &= ~0x80;

}

// Configure pins and other hardware for minimum power

wdt_disable(); //disable watch dog timer

ADCSRA = 0x00; //disable the ADC

UCSR0B = 0x00; //disable UART

cli(); //disable interrupts

PRR = 0xFF; //enable all power reduction modes

DDRB = 0x10; //Set b4 as output, other B pins as input

PORTB = 0x0F; // set ePort pins B0-3 high

DDRC = 0x00; // set all C pins as input

PORTC = 0x7F; // enable pull-ups on all C pins

DDRD = 0xEE; // D0 (rx) and D4 (button) are inputs

PORTD = 0x78; // configure D pins

// Put the command module into sleep mode

// These functions are defined <in avr/sleep.h>

set_sleep_mode(SLEEP_MODE_PWR_DOWN);

sleep_mode();

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote