This past week, not much progress has been made in the project. All subteams were busy with working on the first paper of the semester and also preparing for the presentation that we will have on October 5, 2016. I worked on my paper all week long and did not have any time to make any
progress in the project. All subteams met up to discuss progress and any changes made in the design stage and not much has changed. We have all decided to keep consistent with one system of units and use the English system for all design work.
As far as recreating the work that the summer team did with Processing, I was only able to understand the general idea of how Processing was used to control the vehicles by specifying the vehicle number, the speed of the vehicle, and manually switching its bogie mechanism. I had trouble trying to download the Java files and files that pertained to the Processing software. I might have to consult with one of my mentors or someone who was in the summer team to help me recreate the controls in Processing.
Aside from Processing, I was able to find time during the week to get two sensors to work. We are testing the reliability of the RFID sensor for the application of switching tracks and we are also looking at how the ultrasonic sensor works for the application of forward collision. I was only able to look at the examples that were provided from users online who have used these sensors before. I only understood the general idea of how each sensor works. I will be working closely with my team this coming week to understand how the code works and how we can build off from the code to implement it into our code to control the bogie. There is code attached to this blog post that is for each sensor. One code basically gives the ID of the keychain sensor and the card sensor. The other code calculates the distance and determines if the proximity of an object is too close to the sensor and if it is, an LED will light up.
/*
HC-SR04 Ping distance sensor:
VCC to arduino 5v
GND to arduino GND
Echo to Arduino pin 7
Trig to Arduino pin 8
This sketch originates from Virtualmix: http://goo.gl/kJ8Gl
Has been modified by Winkle ink here: http://winkleink.blogspot.com.au/2012/05/arduino-hc-sr04-ultrasonic-distance.html
And modified further by ScottC here: http://arduinobasics.blogspot.com.au/2012/11/arduinobasics-hc-sr04-ultrasonic-sensor.html
on 10 Nov 2012.
*/
#define echoPin 7 // Echo Pin
#define trigPin 8 // Trigger Pin
#define LEDPin 13 // Onboard LED
int maximumRange = 200; // Maximum range needed
int minimumRange = 0; // Minimum range needed
long duration, distance; // Duration used to calculate distance
void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(LEDPin, OUTPUT); // Use LED indicator (if required)
}
void loop() {
/* The following trigPin/echoPin cycle is used to determine the
distance of the nearest object by bouncing soundwaves off of it. */
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
//Calculate the distance (in cm) based on the speed of sound.
distance = duration/58.2;
if (distance >= maximumRange || distance <= minimumRange){
/* Send a negative number to computer and Turn LED ON
to indicate "out of range" */
Serial.println("-1");
digitalWrite(LEDPin, HIGH);
}
else {
/* Send the distance to the computer using Serial protocol, and
turn LED OFF to indicate successful reading. */
Serial.println(distance);
digitalWrite(LEDPin, LOW);
}
//Delay 50ms before next reading.
delay(50);
}
***************************************************************************************
// Example sketch to read the ID from an Addicore 13.56MHz RFID tag
// as found in the RFID AddiKit found at:
// http://www.addicore.com/RFID-AddiKit-with-RC522-MIFARE-Module-RFID-Cards-p/126.htm
#include <AddicoreRFID.h>
#include <SPI.h>
#define uchar unsigned char
#define uint unsigned int
uchar fifobytes;
uchar fifoValue;
AddicoreRFID myRFID; // create AddicoreRFID object to control the RFID module
/////////////////////////////////////////////////////////////////////
//set the pins
/////////////////////////////////////////////////////////////////////
const int chipSelectPin = 10;
const int NRSTPD = 5;
//Maximum length of the array
#define MAX_LEN 16
void setup() {
Serial.begin(9600); // RFID reader SOUT pin connected to Serial RX pin at 9600bps
// start the SPI library:
SPI.begin();
pinMode(chipSelectPin,OUTPUT); // Set digital pin 10 as OUTPUT to connect it to the RFID /ENABLE pin
digitalWrite(chipSelectPin, LOW); // Activate the RFID reader
pinMode(NRSTPD,OUTPUT); // Set digital pin 10 , Not Reset and Power-down
digitalWrite(NRSTPD, HIGH);
myRFID.AddicoreRFID_Init();
}
void loop()
{
uchar i, tmp, checksum1;
uchar status;
uchar str[MAX_LEN];
uchar RC_size;
uchar blockAddr; //Selection operation block address 0 to 63
String mynum = "";
str[1] = 0x4400;
//Find tags, return tag type
status = myRFID.AddicoreRFID_Request(PICC_REQIDL, str);
if (status == MI_OK)
{
Serial.println("RFID tag detected");
Serial.print("Tag Type:\t\t");
uint tagType = str[0] << 8;
tagType = tagType + str[1];
switch (tagType) {
case 0x4400:
Serial.println("Mifare UltraLight");
break;
case 0x400:
Serial.println("Mifare One (S50)");
break;
case 0x200:
Serial.println("Mifare One (S70)");
break;
case 0x800:
Serial.println("Mifare Pro (X)");
break;
case 0x4403:
Serial.println("Mifare DESFire");
break;
default:
Serial.println("Unknown");
break;
}
}
//Anti-collision, return tag serial number 4 bytes
status = myRFID.AddicoreRFID_Anticoll(str);
if (status == MI_OK)
{
checksum1 = str[0] ^ str[1] ^ str[2] ^ str[3];
Serial.print("The tag's number is:\t");
Serial.print(str[0]);
Serial.print(" , ");
Serial.print(str[1]);
Serial.print(" , ");
Serial.print(str[2]);
Serial.print(" , ");
Serial.println(str[3]);
Serial.print("Read Checksum:\t\t");
Serial.println(str[4]);
Serial.print("Calculated Checksum:\t");
Serial.println(checksum1);
// Should really check all pairs, but for now we'll just use the first
if(str[0] == 197) //You can change this to the first byte of your tag by finding the card's ID through the Serial Monitor
{
Serial.println("\nHello Craig!\n");
} else if(str[0] == 244) { //You can change this to the first byte of your tag by finding the card's ID through the Serial Monitor
Serial.println("\nHello Erin!\n");
}
Serial.println();
delay(1000);
}
myRFID.AddicoreRFID_Halt(); //Command tag into hibernation
}
No comments:
Post a Comment