Author Topic: Communicating with an ATMega8 via AVR ISP MKII  (Read 2630 times)

0 Members and 1 Guest are viewing this topic.

Offline jonagikTopic starter

  • Full Member
  • ***
  • Posts: 63
  • Helpful? 1
Communicating with an ATMega8 via AVR ISP MKII
« on: August 10, 2011, 12:57:29 AM »
Hi,

I'm sorry, I believe I've already asked this but I can't find my original thread and don't believe it yielded an answer.

Is there a C++ API for communicating at runtime with the ATMega8 family of microcontrollers via the AVR ISP MKII from an application on my computer? I can't find anything on the Atmel website (however, there is a lot of information there so I could have missed something).

Cheers,
Jonagik

Offline billhowl

  • Supreme Robot
  • *****
  • Posts: 375
  • Helpful? 32
  • Your success is in your hands.
Re: Communicating with an ATMega8 via AVR ISP MKII
« Reply #1 on: August 10, 2011, 07:10:21 AM »

Offline jonagikTopic starter

  • Full Member
  • ***
  • Posts: 63
  • Helpful? 1
Re: Communicating with an ATMega8 via AVR ISP MKII
« Reply #2 on: August 10, 2011, 07:48:07 PM »
Thanks for that but, from what I can see, these are mostly about programming a microcontroller via the AVRISP. What I'm looking for is runtime serial communication between my PC and my microcontroller. For example, I might want to have an application on my PC which has a button on it which, when pressed, toggles an LED between On and Off with my microcontroller.

Are there USB devices one can buy which allow my application to send binary data to a microcontroller (i.e. a device one can plug into one's computer and have an application tell it when to set an output port high/low and tells the application when an input port it high/low)?

Thanks

Offline corrado33

  • Supreme Robot
  • *****
  • Posts: 611
  • Helpful? 11
Re: Communicating with an ATMega8 via AVR ISP MKII
« Reply #3 on: August 10, 2011, 07:51:03 PM »
You need to learn about UART/USART, then you can do everything you said with hyperterminal on the PC (I think you can use terminal on the mac, but I have no idea how... off to google).  You'd also need a level adapter like this...
http://www.amazon.com/MAX232-RS232-Converter-Adapter-Board/dp/B00471S6MC

Then  you can program your microcontroller to input data from the computer, and if it receives an 'a' then it'll turn the LED on and off.  

Make sense?  It's not communication through the programmer, but rather through a serial cable.  

As for an application on the PC... you'd probably have to make one yourself... but I'm just guessing there.  In all honesty, you could just use hyperterminal and use the arrow keys ;)



« Last Edit: August 10, 2011, 07:55:51 PM by corrado33 »

Offline jonagikTopic starter

  • Full Member
  • ***
  • Posts: 63
  • Helpful? 1
Re: Communicating with an ATMega8 via AVR ISP MKII
« Reply #4 on: August 10, 2011, 07:57:02 PM »
I'm in New Zealand and these adapters tend to be rediculously expensive compared to in the U.S.

Is there a way to, for example, get my computer to read/write from/to a specific USB port (without all that USB handshaking stuff)? The reason for this being i) that I don't have a serial port, and ii) to avoid expense on adapters.

Thanks again.

Offline corrado33

  • Supreme Robot
  • *****
  • Posts: 611
  • Helpful? 11
Re: Communicating with an ATMega8 via AVR ISP MKII
« Reply #5 on: August 11, 2011, 04:03:36 AM »
Hmmm, I don't really know about the USB communication, I'm sure it's possible though.  Admin's Axon II has USB. 

If the adapters are expensive, you could just buy the chip and make the adapter yourself.  (Could be cheaper)  It's a pretty simple circuit actually.  I believe the chip is a MAX232 or some variant. 

Offline robotgoldfish

  • Beginner
  • *
  • Posts: 2
  • Helpful? 0
Re: Communicating with an ATMega8 via AVR ISP MKII
« Reply #6 on: August 11, 2011, 06:48:32 AM »
Their are versions of the Arduino that don't use the UART to communicate to the at-mega.

