Pages: [1]   Go Down
Author Topic: Pins 12 used problem  (Read 721 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: March 15, 2014, 12:09:47 am by brianluihk2007 » Logged

Offline Offline
Edison Member
*
Karma: 64
Posts: 2488
The last thing you did is where you should start looking.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Maybe one of crossroads boards will do.
http://www.crossroadsfencing.com/BobuinoRev17/


* image.jpg (134.06 KB, 1094x458 - viewed 20 times.)
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5144
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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

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:
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
« Last Edit: March 08, 2014, 08:39:06 am by brianluihk2007 » Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5144
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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

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
« Last Edit: March 08, 2014, 09:53:28 am by brianluihk2007 » Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5144
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

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

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

Code:
#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.



« Last Edit: March 13, 2014, 01:35:35 pm by brianluihk2007 » Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5144
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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).
Logged

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

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).
« Last Edit: March 15, 2014, 09:25:32 am by brianluihk2007 » Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5144
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
pinMode(9, OUTPUT);
digitalWrite(9, HIGH);

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

Pages: [1]   Go Up
Jump to: