Show Posts
Pages: 1 2 3 [4] 5 6 ... 511
46  Using Arduino / Project Guidance / Re: Motor control HELP NEEDED!!! on: July 11, 2014, 12:40:18 am
Welcome! There are many existing projects and products you can google. Two things to clarify:

1. What type of motor do you have? Is it a DC motor. If it is, you need some way to track camera location. A stepper motor will provide more repeatability of positions. You will need a motor shield or module to control it.
2. What is camera USB used for? Do you mean you can trigger your camera via a usb connection? If yes, what device do you connect to the other end of the usb cable to trigger your camera, without arduino?
47  Using Arduino / Project Guidance / Re: Looking for RF transmitters, 315 or 433 MHz the only choice? on: July 11, 2014, 12:33:37 am
http://en.wikipedia.org/wiki/LPD433

Governments consider air way under their control. You are not free to use just any frequency for communication in the air without meeting some laws face to face. If you want a lot of wireless devices, get one with networking capability such as xbee.
48  Using Arduino / Project Guidance / Re: Need help with changing code. on: July 10, 2014, 11:08:23 pm
Get your cheap shield, run some sample code. If it works, come ask later.

Do you think someone will work FOR you even before YOU put some real time and money in getting the hardware? This is a volunteer forum. You show you have done your part: get the hardware and run basic test and attempt to make some code conversion, then someone else will do their part to help you.
49  Using Arduino / Project Guidance / Re: Using Software Serial and Hardware Serial with Processing over Bluetooth on: July 10, 2014, 10:55:50 pm
The if available will make sure there is something to read. Before, you used a weird function that I didn't even know about, the readXXXUntil(). I took some time to its code hiding inside the Stream class, and Read inside Software serial etc. This family of read until functions don't use available and times out waiting for values. To be honest, that sounds like a brutal way to get the same result but I don't know exactly how it didn't work, after reading all its code. Someone else can pitch in:

Code:
// Read data from buffer
int SoftwareSerial::read()
{
  if (!isListening())
    return -1;

  // Empty buffer?
  if (_receive_buffer_head == _receive_buffer_tail)
    return -1;

  // Read from "head"
  uint8_t d = _receive_buffer[_receive_buffer_head]; // grab next byte
  _receive_buffer_head = (_receive_buffer_head + 1) % _SS_MAX_RX_BUFF;
  return d;
}

Code:
// private method to read stream with timeout
int Stream::timedRead()
{
  int c;
  _startMillis = millis();
  do {
    c = read();
    if (c >= 0) return c;
  } while(millis() - _startMillis < _timeout);
  return -1;     // -1 indicates timeout
}

Code:
String Stream::readStringUntil(char terminator)
{
  String ret;
  int c = timedRead();
  while (c >= 0 && c != terminator)
  {
    ret += (char)c;
    c = timedRead();
  }
  return ret;
}
50  Using Arduino / Project Guidance / Re: Using Software Serial and Hardware Serial with Processing over Bluetooth on: July 10, 2014, 04:14:35 pm
Please reform your question regarding the if available statement. I couldn't understand it. It worked, right? Are you questioning why?

Using String class objects isn't necessarily a bad thing if you use it correctly. I don't use it because I am old fashion C programmer and understand the 2KB ram is not a lot to play with. If you want to buffer the input and process it line by line in arduino, read about String class and reserve() function. It avoids memory leak all together, since it will start with a String that you set with reserve() to make sure it is large enough to store a whole line.

By nix I do mean a Mac, which is a flavor of unix. I say your reference to your serial port is nix style so I assumed you wouldn't want me to call your computer "PC".
51  Using Arduino / Project Guidance / Re: Control servos by keypad - help code! on: July 10, 2014, 04:04:21 pm
For that matrix keypad, use keypad.h library written by Stanley or my phi_interfaces library. Easy to get key from the pad. Please run some demo code to familiarize with how to get keys from keypads.

Using UNO with a matrix keypad and later an LCD will consume most of its pins, 14 pins to be exact, leaving few for the servos. But you can always upgrade to MEGA in case you run out of pins.

My advice, taking Robin2's advice together, is, besides trying out sample code, to write a function that involves NO LCD, NO keypads, just a function that will take in a parameter and run a certain servo in predefined way. Say:
Code:
#define Servo_1_90_wait_5s 0
#define Servo_2_120_wait_2s 1

