Skip to content

A GUI application designed to communicate with a microcontroller to control a motor's rotation speed and direction.

Notifications You must be signed in to change notification settings

AhmedAlyElGhannam/Controlling-a-Motor-Java-Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Controlling-a-Motor-Java-Project

Introduction

This is the final project of the Developing Applications Using Java course taught in Information Technology Institute (ITI)'s 9-Month Professional Training Program -- Embedded Systems Track as a part of the intensive Android Automotive subfield under the supervision of Eng. Ahmed Mazen from Java Education & Technology Services department.

About The Team

This project was made by Team #4 whose members are:

  1. Ahmed Aly El-Ghannam.
  2. Omar Mohamed Mostafa.
  3. Rahma Abdelkader.

Brief

The project, as the name suggests, is a JavaFX GUI application built to control a DC motor rotation speed and direction---this is done by making the app communicate with an MCU to do the actual motor control logic. Additionally, as a team, we have decided to pick a use case theme for the application as an air conditioner control app. Functionally, it does the exact same job but aesthetically, it makes all the difference. :)

Software Technology Stack

The tools, technologies, and libraries used are as follows:

  1. JDK 8 + JFX8 → GUI.
  2. Make → compilation & packaging of GUI and its dependencies into a single .jar file.
  3. C11 + CMake + MISRAC Standard → development of MCU logic and firmware libraries.
  4. Python3 → scripts to test the functionality of each part of the project separately.

System Architecture

System architecture can be summarized in the following sequence diagram. For more info, you can view the project's full documentation.

Requirements

This section mentions our interpretation of the project's requirements and the design we have followed.

JavaFX

  1. Class for USART communication ###
  2. Class for App (With 2 scenes):
    1. Required. ###
    2. Spice (Air Conditioning)
  3. [Thread] Handler for Slider to get value from defined range + send it via USART SOMEHOW ###
  4. TextField to show motor rpm + CW || CCW. ###
  5. Additional TextField to indicate that an acknowledge frame was received from MCU.
  6. Handler for Spice page switcher button
    1. Knob,
    2. On/Off toggle switch,
    3. CW for Cold && CCW for Hot.

MCU [ATMEGA32 --- debatable]

  1. Drivers: (USART + PWM + Sched [TIMER] + DIO/GPIO [for LEDs])
  2. Every 500ms, read received USART frame and set motor speed accordingly.
  3. USART frame consists of the following fields:
    1. Bit 7-5 -> ID → changes with every sent frame if receivedID == lastID ==> then connection is lost [LED Red] else ==> everything is ok [LED Green]
    2. Bit 4 -> Dir → CW || CCW
    3. Bit 3-0 -> Speed → values from 0 to 15 will be scaled accordingly.
  4. PWM signal should use received speed && dir fields to drive the motor.
  5. Upon receiving a valid frame from JavaFX app, send a USART acknowledgement frame 0xFF to GUI app.

MCU [Actual Requirements]

  1. Scheduler -> every 500ms run function

USART IRQ:

  1. upon receiving a byte (data), save it in some global variable THEN send Ack.

Scheduled Function:

  1. [Alternative --- NOT NEEDED if USART IRQ is used] wait until data byte is received THEN send Ack.
  2. Extract data from received byte.
  3. If ID is the same as old ID → stop motor, light up a red LED, return [This makes MCU check for received byte each time Scheduled function is invoked to resume immediately after connection is back].
  4. Else, Drive motor with specified speed and direction + light up a green LED.

Tasks Distribution

This part is not relevant anymore but it will still be left here for reference.

Tasks --- Java:

  • SerialCommManager class for handling USART communication periodically. A
  • GUI for Required Scene. R
  • Slider handler for required scene. O
  • TextField for speed + dir. R
  • App integration with SerialCommManager. A
  • [ ] TextField for acknowledgement. R
  • EXTRA: GUI for Air Conditioner
  • EXTRA: Handlers for Knob + Toggle Switch

Tasks --- MCU Motor Control:

  • USART Driver. O
  • PWM Driver. R
  • Scheduler (Timer) Driver.
  • DIO/GPIO Driver for LEDs.
  • USART IRQ that handles data reception && ack byte transmission. O
  • Scheduled function that does the speed control logic. A

Video Demo

VideoDemo.mp4

About

A GUI application designed to communicate with a microcontroller to control a motor's rotation speed and direction.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •