NXT IRReceiver Sensor (NIR1032)

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
nikzagvit
Posts: 16
Joined: 31 Oct 2010, 10:33

NXT IRReceiver Sensor (NIR1032)

Post by nikzagvit »

What I2C address at a sensor NXT IRReceiver Sensor (NIR1032)?
mightor
Site Admin
Posts: 1079
Joined: 25 Sep 2010, 15:02
Location: Rotterdam, Netherlands
Contact:

Re: NXT IRReceiver Sensor (NIR1032)

Post by mightor »

Have a look at the NXC and/or ROBOTC programs on the product page: http://www.hitechnic.com/cgi-bin/commer ... ey=NIR1032

The info is all there :)

- Xander "Seek and ye shall find!" Soldaat
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
nikzagvit
Posts: 16
Joined: 31 Oct 2010, 10:33

Re: NXT IRReceiver Sensor (NIR1032)

Post by nikzagvit »

Thanks has found. I apologize for a carelessness.
nikzagvit
Posts: 16
Joined: 31 Oct 2010, 10:33

Re: NXT IRReceiver Sensor (NIR1032)

Post by nikzagvit »

I have written the following code.


#define HTIRR_I2C_ADDR 0x02 // HTIRReceiver I2C device address
#define SensorPort IN_4

// Values contained by registers in active mode
#define HTIRR_MOTOR_1A 0x42 // Motor 1A control
#define HTIRR_MOTOR_1B 0x43 // Motor 1B control
#define HTIRR_MOTOR_2A 0x44 // Motor 2A control
#define HTIRR_MOTOR_2B 0x45 // Motor 2B control
#define HTIRR_MOTOR_3A 0x46 // Motor 3A control
#define HTIRR_MOTOR_3B 0x47 // Motor 3B control
#define HTIRR_MOTOR_4A 0x48 // Motor 4A control
#define HTIRR_MOTOR_4B 0x49 // Motor 4B control

task main ()
{
byte message[];
byte nByteReady = 0;
long count;
int buf[10];
string x;

TextOut(0, LCD_LINE1, "Motor 1A", false);

SetSensorLowspeed(SensorPort);
count = 1;
while (true)
{
ArrayBuild(message, HTIRR_I2C_ADDR, HTIRR_MOTOR_1A);
while (I2CStatus(SensorPort, nByteReady) == STAT_COMM_PENDING);
if(I2CBytes(SensorPort, message, count, buf))
{
x = NumToStr(buf[0]);
TextOut(0, LCD_LINE8, x, false);
}
}
}

I read out from the channel Motor 1A control and I display. I test, at me values 100 and 156, why are displayed?
nikzagvit
Posts: 16
Joined: 31 Oct 2010, 10:33

Re: NXT IRReceiver Sensor (NIR1032)

Post by nikzagvit »

Has understood, here that has turned out

#define HTIRR_I2C_ADDR 0x02 // HTIRReceiver I2C device address
#define SensorPort IN_4

// Values contained by registers in active mode
#define HTIRR_MOTOR_1A 0x42 // Motor 1A control
#define HTIRR_MOTOR_1B 0x43 // Motor 1B control
#define HTIRR_MOTOR_2A 0x44 // Motor 2A control
#define HTIRR_MOTOR_2B 0x45 // Motor 2B control
#define HTIRR_MOTOR_3A 0x46 // Motor 3A control
#define HTIRR_MOTOR_3B 0x47 // Motor 3B control
#define HTIRR_MOTOR_4A 0x48 // Motor 4A control
#define HTIRR_MOTOR_4B 0x49 // Motor 4B control

task main ()
{
byte message[];
byte nByteReady = 0;
long count;
char buf[8];

TextOut(0, LCD_LINE1, "Motor 1A", false);

SetSensorLowspeed(SensorPort);
count = 1;
while (true)
{
ArrayBuild(message, HTIRR_I2C_ADDR, HTIRR_MOTOR_1A);
while (I2CStatus(SensorPort, nByteReady) == STAT_COMM_PENDING);
if(I2CBytes(SensorPort, message, count, buf))
{
TextOut(0, LCD_LINE5, "1: ");
NumOut(6*3, LCD_LINE5, buf[0]);
}
}
}
nikzagvit
Posts: 16
Joined: 31 Oct 2010, 10:33

Re: NXT IRReceiver Sensor (NIR1032)

Post by nikzagvit »

Hello everyone!
I have written small library on operation with a sensor control on i2c protocol. Has written to understand logic of operation of the protocol, the logician of operation API NXC. Many thanks Xander Soldaat.
It is useful such as I to beginners.
Attachments

[The extension rar has been deactivated and can no longer be displayed.]

mightor
Site Admin
Posts: 1079
Joined: 25 Sep 2010, 15:02
Location: Rotterdam, Netherlands
Contact:

Re: NXT IRReceiver Sensor (NIR1032)

Post by mightor »

Very tidy code. Thank you for sharing :) Do you think you could upload a .zip file instead? Not everyone can open .rar files.

Thanks!

- Xander
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
nikzagvit
Posts: 16
Joined: 31 Oct 2010, 10:33

Re: NXT IRReceiver Sensor (NIR1032)

Post by nikzagvit »

Yes I can upload a .zip file
Attachments
nxt_ir_receiver_i2c.zip
(2.87 KiB) Downloaded 329 times
mightor
Site Admin
Posts: 1079
Joined: 25 Sep 2010, 15:02
Location: Rotterdam, Netherlands
Contact:

Re: NXT IRReceiver Sensor (NIR1032)

Post by mightor »

Much obliged, sir :)

- Xander
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests