Pages: 1 [2]   Go Down
Author Topic: WIEGAND 26bits format to Arduino UNO. Requesting guidances.  (Read 4454 times)
0 Members and 1 Guest are viewing this topic.
Manchester (England England)
Online Online
Brattain Member
*****
Karma: 603
Posts: 33396
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok there are some serious missunderstanding going on here.
What on earth are you trying to do, not only with that code but the whole project?
That code just writes the same thing to 15 differant memory locations and the thing it is writing is just the top four bits of an ID code why? Assuming the ID codes are sequential that will only change every 16000 users.
With RFID you normally use the whole of the number to identify some token, not a part of it. You normally have no idea what the token numbers are before you get them. If you have a fixed number of tokens you can put the numbers directly into and array to compair them there is no need for EEPROM storage. You only need to store the codes if you have a dynamic process where you enroll an unknown token in a list of valid tokens. That is a seprate process from the job of reading stored tokens and see if it matches something you have had before.
Also you don't seem to know what a function is and how you call it. So let's start from the beginning by saying what you want to do before you get tangled up with how to do it.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I do have some serious issues which I acknowledge since I just started learning C++

Function is something that I will call when needed and they will only run once, except for loop.

The main idea of my budget project is to get any users up to 15 people to use one of the 2 lockers by means of RFID programming. (I am using fingerprint device in WIEGAND 26bits format)

When locker 1 or 2 is assigned to a user out of 15 people, only that user will open or lock the locker 1 or 2 when he signs in until he sign out, which allows other users to be able to use.

To do that, I need the userID set as token for people who has registered. And whenever their token is used(sign in), it will do the above operation.
Here's my completed locker sketch which I need to use it to connect to EEPROM, ARDUINO and WIEGAND which I haven't start yet.

Code:
#include <stdio.h>
char lockerselect;
int locker1 = 10;
int locker2 = 11;
int i=0;


// the setup routine runs once when you press reset:
void setup() {               
  // initialize the digital pin as an output.
  pinMode(10, OUTPUT);     
  pinMode(11, OUTPUT);     

Serial.begin(9600);
  Serial.println("select your locker"); // prompt user to select locker via serial monitor
}

void serialEvent() {
    if (Serial.available() > 0) {
  lockerselect = Serial.read();
  i = 1;
  }
}

// the loop routine runs over and over again forever:
void loop() {
  if(i) {
  if (lockerselect == '1') {
    Serial.println("Locker 1 has been unlocked.");
    digitalWrite(10, HIGH);   // turn the LED on (HIGH is the voltage level)
    delay(5000);               // wait for a second
    digitalWrite(10, LOW);    // turn the LED off by making the voltage LOW
    delay(5000);               // wait for a second
    Serial.println("OFF 1");
    lockerselect=0; // it will be off forever until locker selection prompt appears.
  }
  if (lockerselect == '2')  {
    Serial.println("Locker 2  has been unlocked.");
    digitalWrite(11, HIGH);   // turn the LED on (HIGH is the voltage level)
    delay(5000);               // wait for a second
    digitalWrite(11, LOW);    // turn the LED off by making the voltage LOW
    delay(5000);               // wait for a second
    Serial.println("OFF 2");
    lockerselect=0; // it will be off forever until locker selection prompt appears.
  }
  i = 0;
  Serial.println("select your locker"); // go back to start of selection
  }
}
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 603
Posts: 33396
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
(I am using fingerprint device in WIEGAND 26bits format)
OK a fingerprint takes about 4K of data, where is this being stored? What number are you getting from the reader, that is have you assigned it during some fingerprint enrolling process?

Quote
The main idea of my budget project is to get any users up to 15 people to use one of the 2 lockers by means of RFID programming. (I am using fingerprint device in WIEGAND 26bits format)
You have not considered the enrolling process, how are the 26 bit numbers going to be associated with the user. This is a different phase to the operation process of placing your fingerprint on a reader and the appropriate locker opens.
This is what I mean by you have not thought through exactly how you want it to operate. If your user ID is just a number from 1 to 15 then there is no need to store that in EEPROM at all. What you might want to store is the relationship between the user ID and the locker they have been allocated. If this could be any locker you need to include this in the enrolling process.
So before you even think how you are going to implement it you have to know EXACTLY what you want your code to do and how the user and supervisor will interact with it.
This is not a beginners project because there is a lot of other stuff apart from reading a token and doing something with the results. Until you figure out exactly what you want to do forget about any coding. You might think you know what you want it to do but you have not expressed that in enough detail to even begin to write a single line of code.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
OK a fingerprint takes about 4K of data, where is this being stored? What number are you getting from the reader, that is have you assigned it during some fingerprint enrolling process?
The reader shows facility code 111 in DEC and user id 0 to 15 in DEC when I setup facility code 111 in DEC using the fingerprint device and add users up to 15 in DEC.
Quote
You have not considered the enrolling process, how are the 26 bit numbers going to be associated with the user. This is a different phase to the operation process of placing your fingerprint on a reader and the appropriate locker opens.
This is what I mean by you have not thought through exactly how you want it to operate. If your user ID is just a number from 1 to 15 then there is no need to store that in EEPROM at all. What you might want to store is the relationship between the user ID and the locker they have been allocated. If this could be any locker you need to include this in the enrolling process.
So before you even think how you are going to implement it you have to know EXACTLY what you want your code to do and how the user and supervisor will interact with it.
This is not a beginners project because there is a lot of other stuff apart from reading a token and doing something with the results. Until you figure out exactly what you want to do forget about any coding. You might think you know what you want it to do but you have not expressed that in enough detail to even begin to write a single line of code.
Your explanation has struck me with an alternative beginner friendly idea. I can use the if-elseif statement for 2 users 2 lockers since I am unable to do 15 users 2 lockers as it's too much for me to absorb given my limited knowledge of C++ right now.
Since I had your help in WIEGAND to ARDUINO sketch, there's nothing else I can dare to ask for help from you. You have helped me for 3 weeks now. It's really admirable to have met nice people like you in the Internet. Really, I thank you very much for your teaching and sharing knowledge even though my project is limited to budgets where I can't just buy converter or stuffs. The next time I learn more about C++, I will eventually have to learn flash memory or RAM as well as EEPROM / AVR. Greatly appreciated for your tolerance towards new learners.

Successfully made 2 users 2 lockers sketch project. The only problem is that I am unable to tell the people who are not user1 or user2 when they scan their fingerprints (unknown users who have not registered) in serial monitor. I guess this is not much of an issue since fingerprint device can tell the people.

Overall, the software for my project is done, with the codes that you created for everyone to use. Credits are yours. I will show it in my powerpoint presentations! Thank you
« Last Edit: June 05, 2013, 10:13:59 pm by zawman » Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 603
Posts: 33396
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The only problem is that I am unable to tell the people who are not user1 or user2 when they scan their fingerprints (unknown users who have not registered)
Is this because the fingerprint reader sends no Weagand code when nothing is recognised? Some readers can be configured to send a code for none recognised fingers, but that depends on the mode it is running in.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yeah. I found out via using oscilloscope that unknown ids do not send out signals from wiegand device.

The reader on admin mode and operation mode do not send out signals for unknown users.

I guess unknown id users can find out by reading at the fingerprint display device if it shows an error beepx4 with red LED.
At another scenario, users who registered before with the help of an admin(me), can look at another display representing the serial monitor to tell them the location of the lockers.

Quite suitable for gyms, swimming pools and some entertainment centres like bowling and billiards, where customers with memberships are entitled to use the lockers.