void servo_routines(int routine_number)
{
  switch (routine_number)
  {
    case Servo_1_90_wait_5s:
    //Move servo 1 to 90 degree position and wait for 5 seconds
    Break;
...
  }
}

void setup()
{
  servo_routines(Servo_1_90_wait_5s);
  delay(10000);
  servo_routines(Servo_2_120_wait_2s).
}
...
Once you have a few servo routines written, call them in setup like servo_routines(Servo_1_90_wait_5s).
Once you are sure that all routines are working properly, then think about adding an interface. Use defined words instead of a number to represent the routine such as Servo_2_120_wait_2s.

Does it make enough sense to you?
52  Using Arduino / Project Guidance / Re: SD Shield for Arduino Due on: July 10, 2014, 02:01:55 am
Just trying to learn here.

mbanzi posted a reply on the product page:
Quote
The pin layout is the same as the recent (2010) boards. it's called R3 layout.
This class of processors do not work at 5v so we have to run at 3.3v. We added the IOREF pin so that shields can detect the operating voltage of their "motherboard" our Ethernet and Wifi shield support that.
To make the IO on this board work at 5v we would have to make it much more complex and expensive.

This means their official ethernet shield can work with the DUE.

AC3000 says the ethernet shield can work with the DUE.

http://arduino.cc/en/Main/ArduinoEthernetShield

These are official faces of Arduino so I don't have doubts that it would work.
53  Using Arduino / Project Guidance / Re: Control servos by keypad - help code! on: July 10, 2014, 01:54:04 am
I want to program to for instance turn servo ONE 90 degrees if i press button 1 on the keypad.

How about completing your description of theory of operation for a starter? What happens if you push button 2? Are you required to enter an angle or just press a key to execute one associated action?
54  Using Arduino / Project Guidance / Re: Using Software Serial and Hardware Serial with Processing over Bluetooth on: July 10, 2014, 01:51:18 am
readStringUntil() is an interesting function but not what you want. In short, it times out if there is no available bytes. A simple way to test is to read one character from software serial, when there is available character, then write to hardware serial. Is there need to buffer a whole line of characters before sending them all back to your nix?

As Robin2 said using String is not the best approach due to limited memory. I did a little digging to corroborate his claim. See how poorly it's done:

Code:
String Stream::readStringUntil(char terminator)
{
  String ret;
  int c = timedRead();
  while (c >= 0 && c != terminator)
  {
    ret += (char)c;
    c = timedRead();
  }
  return ret;
}

The String called ret is initialized without a reserved length so it starts from zero length. Then it would grow to 1 char long, and then 2, etc. I the worst case scenario if you receive 10 characters, you are looking at (1+2+3+...+10) size of wasted memory.

So, if there is no reason to buffer a line and send to your nix, why not doing it the obvious way?

Code:
if (mySerial.available()) Serial.write(mySerial.read());

If memory serves me, Processing tries to run its loop at 60 frames per second? Too much printing with not enough delay.
55  Using Arduino / Project Guidance / Re: What is the best way to detect a stop point on a cable??? on: July 10, 2014, 01:21:32 am
I am not too familiar with a winch motor setup but I can imagine that the least thing you want is arduino fails to detect the marker and keeps rolling the cable. This makes me think of mechanical switches that can be triggered by an object secured on to the cable, not an optical sensor. But now just thinking about this switch, the cable is going to shift from side to side as it is rolled on the winch or do you have something that restricts the cable from shifting from side to side?
56  Community / Bar Sport / Re: Australian ebay seller! on: July 10, 2014, 12:12:07 am
Sometimes ebay has promotions for buyers, say 10% off or something. Around that time, you bet someone has sold an expensive item or two to their friends smiley-wink
57  Community / Bar Sport / Re: The Cracked Pot on: July 09, 2014, 11:16:45 pm
No thanks but let's not talk about religious books. This tale is pretty good by itself. It's posted on the bar and sport forum so of course people will try different ways to interpret it, whichever fits their own life's manner.
58  Community / Bar Sport / Re: How to make a smart watch using arduino on: July 09, 2014, 10:19:18 pm

You are off by a few dollars. You need a wrist strap to compete against that instructable.
59  Community / Bar Sport / Re: The Cracked Pot on: July 09, 2014, 09:50:45 pm
They can in parable-land.

