go_away

Author Topic: Serial communications with PonyProg or AVR ISP?  (Read 7075 times)

0 Members and 1 Guest are viewing this topic.

Offline AdminTopic starter

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,660
  • Helpful? 169
    • Society of Robots
Serial communications with PonyProg or AVR ISP?
« on: March 02, 2007, 09:29:06 PM »
Before I go and break anything, does anyone know if I can output rprintf("hello!") statements from my AVR though either/both the PonyProg and AVR ISP programmers to say Hyperterminal?

I managed to get the uart and rprintf functions to compile without error (using AVRlib), but nothing is appearing in my Hyperterminal connection . . . perhaps I am doing it wrong, but want to make sure I wont break anything before I debug . . .

Offline JesseWelling

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 707
  • Helpful? 0
  • Only You Can Build A Robot!
Re: Serial communications with PonyProg or AVR ISP?
« Reply #1 on: March 03, 2007, 02:49:05 AM »
I really couldn't say. I do all my programing from gumstix to robostix and I use the same serial line to program as I do to send stuff back so i'm guessing it would be ok.....

Offline JonHylands

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 562
  • Helpful? 3
  • Robot Builder/ Software Developer
Re: Serial communications with PonyProg or AVR ISP?
« Reply #2 on: March 03, 2007, 05:59:04 AM »
No, you can't. The programmer connects to MISO and MOSI, which are the SPI programming pins. You need an RS-232 -> TTL converter, and you need to hook it to the pins marked TxD and RxD (pins 2 & 3). You also need to connect ground.

I see on your schematic you are using those two pins to control the servos - you might want to change that to use pins 4 & 5 instead, keeping pins 2 & 3 available.

http://www.sparkfun.com/commerce/product_info.php?products_id=198

That's an example of a simple USB -> TTL converter. Hook Tx on that board to Rx on the AVR, and vice versa for Rx. Leave 3.3 volts unconnected (the USB board is powered from USB).

- Jon

Offline dunk

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
Re: Serial communications with PonyProg or AVR ISP?
« Reply #3 on: March 03, 2007, 06:13:14 AM »
so i was playing with UARTs on an atMega8 last week making a PWM motor controller. (will document the process soon. promise.)

so i'm presuming the AVR ISP programmer you are using is the same as mine here. mine connects to  MOSI, MISO and SCK (pins 17,18 and 19 on the atMega8).
so the UART works on the RXD and TXD pins (pins 2 and 3 on the atMega8).
(i'm guessing Jesse's robostix uses a boot loader to upload the program through the UART.)

so, what you will need to do, get a max232 level shifter to convert the AVRs ttl voltages to the higher voltages needed for a PC serial port.
hook it all up like this: http://homepage.hispeed.ch/peterfleury/avr-uart.html

once you have that done and since you are using the AVRlib code, have a look at the example code in this file in the AVRlib package:
avrlib/examples/rprintf/rprintftest.c

if you have any more problems let me know as i have this working at the moment.

interestingly enough, i couldn't get accurate enough timing with an external cristal while using the UART so i have to use the internal oscillator.
with the external cristal i was just getting junk through the serial connection unless i slowed the baud rate right down.
obviously i'm doing something wrong but i can't work out what.
anyway, it works fine for me with the internal oscillator.

dunk.

Offline dunk

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
Re: Serial communications with PonyProg or AVR ISP?
« Reply #4 on: March 03, 2007, 06:14:02 AM »
ha. snap!

dunk.

Offline Hal9000

  • Supreme Robot
  • *****
  • Posts: 338
  • Helpful? 0
Re: Serial communications with PonyProg or AVR ISP?
« Reply #5 on: March 03, 2007, 06:49:54 AM »
Yeah, Max 232 (or 233 as you don't need all the capactiors with this one) is the one I use.
"The truth is, you can't hide from the truth, cos the truth is all there is" - Handsome Boy Modeling School

Offline JonHylands

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 562
  • Helpful? 3
  • Robot Builder/ Software Developer
Re: Serial communications with PonyProg or AVR ISP?
« Reply #6 on: March 03, 2007, 07:36:20 AM »
interestingly enough, i couldn't get accurate enough timing with an external cristal while using the UART so i have to use the internal oscillator.
with the external cristal i was just getting junk through the serial connection unless i slowed the baud rate right down.
obviously i'm doing something wrong but i can't work out what.
anyway, it works fine for me with the internal oscillator.

You must have been doing something very wrong - the internal RC oscillator is far less accurate than an external crystal. Did you have a couple 18 or 20 pF caps going between the crystal legs and ground?

The other thing you need to do is make sure the fuse bits are set properly for specifying an external high-rate crystal.

- Jon

Offline AdminTopic starter

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,660
  • Helpful? 169
    • Society of Robots
Re: Serial communications with PonyProg or AVR ISP?
« Reply #7 on: March 03, 2007, 09:33:33 AM »
doh! oh well. if I spend any more money it will go over $50 . . .
will just have to rely on a flashy LED for output (as soon as I figure out why it doesnt work) . . . :P

i can always write a future tutorial on serial communications and show people how to upgrade it . . .

yeap . . . educational experience for me . . .

Offline JesseWelling

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 707
  • Helpful? 0
  • Only You Can Build A Robot!
Re: Serial communications with PonyProg or AVR ISP?
« Reply #8 on: March 03, 2007, 01:47:12 PM »
Actualy I think that sense you really don't have easy access to the SPI lines on the Robostix I think those two lines are tied together for easy programing.....I never really looked into it because it 'just worked' :P

Offline dunk

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
Re: Serial communications with PonyProg or AVR ISP?
« Reply #9 on: March 03, 2007, 02:20:33 PM »
Quote
You must have been doing something very wrong - the internal RC oscillator is far less accurate than an external crystal. Did you have a couple 18 or 20 pF caps going between the crystal legs and ground?
yes. i know. annoying hu?
for the crystal and timing capacitors i'm using the same setup as i used the last time i used a Microchip PIC where they worked perfectly.
i'm pretty sure i had the fuse bits set right.
my power source was coming straight from the 5V output on my laptop's USB port.
i must go back to it at some point and see if i can work out where i was going wrong.

but any way, enough of my problems,
Quote
doh! oh well. if I spend any more money it will go over $50 . . .
DigiKey has the max323 for $0.9.
capacitors might cost $1.
so maybe if you call it the $52 robot....

dunk.

Offline AdminTopic starter

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,660
  • Helpful? 169
    • Society of Robots
Re: Serial communications with PonyProg or AVR ISP?
« Reply #10 on: March 03, 2007, 03:55:33 PM »
Quote
I never really looked into it because it 'just worked'
yeap . . . this is why i can do serial communications with PIC's and yet not understand any of it - it was all done for me on the cerebellum . . .

Quote
Quote
doh! oh well. if I spend any more money it will go over $50 . . .
DigiKey has the max323 for $0.9.
capacitors might cost $1.
so maybe if you call it the $52 robot....
well I kinda went over a few $ with shipping already . . . and I would also need a rs232 adaptor and serial cable to add to that list . . . i think this upgrade would make a perfect new tutorial :D
plus, I designed the controller so that there is plenty room for future additions.

 


Get Your Ad Here