General area when it fits no where else

Moderator: Mmiscool

User avatar
By viscomjim
#36348 Darn it all... No difference. I guess I will have to wait till tomorrow to get a hold of my scope. Maybe its time to get a hold of a logic analyser or something that I can capture i2c and see whats up.

Time to buy a bus pirate.
User avatar
By viscomjim
#36402 Mike, OK, so I ordered a logic analyzer that can do i2c (and other serial bus stuff), this is a good thing as I always wanted one and now I can justify it. In the mean time, could you take a look at my code from this thread and at least tell me if I am doing that correctly. At least I can eliminate that portion beforehand.

For instance, can you do several writes in between i2c.begin and i2c.end(), what speed is the bus working at 100khz, 400khz, are delays needed, etc.

I really want this to work as it will open up lots of possibilities for expansion. Being able to use this display (there are others with multiple digits using the same i2c chip, including matrix) would make for a really cool internet based clock in its simplest form and makes for a great beginner project. There are so many cool i2c things out there... and being able to address them using a browser is just awesome.

Here is my code beginnings for an internet clock. This is what I wanted to use the simple array for but I did it differently and technically should work once I figure out why the display is not behaving as it should.

Code: Select allmemclear

address = 112
i2c.begin(address)
i2c.write(33)
i2c.write(129)
i2c.write(239)
i2c.end()

timesetup(-5,0)
delay 500

timer 5000 [refresh]
wait

[refresh]
cls
button "Exit " [Exit]
print time()
disp = time()

i2c.begin(address)

hrones = mid(disp,13,1) 'hour ones
d = hrones
gosub [conv]
i2c.write(2)
i2cwrite(x)

hrtens = mid(disp,12,1) ‘hour tens
d = hrtens
gosub[conv]
i2c.write(0)
i2c.write(x)

mnones = mid(disp,16,1) ’minutes ones
d = mnones
gosub[conv]
i2c.write(8)
i2c.write(x)

mntens = mid(disp,15,1) ‘minutes tens
d = mntens
gosub[conv]
i2c.write(6)
i2c.write(x)

i2c.end()

’serialprint “hours tens = ”
‘serialprintln hrtens
’serialprint “hours ones = ”
‘serialprintln hrones
’serialprint “minutes tens = ”
‘serialprintln mntens
’serialprint “minutes ones = ”
‘serialprintln mnones
wait
'
[Exit]
timer 0
wprint "<a href='/'>Menu</a>"
end

[conv]
if d = 0 then x = 63
if d = 1 then x = 6
if d = 2 then x = 91
if d = 3 then x = 79
if d = 4 then x = 102
if d = 5 then x = 109
if d = 6 then x = 125
if d = 7 then x = 7
if d = 8 then x = 127
if d = 9 then x = 111 
return


One more question, when I do this...

hrones = mid(disp,13,1) 'hour ones

is hrones a number or a string and can it be used this way?

Thanks for the continued work!!!!
User avatar
By viscomjim
#36437 Would it be possible to at least steer me in the right direction to find out how the i2c is implemented, what speed it is operating, etc... Any information at all would be great.
User avatar
By Mmiscool
#36440 The arduino code and equivalent functions are shown below. This is the source code from the basic interpreter to handle i2c. It is pretty much pass thru from arduino but if there needs to be changes made or other options added that is not a problem. Just identifying whats missing will help.

Code: Select all  if (FunctionName == "i2c.begin")
  {
    i2cPinNo = Param0.toInt();
    MyOut = "";
    Wire.beginTransmission(i2cPinNo);
  }
  if (FunctionName == "i2c.write")       MyOut = String(Wire.write(Param0.toInt()));
  if (FunctionName == "i2c.end")         MyOut =  String(Wire.endTransmission());
  if (FunctionName == "i2c.requestfrom")
  {
    i2cPinNo = Param0.toInt();
    byte i2cParamB = Param1.toInt();
    MyOut =  String(Wire.requestFrom(i2cPinNo, i2cParamB));
  }
  if (FunctionName == "i2c.available")   MyOut =  String(Wire.available());
  if (FunctionName == "i2c.read")        MyOut =  String(Wire.read());