Jump to content

D69

Members
  • Content Count

    24
  • Joined

  • Last visited

Everything posted by D69

  1. I've just tested this code again and it works fine on energia 12. On 14 and 16 the char-string conversion creates something odd! If you're not getting a card, but serial is working, then it's either the reader wiring or the reader isn't seeing a compatible card. Unfortunately there's no way to see if the reader is reading. I only have this working on a G2335
  2. I'll set mine back up and have another look
  3. I hope it works for you, it's a brilliant library with loads of potential uses.
  4. Hi No, it should be in your libraries folder. Look under the libraries section here http://energia.nu/Guide_Environment.html
  5. Have you downloaded the library and extracted it to your energia folder?
  6. Looks like you've not installed the library correctly. Double check it's in the right place
  7. D69

    MSP430/TLC5940 Based LED Sequencer

    Very cool, shouldn't be a problem for you with your intended setup, good luck with it I don't read my own signature!
  8. D69

    MSP430/TLC5940 Based LED Sequencer

    For me, an Energia library :-) I don't read my own signature!
  9. D69

    MSP430/TLC5940 Based LED Sequencer

    You may need more than 3 MSPs, TLCs will daisy chain but to many in a chain and you start getting timing and brightness issues, I seem to recall 6 or 9 being a reliable number but worth a test. You will need a resistor either way, it may seem largely irrelevant but it could cause a lot of heat issues if you don't. I have a project using 3tlc and 12v led strips, I had to keep each of the strips under 100ma or the tlc got too hot. The chip is still sinking current, even if you think you're providing the leds with exactly what they need. Also remember to add some decoupling capacitors to keep your signals smooth. I've ended up going back to the duino for my tlc projects as I can't find a decent implementation for the msp yet, which is a massive shame! I don't read my own signature!
  10. Igorx, this is for the msp430 launchpad, not arduino but both dev boards will take 5v and have a 3v output you can use
  11. Hi all I'm currently working with Eelcor's excellent port of the RC522 Mifare library. All is well on the hardware side and most of the code is functioning fine, there's just one section where I'm trying to use a switch/case based on the results of an array lookup (as for loop). The switch works comparing an integer but the value I want is in a char* array which is the only way I can get the array working with the data I want. The funny thing occurs when I try to get a variable to take on the int value of the array. The number always comes out as a negative but can also change, I think based on the amount of code but I'm not sure. I'm positive I'm just being dense and it's something simple but I've gone over it several times and can't figure it out. Any help appreciated Cheers Dean /* Example file for communicating with the NFRC522. The program prints the card data. Created by Eelco Rouw - Originally adapted by Grant Gibson. */ // Pinout // SDA - 2.2 // SCK - 1.5 // Mosi - 1.7 // Miso - 1.6 // IRQ - NC // GND - GND // RST - 1.3 // VCC - VCC #include <Mfrc522.h> // the sensor communicates using SPI, so include the library: #include <SPI.h> int chipSelectPin = 10; int NRSTDP = 5; int ledpin1 = 13; int ledpin2 = 12; int ledpin3 = 11; int cardint = 5; Mfrc522 Mfrc522(chipSelectPin,NRSTDP); unsigned char serNum[5]; int secLevel; String secLevel2; unsigned char sectorKey[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; unsigned char readData[16]; void setup() { Serial.begin(9600); // RFID reader SOUT pin connected to Serial RX pin at 2400bps // Start the SPI library: SPI.begin(); // Initialize the Card Reader digitalWrite(chipSelectPin, LOW); pinMode(RED_LED, OUTPUT); pinMode(ledpin1, OUTPUT); pinMode(ledpin2, OUTPUT); pinMode(ledpin3, OUTPUT); digitalWrite(ledpin1, LOW); digitalWrite(ledpin2, LOW); digitalWrite(ledpin3, LOW); Mfrc522.Init(); } void loop() { unsigned char i,tmp; unsigned char status; unsigned char str[MAX_LEN]; unsigned char RC_size; unsigned char blockAddr; String mycardno; char* myarray[3][5]={ //Array of tags and related names, tag numbers copied from serial console after 1st run {"205928944228","1251291514471","7748944415","157172894468","611918944247"}, {"Dad","Mum","Baby","Dog","Cat"}, {"5","4","3","2","1"} }; status = Mfrc522.Request(PICC_REQIDL, str); if (status == MI_OK) { Serial.println("Card detected"); Serial.print(str[0],BIN); Serial.print(" , "); Serial.print(str[1],BIN); Serial.println(" "); } status = Mfrc522.Anticoll(str); memcpy(serNum, str, 5); if (status == MI_OK) { Serial.println("The card's number is : "); Serial.print(serNum[0], DEC); Serial.print(" , "); Serial.print(serNum[1], DEC); Serial.print(" , "); Serial.print(serNum[2], DEC); Serial.print(" , "); Serial.print(serNum[3], DEC); Serial.print(" , "); Serial.print(serNum[4], DEC); Serial.println(" "); mycardno = String(serNum[0]) += String(serNum[1]) += String(serNum[2]) += String(serNum[3]) += String(serNum[4]); // Appends the content of the serNum array to give a unique card no Serial.println(mycardno); Mfrc522.SelectTag(serNum); status = Mfrc522.Auth(PICC_AUTHENT1A,1,sectorKey,serNum); if (status == MI_OK) { Serial.println("Authenticated...\r\n"); } else { Serial.println("Error authenticating...\r\n"); } status = Mfrc522.ReadBlock(1, readData); if (status == MI_OK) { for(i=0; i<16; i++) { Serial.write(readData[i]); delay(10); } } else { Serial.println("Error reading."); } int i; for(i = 0; i < 5; i = i + 1) { if (mycardno == myarray[0][i]) { Serial.print("Hello "); Serial.println(myarray[1][i]); // Should Print out name matching tag secLevel = int(myarray[2][i]); // Tried setting this to the int of the unsigned char secLevel2 = String(myarray[2][i]); // Setting the string version, works better Serial.print("Security level: "); Serial.println(myarray[2][i]); // Returns correctly Serial.println(secLevel); // Returns random number based on current amount of code Serial.println(secLevel2); // Returns correctly } /*else { Serial.println("Bugger Off"); }*/ } { switch (secLevel) { case -9844: digitalWrite(ledpin1, HIGH); digitalWrite(ledpin2, LOW); digitalWrite(ledpin3, LOW); break; case -9842: digitalWrite(ledpin1, LOW); digitalWrite(ledpin2, HIGH); digitalWrite(ledpin3, LOW); break; case -9840: digitalWrite(ledpin1, LOW); digitalWrite(ledpin2, LOW); digitalWrite(ledpin3, HIGH); break; case -9838: digitalWrite(ledpin1, HIGH); digitalWrite(ledpin2, LOW); digitalWrite(ledpin3, HIGH); break; case -9836: digitalWrite(ledpin1, HIGH); digitalWrite(ledpin2, HIGH); digitalWrite(ledpin3, LOW); break; } } delay(1000); Mfrc522.Init(); } //Serial.println(" "); Mfrc522.Halt(); }
  12. My code is on the previous page, what doesn't run?
  13. That looks good Traxman What's the idea behind your MOSI/MISO setup, I've not seen it done like that before? The ULN with relay combo is working fine at the minute, are there any equivalents arrays with FETs? Just migrated my setup to a breadboard and it works perfectly, ready to stick it onto protoboard now.
  14. Hi RoadRunner Your answer is complete enough for me! I figured I'd come across problems trying to fudge an array of strings and chars but I'm not competent enough yet to know what else to do I double-posted for some reason and graham has suggested using another method that should hopefully improve using typedef struct instead. Thanks for the reply, any guidance is always appreciated.
  15. Hi Graham After a bit of pondering your code really makes sense, just looking at rewriting mine to incorporate it now, should save a few lines and tidy it all up a bit. I've not used typedef before but it actually seems quite logical, I'm assuming the order of variables declared should match the order they're listed in the array. Thanks very much for the assistance, this forum seems to have one of the best user bases I've seen in a while!
  16. Hi Graham Is that because I used char*? I'm not sure why the array would only work as char*, maybe because of the mixed type of values?
  17. Atoi worked a treat, thanks ever so much for the reply
  18. Sounds similar to what I'm working on, adding a uln2003 to help with the mixed power of the leds and relays. Serial eeprom sounds like a good idea too, I was going to try with an SD card but it would be overkill!
  19. Hi all I'm currently working with Eelcor's excellent port of the RC522 Mifare library. All is well on the hardware side and most of the code is functioning fine, there's just one section where I'm trying to use a switch/case based on the results of an array lookup (as for loop). The switch works comparing an integer but the value I want is in a char* array which is the only way I can get the array working with the data I want. The funny thing occurs when I try to get a variable to take on the int value of the array. The number always comes out as a negative but can also change, I think based on the amount of code but I'm not sure. I'm positive I'd just being dense and it's something simple but I've gone over it several times and can't figure it out. Any help appreciated Cheers Dean /* Example file for communicating with the NFRC522. The program prints the card data. Created by Eelco Rouw - Originally adapted by Grant Gibson. */ // Pinout // SDA - 2.2 // SCK - 1.5 // Mosi - 1.7 // Miso - 1.6 // IRQ - NC // GND - GND // RST - 1.3 // VCC - VCC #include <Mfrc522.h> // the sensor communicates using SPI, so include the library: #include <SPI.h> int chipSelectPin = 10; int NRSTDP = 5; int ledpin1 = 13; int ledpin2 = 12; int ledpin3 = 11; int cardint = 5; Mfrc522 Mfrc522(chipSelectPin,NRSTDP); unsigned char serNum[5]; int secLevel; String secLevel2; unsigned char sectorKey[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; unsigned char readData[16]; void setup() { Serial.begin(9600); // RFID reader SOUT pin connected to Serial RX pin at 2400bps // Start the SPI library: SPI.begin(); // Initialize the Card Reader digitalWrite(chipSelectPin, LOW); pinMode(RED_LED, OUTPUT); pinMode(ledpin1, OUTPUT); pinMode(ledpin2, OUTPUT); pinMode(ledpin3, OUTPUT); digitalWrite(ledpin1, LOW); digitalWrite(ledpin2, LOW); digitalWrite(ledpin3, LOW); Mfrc522.Init(); } void loop() { unsigned char i,tmp; unsigned char status; unsigned char str[MAX_LEN]; unsigned char RC_size; unsigned char blockAddr; String mycardno; char* myarray[3][5]={ //Array of tags and related names, tag numbers copied from serial console after 1st run {"205928944228","1251291514471","7748944415","157172894468","611918944247"}, {"Dad","Mum","Baby","Dog","Cat"}, {"5","4","3","2","1"} }; status = Mfrc522.Request(PICC_REQIDL, str); if (status == MI_OK) { Serial.println("Card detected"); Serial.print(str[0],BIN); Serial.print(" , "); Serial.print(str[1],BIN); Serial.println(" "); } status = Mfrc522.Anticoll(str); memcpy(serNum, str, 5); if (status == MI_OK) { Serial.println("The card's number is : "); Serial.print(serNum[0], DEC); Serial.print(" , "); Serial.print(serNum[1], DEC); Serial.print(" , "); Serial.print(serNum[2], DEC); Serial.print(" , "); Serial.print(serNum[3], DEC); Serial.print(" , "); Serial.print(serNum[4], DEC); Serial.println(" "); mycardno = String(serNum[0]) += String(serNum[1]) += String(serNum[2]) += String(serNum[3]) += String(serNum[4]); // Appends the content of the serNum array to give a unique card no Serial.println(mycardno); Mfrc522.SelectTag(serNum); status = Mfrc522.Auth(PICC_AUTHENT1A,1,sectorKey,serNum); if (status == MI_OK) { Serial.println("Authenticated...\r\n"); } else { Serial.println("Error authenticating...\r\n"); } status = Mfrc522.ReadBlock(1, readData); if (status == MI_OK) { for(i=0; i<16; i++) { Serial.write(readData[i]); delay(10); } } else { Serial.println("Error reading."); } int i; for(i = 0; i < 5; i = i + 1) { if (mycardno == myarray[0][i]) { Serial.print("Hello "); Serial.println(myarray[1][i]); // Should Print out name matching tag secLevel = int(myarray[2][i]); // Tried setting this to the int of the unsigned char secLevel2 = String(myarray[2][i]); // Setting the string version, works better Serial.print("Security level: "); Serial.println(myarray[2][i]); // Returns correctly Serial.println(secLevel); // Returns random number based on current amount of code Serial.println(secLevel2); // Returns correctly } /*else { Serial.println("Bugger Off"); }*/ } { switch (secLevel) { case -9844: digitalWrite(ledpin1, HIGH); digitalWrite(ledpin2, LOW); digitalWrite(ledpin3, LOW); break; case -9842: digitalWrite(ledpin1, LOW); digitalWrite(ledpin2, HIGH); digitalWrite(ledpin3, LOW); break; case -9840: digitalWrite(ledpin1, LOW); digitalWrite(ledpin2, LOW); digitalWrite(ledpin3, HIGH); break; case -9838: digitalWrite(ledpin1, HIGH); digitalWrite(ledpin2, LOW); digitalWrite(ledpin3, HIGH); break; case -9836: digitalWrite(ledpin1, HIGH); digitalWrite(ledpin2, HIGH); digitalWrite(ledpin3, LOW); break; } } delay(1000); Mfrc522.Init(); } //Serial.println(" "); Mfrc522.Halt(); }
  20. OK, spent a bit of time on this this evening. Tried knocking together some code to allow hard coding of tag IDs which works OK. Might need to change the for loop though as anything in else just gets repeated, a switch might do the trick but it's late. For anyone interested, here's my code, would appreciate any improvements that could be made, including an scenario where the tag's not recognized as valid. /* Example file for communicating with the NFRC522. The program prints the card data. Created by Eelco Rouw - Originally adapted by Grant Gibson. */ // Pinout // SDA - 2.2 // SCK - 1.5 // Mosi - 1.7 // Miso - 1.6 // IRQ - NC // GND - GND // RST - 1.3 // VCC - VCC #include <Mfrc522.h> // the sensor communicates using SPI, so include the library: #include <SPI.h> int chipSelectPin = 10; int NRSTDP = 5; int ledpin1 = 3; int ledpin2 = 6; int cardint = 5; Mfrc522 Mfrc522(chipSelectPin,NRSTDP); unsigned char serNum[5]; unsigned char sectorKey[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; unsigned char readData[16]; void setup() { Serial.begin(9600); // RFID reader SOUT pin connected to Serial RX pin at 2400bps // Start the SPI library: SPI.begin(); // Initialize the Card Reader digitalWrite(chipSelectPin, LOW); pinMode(RED_LED, OUTPUT); pinMode(ledpin1, OUTPUT); pinMode(ledpin2, OUTPUT); Mfrc522.Init(); } void loop() { unsigned char i,tmp; unsigned char status; unsigned char str[MAX_LEN]; unsigned char RC_size; unsigned char blockAddr; //String mynum = ""; String mycardno; char* myarray[2][5]={ //Array of tags and related names, tag numbers copied from serial console after 1s {"205928944228","1251291514471","7748944415","157172894468","611918944247"}, {"Dad","Mum","Baby","Dog","Cat"} }; status = Mfrc522.Request(PICC_REQIDL, str); if (status == MI_OK) { Serial.println("Card detected"); Serial.print(str[0],BIN); Serial.print(" , "); Serial.print(str[1],BIN); Serial.println(" "); } status = Mfrc522.Anticoll(str); memcpy(serNum, str, 5); if (status == MI_OK) { Serial.println("The card's number is : "); Serial.print(serNum[0], DEC); Serial.print(" , "); Serial.print(serNum[1], DEC); Serial.print(" , "); Serial.print(serNum[2], DEC); Serial.print(" , "); Serial.print(serNum[3], DEC); Serial.print(" , "); Serial.print(serNum[4], DEC); Serial.println(" "); mycardno = String(serNum[0]) += String(serNum[1]) += String(serNum[2]) += String(serNum[3]) += String(serNum[4]); // Appends the content of the serNum array to give a unique card no Serial.println(mycardno); Mfrc522.SelectTag(serNum); status = Mfrc522.Auth(PICC_AUTHENT1A,1,sectorKey,serNum); if (status == MI_OK) { Serial.println("Authenticated...\r\n"); } else { Serial.println("Error authenticating...\r\n"); } status = Mfrc522.ReadBlock(1, readData); if (status == MI_OK) { for(i=0; i<16; i++) { Serial.write(readData[i]); delay(10); } } else { Serial.println("Error reading."); } int i; for(i = 0; i < 5; i = i + 1) { if (mycardno == myarray[0][i]) { Serial.print("Hello "); Serial.println(myarray[1][i]); // Should Print out name matching tag } /*else { Serial.println("Bugger Off"); }*/ } delay(1000); Mfrc522.Init(); } //Serial.println(" "); Mfrc522.Halt(); }
  21. Just a quick note, Pin1 - SS (SDA on mine) goes to 2.2 and Pin7 - RST goes to 1.3 Looking at your pic it's setup the same as mine. I figured it out from the code before I checked the pic of your setup :shock: Cheers Dean
  22. Yes! That sorted it (well that and me stopping being a window-licker and changing the TX/RX jumpers, but did that 1st and got corrupted output) thanks ever so much. Now I just need to get it to recognise my phone Fantastic work! Cheers Dean
  23. Pic of my setup if it helps. Cheers http://db.tt/DPKIrBAA http://db.tt/Ciz7L2iS
  24. Hi Eelcor Not working for me. The sketch (Block1) compiles and uploads but it's not reading cards. I've tested the reader on an Uno and it works fine using Grant's sketch. I'm not getting anything at all in the serial display. I've setup the Launchpad (G2553) and Duino as below: RC522 MSP430 Arduino Colour SAD 1.3 10 Purple SCK 1.5 13 Blue MOSI 1.7 11 Green MISO 1.6 12 Yellow IRQ NA NA GND GND GND Orange RST 2.2 5 Red 3.3V VCC 3.3V Brown Do I need To make any changes to the launchpad? Any help appreciated
×