Learning Bitwise Operations in C Using Remote Experiment on Floating LEDs Blinking Vanja Luković, Radojka Krneta, Aleksandar Peulić, Željko Jovanović, ĐorĎe Damnjanović
Abstract —The application of remote experiment on floating LEDs blinking in learning bitwise operations in C is described in the paper. The experiment on floating LEDs blinking is realized using Microchip PIC microcontroller placed on the BIGPIC 5 platform. Lab module with remote access to this experiment is created with the aim of learning programming techniques from the beginning of engineering studies through creation of simple engineering application program control of LEDs on / off switching. The application is realized using the software tool MicroC PRO for PIC. This lab module with remote experiment was used by students within their first course of C programming language in second year of Electrical, Computer and Mechatronics Engineering study programs at Faculty of Technical Sciences Čačak, University of Kragujevac. Results of student evaluation of this lab module is also presented and discussed. Index Terms—Remote experiment, Microcontroller programming, Bitwise operations in C, Student evaluation
I. INTRODUCTION Higher Education institutions having engineering study programs need to include innovative teaching methods into teaching engineering courses in order to prepare graduates who will be able to participate in solving real engineering task soon after their employment. Therefore, engineering students should identify themselves as engineers even at the beginning of their studies. This can be achieved through growing practical engineering knowledge and skills of students so as to teach them theoretical topics of engineering courses with continuous support of laboratory experimentation. Innovative teaching method based on remote experiments enables students, which are away from laboratories located at their faculties, to do hardware experiments placed in remote laboratory at any time and gain practical engineering knowledge and skills. This innovative teaching method aims to encourage students to understand and learn theory through the practice and, in this way, to prepare themselves for future engineering work. The wider objective of NeReLa project [1] is to increase attractiveness of engineering education through innovative teaching methods as well as through the strengthening of university-secondary vocational schools collaboration. Introducing remote Vanja Luković, Radojka Krneta, Željko Jovanović and ĐorĎe Damjanović are with the Faculty of Technical Sciences Čačak, University of Kragujevac, Svetog Save 65, 32 00 Čačak, Serbia (e-mail:
[email protected],
[email protected],
[email protected] and
[email protected]). Aleksandar Peulić is with the Faculty of Engineering, University of Kragujevac, Sestre Janjić 6, 34000 Kragujevac, Serbia (e-mail:
[email protected]).
experimentation into engineering curricula at higher and secondary education level is one of innovative teaching methods that can attract young people to enroll engineering studies and later, during their study, to help them to autonomously solve simple engineering problems. For the purpose of early introduction of engineering students in the world of real engineering applications, they should to face with laboratory exercises for solving simple engineering tasks, still in the first years of their engineering studies. In this aim the remote experiment on floating LEDs blinking for learning bitwise operations in C is used as lab module by students within their first course of C programming language in second year of Electrical, Computer and Mechatronics Engineering study programs at Faculty of Technical Sciences Čačak. After theoretical classes with the topic “Bitwise operations in C” within the course in programming languages, students had opportunity to perform remote experiment on floating LEDs blinking autonomously from their homes, dormitory, i.e. This remote experiment implied the application of gained theoretical knowledge in the above mentioned topic for programming Microchip PIC microcontroller to afford the target floating LEDs blinking. Obtaining specific visual effect of floating LEDs blinking was assigned to each student as his/her homework assignment, which he/she should solve by programming Microchip PIC microcontroller remotely. The microcontroller is placed on the BIGPIC 5 platform [2] located in remote laboratory at Faculty of Technical Sciences Čacak. Before performing remote experiment, students have to study comprehensive description of this lab module [3] containing guidelines of the key features of BIGPIC 5 platform, MikroC PRO software developing environment for programming PIC microcontrollers [4], as well as theoretical background of bitwise operations in C programming language. First focus of this paper is on description of lab module with remote experiment on floating LEDs blinking. Brief description of key features of MikroElektronika BigPIC5 platform as well as MikroC PRO developing environment for programming PIC microcontrollers is given in the following section. Creating an application in MikroC PRO for PIC is described in such a way that students studying C programing language in second year of engineering studies, who didn‟t yet learn microcontrollers and microcontroller programing, can use this description as guidelines for creating their LEDs blinking application. Also an example solution of LEDs blinking on/off is described in detail. Second focus of this paper is on reviewing results of students‟ evaluation of realized lab module with remote experiment on floating LEDs blinking. Evaluation was conducted by surveying students who attending the course
in C programing language during summer semester in this school year in the second year of undergraduate studies at Faculty of Technical Sciences Čačak, University of Kragujevac. Before performing remote experiment students got detailed instructions and explanations from their teacher about using this remote experiment for solving their individual exercises/ homework assignments. Result of student evaluation will be used for further improving this remote lab module with remote experiment and development of new ones.
Fig. 2. SW5 switch group
II. REMOTE EXPERIMENT ON FLOATING LEDS BLINKING For this remote experiment MikroElektronika BigPIC5 platform was used in integration with CEyeClon remote environment [5]. CEyeClon platform is organized like remote desktop platform with lots of possibilities like IP camera integration or scheduling time user access. Students connect with working environment through CEyeClon viewer [6] which needs to be installed on their personal PCs together with .Net Framework 4.5 [7] before starting the experiment. Besides, students need to install additional software for programming PIC microcontrollers MikroC PRO for PIC [4] on theirs personal PCs.
Fig. 3. On BigPIC5 board LEDs
The Fig. 4 illustrates the connection between PORTD pins and the corresponding LEDs. A resistor is serially connected to LEDs in order to limit current through them.
A. Key features of MikroElektronika BigPIC5 platform
Fig. 4. LEDs schematic
Fig. 1. Main components of MikroElektronika BigPIC5
MikroElektronika BigPIC5 [2] allows students and engineers to easily test and explore abilities of PIC microcontroller. Additionally, it allows PIC microcontroller to be interfaced with external circuits and broad range of peripheral devices. MikroElektronika BigPIC5 is connected to PC using USB cable (4 in Fig. 1). Before establishing USB connection it was necessary to install PICFlash software on PC, to enable a program to be transferred from PC to microcontroller. The main components of MikroElektronika BigPIC5 for the experiment are as the following (Fig. 1): - External power supply 8V – 16V AC/DC - 1 - Selectable external and USB power supply – 2 - Power on/off switch - 3 - USB connector - 4 - Microcontroller - 6 - LEDs – 13 (Fig. 3) - Switch group SW5 allows all LEDs on PORTA, PORTB, PORTC, PORTD, PORTE, PORTF, PORTG, PORTH i PORTJ to be connected/disconnected from the microcontroller – 14 (Fig. 2)
BigPIC5 has 67 LEDs (Fig. 3) arranged in nine groups and connected to PIC microcontroller: PORTA, PORTB, PORTC, PORTD, PORTE, PORTF, PORTG, PORTH and PORTJ. With the exception of PORTA and PORTG, each group consists of eight LEDs and can be enabled/disabled using switches of the switch group SW5. PORTA and PORTG have 6 and 5 LEDs, respectively. When enabled, LEDs displays the states of corresponding microcontroller pin. Other ways the LEDs are always off, no matter what the port state is, since no current can flaw through them. B. MikroC PRO developing environment for programming PIC microcontrollers MikroC for PIC [4] is a very powerful development tool for programming PIC microcontrollers. It is designed to maximally facilitate developer‟s job in applications development. PIC microcontrollers are the most popular 8bit microcontrollers, which are used in wide range of applications. On the other hand, the C programming language, as one of the most widely used programming language is natural choice for microcontroller programming. MikroC PRO for PIC provides a very efficient and advanced IDE (Integrated Development Environment), ANSI compliant compiler, a wide range built in libraries, comprehensive documentation and numerous examples
ready for use. MikroC PRO for PIC allows easy and fast application development. MikroC PRO for PIC environment consists of (Fig. 5): -
01- Main toolbar 02- Code explorer 03- Projects settings 04- Messages 05- Code Editor 06- Image preview 07- Project manager 08- Library manager Fig.6. Defining the name and location of the project, microcontroller and microcontroller clock in the software tool mikroC PRO for PIC
In the next step existing source files can be included in the project. In the third step, libraries for including in the project are specified. In the last step project can be additionally configured. After writing a program, it is necessary to translate it to the machine language, a language that is understandable to the microcontroller. This is done by the command Build from the Build menu, after that HEX file (Fig. 7) is created and by issuing the command Program from the same menu the file is loaded into microcontroller memory (Fig. 8). If there were anomalies during the execution of the program, it is necessary to debug a program.
Fig. 5. MikroC PRO for PIC environment
MikroC PRO for PIC organizes applications into projects consisting of a single project file (with .mcppi extension) and one or more source files (files with .c extension). The MikroC PRO for PIC compiler allows a programmer to manage several projects at a time. Source files can be compiled only if it is a part of the project. A project file contains: project name and optional description, target microcontroller in use, microcontroller clock, list of the project source files, binary files (.mci) and other files. C. Creating application project on floating LEDs blinking in MikroC PRO for PIC The new project is created by choosing New Project option from the cascading menu New File (Fig. 5). This command starts a wizard that takes programmer through the four steps. In the first step the name of the project, the path to the project, used microcontroller and microcontroller clock have to be defined (Fig. 6). In our case the used PIC microcontroller was PIC 18F8520, while microcontroller clock was set to 10.000000 MHz.
Fig. 7. Building the project and creating HEX file which can be loaded in microcontroller
Students‟ activities during the experiment included following tasks: - Creating LED blinking application for given task in the MikroC PRO for PIC on student‟s personal PC; - Login to Lirex platform [8] over Ceyeclon viewer using access key, which is got from Lirex administrator; - Creating a folder with the student‟s name and surname in the existing Led blinking/Codes folder on the desktop of remote server; - Coping Notepad file containing source file code realized in MikroC PRO for PIC project to the personal student‟s Led blinking/Codes folder on the remote server; - Opening MikroC PRO for PIC on the remote server and editing existing source file in existing LedBlinking.mcppi project on remote server, by replacing it with student‟s Notepad file contents; - Runing Build and Build + Program commands (Fig. 7) and creating LedBlinking.hex file.
char counter; /*Delay of 1s*/ void wait(){ Delay_ms(1000); } void main() TRISB = TRISC = TRISD = PORTB = PORTC = PORTD =
//set direction to be output //set direction to be output //set direction to be output //turn OFF the PORTB leds //turn OFF the PORTC leds //turn OFF the PORTB leds
/*Floating LED’s turning on with pauses of 1s */ while(1){ for(counter = 0; counter