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 / 17518
17517  |  17519
Subject: 
Re: LEGO RCX and I2C
Newsgroups: 
lugnet.robotics
Date: 
Thu, 21 Mar 2002 09:03:25 GMT
Original-From: 
Ralf Krause <KRAUSE.RALF@ihatespamWEB.DE>
Viewed: 
819 times
  
Hi Steve,

your time stamp is rather wrong ... today it's 2002-03-21 and not 27.

The software seems to be good readable and not like something to bother
with. The author did his work and wrote a lot of comments within the source
so you would be able to learn all about the i2c protocol. (look to the first
lines of the source)

I don't know if the speed is enough for real robots but to light a knight
rider or a 7 segment diplay it's great because it's easy usable.

Ralf


//===========================================================================
// File:        i2c_master.nqc
// Description: Single-Master I2C bus communication functions which enables
//              Mindstorm to access a wide range of I2C Slave devices.
// Remarks:     This program requires special hardware on Sensor Ports 1 & 2
// Compiler:    Requires RCX 2.0 firmware, compile with
//              NQC 2.2 or later using -Trcx2 command line option
// Author:      Wim Huiskamp
// Date:        28-7-01
//
// History:     V1.0, 28-07-01, First release (Wim Huiskamp)
//              V1.1, 14-12-01, Fixed bug in i2c_ackn for unrolled loop,
//                              fixed several comments (Wim Huiskamp)
//
//===========================================================================

// General purpose defines
#define bool int

// I2C serial bus port definitions. Select your preference.
// The RCX should have my special hardware connected to its sensor ports.
// Note : The SCL/SDA definitions are used by all I2C subs and functions.
#define SCL SENSOR_1
#define SDA SENSOR_2

// I2C globals for subroutines :
int i2c_data;     // Databyte to be transmitted or received
bool i2c_ackn;    // Acknowledge bit to be transmitted or received

// Predefined I2C slave addresses for port expander devices
#define PCF8574_0 0x40
#define PCF8574_1 0x42


// I2C serial bus output bit banging Macro's
//
// Note: Active Ports result in 'low' I2C level on my hardware
//       Passive Ports result in 'high' I2C level
#define SCL_Lo() SetSensorType(SCL, SENSOR_TYPE_LIGHT)
#define SCL_Hi() SetSensorType(SCL, SENSOR_TYPE_TOUCH)
#define SDA_Lo() SetSensorType(SDA, SENSOR_TYPE_LIGHT)
#define SDA_Hi() SetSensorType(SDA, SENSOR_TYPE_TOUCH)


// The following code may be used to replace SCL_Hi. The new macro will
// wait until SCL actually goes High. This is necessary to deal with slow
// Slaves that use 'serial clock stretching' to slow down the I2C master.
// Don't expect to need this here, RCX is slow enough already !
// Note that we might freeze up the RCX when the bus gets stuck low.

and so on



on 2002-03-27 0:54 Uhr, Steve Baker at sjbaker1@airmail.net wrote:

Ralf Krause wrote:

the Elektor - Magazine for Electronics and Computer - comes with a very
interesting project. They have a pcb and software in NQC.

Have a look to the homepages
http://www.elektor-electronics.co.uk/
http://www.elektor.de/
http://www.elektuur.nl/
http://www.elektor.fr/

I2C Interface for Lego RCX 'Brick'

It has, by now, become well known that the Lego RCX-module is eminently
suitable for experimenting with such things as robotics. But once the
designs
grow beyond simple experimentation it quickly becomes obvious that the
number
of inputs and outputs that this control module provides, are rather
insufficient. That¹s why Elektor Electronics presents the I2C-interface for
this Lego brick. An entirely new world is opened up: in principle, no fewer
than 128 I2C-devices may be connected to the bus!

That's very cool - I've been advocating the use of I2C for Lego robotics for
a long time.

I'm not sure I'd bother with the interface to the RCX though - I was thinking
in terms of an I2C computer also.

----------------------------- Steve Baker -------------------------------
Mail : <sjbaker1@airmail.net>   WorkMail: <sjbaker@link.com>
URLs : http://www.sjbaker.org
     http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net
     http://prettypoly.sf.net http://freeglut.sf.net
     http://toobular.sf.net   http://lodestone.sf.net



--
____________________________________________

Ralf Krause
Bertha-von-Suttner-Gesamtschule Dormagen
Marie-Schlei-Strasse 6
41542 Dormagen
Germany

http://www.bvsdormagen.de
mailto:krause.ralf@web.de
____________________________________________



1 Message in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    
Active threads in Robotics

 
Verified and Trusted Team of Hackers
5 hours ago
Custom Search

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