8 replies [Last post]
rsmerali
Offline
Last seen: 1 year 30 weeks ago
Joined: 12/27/2009

Most of the intelligence for the robot will be on a high-level computer. However, computers cannot perform certain tasks, so we will need a microcontroller (uC) to do that. Specifically the tasks are:
1. Use an ATMega8 microcontroller to simultaneously control two servo motors
- Should use interrupts
2. Run the uC at 16MHz and communicate with a computer's serial port.
3. Work with the electrical team to create a PCB for the uC circuit.
4. Work with the software team to write an MRDS driver for the board.
- Exact communication protocol should be well defined.

Rehman

Justin
Offline
Last seen: 48 weeks 19 hours ago
Joined: 05/11/2010
Serial Communication Protocol and UART

Serial Communication Protocol
I'm unclear as to what the ultimate goal is. I believe it is receiving data that Billy will send via the uC, parsing it, and returning the string/integer. What exactly is the data?

UART
I believe the code and circuit that I have works, but for some reason its very difficult to replicate (for now). We did manage to get UART example to work, but have yet to test the uart_getc() function. It would seem as though Chen did not change anything to my circuit or code, so I would be grateful if someone (perhaps Chen?) could explain what changed or what I was doing wrong. I will come in tomorrow.

EDIT: UART works fine. Can successfully transmit and read from the uC. Need to know if heading will just be left/right/center or if an actual degrees of turn in necessary.

@Billy:
As far as I know, we need to transmit speed and heading. We could just transmit a string who's first character says right, left or center, and the numbers following represent the desired speed. For instance
"R2075" would mean to go right at speed value 2075. Hmmm how to make it faster...

Justin
Offline
Last seen: 48 weeks 19 hours ago
Joined: 05/11/2010
UART Error

I'm doing the UART tutorial and just attempted to compile the UART program in the programming tutorial (example code 4). I've already retrieved UART.h, global.h, buffer.h, and UART.c from the internet and included them in the headers folder and source files folder. On attempting to compile, I receive the following error message:

avr-gcc -mmcu=atmega8 -Wall -gdwarf-2 -Os -std=gnu99 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT uart.o -MF dep/uart.o.d -c ../uart.c
../uart.c:1:16: error: io.h: No such file or directory
../uart.c:2:24: error: interrupt.h: No such file or directory
../uart.c:3:22: error: sig-avr.h: No such file or directory
../uart.c:18: warning: return type defaults to 'int'
../uart.c: In function 'SIGNAL':
../uart.c:18: warning: type of 'SIG_UART_TRANS' defaults to 'int'
../uart.c:26: warning: implicit declaration of function 'outp'
../uart.c:26: error: 'UDR' undeclared (first use in this function)
../uart.c:26: error: (Each undeclared identifier is reported only once
../uart.c:26: error: for each function it appears in.)
../uart.c: At top level:
../uart.c:46: warning: return type defaults to 'int'
../uart.c:45: error: redefinition of 'SIGNAL'
../uart.c:18: error: previous definition of 'SIGNAL' was here
../uart.c: In function 'SIGNAL':
../uart.c:46: warning: type of 'SIG_UART_RECV' defaults to 'int'
../uart.c:49: warning: implicit declaration of function 'inp'
../uart.c:49: error: 'UDR' undeclared (first use in this function)
../uart.c: In function 'uartInitBuffers':
../uart.c:59: error: 'UART_RX_BUFFER_ADDR' undeclared (first use in this function)
../uart.c:61: error: 'UART_TX_BUFFER_ADDR' undeclared (first use in this function)
../uart.c: At top level:
../uart.c:64: error: conflicting types for 'uartSetBaudRate'
../uart.h:94: error: previous declaration of 'uartSetBaudRate' was here
../uart.c: In function 'uartSetBaudRate':
../uart.c:67: error: 'UBRRL' undeclared (first use in this function)
../uart.c: In function 'uartInit':
../uart.c:79: error: 'RXCIE' undeclared (first use in this function)
../uart.c:79: error: 'TXCIE' undeclared (first use in this function)
../uart.c:79: error: 'RXEN' undeclared (first use in this function)
../uart.c:79: error: 'TXEN' undeclared (first use in this function)
../uart.c:79: error: 'UCSRB' undeclared (first use in this function)
../uart.c:82: error: 'UART_BAUD_RATE' undeclared (first use in this function)
../uart.c: In function 'uartSendByte':
../uart.c:106: error: 'UDR' undeclared (first use in this function)
make: *** [uart.o] Error 1
Build failed with 21 errors and 14 warnings...

