NXC: RFID-Sensor values?
NXC: RFID-Sensor values?
I'm looking for the command to read RFID-Sensor values (Codatex). If I enter "RFID" and press F1 I can't find any help topic.
Can someone help please?
Can someone help please?
Re: NXC: RFID-Sensor values?
Google search + "rfid sensor nxc" = http://www.codatex.com/index.php?en_NXC (top link)
A word to the wise, this sensor is very, very bitchy to work with. Sometimes it will return bogus values, sometimes nothing at all.
Regards,
Xander
A word to the wise, this sensor is very, very bitchy to work with. Sometimes it will return bogus values, sometimes nothing at all.
Regards,
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)
-
- Posts: 323
- Joined: 29 Sep 2010, 05:03
Re: NXC: RFID-Sensor values?
Another word to the wise... Be very careful with using the low level i2c interface with this sensor. It is very easy to corrupt the firmware on the device (I managed to do this to two sensors while getting the sensor working with leJOS), you can get hold of a firmware update program, but it's best not to have to!
Andy
Andy
Re: NXC: RFID-Sensor values?
thx to both of you for the help!
Re: NXC: RFID-Sensor values?
The latest BricxCC test release includes Codatex RFID API functions in NXCDefs.h which are documented in the NXC help files. I still need to add a sample program for them. Here's the sample code that the API functions were based on:
John Hansen
Code: Select all
/*
char RFIDInit(const byte port)
{
byte buf[] = {0x04, 0x32};
I2CWrite(port, 0, buf);
char status = I2CCheckStatus(port);
while (status > 0)
status = I2CCheckStatus(port);
return status;
}
char RFIDMode(const byte port, const byte mode)
{
return I2CSendCommand(port, CT_ADDR_RFID, mode);
}
byte RFIDStatus(const byte port)
{
byte result;
ReadI2CRegister(port, CT_ADDR_RFID, CT_REG_STATUS, result);
return result;
}
bool RFIDRead(const byte port, byte & output[])
{
byte inbuf[] = {CT_ADDR_RFID, CT_REG_DATA};
byte count = 5;
return I2CBytes(port, inbuf, count, output);
}
void RFIDStop(const byte port)
{
RFIDInit(port);
Wait(10);
RFIDMode(port, RFID_MODE_STOP);
}
bool RFIDReadSingle(const byte port, byte & output[])
{
RFIDInit(port);
Wait(15);
RFIDMode(port, RFID_MODE_SINGLE);
Wait(250);
return RFIDRead(port, output);
}
bool RFIDReadContinuous(const byte port, byte & output[])
{
RFIDInit(port);
Wait(15);
if (RFIDStatus(port) != 1) {
RFIDMode(port, RFID_MODE_CONTINUOUS);
Wait(250);
}
return RFIDRead(port, output);
}
*/
task main()
{
SetSensorLowspeed(S1);
while (true) {
byte data[];
if (RFIDReadContinuous(S1, data)) {
for(int i = 0; i < 5; i++) {
byte x = data[i];
NumOut(0, LCD_LINE1-(i*8), x);
}
}
else
TextOut(0, LCD_LINE1, "RFID Read Failed", true);
Wait(500);
}
}
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
http://bricxcc.sourceforge.net/
Re: NXC: RFID-Sensor values?
While I noticed the bitchyness of the CODATEX RFID sensor at first, it's now working stable with our MATLAB Toolbox AFAIK (and I think we've got 10 or 20 sensors of them, something in that magnitude).
This Tutorial by Ralph Hempel helped me a lot: http://www.hempeldesigngroup.com/lego/p ... fidsensor/ , together with the NXC code.
I ended up doing my own test. I think I've seen once that the returned ID was simply WRONG. But I could never ever reproduce this invalid ID, since then I either get no reading (ID tag too far away) or the correct ID. Are you SURE it's a hardware problem, Xander?
Anyway, the code I ended up with is this:
http://www.mindstorms.rwth-aachen.de/tr ... OpenRFID.m
http://www.mindstorms.rwth-aachen.de/tr ... /GetRFID.m
I know most of you do MATLAB, but all you need to know is that % is the comment sign. I tried to document what I did, maybe it's helpful for somebody...
This Tutorial by Ralph Hempel helped me a lot: http://www.hempeldesigngroup.com/lego/p ... fidsensor/ , together with the NXC code.
I ended up doing my own test. I think I've seen once that the returned ID was simply WRONG. But I could never ever reproduce this invalid ID, since then I either get no reading (ID tag too far away) or the correct ID. Are you SURE it's a hardware problem, Xander?
Anyway, the code I ended up with is this:
http://www.mindstorms.rwth-aachen.de/tr ... OpenRFID.m
http://www.mindstorms.rwth-aachen.de/tr ... /GetRFID.m
I know most of you do MATLAB, but all you need to know is that % is the comment sign. I tried to document what I did, maybe it's helpful for somebody...
RWTH - Mindstorms NXT Toolbox for MATLAB
state of the art in nxt remote control programming
http://www.mindstorms.rwth-aachen.de
MotorControl now also in Python, .net, and Mathematica
state of the art in nxt remote control programming
http://www.mindstorms.rwth-aachen.de
MotorControl now also in Python, .net, and Mathematica
Re: NXC: RFID-Sensor values?
I am pretty sure it was a hardware problem. I have a protocol analyser that tells me what is coming down the line It was a sporadic thing. The driver I've made is pretty stable. I haven't used this sensor since I'm done with the driver, though.
- 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)
-
- Posts: 346
- Joined: 27 Sep 2010, 03:05
- Contact:
Re: NXC: RFID-Sensor values?
My PSumo robots use RFID cards, so I've seen hundreds of cards scanned by kids.
http://www.teamhassenplug.org/sumo/PSumo.html
There are a few different types of id's I've seen.
1) all zeros
2) all 8s
3) valid ID
It's set-up so if the ID is not recognized, the card can simply be scanned again.
Steve
http://www.teamhassenplug.org/sumo/PSumo.html
There are a few different types of id's I've seen.
1) all zeros
2) all 8s
3) valid ID
It's set-up so if the ID is not recognized, the card can simply be scanned again.
Steve
---> Link to lots of MINDSTORMS stuff under my picture --->
Re: NXC: RFID-Sensor values?
I use RFID cards in my ATM machine programmed in NXC. I had significant problems when the brick is first powered up and the program runs the first time. It always takes several read attempts (usually between 4 and 7) before any card will return valid data. After it works it continues to work for the rest of time until the brick is power cycled. I messed with the program for a long time but nothing I did changed the symptoms. If the program is stopped and restarted without cycling power on the brick then the first card will always be read correctly.
Ron.
Ron.
Who is online
Users browsing this forum: No registered users and 0 guests