Mindsensors RCX Mux for NXT

This is where you talk about the NXJ hardware related topics such as the brick, sensors, LEGO pieces, etc.

Moderators: 99jonathan, roger, imaqine

Mindsensors RCX Mux for NXT

Postby mdsmitty » Sat Feb 16, 2008 5:53 pm

Hi all,
I'm one of the beta testers for the RCX mux from mindsensors. I'm posting here because i have a LeJOS specific question. I2CSensor has two sendData methods. one sends a byte and the other sends a byte array. To activate port one on the mux you have to send 0xfe (254) to register 0x00 (0). Both methods require a byte, not an int. 254 is a int since its above 127. if I cast the int to a byte i have a value of -2. I tried this it does not work. the binary value of what the mux should be receiving is 1111 1110. I'm not sure what value i should be passing to the mux. I looked at a working example of NXC however in NXC you pass an int not a byte. Any suggestions on what i should be passing as a value.

Mike
mdsmitty
Novice
 
Posts: 78
Joined: Tue Feb 27, 2007 3:07 am

Postby lawrie » Sat Feb 16, 2008 11:34 pm

Casting to a byte is the right thing to do. If it is not working, it is probably for some other reason.
lawrie
leJOS Team Member
 
Posts: 922
Joined: Mon Feb 05, 2007 1:27 pm

Postby mdsmitty » Tue Feb 19, 2008 3:14 am

After some messing around im still no where but i have come up with a few more questions.
Can LeJOS operate a sensor port as an analog port and a digital port at the same time.
Also is there a way to confirm I2CSensor.sendData(int,byte) does it thing it returns a 0 if successful but it returns a 0 with no deices attached to the ports.
mdsmitty
Novice
 
Posts: 78
Joined: Tue Feb 27, 2007 3:07 am

Postby gloomyandy » Tue Feb 19, 2008 4:54 pm

Hi,
You should be able to read the analog values while using i2c. However I'm not sure if anyone has actually done this! How are you trying to access the port? You may have to take care that you are supplying the correct voltage to the sensor. I think you probably just want to access it as a i2c sensor and then use readRawValue to access the analog side of things.

There is currently no real error return from the i2c access functions. Sorry! Things that may be worth checking ......
1. Are you using the correct device address? By default devices are at address 1 and this is built into the getData calls. However some devices can be set to be at other addresses to multiple devices to be used on the same i2c bus.
2. When reading and writing to the device some devices allow you to read/write multiple bytes in one go. Others do not (and some insist that you do!). So if the values you are trying to read/write are multiple bytes in size you may want to try it all ways.
3. Have you tried a port that is not port 4. Port 4 has some additional hardware attached to it that may upset the sensor (even if it works with the Lego firmware it may not work on this port with leJOS).
4. Do you have access to a scope or other hardware tools? If so I may be able to help more....

All the best...

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4085
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Postby mdsmitty » Fri Feb 22, 2008 2:54 am

Andy,
I can read analog and digital from the same port but i have no way of connecting the 2 sensors at the same time with out hacking up some cable. when i ordered the beta mux i thought about getting the splitter that mindsensors has, i guess i should have. is there a voltage difference from a rcx light sensor and the i2c bus?
1) the address on the device is is 7e but im using 7d because its to my understanding from a previous post that i2csensor.setaddress adds one to the value. although i have tried both values.
2) just writing one byte. No documentation was presented from miiindsesnors just some emails with the adress and the register and what bytes do what when passed to that register. everything was a single byte.
3) im using port one i figured best to stay away from 4. i tried the mux with the lego firmware it works great.
4)sorry no scope.

Mike
mdsmitty
Novice
 
Posts: 78
Joined: Tue Feb 27, 2007 3:07 am

Postby gloomyandy » Fri Feb 22, 2008 8:34 am

Hi Mike,
That address is a little odd. I'm surprised that it has a non standard address by default. Things that are worth trying.....
1. Try talking to the device without setting any address (so use the default address of 1). You may want to try accessing the "standard" items like vendor id etc. to see if you can make those work.
2. There is a lot of confusion about i2c addresses. leJOS actually shifts the address value left by 1 bit before putting it out on the bus. So you may want to try using (0x7d >> 1) as the address value....

Good luck!

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4085
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Postby gloomyandy » Fri Feb 22, 2008 9:18 am

Oh and give (0x7e >> 2) a try as well!

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4085
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Postby mdsmitty » Tue Apr 08, 2008 4:12 am

I got the thing working and works quite well. Lawrie had posted in another thread about setAdress and dividing the address by 2. that worked. I'm going to submit this class along with a sample for the next release. I do have one question if future releases will it still be necessary for setaddress to divide by 2 or will just the address be all thats required..
mdsmitty
Novice
 
Posts: 78
Joined: Tue Feb 27, 2007 3:07 am


Return to NXJ Hardware

Who is online

Users browsing this forum: No registered users and 0 guests

more stuff