jessicaxiejw
Offline
Last seen: 1 year 35 weeks ago
Joined: 05/11/2010
Rehman, I worked with Justin.

Rehman, I worked with Justin. I have everything in the correct case and in the same folder, but we still get the same error. We can't find uart.c and uart.h file from our computer, so we download it from a website. The errors we got is shown below. The error Justin shows you is what we got after we download and include avrlibdefs.h and avrlibtypes.h files.

../global.h:25:24: error: avrlibdefs.h: No such file or directory
../global.h:27:25: error: avrlibtypes.h: No such file or directory
In file included from ../U_A_R_T.c:10:
../uart.h:176: error: expected ')' before 'baudrate'
../uart.h:191: error: expected ')' before 'data'
../uart.h:205: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'uartReceiveByte'
../uart.h:209: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'uartReceiveBufferIsEmpty'
../uart.h:217: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'uartAddToTxBuffer'
../uart.h:226: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'uartSendBuffer'

rsmerali
Offline
Last seen: 1 year 30 weeks ago
Joined: 12/27/2009
Directories

Looks like the compiler can't find the dependent files. Put all the files in the same folder and just have "#include uart.c", etc. as opposed to "#include ../uart.c", etc. Also make sure that everything is the correct case, i.e. not "UART.c".

Cheers,
Rehman

Justin
Offline
Last seen: 48 weeks 19 hours ago
Joined: 05/11/2010
UART

I was doing the UART tutorial with the help of Soren, specifically the section that involves the light sensor turning on an LED if it detects a shiny surface. Assuming that the wiring is done correctly, that the programming is correct*, and that the polulu driver is installed correctly**: what would prevent AVR Studio from downloading the program to the uC?

*there is an error in example 3b of the programming tutorial.
"PORTB (1 PB0); // set for digital input" should be "PORTB = (1 PB0); // set for digital input"
I had to take out the double triangle brackets since the forum recognizes them as HTML tags.

**the programmer shows two green lights

Justin

EDIT: Solved -> Fried uC and incorrect hex file being uploaded to uC

Justin
Offline
Last seen: 48 weeks 19 hours ago
Joined: 05/11/2010
Getting Started

Being new to microprocessor control, I was tasked to learn how to blink an LED. Today I decided to get going on this assignment. I'm reading the sumo robot tutorial, section "C Programming for Microcontrollers" and have finished installing WinAVR, Programmer's Notepad, and Br@y++'s terminal. The next steps of the tutorial requires that I have Butterfly, a breadboard, etc. Is there some simulation program I can use? If not, perhaps it would be best to spend an afternoon or two at UT doing the tutorials--who would I speak to, to do this?

On a separate note: when is the next meet for embedded?

Justin

rsmerali
Offline
Last seen: 1 year 30 weeks ago
Joined: 12/27/2009
Sumo Tutorial

An AVR Butterfly? Are you sure you're reading the sumo tutorial by UTRA? We do everything on an ATMega8 uC, the Butterfly has a much more powerful processor. Although we can lend you a Butterfly ($20 deposit) if you're interested. Otherwise I suggest an ATMega8 chip.

Rehman

soren
Offline
Last seen: 23 weeks 3 days ago
Joined: 03/30/2010
Sumo Tutorial

Hey Justin,

You can come to the lab(EA106) any day of the week. We have all the requirements(uC, voltage regulator, oscillator, etc.), and I can walk you through the tutorial.

Make sure you come to the PCB tutorial on Saturday at 1pm.

Next meeting is on Monday, May 17th at 6pm.

Please refer to our Google Calendar for all the events and meetings.

Sincerely,
Soren