To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 22711
22710  |  22712
Subject: 
RE: interfacing PCs with LEGO?
Newsgroups: 
lugnet.robotics
Date: 
Tue, 24 Aug 2004 14:41:11 GMT
Original-From: 
PeterBalch <PeterBalch@compuserve!ihatespam!.com>
Viewed: 
1024 times
  
Joe

By UART you mean it follows a standard serial protocol?

Yes. It's the same as RS232 except that the voltage is inverted (and swings
between 0V and 5V instead of +/- 9V). To connect it to a PC serial port,
you need to invert it with one transistor for transmit and another for
receive. I've never yet met a PC that isn't perfectly happy with RS232 that
swings between 0V and 5V - but you won't get the same distance as with
proper RS232 (swings between -9V and +9V): 1 metre is fine 100m is not.
Watch out for laptops - you can tell them that you want no h/w handshaking
but they still demand it; you have to tie CTS to RTS and DSR to DTR (pins
at the serial port plug).

The UART in the 16F627 will run at various speeds depending on what crystal
you use. If you use the internal oscillator (i.e. no crystal) then you can
run it up to (and beyond) 57600bps. I usually use 9600bps. The internal
oscillator tolerance is -9%..+7% which is just about good enough for RS232.
In practice, I've not have one that was unable to communicate reliably.
(You're building one robot - I have to worry about commercial production
runs.)

Programming PICs is harder than PCs because you don't have all the nice
debugging tools (unless you're going to spend many hundreds on an
in-circuit emulator).

When starting a new project, my "Hello World" program is simply to get one
of the 8-bit I/O ports to count 0..255 forever. Then look for the signal
with a scope (yes, you definitely will need an oscilloscope - minimum
20MHz, 2-channel - look on eBay?).

The next program receives a byte from the UART adds one onto it and
transmits the result on the UART.

Then add the I/O functions you really want. Each function operates on a
command byte from the UART and sends a result byte back to the UART.
Finally add the logic that ties the functions together (which in your case
is no logic - all the logic is in the PC).

Peter



1 Message in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR