Page 4
NEX Robotics Fire Bird V Software Manual Notice The contents of this manual are subject to change without notice. All efforts have been made to ensure the accuracy of contents in this manual. However, should any errors be detected, NEX Robotics welcomes your corrections.
Page 5
1. User must go through the Fire Bird V’s Hardware and Software manuals before using the robot. 2. Crystal of the ATMEGA2560 microcontroller is upgraded to 14.7456MHz from 11.0592 MHz in all the Fire Bird V ATMEGA2560 robots delivered on or after 1 December 2010. This documentation is made considering crystal frequency as 14.7456MHz.
Page 6
NEX Robotics Fire Bird V Software Manual Index Fire Bird V ATMEGA2560 Programming the Fire Bird V ATMEGA2560 Robot Input / Output Operations On the Robot Robot Position Control Using Interrupts Timer / Counter Operations On The Robot LCD Interfacing...
Page 7
NEX Robotics Fire Bird V Software Manual 1. Fire Bird V ATMEGA2560 The Fire Bird V robot is the 5 in the Fire Bird series of robots. First two versions of the robots were designed for the Embedded Real-Time Systems Lab, Department of Computer Science and Engineering, IIT Bombay.
Page 8
NEX Robotics Fire Bird V Software Manual Figure 1.2: ATMEGA2560 (AVR), P89V51RD2 (8051) and LPC2148 ARM7 microcontroller adaptor boards for Fire Bird V 1.1 Avatars of Fire Bird V Robot All Robots use the same main board and microcontroller adaptor board. All Fire Bird V Robots share the same unified architecture.
Page 9
NEX Robotics Fire Bird V Software Manual Figure 1.4 Fire Bird V ATMEGA2560 robot 2.2 Fire Bird V Block Diagram: Figure 1.5: Fire Bird V ATMEGA2560 robot block diagram www.nex-robotics.com...
Page 10
NEX Robotics Fire Bird V Software Manual 1.3 Fire Bird V ATMEGA2560 technical specification Microcontroller: Atmel ATMEGA2560 as Master microcontroller (AVR architecture based Microcontroller) Atmel ATMEGA8 as Slave microcontroller (AVR architecture based Microcontroller) Sensors: Three white line sensors (extendable to 7)
Page 11
NEX Robotics Fire Bird V Software Manual 2. Programming the Fire Bird V ATMEGA2560 Robot There are number of IDEs (Integrated Development Environment) available for the AVR microcontrollers. There are free IDEs which are based on AVR GCC like AVR Studio from ATMEL and WIN AVR and proprietary IDEs like ICC AVR, Code vision AVR, IAR and KEIL etc.
Page 12
NEX Robotics Fire Bird V Software Manual Figure 2.2 Click next in the WIN AVR setup wizard. Figure 2.3 www.nex-robotics.com...
Page 13
NEX Robotics Fire Bird V Software Manual Press “I Agree” after going through license agreement. Figure 2.4 Make sure that you have to select the drive on which operating system is installed. Figure 2.5 www.nex-robotics.com...
Page 14
NEX Robotics Fire Bird V Software Manual Select all the components and press “Install”. Figure 2.6 Click “Finish” to complete WIN AVR installation Figure 2.7 www.nex-robotics.com...
Page 15
NEX Robotics Fire Bird V Software Manual 2.2 Installing AVR Studio Go to “Software and Drivers” folder from the documentation CD, copy folder “AVR Studio 4.17” on the PC and click on “AvrStudio417Setup.exe” to start the installation process. Figure 2.8 Click on “Run”...
Page 16
NEX Robotics Fire Bird V Software Manual Click “Next” to start installation of AVR Studio 4 Figure 2.10 After clicking “Next”, go through the license agreement. If it is acceptable then click “Next” Figure 2.11 www.nex-robotics.com...
Page 17
NEX Robotics Fire Bird V Software Manual Now choose the destination drive. Select the same drive in which your operating system and WINAVR is installed. Figure 2.12 Select for the “Install / upgrade Jungo USB Driver” to support In System Programming (ISP) by AVRISP mkII Figure 2.13...
Page 18
NEX Robotics Fire Bird V Software Manual Click “Next” to start the installation process. Figure 2.14 Click “Finish” to complete the installation process. Figure 2.15 www.nex-robotics.com...
Page 19
NEX Robotics Fire Bird V Software Manual 2.3 Setting up Project in AVR Studio AVR studio is an Integrated Development Environment (IDE) for writing and debugging AVR applications. As a code writing environment, it supports includes AVR Assembler and any external AVR GCC compiler in a complete IDE environment.
Page 20
NEX Robotics Fire Bird V Software Manual 1. Open AVR Studio. If any project is running it can be closed by clicking on Project in the menu bar and select Close Project. 2. To create a new project, click on Project in the menu bar and select “New Project”.
Page 21
NEX Robotics Fire Bird V Software Manual 4. Select debug platform and Device. In this case we have selected “AVR simulator” and “ATMEGA2560” microcontroller and click finish. Figure 2.19 5. Now we are almost ready to write our first code. Before we start coding we will check other setting to make sure that they are set properly.
Page 22
NEX Robotics Fire Bird V Software Manual 6. Open Project menu and click on the Configuration option. Figure 2.21 7. In the Project Option “General” tab will open. Select device as “ATMEGA2560” and frequency (Crystal Frequency) as 14.7456MHz i.e. 14745600Hz. Set the optimization level be at “-O0”.
Page 23
NEX Robotics Fire Bird V Software Manual The levels of optimization are: • -O0 No optimization. This is the same as not specifying any optimization. • -01 Optimize. Reduces code size and execution time without performing any optimizations that take a great deal of compilation time.
Page 24
NEX Robotics Fire Bird V Software Manual 2.4 Writing your first code in AVR Studio This program will make robot’s buzzer beep. Copy the following code in window “code area” as shown in figure 2.25. We will see how this code works in the next chapter.
Page 25
NEX Robotics Fire Bird V Software Manual We are now going to compile this code to generate the hex file and we will load same on the Robot’s microcontroller. Select “Build” menu and click on “Rebuild All”. It will compile the “buzzer_test.c”...
Page 26
NEX Robotics Fire Bird V Software Manual 2.5 Debugging the code in AVR studio After successful compilation of the code we can debug the code by AVR Debugger provided by AVRStudio. Here is the illustration of debugging of code given in Exp1 (buzzer ON-OFF folder).
Page 27
NEX Robotics Fire Bird V Software Manual Press “F11” key or “Step into” button from the toolbar to start debugging statement by statement. Processor details are visible at left window and the I/O port status is displayed at the rightmost window.
Page 28
NEX Robotics Fire Bird V Software Manual 2.6 Loading your code on robot using AVR Boot loader from NEX Robotics All AVR microcontrollers can be programmed using In System Programming (ISP), external programmer or using boot loader. Advantage with the boot loader is that you don’t need any external hardware to load .hex file on the microcontroller.
Page 29
NEX Robotics Fire Bird V Software Manual serial converter chip is powered by USB. If any fault occurs then turn off the robot and remove the USB cable and repeat the same procedure. 2.6.4 Installing Bootloader GUI on the PC Step 1: Copy “AVR Bootloader”...
Page 30
NEX Robotics Fire Bird V Software Manual Figure 2.32 Figure 2.33 2.6.5 Using AVR Bootloader Step 1: Go to Start Menu and click on “AVR Bootloader”. AVR Bootloader software will start. Figure 2.34 www.nex-robotics.com...
Page 31
NEX Robotics Fire Bird V Software Manual Figure 2.35 Step 2: Figure 2.36 In this step we will configure port settings, select the microcontroller and .hex file which is to be loaded on the robot. 1. Make sure that drivers for FT232 USB to serial converter are installed.
Page 32
NEX Robotics Fire Bird V Software Manual 7. If Robot’s COM port number is more than COM8 then change it to any COM port number between COM1 to COM8. 8. Set the Baud rate at 115200 bps. 9. Select ATMEGA2560 microcontroller 10.
Page 33
NEX Robotics Fire Bird V Software Manual After successfully programming following text will appear in message box: Serial port timeout set to 5 sec. Found AVRBOOT on COM7! Entering programming mode... Parsing XML file for device parameters... Parsing '.\ATmega2560.xml'... ####### Saving cached XML parameters...
Page 34
All AVR microcontrollers can be programmed by using external In System Programmer. In the manual we are going to cover AVRISP mkII from ATMEL and AVR USB programmer NR- USB-006 from NEX Robotics for In System Programming (ISP). For ATMEGA2560 (master) and ATMEGA8 (slave) ISP is done via their SPI port. Both microcontrollers also talk with each other using SPI bus where ATMEGA2560 acts as master and ATMEGA8 acts as slave.
Page 35
NEX Robotics Fire Bird V Software Manual Figure 2.40: ISP socket on the ATMEGA2560 microcontroller adaptor board Note: ATMEGA8 slave microcontroller is used for collecting analog data from IR proximity sensors 6, 7, 8, Robot current sense (if ACS712 current sensor is installed), extended white line sensor channels 4, 5, 6, 7 and pin on the servo expansion port.
Page 36
AVRISP mkII programmer from the ATMEL is the most versatile programmer. It is very easy to use and has more features. It is the most recommended programmer for the robot after AVR Bootloader from NEX Robotics. Figure 2.41: AVRISP mkII Step 1: 1.
Page 37
NEX Robotics Fire Bird V Software Manual Figure 2.43 5. Select platform as AVRISP mkII and Port as USB Port and press connect. 6. Window as shown in Figure 2.44 will appear. Figure 2.44 www.nex-robotics.com...
Page 38
Figure 2.45 shows the 6 to 10 pin converter for the In System Programming. 2. Connect AVRISP adaptor between robot and AVRISP mkII. Insert 10 pin FRC connector in the Fire Bird V ATMEGA2560 robot and turn the power on. For ISP port location and other precautions refer to section 2.7.
Page 39
NEX Robotics Fire Bird V Software Manual If ISP does not work properly then try to reduce the ISP frequency and try it again by clicking on the “Settings” button which is located inside the “Programming Mode and Target Settings frame”.
Page 40
NEX Robotics Fire Bird V Software Manual Step 4: Loading .hex file on the microcontroller 1. Go to “Program” tab. 2. Check on Erase device before programming and Verify device after programming check box. 3. Browse and select the desired hex file in the flash section 4.
Page 41
Fire Bird V Software Manual 2.9 Fuse settings for ATMEGA2560 (Master) microcontroller All the microcontroller’s Fuse settings are factory set at the NEX Robotics before shipping the robot. Do not change them. This information is only given for the reference.
Page 42
NEX Robotics Fire Bird V Software Manual Figure 2.50: Fuse settings of ATMEGA2560 microcontroller Following fuse settings are done: 1. Brown-out detection set at 2.7V (checked) 2. JTAG enabling is disabled (JTAGEN) (unchecked) 3. Boot size is selected at 2408 bytes.
Page 43
Fire Bird V Software Manual 2.10 Fuse settings for ATMEGA8 (Slave) microcontroller All the microcontroller’s Fuse settings are factory set at the NEX Robotics before shipping the robot. Do not change them. This information is only given for the reference.
Page 44
Fire Bird V Software Manual 2.11 Loading bootloader code on the ATMEGA2560 microcontroller Fire Bird V ATMEGA2560 robot is factory shipped with the bootloader. If you do In System Programming using any ISP programmers then bootloader will get erased. To load the bootloader you will need the ISP programmer.
Page 45
2.12 Loading your code on the robot using AVR USB programmer from NEX Robotics USBasp, is an USB port based programmer from NEX Robotics. This programmer requires avrdude.exe file which comes with WINAVR. So installation of WINAVR is necessary for this programmer.
Page 46
NEX Robotics Fire Bird V Software Manual 3. Input / Output Operations on the Robot ATMEGA2560 microcontroller has ten 8 bit ports from PORT A to PORT F and PORT H to PORT L (no PORT I) and PORT G has 6 bits. Input/output operations are the most essential, basic and easy operations.
Page 47
NEX Robotics Fire Bird V Software Manual 3.1 Registers for using PORTs of the ATMEGA2560 microcontroller Each pin of the port can be addressed individually. Each pin individually can be configured as input or as output. While pin is input it can be kept floating or even pulled up by using internal pull-up.
Page 48
NEX Robotics Fire Bird V Software Manual Note: • ‘X’ represents port name – A, B, C, D, E, F, G, H, J, K, L. • Tri-State is the floating pin condition. • For more details, refer to ATMEGA2560 datasheet which is located in the “Datasheets”...
Page 49
NEX Robotics Fire Bird V Software Manual D. To disable pull-ups of all the ports we need to set Bit 2 of SFIOR to logic one. Special Function I/O register – SFIOR ACME PSR0 PSR321 Read/ Write Initial Val Table 3.4...
Page 50
NEX Robotics Fire Bird V Software Manual OC4C / PH5 socket) OC2B / PH6 SS/PCINT0/PB0 ISP (In System Programming), SPI Communication with SCK/PCINT1/PB1 Output ATMEGA8 **, Connection to the SPI port on the main MOSI/PCINT2/PB2 Output board MISO/PCINT3/PB3 Input OC2A/PCINT4/PB4...
Page 51
NEX Robotics Fire Bird V Software Manual Ground PJ0/RXD3/PCINT9 PJ1/TXD3/PCINT10 PJ2/XCK3/PCINT11 LED bargraph display and GPIO* (Available on expansion Output PJ3/PCINT12 slot of the microcontroller socket) PJ4/PCINT13 PJ5/PCINT14 PJ6/PCINT15 Sharp IR ranges sensor 2, 3, 4 and red LEDs of white line PG2/ALE sensor 1, 2, 3 disable.
Page 52
NEX Robotics Fire Bird V Software Manual (Floating) Input PF2/ADC2 ADC input for white line sensor 2 (Floating) Input PF1/ADC1 ADC input for white line sensor 3 (Floating) Input PF0/ADC0 ADC input for battery voltage monitoring (Floating) AREF ADC reference voltage pin (5V external) ******...
Page 53
NEX Robotics Fire Bird V Software Manual 3.3 Application example Buzzer Beep Located in the folder “Experiments \ Buzzer_Beep” folder in the documentation CD. In the previous chapter, we have loaded buzzer beep code in Fire Bird V. Now we will see in detail the structure of this code.
Page 54
NEX Robotics Fire Bird V Software Manual unsigned char port_restore = 0; port_restore = PINC; port_restore = port_restore & 0xF7; PORTC = port_restore; void init_devices (void) cli(); //Clears the global interrupts port_init(); sei(); //Enables the global interrupts //Main Function main(void) init_devices();...
Page 55
NEX Robotics Fire Bird V Software Manual 3.4 Application example Simple Input – Output operation Located in the folder “Experiments \ I-O Interfacing” folder in the documentation CD. This experiment demonstrates simple Input and Output operation. When switch is pressed buzzer and bargraph LED display is turned on.
Page 56
NEX Robotics Fire Bird V Software Manual LEFT LEFT RIGHT RIGHT PL3 (PWML) for DIRECTION (LB) FWD(LF) FWD(RF) BWD(RB) left motor PA1 (L2) PA2 (R1) PA3 (R2) PL4 (PWMR) for (L1) right motor As per velocity FORWARD requirement As per velocity...
Page 57
NEX Robotics Fire Bird V Software Manual Note: • All the soft turns should be used when you need more accuracy during turning • Soft left 2 and Soft right 2 motions are very useful in grid navigation. Application example: Robot direction control Located in the folder “Experiments \ Motion_Control_Simple”...
Page 58
NEX Robotics Fire Bird V Software Manual 3.6 Functions used by the robot for configuring various ports of the ATMEGA2560 microcontroller 3.6.1 Buzzer Buzzer is connected to the PORTC 3 pin of the microcontroller. Buzzer is turned on of logic 1 is applied at the PORTC 3 pin. For more information on the hardware refer to section 3.13 in the Hardware Manual.
Page 59
NEX Robotics Fire Bird V Software Manual 3.6.3 Bargraph LED display Bargraph LED display is connected to the port J of the microcontroller. It can be used as general purpose LED display to display data or information for debugging. void LED_bargraph_config (void) DDRJ = 0xFF;...
Page 60
NEX Robotics Fire Bird V Software Manual 3.6.4.3 Robot direction set functions Sets robot’s direction void forward (void) //both wheels forward motion_set(0x06); void back (void) //both wheels backward motion_set(0x09); void left (void) //Left wheel backward, Right wheel forward motion_set(0x05); void...
Page 61
NEX Robotics Fire Bird V Software Manual 3.6.5 Functions for Robot’s sensors switching on / off Using these function robots sensors can be switched on or off. Before using these functions, make sure that Jumper 2, 3, 4 are open on the main board. For more details refer to the section 3.10, 3.11 and 3.12 0f the Hardware Manual.
Page 62
NEX Robotics Fire Bird V Software Manual void turn_on_ir_proxi_sensors (void) //turn on IR Proximity sensors PORTH = PORTH & 0xF7; void turn_off_ir_proxi_sensors (void) //turn off IR Proximity sensors PORTH = PORTH | 0x08; void turn_on_all_proxy_sensors (void) // turn on Sharp 2, 3, 4, red LED of the white line sensors, Sharp 1, 5 and IR proximity sensor PORTH = PORTH &...
Page 63
NEX Robotics Fire Bird V Software Manual 3.6.7.2 servo2_pin_config(); //Configure PORTB 6 pin for servo motor 2 operation void servo2_pin_config (void) DDRB = DDRB | 0x40; //making PORTB 6 pin output PORTB = PORTB | 0x40; //setting PORTB 6 pin to logic 1 3.6.7.3 servo3_pin_config();...
Page 64
NEX Robotics Fire Bird V Software Manual 4. Robot Position Control Using Interrupts Fire Bird V incorporates various interrupt handling mechanisms such as timer overflow interrupts, timer compare interrupts, serial interrupts for doing specific tasks. In this chapter, we will have a brief overview of interrupt concept and will implement external hardware interrupts for position estimation of robots using position encoders.
Page 65
NEX Robotics Fire Bird V Software Manual Shorter pulses are not guaranteed to generate an interrupt. If low level interrupt is selected, the low level must be held until the completion of the currently executing instruction to generate an interrupt. If enabled, a level triggered interrupt will generate an interrupt request as long as the pin is held low.
Page 66
NEX Robotics Fire Bird V Software Manual Note: • n = 7, 6, 5 or 4. • When changing the ISCn1/ISCn0 bits, the interrupt must be disabled by clearing its Interrupt Enable bit in the EIMSK Register. Otherwise an interrupt can occur when the bits are changed.
Page 67
NEX Robotics Fire Bird V Software Manual 4.1.2 Functions for configuring interrupt pins (called inside the “port_init()” function) //Function to configure INT4 (PORTE 4) pin as input for the left position encoder void left_encoder_pin_config (void) DDRE = DDRE & 0xEF;...
Page 68
NEX Robotics Fire Bird V Software Manual Various syntaxes for ISR are described in datasheet of ATMEGA2560 microcontroller and also in < iomxx0_1.h> files in winavr/avr/include/avr folder. //ISR for right position encoder ISR(INT5_vect) //Your code //SR for left position encoder...
Page 69
NEX Robotics Fire Bird V Software Manual 4.2.1 Calculation of position encoder resolution: Case 1: Robot is moving forward or backward (encoder resolution is in mm) Wheel diameter: 5.1cm Wheel circumference: 5.1cm * 3.14 = 16.014cm = 160.14mm Number slots on the encoder disc: 30 Position encoder resolution: 163.2 mm / 30 = 5.44mm / pulse.
Page 70
NEX Robotics Fire Bird V Software Manual Total pulses in 360 Rotation of Robot = Number of slots on the encoder disc / Number of wheel rotations of in 360 rotation of robot = 30 x 5.882 = 176.46 (approximately 176) Position Encoder Resolution in Degrees = 360 /176 = 2.045 degrees per count...
Page 71
NEX Robotics Fire Bird V Software Manual 4.2.3.2 Function for moving robot forward and back by specific distance //Function used for moving robot forward by specified distance void linear_distance_mm(unsigned int DistanceInMM) float ReqdShaftCount = 0; unsigned long int ReqdShaftCountInt = 0;...
Page 72
NEX Robotics Fire Bird V Software Manual 4.2.3.7 soft left in degrees void soft_left_degrees(unsigned int Degrees) // 176 pulses for 360 degrees rotation 2.045 degrees per count soft_left(); //Turn soft left Degrees=Degrees*2; angle_rotate(Degrees); 4.2.3.8 soft right in degrees void soft_right_degrees(unsigned int Degrees) // 176 pulses for 360 degrees rotation 2.045 degrees per count...
Page 73
NEX Robotics Fire Bird V Software Manual Note: 1. Make sure that in the configuration options following settings are done for proper operation of the code Microcontroller: ATMEGA2560 Frequency: 14745600 Optimization: -O0 (For more information read section: Selecting proper optimization options below figure 2.22 in the software manual)
Page 74
• Velocity calculation – Timer can be used for robot’s velocity estimation. In the Fire Bird V ATMEGA2560 robot Timer 5 is used to generate PWM for robot velocity control. Timer 1 is used for servo motor control. All other timers are free and can be used for other purposes.
Page 75
NEX Robotics Fire Bird V Software Manual 5.1 Important terms involved in the timers: BOTTOM: The counter reaches the BOTTOM when it becomes 0x0000. MAX: The counter reaches its MAX value when it becomes 0xFF (decimal 255) for 8 bit timer or 0xFFFF (decimal 65535) for 16 bit timer.
Page 76
NEX Robotics Fire Bird V Software Manual 5.2 16 bit Timer Registers Note: • In all the terms ‘n’ represents timer number which can be 1, 3, 4 or 5 and ‘X’ represents output compare channel number which can be A, B or C.
Page 77
NEX Robotics Fire Bird V Software Manual COMnA1 COMnA0 Description COMnB1 COMnB0 COMnC1 COMnC0 Normal port operation, OC5A, OCnB, OCnC disconnected WGMn3:0 = 14 or 15: Toggle OCnA on Compare Match, OCnB and OCnC disconnected (normal port operation). For all other WGMn settings, normal port operation, OCnA/OCnB/OCnC disconnected.
Page 78
NEX Robotics Fire Bird V Software Manual Bit 5 – Reserved Bit This bit is reserved for future use. For ensuring compatibility with future devices, this bit must be written to zero when TCCRnB is written. Bit 4:3 – WGMn3:2: Waveform Generation Mode See TCCRnA Register description and refer to table 5.3...
Page 79
NEX Robotics Fire Bird V Software Manual Table 5.3: Waveform generation mode bit description 5.2.4 TIMSKn – Timer/Counter n Interrupt Mask Register ICIEn OCIEnC OCIEnB OCIEnA TOIEn Read / Write Initial Value Bit 5 – ICIEn: Timer/Counter n, Input Capture Interrupt Enable When this bit is written to one, and the I-flag in the Status Register is set (interrupts globally enabled), the Timer/Counter n Input Capture interrupt is enabled.
Page 80
NEX Robotics Fire Bird V Software Manual Bit 1 – OCIEnA: Timer/Counter n, Output Compare A Match Interrupt Enable When this bit is written to one, and the I-flag in the Status Register is set (interrupts globally enabled), the Timer/Counter n Output Compare A Match interrupt is enabled. The corresponding Interrupt Vector (See “Interrupts”...
Page 81
NEX Robotics Fire Bird V Software Manual Bit 0 – TOVn: Timer/Counter n, Overflow Flag The setting of this flag is dependent of the WGMn3:0 bits setting. In Normal and CTC modes, the TOVn Flag is set when the timer overflows. Refer to Table 5.3 for the TOVn Flag behavior when using another WGMn3:0 bit setting.
Page 82
NEX Robotics Fire Bird V Software Manual 5.3.2 PWM generation using Timer PWM using Timer n All 16 bit timers are identical in nature. We are using timer 5 for PWM as input pins of the motor driver IC L293D are connected to PL3 (OC5A) and PL4 (OC5B).
Page 83
NEX Robotics Fire Bird V Software Manual 5.3.3 Timer 5 configuration in 8 bit fast PWM mode Function Timer5_init() function initializes the function in 8 bit fast PWM generation mode. // Timer 5 initialized in PWM mode for velocity control...
Page 84
NEX Robotics Fire Bird V Software Manual It is very important that all the devices should be configured after disabling all the interrupts. All the peripherals of the microcontroller will be configured inside init_devices() function. 5.3.5 Functions for PWM output pin configuration and robot’s velocity control 5.3.5.1 Functions for PWM output pin configuration (called inside the “port_init()”...
Page 85
NEX Robotics Fire Bird V Software Manual 2. Auxiliary power can supply current up to 1 Ampere while Battery can supply current up to 2 Ampere. When both motors of the robot changes direction suddenly without stopping, it produces large current surge. When robot is powered by Auxiliary power which can supply only 1 Ampere of current, sudden direction change in both the motors will cause current surge which can reset the microcontroller because of sudden fall in voltage.
Page 86
NEX Robotics Fire Bird V Software Manual 5.4.1 Timer 1 configuration in 10 bit fast PWM mode Function Timer1_init() function initializes the function in 10 bit fast PWM generation mode. //TIMER1 initialization in 10 bit fast PWM mode //prescale:256 // WGM: 7) PWM 10bit fast, TOP=0x03FF // actual value: 52.25Hz...
Page 87
NEX Robotics Fire Bird V Software Manual PositionTiltServo = ((float)degrees / 1.86) + 35.0; OCR1BH = 0x00; OCR1BL = (unsigned char) PositionTiltServo; //Function to rotate Servo 3 by a specified angle in the multiples of 1.86 degrees void servo_3(unsigned char...
Page 88
NEX Robotics Fire Bird V Software Manual Note: 1. Make sure that in the configuration options following settings are done for proper operation of the code Microcontroller: ATMEGA2560 Frequency: 14745600 Optimization: -O0 (For more information read section: Selecting proper optimization options below figure 2.22 in the software manual)
Page 89
NEX Robotics Fire Bird V Software Manual 6. LCD Interfacing To interface LCD with the microcontroller in default configuration requires 3 control signals and 8 data lines. This is known as 8 bit interfacing mode which requires total 11 I/O lines. To reduce the number of I/Os required for LCD interfacing we can use 4 bit interfacing mode which requires 3 control signals with 4 data lines.
Page 90
NEX Robotics Fire Bird V Software Manual The data bus is bidirectional, 4 bit wide and is connected to PC4 to PC7 of the microcontroller. The MSB bit (DB7) of data bus is also used as a Busy flag. When the Busy flag is 1, the LCD is in internal operation mode, and the next instruction will not be accepted.
Page 91
NEX Robotics Fire Bird V Software Manual After the initialization of LCD in 4-bit mode is complete, then for sending the data in nibbles there is no need of providing any delay between two nibbles of same byte, the most significant nibble (higher 4-bits) is sent first, immediately followed by the least significant nibble (lower 4- bits).
Page 92
NEX Robotics Fire Bird V Software Manual lcd_port = 0x30; //Sending 3 in the upper nibble sbit(lcd_port,EN); //Set Enable Pin _delay_ms(5); //delay cbit(lcd_port,EN); //Clear Enable Pin _delay_ms(1); cbit(lcd_port,RS); //RS=0 --- Command Input cbit(lcd_port,RW); //RW=0 --- Writing to LCD lcd_port = 0x30;...
Page 93
NEX Robotics Fire Bird V Software Manual 6.1.4 Function to write data on LCD //Function to write data on LCD cbit(lcd_port,EN); void lcd_wr_char(char letter) letter = letter & 0x0F; char temp; letter = letter<<4; lcd_port &= 0x0F; temp = letter;...
Need help?
Do you have a question about the Fire Bird V ATMEGA2560 and is the answer not in the manual?
Questions and answers