Support fur i2c (itc Devantech SRF02 u. USB-i2c

Guten Abend,

leider bin ich in der Suche nicht fündig geworden und die Site scheint ein Problem bei der Darstellung der einzelnen Nodes zu haben.

Ich suche eine Möglichkeit einen Devantech USB-I2C-Adapter zum Laufen zu bringen. Ich betreibe damit einen SRF02 Ultraschall Abstandsmesser von Devantech (Beides bei roboter-teile.de gekauft).

Im Grunde müsste der RS232-node den Sensor via USB ansprechen. Ich sende also einen per Spellvalue gewandelten Hex Befehl an den Sensor. Dieser zeigt allerdings nicht (wie beim Devantech-Tool zu sehen) per LED an, dass er etwas empfängt, und er sendet auch keine Daten.

Die Frage: Hat jemand das Problem gelöst und eine Tipp, was man tun muss, dass es funktioniert?

OK, I realize that this an English speaking forum, so I’ll say again in English.

I’m connecting an Devantech Ultrasonic distance meter (SRF02) via an USB-I2C-Adapter to vvvv. The RS232 node should actually send a Hex Command to the Interface. But there is no reaction (LED blinking) or so.

Drivers are installed, the supplied app from devantech reads the distances perfectly.

Anyone here ever used an USB-I2C-contruct this way and had good results?

Thanks for Your help

it’s no problem to ask in any language!
but your english seems to be quite well :)

can you attach the patch here?

Thanx, I try but often fail.

I can try to attach the patch, but it’s not really ready yet. I’m still trying to find a way the supply the USB-I2C Adapter with that Hex Command.

http://www.robot-electronics.co.uk/htm/usb_i2c_tech.htm
and
http://www.robot-electronics.co.uk/htm/srf02tech.htm

are ment to help, but confuse (me) more than help.

Thanks for helping.

patch to look at (3.1 kB)

hi philipp, i just had a look at your patch and the documentation you provided and i think you’re doing some things wrong ;)

first of all don’t use SpellValue (String). you want to send the command “Real Ranging Mode - Result in micro-seconds” (82 in dec), but you’re sending 52 (dec) which is not a valid command. so i’d recommend to avoid the hex address representation and stick to the dec ones.

second thing, simply writing 82 is not enough. you need to tell the SRF02 to do a ranging (writing a 82 to its command register), then you need to wait up to 66ms till it has written the ranging result to its output registers and after that you can read the result from there.

now to tell it to do the ranging have a look at the example “Writing to I2C devices with a 1 byte internal address register” from here. the byte sequence should look like this:
0x55 | 0xE0 | 0x00 | 0x01 | 0x52
in dec
85 | 224 | 0 | 1 | 82
this tells the usb-i2c module to write one byte (the actual SRF02 command) to the i2c device located at address 0xE0 (the SRF02) and register 0x00 (the command register).

after that you can read the data. probably like this:
0x55 | 0xE1 | 0x02 | 0x02
this tells the usb-i2c module to read two bytes from the i2c device located at address 0xE0 from register 0x02.
again have a look at the section “Reading from I2C devices with a 1 byte internal address register”.

also check the section “Checking for Completion of Ranging” here.

hope this helps.

oh and please don’t take the things i wrote here for granted, i don’t have that hardware to test it…

Thank You very much!

This is a bright light at the end of my tunnel. I will try to put things in order. Sorry for being so underdeveloped.

OK, thanks again, and thank you Kalle. I used the patch you did to encode a string to have some easier way of putting my commands in.

Now I only have the Problem, that I don’t have the slightest idea how to read out the distance measured from what I’m getting from the Sensor.

But so far this is where I am right now.

(Sorry for adding another Newbypatch)

Anyone an idea how to easily extracting the distance information?

Of course I’ll need to implement the 500mS wait somehow without making things to shuttery.

AND of course the reading register is 2 and not 0. I’ll upload another corrected patch, as soon as I get this stupid web problem around here fixed.

EDIT: OK here goes. It’s the latest state. I can’t seem to find the right string for reading. LED responds on the write but not on the read send. (see att.)

REM_String.v4p (23.5 kB)
String_Start_Sensor.v4p (65.7 kB)
String_Read_Sensor.v4p (65.7 kB)

as a hint: use Ord (String) and set format to Unsigned16BitHex to convert hex to dec instead of this huge =, Switch, Frac thing.

the read command you’re sending to the device doesn’t look right to me. you should not send the command byte again. so instead of

0x55 | 0xE0 | 0x02 | 0x02 | 0x51

you should send

0x55 | 0xE0 | 0x02 | 0x02

ok and i’m not sure if this whole thing will work like you patched it.
basically you’re in 3 possible states:

  • send new ranging command (Ranging)
  • wait till data is available (Polling)
  • read data (Reading)

you could implement this with the Automata (Animation) node like this:

Ranging OnRangingDone Polling DoPolling
Polling OnPollingDone Reading DoReading
Reading OnReadDone Ranging DoRanging

so you have to implement those three actions now:

Ranging
send the ranging command to the device and if the rs232 node returns non-zero emit the OnRangingDone event.

Polling
like described in the article, read register 0 of your device and once it returns a value other than 255 (0xFF) the ranging is complete and you can emit the OnPollingDone event.

Reading
read the ranging result from the device. in register 2 (R2) is the high byte in register 3 (R3) the low byte. so your final result is:
(R2 << 8) | R3
and now emit the OnReadDone event and the automata goes back to Ranging state.

Thank you again Elias!

As you can see I’m pretty stupid about the grammar of vvvv - I’m more the physical type.

I’ll try simplifying the nodes and having the process rather feedback based than time based.