Hardware Sofware Partitioning
Hardware Sofware Partitioning
Design a system HONEY BEE COUNTER with following specifications. The bees are
assumed to enter the bee hive in rectangular box through a small hole. Another hole is made
for the bees to exit. Assume suitable sensors are placed at entry & exit holes. The system is
designed to display the number of bees in hive at any time. Assume initially there are no bees
in hive.
Block Diagram:
Entry Sensor (IR Microcontroller
Display module Power supply
Sensor, Camera (Counter logic
module
etc) & storage)
Pseudo Code:
Initialize bee_count = 0
// Main Loop
Loop:
if Entry Sensor is triggered:
Increment bee_count by 1
Update Display with current bee_count
if Exit Sensor is triggered:
if bee_count > 0:
Decrement bee_count by 1
Update Display with current bee_count
else:
// Ensure count does not go below zero
bee_count = 0
// Small delay to prevent multiple triggers
Delay (a small interval)
End Loop
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
// Define pins for entry and exit sensors (these can be connected to GPIO pins)
#define ENTRY_SENSOR_PIN 2
#define EXIT_SENSOR_PIN 3
// Function prototypes
void initialize_system(void);
bool is_bee_entering(void);
bool is_bee_exiting(void);
void update_display(int count);
void delay_ms(uint16_t ms);
// Global variable to store the count of bees in the hive
int bee_count = 0;
int main(void) {
initialize_system();
while (1) {
// Check if a bee is entering
if (is_bee_entering()) {
bee_count++; // Increment bee count
update_display(bee_count); // Update display with new count
delay_ms(200); // Delay to avoid multiple counts for a single bee
}
// Check if a bee is exiting
if (is_bee_exiting()) {
if (bee_count > 0) { // Ensure count does not go negative
bee_count--; // Decrement bee count
update_display(bee_count); // Update display with new count
}
delay_ms(200); // Delay to avoid multiple counts for a single bee
}
}
return 0;
}
// Function to initialize system peripherals
void initialize_system(void) {
// Initialize GPIO pins for sensors
pinMode(ENTRY_SENSOR_PIN, INPUT);
pinMode(EXIT_SENSOR_PIN, INPUT);
// Initialize the display (e.g., LCD or LED display)
initialize_display();
// Display initial bee count (0)
update_display(bee_count);
}
// Function to check if a bee is entering
bool is_bee_entering(void) {
// Returns true if the entry sensor is triggered
return digitalRead(ENTRY_SENSOR_PIN) == HIGH;
}
// Function to check if a bee is exiting
bool is_bee_exiting(void) {
// Returns true if the exit sensor is triggered
return digitalRead(EXIT_SENSOR_PIN) == HIGH;
}
// Function to update the display with current bee count
void update_display(int count) {
// Example function to update display, assuming a simple integer display
// Replace with actual display code for your hardware
printf("Bee Count: %d\n", count);
}
// Simple delay function (blocking)
void delay_ms(uint16_t ms) {
for (uint16_t i = 0; i < ms; i++) {
_delay_ms(1);
}
}
PROBLEM 2
Design MCU based system to control temperature of the furnace with following
specifications. The furnace temperature has to maintain at 30±10C. Connect suitable sensors
& actuators. Display the temperature on LCD. The power consumption has to be minimized.
Show the design & implementation (diagram +Program).
// Temperature Thresholds
const float targetTemp = 30.0; // Target temperature in °C
const float lowerThreshold = 20.0; // Minimum temperature in °C
const float upperThreshold = 40.0; // Maximum temperature in °C
// LCD initialization
LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C address might vary
void setup() {
// Initialize Serial Monitor
Serial.begin(9600);
// Initialize LCD
lcd.begin();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Furnace Temp Ctrl");
// Setup heater and fan pins
pinMode(heaterPin, OUTPUT);
pinMode(fanPin, OUTPUT);
void loop() {
// Read temperature from LM35
float voltage = analogRead(tempSensorPin) * (5.0 / 1023.0);
float temperatureC = voltage * 100; // Convert voltage to temperature (°C)
For communication between these MCUs, we would likely use Serial Communication
Protocols such as RS-485, CAN Bus, or I2C. Here’s why each might be a suitable choice:
1. RS-485: This protocol is ideal for industrial environments due to its robustness over
long distances and resistance to electrical noise, which is often present in a chemical
plant. It can support multiple devices on a single bus, making it possible to
interconnect the MCUs over a reliable network.
2. CAN Bus (Controller Area Network): Widely used in industrial and automotive
systems, CAN is also robust and handles communication effectively in noisy
environments. It supports multi-master communication, allowing the MCUs to
communicate as peers.
3. I2C (Inter-Integrated Circuit): Although commonly used for short-range
communication, I2C could be considered for smaller installations. If all MCUs are
relatively close, this simple protocol is a cost-effective option.
Each MCU will communicate its data (such as liquid level, temperature, and control signals)
over the chosen bus. The Master Room MCU (MCU 3) would listen to the data broadcast
from MCU 1 and MCU 2 and then display it on the LCD for monitoring.
1. Performance Optimization:
● Hardware is generally faster than software because it operates directly on the
underlying physical components. Performance-critical tasks are often
implemented in hardware to achieve higher speed and efficiency.
2. Flexibility:
● Software is more flexible than hardware and can be easily updated or
modified. Functions that may change frequently or require adaptability are
often implemented in software to allow for easier updates.
3. Cost Considerations:
● Hardware components can be expensive to design and manufacture. If a
function can be adequately performed by software without compromising
performance, it might be more cost-effective to implement it in software.
4. Power Consumption:
● Hardware typically consumes more power than software. In battery-powered
or energy-efficient systems, designers may choose to implement certain
functions in software to minimize power consumption.
5. Parallelism:
● Hardware is well-suited for parallel processing, making it efficient for tasks
that can be divided into multiple independent sub-tasks. Software, on the other
hand, may be limited in its ability to exploit parallelism.
6. Real-Time Requirements:
● Real-time systems often require strict timing constraints. Critical real-time
functions may be implemented in dedicated hardware to ensure timely and
predictable execution.
7. Resource Utilization:
● Hardware implementations are often more resource-intensive in terms of
silicon area and power consumption. Software implementations, while more
flexible, may be more resource-efficient.
8. System Integration:
● Hardware and software components must seamlessly integrate into a cohesive
system. The partitioning decisions need to take into account the interfaces and
communication protocols between hardware and software modules.
USE CASE 1:
USE CASE 2:
RESEARCH PAPER: Construction of a Smart Vision-Guided Robot system for manipulation in a
Dynamic Environment disclaimer
USE CASE 3:
https://in.mathworks.com/help/soc/ug/motor-control-simulation-example.html