Canada
Asked — Edited
Resolved Resolved by DJ Sures!

Ez-B Fails With I2c Script

This is the first time I have tried using the I2C command and port. The EZ-B browns out (blue tooth is still blinking) when I run the command with nothing attatched at the port. Sometimes it fails right away running the script once and sometimes it takes 3 to 4 times for it to fail. No brownouts occur when not running the script!

I2CWrite(0,0x09,"n",0x00,0x00,0x11) ran Script 2

2/14/2014 3:46 PM - Comm Err: The operation has timed out. 2/14/2014 3:46 PM - BbytesToExpect: 1 2/14/2014 3:46 PM - Received: 2/14/2014 3:46 PM - Disconnected 2/14/2014 3:46 PM - Disconnected 2/14/2014 3:46 PM - Disconnected

second attempt, ran script 4 times and EZ-Board crashed.. following dbug info 2/14/2014 3:47 PM - Attempting connection on COM3 2/14/2014 3:47 PM - Connected to COM3 at 9600 2/14/2014 3:47 PM - EZ-B reports EZ-Robot OS v16 2/14/2014 3:47 PM - Welcome to EZ-B v3! 2/14/2014 3:47 PM - Connected 2/14/2014 3:47 PM - Setting battery monitor voltage: 6 2/14/2014 3:47 PM - Setting battery protection: True 2/14/2014 3:47 PM - Disgard incoming buffer (This usually means your EZ-B requires more power or the communication is unstable) 2/14/2014 3:48 PM - Comm Err: The operation has timed out. 2/14/2014 3:48 PM - BbytesToExpect: 1 2/14/2014 3:48 PM - Received: 2/14/2014 3:48 PM - Disconnected 2/14/2014 3:48 PM - Disconnected 2/14/2014 3:48 PM - Disconnected

I checked the underside of the board for any "shorting issues" at the I2C area with a magnifying glass and found none. I did take a plastic spudder probe and gently rubbed in between all 4 pins. Topside at the prcessor looked clean and free of any possible contaminates. I also, while the EZ was powered up checked voltages at the +5 volts and ground at the I2C pinouts. There was 5 volts at the SCL and SDA pinouts to ground. I dont know if that is normal?! When the EZ-Board was powered downd I measured 70K between SDA and SCL pinouts. The BlinkM type works fine on my "other" board . This is the first time I have tried using the I2C command and port. I hope someone can verify my voltage readings at the SDA and SCL points to compare my findings. I am not sure what else I can do to further trouble shoot, any ideas would be greatly appreciated:) Thanks for any assistance, Glen


ARC Pro

Upgrade to ARC Pro

Take control of your robot's destiny by subscribing to Synthiam ARC Pro, and watch it evolve into a versatile and responsive machine.

United Kingdom
#25  

Try $variable = I2CRead(0,"Auto",0x09,2)

By $variable = I2CRead() I meant the command but was too lazy to fill in the parameters.

While I2CRead() is a command it is useless without it being assigned to a variable, ARC would read it but instantly forget it. If you think about it, how would you use the information read by the I2CRead() command without it being assigned to a variable or used as part of an IF nest etc?

Either assign it to a variable so you can call on that variable later i.e.

Print($variable)

or use it as part of another command i.e.

If(I2CRead(0,"auto",0x09,2) = 0xFF) Servo(D0, 90) EndIf

#26  

No syntax error on your "If(I2CRead etc example! yay progress with the Read command!...but...

I am afraid the $variable has no bearing on the Script because it always fails a syntax check every time at the "Read"...and ....I2CRead does not come out on the Script helper window!? ie when entering anything on the Script line a blue helper window opens up...but nothing shows for I2CRetc?! I think I better upload the latest Software version to eliminate any corruption in my copy! and retry everything

#27  

After deleting the old version(Best practice) I installed the latest version and retried the I2CWrite and I2CRead commands with exactly the same results! No I2C help window for the I2CRight unknown command etc and the Write command still browns out the EZBoard.

United Kingdom
#28  

The best example for I2C (and the BlinkM) is the I2C example in ARC.

Getting the RGB values is already written;

# 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("BlinkM Address: " +  $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("Received: " + Length($Raw) + " Bytes")

# 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])

From that you can see that first the I2C device is written to with I2CWrite(), it asks for the RGB values, then the variable $raw is assigned the values with the I2CRead command.

It also shows that Auto doesn't need to be in quotes after all.

The example shows how to use the I2CRead command correctly by defining a variable, in this case $raw.

#29  

Thank you @Rich ...That is a very good example but immediately my board browns out (blue light goes out and red Bluetooth begins to blink) with the device plugged in. The I2CRead as a variable does not fail as a "syntax error :unknown command "
Does the I2CRead command always have to be written as a variable? Why cant it stand alone as a Command? and why doesn't the Read come out in the blue helper window when writing on the command line? I am fairly sure all the other commands are given in the helper window.

United Kingdom
#30  

I2CRead is covered by the help in the right side of the script dialogue but it doesn't come up when you start to write it, there are a few other commands which don't either, usually when they aren't the first command on the line.

To help you understand why I2CRead can't be used as a stand alone I'll ask, in what scenario do you see you using it as a stand alone command?

It doesn't have to be set to a variable, you can use it in an If or in a Print etc. but running just I2CRead(0, Auto, 0x30, 3) would return a result and then what? It needs to store it as something or do something with it. The same applies to GetPing, GetADC, HTTPGet amongst others.

#31  

Thank you @Rich (who is doing an all nighter! tired) ...I just assumed all commands where "helped"..thats only a very minor issue but clarified! I believe now, with your clarification , I2CRead is only ever used within a Variable as in the example given on the right side Script definitions! ..
Would that be the reason I am getting "syntax error :unknown command " when its the only command on a script line? If that's the case , then now we know! and I should open a software issue help and can give you the deserved credit for that, tomorrow when your awake! The Write issue will be separate and is yet not resolved... I just need to know if its a board issue or software though I am leaning on the board! 80% (why isn't the board browning out on the very first run but sometimes the second or third or 5th?)

United Kingdom
#32  

Don't worry about giving the credit, I have enough already to let one or two go by without receiving any:)

When I2CRead is the only command on the script line the syntax is incorrect. The Unknown command is a little misleading since the command is known, it's just been used incorrectly. Think of it (and any of the other Get commands) as data than as a command. Similar to if you just put "Hello World" on a single script line, it means nothing without another command, or like math commands i.e. $ping / $date these mean nothing without a command such as $variable or Print or IF.