http://arduino.cc/en/Main/ArduinoBoardSerial     //This is the current UNO that uses a at-mega-8u2 instead of a UART

http://arduino.cc/en/Main/ArduinoBoardUno       //This uses level shifting resistors to connect to an old school serial port.

http://metalab.at/wiki/Metaboard                      //This one has a Bootloader that handles the UARTs job in software.

Offline jonagikTopic starter

  • Full Member
  • ***
  • Posts: 63
  • Helpful? 1
Re: Communicating with an ATMega8 via AVR ISP MKII
« Reply #7 on: August 11, 2011, 09:01:13 PM »
Making the adapter could be a good option. I've read through the datasheets on some of the chips for this but can't establish how to make the circuit. Can someone please point me in the right direction?

Thanks

Offline jonagikTopic starter

  • Full Member
  • ***
  • Posts: 63
  • Helpful? 1
Re: Communicating with an ATMega8 via AVR ISP MKII
« Reply #8 on: August 11, 2011, 11:12:30 PM »
Hi,

I think I've got the solution. Please let me know if there are any errors.

I get a USB to COM (serial) adapter. Then I create this device (http://www.sparkfun.com/datasheets/Prototyping/RS232-Shifter-v2.pdf). I connect the Rx and Tx to two I/O ports on my uC. I then write software on my computer to send/receive via COM1 and on my uC to send/receive via the two ports to be used for I/O.

Any problems?

Thanks

Offline corrado33

  • Supreme Robot
  • *****
  • Posts: 611
  • Helpful? 11
Re: Communicating with an ATMega8 via AVR ISP MKII
« Reply #9 on: August 12, 2011, 04:07:54 AM »
Yes, that is exactly what I was saying you should do.   :P

Except it's not "Tx, Rx, and two other i/o pins".  You need to hook up Tx, Rx, and you need to provide power and ground to the chip.  No other i/o pins. 

Just be forewarned, I know sometimes those usb to serial cables don't work exactly like a serial port.  I believe admin uses one for his stuff, but I've also heard other people on the forum say they've had trouble getting stuff to work with them.

Offline jonagikTopic starter

  • Full Member
  • ***
  • Posts: 63
  • Helpful? 1
Re: Communicating with an ATMega8 via AVR ISP MKII
« Reply #10 on: August 13, 2011, 04:30:55 AM »
I dont understand what you mean in your second paragraph. I thought I could connect Serial Rx to an output port and Tx to an input port. What do you suggest?

Yes, that is exactly what I was saying you should do.   :P

Except it's not "Tx, Rx, and two other i/o pins".  You need to hook up Tx, Rx, and you need to provide power and ground to the chip.  No other i/o pins. 

Just be forewarned, I know sometimes those usb to serial cables don't work exactly like a serial port.  I believe admin uses one for his stuff, but I've also heard other people on the forum say they've had trouble getting stuff to work with them.

Offline corrado33

  • Supreme Robot
  • *****
  • Posts: 611
  • Helpful? 11
Re: Communicating with an ATMega8 via AVR ISP MKII
« Reply #11 on: August 13, 2011, 06:10:36 AM »
I dont understand what you mean in your second paragraph. I thought I could connect Serial Rx to an output port and Tx to an input port. What do you suggest?


No you are correct, although I recommend some kind of protection in case you hook it up backwards (some people use 2.2k resistors, some use 1k resistors etc).  You'd hook the serial Rx and Tx and stuff up to the max chip then hook the tx and rx of the chip to the rx and tx of the atmega.  Just follow the schematic.  You can't hook up the serial cable direction to the atmega.  You need the schematic you posted if  you want it to work, and not destroy your chip. 

Offline jonagikTopic starter

  • Full Member
  • ***
  • Posts: 63
  • Helpful? 1
Re: Communicating with an ATMega8 via AVR ISP MKII
« Reply #12 on: August 14, 2011, 03:58:36 PM »
Cool, thanks.

Won't such a high resistance drop the voltage too low to be detected? Also, how do I know the voltage coming off the converter chip so I can hook up an appropriate resistor if necessary?
« Last Edit: August 14, 2011, 04:00:06 PM by jonagik »

 


Get Your Ad Here

data_list