|
Post by Vinicius on Jul 22, 2014 23:36:20 GMT -8
Hello, i've searched on the forum, but i couldn't find anything that helped me. I have an Arduino Ethernet and a Gameduino, stacking the GD on top of the Arduino doesn't let me even display the hello world sketch, what i have to do to make it work? However i can connect to the internet. Do i have to specify CS pins? I'm a newbie >_> Any help is appreciated, thank you.
|
|
peterm
Junior Member

Posts: 17
|
Post by peterm on Jul 24, 2014 23:45:11 GMT -8
Note this is for the EtherMega board from Freetronics EtherMega to Gameduino2 ----------------- ------------ SCK PB.1 Pin# 52 D13 - SCK MOSI PB.2 Pin# 51 D11 - MOSI MISO PB.3 Pin# 50 D12 - MISO CS PB.0 Pin# 53 D8 - GPU sel Look for a Gameduino2 file (In the Library) called 'Wiring.h' up the top of the file look for '#define CS 10' and change the '10' to '53' For the SD card usage choose some unused pin on the Arduino Ethernet to connect to the Gameduino2 'SD sel' (sdcard chip select) not far from the changes you just made you need to look for pinMode(9, OUTPUT); digitalWrite(9, HIGH); change the '9' to the Arduino Ethernet pin you are goiung to use. don't forget to connect the +5 and GND pins see here for the Gameduino2 pcb drawing under 'Hardware'. excamera.com/sphinx/gameduino2/
|
|
|
Post by Vinicius on Jul 25, 2014 0:39:16 GMT -8
Thank you for your reply  i didn't understand what you meant about that 34 pin °_° (by the way pins are wrong, which is not a problem, don't worry) You want me to change the 8 ( which is Gameduino CS ) and 9 pin (which is Gameduino SD card CS) because they might be already used by the Ethernet? I can initialize the ethernet and receive a correct IP (which i can ping) before the GD.Begin in the setup(), while in the loop() (after the GD.begin) i can't do anything. i even tried to set 8 pin to high when i want to do some ethernet stuff.
|
|
peterm
Junior Member

Posts: 17
|
Post by peterm on Jul 25, 2014 2:56:00 GMT -8
Vinicius
Sorry!, my mistake, just looked on the Internet and found the board (also I did not realise I already had one)
Ignore my header explanation.
I just tried fitting the Gameduino2 on the Ehernet Sheild and I can see what you are talking about sitting on the RJ45 connector.
You can use the original SPI pins but find which pins are free to use with the Chip Selects (GPU and the SD). (you can still use the original SPI pins SCK/MISO/MOSI).
If anyone has issues similar issues fitting the Gameduino2 onto a Shield, you can always buy a Stackable Header kit and extend the height. (obviously you watch for any used pins which may clash with the operation)
One test which may be usefull is to connect the Arduino directly to the Gameduino2 without the Ethernet Shield.
|
|
peterm
Junior Member

Posts: 17
|
Post by peterm on Jul 25, 2014 3:14:08 GMT -8
I looked at the Ethernet Shield circuit and I could not see any problem with Pins clashing/crashing.
I think this may require some different Initialization if it you still can't get it to work.
You may have to wait till James possibly posts a solution.
|
|
|
Post by Vinicius on Jul 25, 2014 5:06:09 GMT -8
Hello!
Thank you for your reply.
The situation is this:
Gameduino 2
| |
Wifi shield
| |
Arduino Ethernet (not Ethernet Shield)
I'm using the Wi-Fi shield as a stackable header, can it cause issues?
I can connect to the internet (i can ping the Arduino), and I can use the Gameduino.
The problem is that when i try to use a modbus library (http://myarduinoprojects.com/modbus.html)
the gameduino freezes, if i unplug it and plug it again via the usb cable, I can't even see the display light (sorry for my bad english, by the way)
Arduino Ethernet CS(Ethernet:10 and SD:4) and Gameduino CS (Gameduino:8 and SD:9) are compatible, pin 10 through 13 are used by the Arduino Ethernet but it shouldn't be a problem.
Tried to set to high the Gameduino CS before i use Modbus, tried to use GD.___end and resume, but it always freezes.
Looked the library and it just tries to connect to a server, and send packets (oh well, it's a modbus library >_>), nothing special.
Maybe it's the Wi-fi Shield that causes this, but i can't connect it in other ways right now.
Any help appreciated!
|
|
|
Post by jamesbowman on Jul 25, 2014 8:03:26 GMT -8
OK, when you have several SPI devices sharing a bus, you have to make sure that only one is enabled at a time, otherwise they clash. Here we have four (!) devices all talking on the same SPI bus: - FT800Q (pin 8)
- GD2's sdcard (pin 9)
- Ethernet shield (pin 10)
- Ethernet shield's sdcard (pin 4)
the "GD.begin()" function takes care of the first two, but the second two need to be disabled before calling GD.begin():
pinMode(4, OUTPUT); digitalWrite(4, HIGH); pinMode(10, OUTPUT); digitalWrite(10, HIGH);
// Initialize GD2 GD.begin(0);
So an Ethernet-shield friendly "hello world" looks like:
#include <EEPROM.h> #include <SPI.h> #include <GD2.h>
void setup() { pinMode(4, OUTPUT); digitalWrite(4, HIGH); pinMode(10, OUTPUT); digitalWrite(10, HIGH);
GD.begin(0); }
void loop() { GD.ClearColorRGB(0x103000); GD.Clear(); GD.cmd_text(240, 136, 31, OPT_CENTER, "Hello world"); GD.swap(); }
That's how to get the GD started with the Ethernet shield installed. Now how to use both at the same time. To do this, we need to deselect the GD2, talk to the Ethernet then re-select the GD2. So every Ethernet conversation needs to be "wrapped" in a pair of calls like this:
GD.__end(); // deselect GD2 ... talk to Ethernet shield ... GD.resume(); // select GD2 again
So for example the full "setup()" function to start up the GD2 and the Ethernet might look like:
#include <Ethernet.h>
static byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };
void setup() { Serial.begin(115200);
// Make sure that the Ethernet shield's SPI bus is idle pinMode(4, OUTPUT); digitalWrite(4, HIGH); pinMode(10, OUTPUT); digitalWrite(10, HIGH);
// Initialize GD2 GD.begin(0);
GD.__end();
// Initialize Ethernet and get IP Serial.println("acquiring IP address..."); if (Ethernet.begin(mac) == 0) Serial.println("Failed to configure Ethernet using DHCP");
GD.resume(); }
|
|
|
Post by Vinicius on Jul 28, 2014 2:31:55 GMT -8
Hello, thank you for your reply.
Been busy in the weekend and I couldn't try what you wrote.
Tried this morning, it connects fine, still no modbus communication.
if i just initialize the modbus class like (wrapped in .__end and .resume)
MgsModbus Mb;
the Gameduino stops working, it just starts to flash random, and the modbus doesn't work either.
the MgsModbus class constructor is empty:
MgsModbus::MgsModbus()
{
}
This is probably the modbus library fault, but i don't know what is causing it.
There are some other things i have to check for ethernet connection with Gameduino 2?
I think it's a Serial communication problem, in this case, can i rewrite the connection with the SPI bus?
for example, can i set SPI MOSI, SPI MISO, SPI SCK to other pins which are not 11,12,13?
|
|