Objective
- To familiarise with the ATMega328P AVR microcontroller architecture through Atmel AVR on Microsoft Visual Code
- To familiarise yourself with the MCU and Motor module, particularly using the Analogue/Digital Converter (ADC) module on the MCU board, and utilising the Stepper Motor driver on the Motor board
- Apply basic concepts and understanding of the AVR microcontroller by programming in C
- Gain experience in interfacing with AVR architecture through the Arduino Uno
Assignment 2 - PIC Microcontroller
- The assignment is split into two sections
- i. Part A - Mastery Checklist
- ii. Part B - AVR Arduino Program Application iii.
- Part C - Reflection
Required Equipment
- Software Requirements
- You will need a computer/laptop with the following software installed:
- Microsoft Visual Code
- C/C++ (Microsoft)
- PlatformIO IDE (PlatformIO) with Atmel AVR platform
- Microsoft Visual Code
- You will need a computer/laptop with the following software installed:
- Hardware Requirements
- You will need the following hardware:
- DXK Arduino Uno
- RGB LED module
- Stepper Motor
- Servo Motor
- Liquid Crystal Display (LCD)
- Joystick Module
- Potentiometer
- You will need the following hardware:
Part A - AVR Arduino Program Application
- At demonstrations, you are required to present YOUR OWN DXK board, with the program on the board ready for assessment. The assessor will test your board and judge if it meets the assignment requirements.
- You will be questioned on your submission. If you cannot demonstrate a full and complete understanding of your system (Both in your program as well as basic specifics of the MXK board) you will receive ZERO marks. Blindly copying is plagiarism and will NOT be tolerated.
- The program application will be programmed using C programming language.
- The template for Assignment 2 is available on UTS Online. Please use the template for the assessment. The only file you will need to change is main.c.
- You are not to use any other libraries (other than the ones already written in main.c) for this assessment.
- Your main.c file should be uploaded to TurnItIn on UTSOnline by the end of the lab.
- At the end of assessment, you are required to hand over a copy of your code to the assessor’s USB stick.
System Operation - Overall
- The system will have 2 states based on the joystick button toggle: LCDADC, STEPPER, and LCDSFT.
- When the system is powered, it will enter LCDADC mode after the stepper motor setups
- In STEPPER mode, the joystick will turn the stepper motor clockwise/anti-clockwise depending on the direction of the joystick. The reading from the joystick will control the speed at which the stepper motor rotates. (delay range of 4ms-10ms would suffice)
- In LCDSFT mode, the joystick button will shift from page 1 to page 2
- In all 3 states, there are certain information to be displayed on the 16x2 including the ADC conversion result between 0-1023 (10-bit ADC)
System Operation (1) - LCD and RGB LED
- When the system is powered on, the LCD should initialise properly (with backlight on)
- The LCD should be set to function with 4-bit data transfer using parallel wiring from your Arduino at the pins of your choice
- The LCD should initialise with the 16x2 displaying the following below:
- 12345678 should reflect YOUR student number. i.e. if your student number is 99021123, the LCD should display your student number
- xxxx indicates the actual calculated ADC value from System Operation (2)
- yyy indicates the current step count which is wrapped (-4095-]4096)
- The step count and ADC should be updated constantly
- In LCDSFT mode, the joystick button will switch from one page to the other (in an endless cycle based on some REASONABLE threshold of your choice, e.g. which values correspond with a page switch in your ADC result
- Page 2 of the LCD should show the following
- In LCDADC mode, the RGB LED should show RED only
- In LCDSFT mode, RGB LED should fade between GREEN and BLUE using PWM
System Operation (2) - Analogue Digital Converter
- When the system is powered on, the ADC should be initialized properly.
- The ADC should run constantly in a loop.
- One of the channels from the joystick is to be connected to an ADC pin of your choice.
- The output reading from the ADC conversion for the joystick input should be displayed and updated constantly in the LCD - System Operation (1).
- Hint: The ADC should run between 50kHz and 200kHz. Your clock source is 16MHz, and you can set ADC pre-scalers in ADCSRA register.
System Operation (3) - Stepper Motor
- The stepper motor should be initialized when the system is powered on.
- The stepper motor should initially rotate 256 steps clockwise at a fast speed, and then
256 steps anti-clockwise at a slow speed. (Make your delay/motor period 1ms and 5ms respectively) - In STEPPER mode, the joystick will control the stepper motor turning. The position of the joystick will determine the speed - the further away from the middle will cause the stepper to turn faster
- In LCDSFT mode, the stepper motor doesn’t rotate
System Operation (4) - Timer, Servo Motor, and PWM
- If there are any delays used in the program, Timers must be used.
Marking scheme - Part B
- Students should read the tabulated marking scheme and make sure their solution and reflection comply with the relevant points.
- The tutor will assess the program during the demonstration and question your code during demonstration individually. Demonstration will be limited to 10 minutes.
- NOTE: LCDSFT state is treated as an extension module. There will be some resources provided, however, tutors will not help directly with that module.
- PROTECT YOUR OWN WORK: Do not give any other students any part of your assignment. Students found sharing work will be awarded ZERO marks and may face disciplinary action.
- If your friends are asking for help, you should NOT give them your report or assignment. Rather, help them by explaining the theory behind the problem, or refer them a source where they can get further information.
- Putting the question in the discussion board is also a good alternative as they are checked by tutors regularly throughout the semester.
NOTE: If you think you can’t implement the whole assignment and you decide to implement part of it only, then we expect to see some outcomes. For example:
- If you decide to tackle STEPPER Mode, you must show the stepper motor moving clockwise/anticlockwise when the joystick is pressed. If you are unable to interface with the joystick, use a button as an alternative way to move the stepper motor.
- If you cannot implement the use of timers, you may use the _delay_ms([delay time in milliseconds]) function as a placeholder.
- If you are unable to implement the stepper motor hardware, you can use LEDs to indicate your phase outputs for the stepper motor driver.
- If you are unable to implement the ADC, you can use a press button to indicate reaching the threshold or not.
Notes on the internet
Should you decide to use information from the internet, then you must provide a reference and full explanation. However, all information required to implement this assignment yourself has been provided through tutorials, lecture and lab videos, as well as the interactive lectures.
Other Notes
- Any student taking more than 10 minutes will be awarded with the marks they have accrued UP TO THAT POINT and the demonstration will end.
- The assessor will collect your code on their USB memory stick.
- No alternative assessment for demonstration will be scheduled.
- Assignment 2: Part C is a reflection of your efforts in Part B. Your reflection will NOT BE EVALUATED IF YOU DO NOT DEMONSTRATE PART B.
Students with difficulty meeting assessment requirements
Students who experience signification difficulty, or anticipate that they will experience significant difficulty in meeting assessment requirements must submit an “Application for Special Consideration form” to the Registrar before the due date of the assessment item. Significant difficulty means:
- Serious illness or psychological condition
- Loss or bereavement
- Hardship/trauma
Note also that students may apply for special consideration because of illness or other circumstances (not work related) beyond their control. The “Application for Special
Consideration form” has a section that must be filled in by a doctor, counsellor or other relevant professional authority. A medical certificate alone is not adequate and will not be accepted.
Note that it is up to the students to provide adequate information about their circumstances. University staff will not chase additional information and the Subject Coordinator has the right to reject applications that lack sufficient information.
It is the student’s responsibility to contact the Subject Coordinator to find out what action has been taken and to obtain details of any additional assessment required or learning and assessment special arrangements.
For further details please refer to section 4.6 of the “Coursework Assessment Policy and Procedures Manual”.