Asked — Edited
Resolved Resolved by Jeremie!

I2c Information Update?

DJ, Anybody,

Is there new information about I2C? The last reference I can find is: https://synthiam.com/Community/Questions/322

I am trying to write a script that will have the EZ-B v4 respond as an I2C slave to a master I2C device. To do this, the master device sends the EZ-B data, the EZ-b is then able to respond by sending data to the master.

The script fails and the WiFi connection is broken. I have to power down, then reconnect the EZ-B.

Here is a script snippet: (The address of the master is 0x4)

The master is in a loop I2C writing a '1', then I2C reading << :loop $V1 = I2CRead(0,0x4,1) Print ("V1 = "+$V1) I2CWrite(0,0x4,40) #decimal 40 is the value I want written sleep(1000) goto(loop)

Thank you.


ARC Pro

Upgrade to ARC Pro

Become a Synthiam ARC Pro subscriber to unleash the power of easy and powerful robot programming

PRO
Synthiam
#1  

You are unable to "read" unless there is a request sent.

Attempting to read i2c will pause forever (as you are experiencing) without knowing there is data. Do something like this...

  1. Send a request for data

  2. Read the known data size that has been requested

PRO
Synthiam
#2  

For more information, look at the i2c BlinkM example...


# Shift the bits over
# Set the LSB (first bit) to a 1
# When first bit is a 1 on i2c, that means
# it is a Read Address
$i2cAddress = 0x09

Print(&quot;BlinkM Address: &quot; +  $i2cAddress)

# Tell BlinkM we want the RGB Values
i2cWrite(0, $i2cAddress, 0x67)

# Receive the RGB Values
$raw = i2cRead(0, AUTO, $i2cAddress , 3)

# Print the number of bytes
Print(&quot;Received: &quot; + Length($Raw) + &quot; Bytes&quot;)

# Print the hex value of each byte
PrintHex($Raw)

# Split the array of bytes and assign to each variable
$Red = GetByte($Raw[0])
$Green = GetByte($Raw[1])
$Blue = GetByte($Raw[2])

#3  

DJ,

Thanks for the quick reply.

Your script is setting the EZ-b as the master and the BlinkM as the slave. I need the EZ-b to be the slave.

PRO
Synthiam
#4  

The EZ-B is unable to be a slave - it's configured as a master by factory.

#5  

I am trying to use the EZ-b as a 'capability enhancer' for robots built with the Lego EV3. To do this the EV3 uses a Dexter Industries I2C sensor block. This block sets the EV3 as the I2C master.

I have connected the EV3 via an arduino and got it to work with the information in http://www.dexterindustries.com/howto/connecting-ev3-arduino/

Near the end is a section headed "EV3 as the Master".

BTW- https://synthiam.com/Community/Questions/6532 shows the robot that I wish to 'enhance' with all the super EZ-B capabilities. A video is at: https://www.youtube.com/watch?v=DiGyeV759JE

Again, thanks.

PRO
Canada
#6  

Hi @OldbotBuilder,

You could essentially run your robot with 2 masters. The ez-bv4 can communicate serially to the Arduino. You could write a program on the Arduino that could translate your serial data from the ez-b and create I2C commands to send to the EV3 controller, probably wouldn't be that efficient but it's an idea.

Otherwise, I would suggest to try interfacing the motors and sensors from the EV3 directly to the ez-b. I believe LEGO peripherals also communicate as I2C slaves, but I don't have enough info on these new LEGO kits to confirm that.

#7  

From what I read, it looks like the EV3 can only be a Master (no slave option) and the EZB as DJ said likewise is designed to only be a Master.

My thoughts are you would either need to use an Arduino in between the two. Or it might be possible to communicate with the LEGO EV3 over wifi using TCP/IP. This might work.

#8  

Jeremie and JustinRatliff,

Good ideas and I will look into both suggestions. Thanks to you both.

Now - how does the 'resolved by' credit get assigned?