Show Posts
|
|
Pages: [1] 2 3 4
|
|
1
|
Using Arduino / Networking, Protocols, and Devices / Re: Arduino WiFi Shield UDP Support
|
on: April 23, 2013, 09:27:15 am
|
Indeed while copying the code I added a "z" in it but it "works" here it is with the same bug i was talking about earlier :
Hi Ohhopi, So I understand you still get the same feed back from Serial: "ntp server update failed" What did you try to find where the bug is? Did you try my suggestion to start from a tested working example and seeing when it starts failing? Another good thing to do is add a lot of debug printouts. So everytime you think your code does something the Serial prints this out for you so you are sure it is actually the way you expect it to be. One thing I see that is probably not right is this: in getTimeAndDate() : sendNTPpacket(timeServer); delay(1000);
Which means you are doing this request every second. According to this page http://tf.nist.gov/tf-cgi/servers.cgi you shouldn't query the servers more than once every 4 seconds. You'll see in the UDPNTPClient example that they wait 10 seconds between each call.
|
|
|
|
|
4
|
Using Arduino / Networking, Protocols, and Devices / Re: Arduino WiFi Shield UDP Support
|
on: April 15, 2013, 05:40:31 pm
|
IP Address: 192.168.2.6 Just a wild guess: is it possible the receiving ip should be something like 192.168. 2.something... instead of the 192.168. 1.212 you were using? usually when you are on the same network, the range of IPs is limited so only the last byte is different. I have no idea why you get this weird output like signal strength (RSSI): 0 Encryption Type: 0 did you correctly upgrade the WifiShield firmware? Are you using the correct library?
|
|
|
|
|
5
|
Using Arduino / Networking, Protocols, and Devices / Re: Arduino WiFi Shield UDP Support
|
on: April 15, 2013, 03:41:42 pm
|
Is the initialization of your class correct? Is it right I'm initializing it like this: Udp.begin(receiverPort); ...using receiverPort as argument? Is the composition of the UDP message correct? Well yes and no. If you look at the header file of WifiUDP ( https://github.com/mlafauci/Arduino/blob/wifishield-bugfix/libraries/WiFi/WiFiUdp.h ), you'll see that the method is commented like this: virtual uint8_t begin(uint16_t); // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use
so it's expecting you to pass the port the Arduino should listen on, not the one to send to. But since you are not listening on the Arduino and the local and remote port can be the same, this shouldn't be a problem. The construction of your UDP message Udp.beginPacket(receiverIP, receiverPort); //start udp packet Udp.write(valueInBytes, 8); //write sensor data to udp packet Udp.endPacket(); // end packet looks right to me. It's difficult to debug these kind of things from a distance. What I would do in such a case is try with the simplest setup that works and then change the code until it breaks. Step by step, compiling and testing with every change. At a certain point it will stop working. So I would suggest you start with my example, start changing things and see how far you can get. I would start by checking these: - do you really want delay(10000); // 10sec delay? - is the receiving computer really at IP 192.168.1.212 ? and is it listening at port 9100 ? - more really obvious mistakes that are easy to overlook :-)
|
|
|
|
|
6
|
Products / Arduino Due / Re: speed of digitalWrite and digitalRead on Arduino Due.
|
on: April 15, 2013, 01:25:32 pm
|
so I've changed my test like this: //#include <digitalWriteFast.h> // uncomment for Arduino UNO
/* I'm trying to see how fast some instructions are on Arduino UNO and Arduino DUE */
long sampleSize = 1000000; // do a million times! long lastTime;
//----------------------------------------------------------------------------- void setup(){ delay(50); // wait a bit. (Arduino Due prints nonsense to the serial port...??) Serial.begin(115200); // go really fast serial! Serial.print("Sample size: "); Serial.println(sampleSize); // I will store my value in this: int n; // and use these pins for writing or reading pinMode(2, OUTPUT); pinMode(3, INPUT);
Serial.println("digitalWrite:"); lastTime = micros(); for(long i =0; i < sampleSize; i++){ digitalWrite(2, HIGH); digitalWrite(2, LOW); } printTime( micros() - lastTime);
#ifdef digitalWriteFast // not working with Arduino Due Serial.println("digitalWriteFast:"); lastTime = micros(); for(long i =0; i < sampleSize; i++){ digitalWriteFast(2, HIGH); digitalWriteFast(2, LOW); } printTime( micros() - lastTime); #endif
Serial.println("digitalRead:"); lastTime = micros(); for(long i =0; i < sampleSize; i++){ n = digitalRead(3); } printTime( micros() - lastTime); #ifdef digitalReadFast Serial.println("digitalReadFast:"); lastTime = micros(); for(long i =0; i < sampleSize; i++){ n = digitalReadFast(3); } printTime( micros() - lastTime); #endif
}
//----------------------------------------------------------------------------- void loop(){ // do nothing }
//----------------------------------------------------------------------------- void printTime( long microsecs){ int mins, secs, msecs, usecs;
msecs = floor(microsecs / 1000); usecs = microsecs % 1000;
secs = floor(msecs / 1000); msecs = msecs % 1000;
mins = floor(secs / 60); secs = secs % 60; Serial.print("time: "); Serial.println(microsecs);
Serial.print(mins); Serial.print(" min "); Serial.print(secs); Serial.print(" sec "); Serial.print(msecs); Serial.print(" msec "); Serial.print(usecs); Serial.println(" usecs"); Serial.println(""); delay(20); }
and the new results are: Arduino UNOSample size: 1000000 digitalWrite: time: 8991484 0 min 8 sec 991 msec 484 usecs digitalWriteFast: time: 754608 0 min 0 sec 754 msec 608 usecs digitalRead: time: 5721828 0 min 5 sec 721 msec 828 usecs digitalReadFast: time: 691724 0 min 0 sec 691 msec 724 usecs Arduino DueSample size: 1000000 digitalWrite: time: 5148742 0 min 5 sec 148 msec 742 usecs digitalRead: time: 1275278 0 min 1 sec 275 msec 278 usecs Much better! :-) So I guess I won't be needing to worry about the speed of digitalWrite or read.
|
|
|
|
|
8
|
Using Arduino / Networking, Protocols, and Devices / Re: Arduino WiFi Shield UDP Support
|
on: April 15, 2013, 01:03:52 pm
|
srrichie, Your suggestion was already implemented in my code (I'm not THAT noob )
Sorry about that, I didn't mean to call you a noob, it's just difficult to hunt down bugs when you don't post full code. the sketch you posted compiles just fine. Could you provide more information about the errors you get? best, tim.
|
|
|
|
|
9
|
Products / Arduino Due / speed of digitalWrite and digitalRead on Arduino Due.
|
on: April 15, 2013, 12:41:25 pm
|
hi all, I'm think about using the Arduino Due as the brains of a Reprap like machine. It will read commands from an SD card (or from it's memory, maybe Due has enough?), parse them and control stepper motors. So I ordered one and started doing some tests. I've found that digitalWrite and digitalRead are remarkably slower on the Due than the UNO. I used this sketch as a test: #include <digitalWriteFast.h>
/* I'm trying to see how fast some instructions are on Arduino UNO and Arduino DUE */
int sampleSize = 1000000; // do a million times! long lastTime;
//----------------------------------------------------------------------------- void setup(){ delay(50); // wait a bit. (Arduino Due prints nonsense to the serial port...??) Serial.begin(115200); // go really fast serial! // I will store my value in this: int n; // and use these pins for writing or reading pinMode(2, OUTPUT); pinMode(3, INPUT);
Serial.println("digitalWrite:"); lastTime = micros(); for(int i =0; i < sampleSize; i++){ digitalWrite(2, HIGH); digitalWrite(2, LOW); } printTime( micros() - lastTime);
#ifdef digitalWriteFast // not working with Arduino Due Serial.println("digitalWriteFast:"); lastTime = micros(); for(int i =0; i < sampleSize; i++){ digitalWriteFast(2, HIGH); digitalWriteFast(2, LOW); } printTime( micros() - lastTime); #endif
Serial.println("digitalRead:"); lastTime = micros(); for(int i =0; i < sampleSize; i++){ n = digitalRead(3); } printTime( micros() - lastTime); #ifdef digitalReadFast Serial.println("digitalReadFast:"); lastTime = micros(); for(int i =0; i < sampleSize; i++){ n = digitalReadFast(3); } printTime( micros() - lastTime); #endif
}
//----------------------------------------------------------------------------- void loop(){ // do nothing }
//----------------------------------------------------------------------------- void printTime( long microsecs){ int mins, secs, msecs, usecs;
msecs = floor(microsecs / 1000); usecs = microsecs % 1000;
secs = floor(msecs / 1000); msecs = msecs % 1000;
mins = floor(secs / 60); secs = secs % 60; Serial.print("time: "); Serial.println(microsecs);
Serial.print(mins); Serial.print(" min "); Serial.print(secs); Serial.print(" sec "); Serial.print(msecs); Serial.print(" msec "); Serial.print(usecs); Serial.println(" usecs"); Serial.println(""); delay(20); }
I commented out "#include <digitalWriteFast.h>" when compiling for the Due. These are the results: Arduino Due:digitalWrite: time: 5196306 0 min 5 sec 196 msec 306 usecs digitalRead: time: 1156070 0 min 1 sec 156 msec 70 usecs Arduino UNO:digitalWrite: time: 142964 0 min 0 sec 142 msec 964 usecs digitalWriteFast: time: 8624 0 min 0 sec 8 msec 624 usecs digitalRead: time: 87508 0 min 0 sec 87 msec 508 usecs digitalReadFast: time: 7544 0 min 0 sec 7 msec 544 usecs Sanguino ATMEGA664A (Reprap motherboard v1.2)digitalWrite: time: 142964 0 min 0 sec 142 msec 964 usecs digitalWriteFast: time: 8628 0 min 0 sec 8 msec 628 usecs digitalRead: time: 86440 0 min 0 sec 86 msec 440 usecs digitalReadFast: time: 7548 0 min 0 sec 7 msec 548 usecs Does anyone know why I find this difference? Is there already a digitalWriteFast library for Due available? best, tim.
|
|
|
|
|
10
|
Using Arduino / Networking, Protocols, and Devices / Re: Arduino WiFi Shield UDP Support
|
on: April 15, 2013, 11:27:29 am
|
srrichie, just strip your sketch from all the calls to ethernetUDP and replace it with the appropriate parts of WifiUDP calls in the example I posted above in this thread. so EthernetUDP Udp; becomes WiFiUDP Udp; etc... and if something doesn't work, post your complete code then we can take a look at it and quickly see any mistakes. I would also suggest to always compile with verbose output. You can switch verbose output on in Arduino > Preferences
|
|
|
|
|
13
|
Using Arduino / Networking, Protocols, and Devices / Re: Arduino WiFi Shield UDP Support
|
on: April 15, 2013, 06:25:18 am
|
Hi ohhopi, I don't understand. Your code doesn't compile for me. I'm using this Time library: http://playground.arduino.cc/Code/timeAre you using a different one? Is the code you posted really the one you use?? I get these errors: sketch_apr15a.ino:93: warning: this decimal constant is unsigned only in ISO C90 sketch_apr15a:9: error: 'IPAddzress' was not declared in this scope sketch_apr15a:9: error: 'address' was not declared in this scope sketch_apr15a.ino: In function 'int getTimeAndDate()': sketch_apr15a:85: error: 'sendNTPpacket' cannot be used as a function sketch_apr15a.ino: At global scope: sketch_apr15a:102: error: redefinition of 'long unsigned int sendNTPpacket' sketch_apr15a:9: error: 'long unsigned int sendNTPpacket' previously defined here sketch_apr15a:102: error: 'IPAddzress' was not declared in this scope sketch_apr15a:102: error: 'address' was not declared in this scope
best, tim.
|
|
|
|
|
14
|
Using Arduino / Networking, Protocols, and Devices / Re: Arduino WiFi Shield UDP Support
|
on: April 14, 2013, 12:06:35 pm
|
ohhopi, I'd love to help you, but I can't test it myself right now. Do you have any compile errors? if so, can you post them? buzlityr, The upload script is really not so complicated, you should be able to recreate its behaviour on windows. Check it out here: https://github.com/mlafauci/Arduino/blob/wifishield-bugfix/hardware/arduino/firmwares/wifishield/scripts/ArduinoWifiShield_upgrade.shit really only sets some paths and then does ./avr-objcopy --output-target=ihex $WIFI_FW_PATH/wifi_dnld.elf $WIFI_FW_PATH/wifi_dnld.hex ./avr-objcopy --output-target=ihex $WIFI_FW_PATH/wifiHD.elf $WIFI_FW_PATH/wifiHD.hex and then dfu-programmer at32uc3a1256 erase dfu-programmer at32uc3a1256 flash --suppress-bootloader-mem $WIFI_FW_PATH/wifiHD.hex dfu-programmer at32uc3a1256 start I think it shouldn't be to difficult to recreate from the command line, right? best, tim.
|
|
|
|
|