The trick is not to take it literally. Since it's not is any religious book I think we're on safe ground there.


Religious books? You wish they have such wonderful and deeply meaningful stories on religious books. smiley-cool
60  Using Arduino / Networking, Protocols, and Devices / Re: Possible cause of incomplete server response and glued together responses? on: July 09, 2014, 03:50:15 pm
My original code is posted but without this feature so here is current code. It only receives server reply after HTTP request header and data are both sent. The feature appears twice in the code.

I'd love some critics. The server_response_time is 30,000 milliseconds.

Code:
//Receive server reply and log it to Debug(serial), debugfile. Returns the reply code.
int receive_server_reply(Client* my_in)
{
boolean catch_next_byte=false; // This indicates the next byte from buswave server should be captured as reply value. This is turned on only when cell_send_response_indicator character is detected (usually '*').
char HTTP_response_code[]="   "; // This stores the HTTP response code such as 200 or 500, for later recognition.
int reply=cell_send_response_network_reg_err;
unsigned int received_byte_cnt=0; // This counts received bytes from server. It is used to determine where the HTTP respond code is located.
unsigned long connect_time;
// Ready the debug file
if (!debugfile.open(debug_file_name, O_WRITE | O_CREAT | O_AT_END)) // Send data to debugfile
{
Debug->print(millis());
Debug->println(F(":Can't open debug file"));
my_in->stop();
while(1){}
}

// Wait on server response
connect_time=millis();
Debug->print(millis());
Debug->println(F(":Waiting for server response"));
while (millis()-connect_time<server_response_time)
{
char c;
if (my_in->available())
{
c= my_in->read();
Debug->write(c);
debugfile.write(c);
if ((received_byte_cnt>8)&&(received_byte_cnt<12)) HTTP_response_code[received_byte_cnt-9]=c; // Store the HTTP response code
if (received_byte_cnt==11) // Got the response code
{
if (strcmp("200",HTTP_response_code)!=0) // Cache data if response is not 200.
{
while (millis()-connect_time<server_response_time) // Still receive the rest of the response until there is none.
{
if (my_in->available())
{
c= my_in->read();
Debug->write(c);
debugfile.write(c);
}
if ((!my_in->connected())&&(!my_in->available())) break; // As of Arduino IDE 1.0.5r2, the available() was removed from the connected() code so despite the ref page saying that connected() returns true when connection broke and there is still characters available, it would not return true.. You have to test available() before skip out of loop.
}
debugfile.println(F("Server not responding 200"));
Debug->println(F("Server not responding 200"));
reply=cell_send_response_network_reg_err;
break;
}
}
received_byte_cnt++;
}
if (catch_next_byte)
{
reply=c;
catch_next_byte=false;
}
if (c==cell_send_response_indicator) catch_next_byte=true;
if ((!my_in->connected())&&(!my_in->available())) break; // As of Arduino IDE 1.0.5r2, the available() was removed from the connected() code so despite the ref page saying that connected() returns true when connection broke and there is still characters available, it would not return true.. You have to test available() before skip out of loop.
}

Debug->println();
Debug->print(millis());
Debug->println(F(":Disconnecting from server."));

debugfile.println();
debugfile.close();

PGM_RAM(network_msg_02,formatting_buffer);
sprintf(buffer,formatting_buffer,(int)reply);
Debug->println(buffer);
debug_log(buffer);

return reply;


Here is a sample server response. I am trying to catch the HTTP/1.1 200 to confirm success, and the response number after the *, such as *0 towards the end. This tells arduino whether it should do something, say disable a device or restart etc.

Code:
15:46:32.993> HTTP/1.1 200 OK
15:46:32.993> Date: Wed, 09 Jul 2014 20:46:09 GMT
15:46:33.055> Server: Apache/2.2.22 (Ubuntu)
15:46:33.055> Vary: Accept-Encoding
15:46:33.055> Connection: close
15:46:33.118> Transfer-Encoding: chunked
15:46:33.118> Content-Type: text/html; charset=utf-8
15:46:33.118>
15:46:33.180> 2
15:46:33.180> *0
15:46:33.180> 0
15:46:33.180>
15:46:33.180>

I am using Terminal by Br@y++ so I enabled time stamp smiley
Pages: 1 2 3 [4] 5 6 ... 511