Go Down

Topic: Pins 12 used problem (Read 977 times) previous topic - next topic

Mar 08, 2014, 04:04 am Last Edit: Mar 15, 2014, 06:09 am by brianluihk2007 Reason: 1
Second problem :http://forum.arduino.cc/index.php?topic=224279.msg1634819#msg1634819


First problem (Fixed)


i am using arduino UNO,  arduino ethernet  and arduino RFID-RC522 to do a project which is send RFID code to internet through ethernet  module.
Pin 10 - 13 pins are used by ethernet  and rfid module.
Can i change module pin?
if not, what can i do?

CODE: https://docs.google.com/document/d/1ENdNz8edigtVshO4ONCVPB9jC54Q_kCtvdUsftN-1MM/edit

LarryD

Maybe one of crossroads boards will do.
http://www.crossroadsfencing.com/BobuinoRev17/
The way you have it in your schematic isn't the same as how you have it wired up!

pylon

You haven't provided a link to the RFID reader you use but probably you can change it's SS pin to any other GPIO pin. Pins 11-13 are the SPI bus pins (MISO, MOSI and SCLK) which are shared by all SPI bus devices.

#3
Mar 08, 2014, 02:25 pm Last Edit: Mar 08, 2014, 02:39 pm by brianluihk2007 Reason: 1
I see.
I am doing a project within few week and i do not have any knowledge and support on arduino.

i tried to change SS pin from 10 pin to 9 pin, but it is unsuccessful.
Code: [Select]
const int chipSelectPin = 10; => const int chipSelectPin = 9;

I don't know it is correct or not.
Could you teach me more about how to change SS pin or provide a link to RFID reader.
Thank a lot!

RFID CODE      : https://docs.google.com/document/d/1ENdNz8edigtVshO4ONCVPB9jC54Q_kCtvdUsftN-1MM/edit
Ethernet CODE   :http://arduino.cc/en/Tutorial/WebClientRepeatingT

pylon

Quote
Could you teach me more about how to change SS pin or provide a link to RFID reader.


You have to provide a link to the hardware you're using! I cannot know what hardware you bought.

The modification you made to the software should work, given you also wired the hardware correctly. Take a picture of your setup and post it.

#5
Mar 08, 2014, 03:51 pm Last Edit: Mar 08, 2014, 03:53 pm by brianluihk2007 Reason: 1
image: https://drive.google.com/folderview?id=0B-9jhrQur3BpRFFxNDl0eTQ5WTQ&usp=sharing
NSS ->10
SCK ->13
MOSI -> 11
MISO ->12
GND -> GND
RST -> 5V
VCC -> 3.3V

pylon

You have to wire the SS pin of the reader to pin 9 of the Arduino if you changed the code as you wrote.

Thank a lot.
It is work now.
I think the problem which is poor contact at most of times.

#8
Mar 13, 2014, 06:09 pm Last Edit: Mar 13, 2014, 07:35 pm by brianluihk2007 Reason: 1
Code: [Select]
#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
//IPAddress server(127.0.0.1);  // numeric IP for Google (no DNS)
char server[] = "ssciatesting.webege.com";    // name address for Google (using DNS)

// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192,168,0,104);

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;

void setup() {
// Open serial communications and wait for port to open:
 Serial.begin(9600);
  while (!Serial) {
   ; // wait for serial port to connect. Needed for Leonardo only
 }

 // start the Ethernet connection:
 if (Ethernet.begin(mac) == 0) {
   Serial.println("Failed to configure Ethernet using DHCP");
   // no point in carrying on, so do nothing forevermore:
   // try to congifure using IP address instead of DHCP:
   Ethernet.begin(mac, ip);
 }
 // give the Ethernet shield a second to initialize:
 delay(1000);
 Serial.println("connecting...");

 // if you get a connection, report back via serial:
 if (client.connect(server, 80)) {
   Serial.println("connected");
   // Make a HTTP request:
   client.println("GET /cart/registration/register.php?phoneNumber=000000 HTTP/1.1");
   client.println("Host: ssciatesting.webege.com");
   client.println("Connection: close");
   client.println();
 }
 else {
   // kf you didn't get a connection to the server:
   Serial.println("connection failed");
 }
}
                           
