28.12.2014 Views

Nuts & Volts

Nuts & Volts

Nuts & Volts

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

⇒ PIC to PC Communication<br />

⇒ As I write this, my first “Getting<br />

Started with PICs” article has been published<br />

and the email response has been<br />

outstanding. Apparently, a lot of people<br />

like the topic and want to know more<br />

about getting started with PICs. Being<br />

able to write these articles is really a joy<br />

for me because I have a real passion for<br />

programming PICs and I learned a lot of<br />

it the hard way — via trial and error.<br />

Having the chance to share my knowledge<br />

with others is only beneficial,<br />

though, if someone wants to read it.<br />

The feedback email proves a lot of<br />

people are reading. Feedback also<br />

tells me what readers want to see,<br />

and I can form my future articles<br />

around that feedback. It’s just a great<br />

example of two-way communication.<br />

That’s also the topic of this month’s<br />

column — communication.<br />

Think about it. A major portion of<br />

your monthly bills are dedicated to<br />

communication — your phone bill<br />

(both land line and cell), your cable TV<br />

bill, your Internet bill, your magazine<br />

subscriptions, books you buy, maybe<br />

even a satellite radio bill — they are all<br />

forms of communication we are<br />

willing to pay for. This month, I want<br />

to address one form of PIC-to-PC communication<br />

using serial RS232 format,<br />

and you get this one for free (excluding<br />

the magazine subscription fee).<br />

78 March 2006<br />

Before I received my first computer<br />

as a gift — a Commodore VIC20 —<br />

I was fascinated with computer control.<br />

Many years ago, I interfaced a circuit<br />

built around a chip I found at<br />

RadioShack, which made the VIC20 talk<br />

via its expansion port. Nobody in my<br />

family seemed to care too much, but I<br />

was excited that I had figured out how<br />

to control external electronics from a<br />

computer. There have since been many<br />

books written on how to use the parallel<br />

port or serial port on a PC to control<br />

electronics, and USB is taking over as<br />

the communication port of choice.<br />

Despite the USB revolution, the<br />

RS232 serial port interface is still the<br />

most common method of communicating<br />

with various off-the-shelf<br />

modules found in the pages of <strong>Nuts</strong> &<br />

<strong>Volts</strong>. You can get RS232 style serial<br />

LCDs, dataloggers, servo motor<br />

controllers, and DC motor controllers,<br />

just to name a few. You can also find<br />

loads of Windows PC software all over<br />

the web that will accept or send ASCII<br />

data from the serial port.<br />

Therefore, in my opinion, one of<br />

the fundamental projects every PIC<br />

by Chuck Hellebuyck<br />

hobbyist should know is how to communicate<br />

between a PIC and a PC serial<br />

port. After that, you can add an RS232<br />

to USB converter if you need USB.<br />

GETTING STARTED<br />

For this article, I wanted to keep it<br />

simple and demonstrate how to have a<br />

PC user control a bank of LEDs. By<br />

entering the number on the PC, the user<br />

can turn on a specific LED at a remote<br />

location only connected to the PC by a<br />

serial cable. The remote module will<br />

have a PIC to handle the interface and<br />

start the communication by sending a<br />

message to the PC asking which LED to<br />

light. The PC user enters their choice,<br />

hits the “enter” key, and the PIC circuit<br />

receives it and then lights the proper<br />

LED. It’s simple two-way communication<br />

with a functional purpose.<br />

For the software — once again —<br />

I turn to the PICBasic Pro sample<br />

version to handle the software. At the<br />

end of the article, though, I’ll address<br />

some of the options for going beyond<br />

the sample version’s limitation of 31<br />

commands, as some email has

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!