NXT IRReceiver Sensor (NIR1032)
NXT IRReceiver Sensor (NIR1032)
What I2C address at a sensor NXT IRReceiver Sensor (NIR1032)?
Re: NXT IRReceiver Sensor (NIR1032)
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
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)
| 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)
Re: NXT IRReceiver Sensor (NIR1032)
Thanks has found. I apologize for a carelessness.
Re: NXT IRReceiver Sensor (NIR1032)
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?
#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?
Re: NXT IRReceiver Sensor (NIR1032)
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]);
}
}
}
#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]);
}
}
}
Re: NXT IRReceiver Sensor (NIR1032)
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.
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.]
Re: NXT IRReceiver Sensor (NIR1032)
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
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)
| 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)
Re: NXT IRReceiver Sensor (NIR1032)
Yes I can upload a .zip file
- Attachments
-
- nxt_ir_receiver_i2c.zip
- (2.87 KiB) Downloaded 329 times
Re: NXT IRReceiver Sensor (NIR1032)
Much obliged, sir
- Xander
- 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)
| 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)
Who is online
Users browsing this forum: No registered users and 3 guests