void loop()
{
 // if there are incoming bytes available
 // from the server, read them and print them:
 if (client.available()) {
   char c = client.read();
   Serial.print(c);
 }

 // if the server's disconnected, stop the client:
 if (!client.connected()) {
   Serial.println();
   Serial.println("disconnecting.");
   client.stop();

   // do nothing forevermore:
   while(true);
 }
}


RFID-RC522
NSS ->9
SCK ->13
MOSI -> 11
MISO ->12
GND -> GND
RST -> 5V
VCC -> 3.3V



The result will display in serial port when pin 12 removed!
if i keep the correct setting, it will stop in "Ethernet.begin(mac)".
if i delete "Ethernet.begin(mac)", it will stop in "client.connect(server, 80)".
if i remove pin 12, i cannot use RFID.
What can i do? Please give more detail, thank a lot.




pylon

Quote
What can i do? Please give more detail, thank a lot.


Detail about what? If the RFID reader is still connected you have to set it up correctly. At least you have to define pin 9 as an output and drive it high (to disable it's bus usage).

#10
Mar 15, 2014, 03:21 am Last Edit: Mar 15, 2014, 03:25 pm by brianluihk2007 Reason: 1
I feel so sorry about my poor english and presentation.
And, i thank you for your attention and teaching.

This is my situation, now.
I have changed Pin 10 to 9 successfully.
I am trying to integrate Ethernet module and RFID module.

RFID-RC522
NSS ->9
SCK ->13
MOSI -> 11
MISO ->12
GND -> GND
RST -> 5V
VCC -> 3.3V

Ethernet code(arduino.cc example): http://goo.gl/vL3PTq
RFID code: http://goo.gl/FWzwJw
Device image:http://goo.gl/HR4ddi


Here is my test case:
Case 1 : RFID code(pins 9 ) + Ethernet and RFID module                                   -> Success
Case 2 : ethernet code         + Ethernet module only                                           -> Success
Case 3 : ethernet code         + Ethernet and RFID module                                  -> Fail(Stop in "Ethernet.begin(mac)" )
Case 4 : ethernet code         + Ethernet and RFID module(remove RFID pin 12) -> Success
Case 5: RFID code (pins 9 ) + Ethernet and RFID module(remove RFID pin 12) -> Fail

In case 3 & 4, Pin 12 is blocked by RFID, but pin 12 is shared by all SPI bus devices as you say.
In this time, i want to complete Ethernet function only with rfid module.
What is the function of Pin 12 (MISO)?

Can i change pin 12 to other pin?
Or i miss some code which share pin 12 to muti-devices?

what does it mean? Does it mean :  digitalWrite(ss, LOW);  SPI.transfer(0);   SPI.transfer(value);   digitalWrite(ss, HIGH);
Quote
At least you have to define pin 9 as an output and drive it high (to disable it's bus usage).

pylon

Quote
What is the function of Pin 12 (MISO)?


That's the pin, the slave devices sends their answer back to the Arduino.

Quote
Can i change pin 12 to other pin?


No, the hardware is fixed to that pin and you don't have to.

Quote
Or i miss some code which share pin 12 to muti-devices?


You're problem is not in pin 12 but in a missing handling of the SS (Slave Select) pins.

Quote
what does it mean? Does it mean :  digitalWrite(ss, LOW);  SPI.transfer(0);   SPI.transfer(value);   digitalWrite(ss, HIGH);


Not really. I meant just the easy case where you want to deactivate a device completely, so in your situation, deactivating the RFID reader while your code is just using the Ethernet interface. To allow that you have to insert the following lines into the setup() routine:
Code: [Select]
pinMode(9, OUTPUT);
digitalWrite(9, HIGH);


Using that your posted Ethernet code will work with both devices connected.

Go Up