Escolar Documentos
Profissional Documentos
Cultura Documentos
Application example: Robot control over serial port via XBee wireless
communication module
(located on the ATMEGA260 microcontroller adaptor
board)
In this experiment for the simplicity PL3 and PL4 are kept at logic 1.
Connection Details:
Serial Communication: PORTD 2 --> RXD1 UART1 receive for RS232 serial
communication
PORTD 3 --> TXD1 UART1 transmit for RS232
serial communication
Commands:
Keyboard Key ASCII value Action
8 0x38 Forward
2 0x32 Backward
4 0x34 Left
6 0x36 Right
5 0x35 Stop
7 0x37 Buzzer on
9 0x39 Buzzer off
Note:
Microcontroller: atmega2560
Frequency: 14745600
Optimization: -O0 (For more information read section: Selecting proper
optimization
options below figure 2.22 in the Software
Manual)
2. Difference between the codes for RS232 serial, USB and wireless communication
is only in the serial port number.
Rest of the things are the same.
4. 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.
It is a good practice to stop the motors for at least 0.5seconds before
changing
the direction. This will also increase the useable time of the fully charged
battery.
the life of the motor.
*********************************************************************************/
/********************************************************************************
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
********************************************************************************/
#include<avr/io.h>
#include<avr/interrupt.h>
#include<util/delay.h>
//Main Function
int main(void)
{
init_devices();
while(1);
}