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.
This project was made by Team #4 whose members are:
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. :)
The tools, technologies, and libraries used are as follows:
- JDK 8 + JFX8 → GUI.
- Make → compilation & packaging of GUI and its dependencies into a single
.jar
file. - C11 + CMake + MISRAC Standard → development of MCU logic and firmware libraries.
- Python3 → scripts to test the functionality of each part of the project separately.
System architecture can be summarized in the following sequence diagram. For more info, you can view the project's full documentation.
This section mentions our interpretation of the project's requirements and the design we have followed.
- Class for USART communication ###
- Class for App (With 2 scenes):
- Required. ###
- Spice (Air Conditioning)
- [Thread] Handler for Slider to get value from defined range + send it via USART SOMEHOW ###
- TextField to show motor rpm + CW || CCW. ###
- Additional TextField to indicate that an acknowledge frame was received from MCU.
- Handler for Spice page switcher button
- Knob,
- On/Off toggle switch,
- CW for Cold && CCW for Hot.
- Drivers: (USART + PWM + Sched [TIMER] + DIO/GPIO [for LEDs])
- Every 500ms, read received USART frame and set motor speed accordingly.
- USART frame consists of the following fields:
- Bit 7-5 -> ID → changes with every sent frame if receivedID == lastID ==> then connection is lost [LED Red] else ==> everything is ok [LED Green]
- Bit 4 -> Dir → CW || CCW
- Bit 3-0 -> Speed → values from 0 to 15 will be scaled accordingly.
- PWM signal should use received
speed
&&dir
fields to drive the motor. - Upon receiving a valid frame from JavaFX app, send a USART acknowledgement frame
0xFF
to GUI app.
- Scheduler -> every 500ms run function
USART IRQ:
- upon receiving a byte (data), save it in some global variable THEN send Ack.
Scheduled Function:
- [Alternative --- NOT NEEDED if USART IRQ is used] wait until data byte is received THEN send Ack.
- Extract data from received byte.
- 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].
- Else, Drive motor with specified speed and direction + light up a green LED.
This part is not relevant anymore but it will still be left here for reference.
- 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
- 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