View unanswered posts | View active topics It is currently Thu Aug 21, 2014 2:19 am






Reply to topic  [ 12 posts ] 
Port Splitter for NXT Digital Sensors 
Author Message
Rookie

Joined: Fri Jan 03, 2014 4:58 pm
Posts: 10
Post Port Splitter for NXT Digital Sensors
Hi,
i want use port splitter for NXT digital sensors. I tried connect ultrasonic sensor and compas sensor to the splitter and splitter to the input port S1. I wanted only display the values on NXT brick display. But i dont know how to differentiate sensors on the same port. Cann someone explain to me how to declare both sensors in RobotC? Thanks for the anwer.


Fri Jan 17, 2014 4:34 pm
Profile
Expert
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 101
Post Re: Port Splitter for NXT Digital Sensors
I believe the best option for you is to use Xander's drivers. In ROBOTC under the File menu, choose the Open Sample Program option. From there, navigate to the "3rd Party Sensor Drivers" folder and open "lego-ultrasound-SMUX-test1.c" That should provide you with the basic framework for how to read an ultrasonic sensor value from a sensor multiplexor.

_________________
Burning Lights Programming
FTC Team 6100 Chariots of Fire - Programmer (2012-2013)
FTC Team 7468 Blue Chariots of Fire - Programmer (2013-2014)
Check out our team website at http://cof7468.weebly.com/.


Fri Jan 17, 2014 5:25 pm
Profile
Rookie

Joined: Fri Jan 03, 2014 4:58 pm
Posts: 10
Post Re: Port Splitter for NXT Digital Sensors
Ok, I can use drivers for sensor multiplexer also for port splitter, too? Thats the same proces?


Fri Jan 17, 2014 5:42 pm
Profile
Rookie

Joined: Fri Jan 03, 2014 4:58 pm
Posts: 10
Post Re: Port Splitter for NXT Digital Sensors
I tried this one Xander´s code, but program doesn´t work...

Code:
#pragma config(Sensor, S1,     HTSMUX,              sensorLowSpeed)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include "hitechnic-sensormux.h"
#include "hitechnic-compass.h"
#include "lego-ultrasound.h"

const tMUXSensor LEGOUS = msensor_S1_1;
const tMUXSensor COMPASS = msensor_S1_2;

task main () {
  int dist = 0;
  int direct = 0;

  eraseDisplay();
  nxtDisplayTextLine(0, "Lego US Sensor");

  while(true) {

    dist = USreadDist(LEGOUS);
      direct = HTMCreadHeading(COMPASS);

    nxtDisplayTextLine(3, "Dist:  %3d cm", dist);
    nxtDisplayTextLine(5, "Direct:  %3d", direct);
    wait10Msec(50);
  }
}


Fri Jan 17, 2014 6:19 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Port Splitter for NXT Digital Sensors
hanzi23 wrote:
Ok, I can use drivers for sensor multiplexer also for port splitter, too? Thats the same proces?

Xander's drivers are for the HiTechnic Sensor MUX. What kind of port splitter are you using? If it is not the Hitechnic sensor mux, I am afraid it won't work. Besides, I believe that part may be illegal for FTC if it is not on the "approved list".


Fri Jan 17, 2014 9:15 pm
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: Port Splitter for NXT Digital Sensors
to my guess he's using simple splitters, no multiplexers.

Maybe better don't use #pragma config (delete these lines!),
switch S1 to I²C mode
and then just set sensors manually to the same port.
I often did this already for 3 i2C sensors at 1 NXT port (by NXC).

Code:
dist = USreadDist(S1);
direct = HTMCreadHeading(S1);


If both devices have different i2c device addresses the sensor reading works automatically correct, for i2c for up to 127 devices at 1 NXT port.
Be sure you have a sleep(20_ms) between your readings (i2c bus delay).

Admittedly, unfortunately, Mindsensors often uses the same i2c device address as Lego (0x02), then it won't work of course.
So what is your device address for the compass like?

If the i2c device addresses are different and it doesn't work though, try to use your USS in single shot mode.
In case they are identical then you will need a sensor multiplexer.

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Sat Jan 18, 2014 4:41 am
Profile
Rookie

Joined: Fri Jan 03, 2014 4:58 pm
Posts: 10
Post Re: Port Splitter for NXT Digital Sensors
I use, this one port splitter http://mindsensors.com/index.php?module=pagemaster&PAGE_user_op=view_page&PAGE_id=79

I read a user guide and port splitter should support LEGO Ultrasonic Sensor and HiTechnic Compass Sensor. If i connect only one of them to the NXT Brick throught the port splitter, so everything is working correctly. But both together not. I´m probably using the wrong I2C adressing.


Sat Jan 18, 2014 5:51 am
Profile
Rookie

Joined: Fri Jan 03, 2014 4:58 pm
Posts: 10
Post Re: Port Splitter for NXT Digital Sensors
I read user guide again and Magnetic compass for NXT (CMPS-Nx) isn´t the same as HiTechnic Compass sensor. HT Compass isn´t probably supported with port splitter.... But thanks for your help :)


Sat Jan 18, 2014 6:04 am
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: Port Splitter for NXT Digital Sensors
surely, every i2c device is "supported" by the portssplitter, it's just 3x electrical connection plug.
Of course you need the correct device driver from Xander's suite.

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Sat Jan 18, 2014 6:07 am
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: Port Splitter for NXT Digital Sensors
CMPS-Nx sounds as if it's the Mindsensors compass driver or whatever.

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Sat Jan 18, 2014 6:15 am
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: Port Splitter for NXT Digital Sensors
Hitechnic website says:
Quote:
The compass can be programmed using LEGO Mindstorms NXT Software Compass Block*. If the Compass Block is not available you may also use the standard Ultrasonic Block.

That means that both devices must have the same i2c bus device address, otherwise this wouldn't work (0x02 as I suspected).
So compass and USS can't work at the same time at the same NXT port (a quite stupid thing done by the manufactures IMO), but both sensors work with different i2c sensors nevertheless at the portsplitter.

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Sat Jan 18, 2014 6:26 am
Profile
Rookie

Joined: Fri Jan 03, 2014 4:58 pm
Posts: 10
Post Re: Port Splitter for NXT Digital Sensors
Ok, thanks for explanation.


Sat Jan 18, 2014 8:26 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 12 posts ] 

Who is online

Users browsing this forum: mightor and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.