Now, that my budget project is a few steps more to go to completion, Mr. Mike Cook, I greatly appreciate your help, teaching and sharing your knowledge, especially the trick of removing odd and even parity by using bits mask. There are so many more people who have supported me along the way, be it in Internet or reality, but I think I’ve taken up enough of your time. I wish you success in everything you do. Thank you so much. Thank you for pushing(not the forced one, I mean) me to love C++ more than ever.

Hope to see you somewhere in the world, given an opportunity arises!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello Mr. Mike Cook. It had been a while.

Well, it's like this, my serial monitor has been sending correct information until recently that it shows me random values from facility codes and USERID codes. I found out the wiegand signals are set at HIGH at first pulse.

Below is the Serial Monitor Communication.
Code:
Facility Code 1
User ID 2
Locker 2 has been unlocked. Please proceed to the location of Locker 2.
Locker 2 has activated the lock system. Please close the locker door when you are done.
Facility Code 128
User ID -32768
Facility Code 1
User ID 1
Locker 1 has been unlocked. Please proceed to the location of Locker 1.
Locker 1 has activated the lock system. Please close the locker door when you are done.
Facility Code 64
User ID 16384
Facility Code 1
User ID 3
Locker 3 has been unlocked. Please proceed to the location of Locker 3.
Locker 3 has activated the lock system. Please close the locker door when you are done.

Each time, a scan is successful and shows a correct facility code and user ID, the println will show.
After that, another scan is performed and it will show me random values instead of USERID 1, 2 or 3. (there are only 3 users anyways)

How do I solve this?
You can check my code in your message folder. The sketch exceeded 9.5k of a post so.. I have to remove the loop since it's pretty understandable.
« Last Edit: July 30, 2013, 02:12:47 am by zawman » Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 603
Posts: 33396
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The sketch exceeded 9.5k of a post so
In which case you should include it as an attachment, use the Additional Options triangle at the bottom left corner of the reply box.

Quote
After that, another scan is performed and it will show me random values
This sounds like you are not getting exactly 26 bits from your reader but perhaps a few more. I bet they are not random. Write down the number of the correct scan and incorrect scan in binary. Then try and see where they are the same and where they differ and try and see exactly how many pulses you are getting from the reader. Then use that value in your code.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Mr Mike Cook, I have attached my sketch with all codes set to BIN and I disable loop function since I do not want to damage my relay circuit.

My serial Monitor shows every value in BIN format.

Code:
rawToken BIN10000000000000001
rawToken DEC65537
Facility Code BIN1
Facility Code DEC1
User ID BIN1
User ID DEC1
Locker 1 has been unlocked. Please proceed to the location of Locker 1.
Locker 1 has activated the lock system. Please close the locker door when you are done.

rawToken BIN10000000000000010
rawToken DEC65538
Facility Code BIN1
Facility Code DEC1
User ID BIN10
User ID DEC2
Locker 2 has been unlocked. Please proceed to the location of Locker 2.
Locker 2 has activated the lock system. Please close the locker door when you are done.

rawToken BIN11000000010000000000000
rawToken DEC6299648
Facility Code BIN1100000
Facility Code DEC96
User ID BIN10000000000000
User ID DEC8192

rawToken BIN10000000000000011
rawToken DEC65539
Facility Code BIN1
Facility Code DEC1
User ID BIN11
User ID DEC3
Locker 3 has been unlocked. Please proceed to the location of Locker 3.
Locker 3 has activated the lock system. Please close the locker door when you are done.

According to the bugged value:
rawToken BIN11000000010000000000000
rawToken DEC6299648
Facility Code BIN1100000
Facility Code DEC96
User ID BIN10000000000000
User ID DEC8192

The rawtoken is consists of only 23 bits instead of 24. Why??

* WIEGAND_ARDUINO_LOCKER_testing_bug.ino (10.17 KB - downloaded 7 times.)
« Last Edit: August 02, 2013, 01:52:29 am by zawman » Logged

Pages: 1 [2]   Go Up
Jump to: