subtle and really obvious once I saw it. There is the
lesson: When the data you observe doesn’t make any
sense, examine your assumptions; at least one of them
is wrong!
So, there you have it. To add more sensors, simply
daisy-chain more boards on to the SCI bus. Make sure that
each of them has a different address though! Figure 8
shows my entire test setup with all of the boards wired
together. Not pretty, but it worked great.
ENHANCEMENTS: You can
always do better…
There is certainly room for future enhancement here.
Here are some of the modifications and changes that I
want to make:
1) Add a command to change the board address so I don’t
have to compile the address in.
2) Carefully measure the required data setup time so I can
run the bus as fast as possible – find out what is possible.
3) Find the maximum wire length before data corruption
occurs.
4) Investigate devices that have an open drain output
so that I don’t have to worry about damaging a part if
bus contention occurs (two parts driving the line in
opposite directions).
5) Add more kinds of sensors!
That’s all folks! Have fun and let me know what you
come up with if you like this bus architecture.
Remember, the complete source code for this article
is available on the SERVO Magazine website under Mr.
Roboto as SPIsonar.zip. It will have three files in it:
SPIsonar.c for the PIC16F630 and CCS C compiler, and
atm168.c and atm168.h for the ATMega168 processor
side of the project. I used avr-gcc 4. 3.0 as my compiler
with Eclipse and the AVR Eclipse plugin as my development
environment. If you want to know how to use this
environment, see my columns in the August and
September issues.
Well, we’ve come to the end of another Mr. Roboto
column and I hope you’ve felt that it was time well spent.
As usual, I can be reached for questions, comments, and
criticisms at roboto@servomagazine.com and I’ll be happy
to work on it! Until next time, keep on building those
robots! SV
Robotiics Showcase
C Stamp is ...
LOWCOSTPCB
MANUFACTURING!
Mi
cro
co
nto
r
lle
rs!
Sensors and
Boards
Communications!
for Development!
D is pla y s!
Come see what else at
7KH (VFDSH
5RERW¶V EXLOW LQ
PLFURSURFHVVRU
HQDEOHV LW WR
³WKLQN´ RQ LWV RZQ
6 ROG HULQ J
UH T XLUH G
. 65
7KH URERW IURJ PRYHV IRUZDUG
ZKHQ LW GHWHFWV VRXQG DQG
UHSHDWV VWDUW PRYH IRUZDUG
VWRS OHIW WXUQ VWRS ULJKW
WXUQ VWRS . 65
PP :KLWH
ZDWHU FOHDU
/(' 9
PFG
$%
VHFRQG YRLFH UHFRUGHU SOD\EDFN
PRGXOH 7KH HOHFWUHW PLFURSKRQH LV RQ WKH
ERDUG 2QH EXWWRQ UHFRUGV WKH RWKHU EXWWRQ LV
PRPHQWDULO\ SUHVVHG WR UHSOD\ WKH PHVVDJH
SUH DVVHPEOHG
7KH 9HOOHPDQ 3HUVRQDO 6FRSH
LV QRW D JUDSKLFDO PXOWLPHWHU
EXW D FRPSOHWH SRUWDEOH
RVFLOORVFRSH DW WKH VL]H DQG
FRVW RI D JRRG PXOWLPHWHU
+ 36 $146.
7KRXVDQGV
PRUH LWHPV RQ
RXU ZHE VLWH
THOUSANDS OF ELECTRONIC
PARTS AND SUPPLIES
VISIT OUR ONLINE STORE AT
www.allelectronics.com
WALL TRANSFORMERS, ALARMS,
FUSES, CABLE TIES, RELAYS, OPTO
ELECTRONICS, KNOBS, VIDEO
ACCESSORIES, SIRENS, SOLDER
ACCESSORIES, MOTORS, DIODES,
HEAT SINKS, CAPACITORS, CHOKES,
TOOLS, FASTENERS, TERMINAL
STRIPS, CRIMP CONNECTORS,
L.E.D.S., DISPLAYS, FANS, BREADBOARDS, RESISTORS, SOLAR CELLS,
BUZZERS, BATTERIES, MAGNETS,
CAMERAS, DC-DC CONVERTERS,
HEADPHONES, LAMPS, PANEL
METERS, SWITCHES, SPEAKERS,
PELTIER DEVICES, and much more....
www.c-stamp.com
ORDER TOLL FREE
1-800-826-5432
Ask for our FREE 96 page catalog
SERVO 06.2009
19