Show Posts
Pages: [1]
1  Using Arduino / Motors, Mechanics, and Power / Re: Building a motor control feedback loop on: October 07, 2012, 06:13:21 am
They are both turning in the same direction yes. I noticed that the drawing is incorrect, the bottom motor polarities are reversed. Is it possible that the impedance of the motors are different (not accurate enough), and that is why they run at different speeds with, in theory, equal current flowing through them?

I will try to hook them up directly to the battery, and see what happens then.
2  Using Arduino / Motors, Mechanics, and Power / Re: Building a motor control feedback loop on: October 06, 2012, 10:31:31 am
That is a good idea, but when I tried it, it didn't work as expected. I really thought it would work, but now one motor runs at full speed and the other runs at a very low speed. I don't understand why, since in theory the same current should flow through them..

The attachment shows how I connected the motors.
3  Using Arduino / Motors, Mechanics, and Power / Building a motor control feedback loop on: October 05, 2012, 07:51:03 pm
My current project consists of a Rover 5, an Android phone and a bluetooth transceiver. My goal is to control the rover via bluetooth, from my phone. I'm using the Amarino toolkit, which really is great.

I have come as far as to being able to control the speed on the motors (there are 4 of them) independently. My problem comes forth when I try to run them together. The rover has belts that physically connects two motors together, and when I realized that the motors run at different speeds when I supply them with the same voltage (It's measured), I had a problem.

I've googled my problem, and it seems everyone is using engine controllers to counter this problem, but I want to build this by myself. If possible..

Each motor has a rotary encoder(quadrature), which produces a frequency (actually two, 90 degrees out of phase) based on it's speed. My idea is to compare two frequencies (from the two motors at the same side). Then I want that difference to either increase or decrease one of the two motors' voltage, so that two and two motors run at the exact same speed.

I am now using the PWM output of the Arduino to control the voltage of the motors.

I can't seem to put this idea into programming language(or electronic components), and I'm not even sure it is doable.  Maybe I'm thinking too complicated, and there is another much easier way to counter this problem?

My mind is open for suggestions!
4  Using Arduino / Programming Questions / Re: Problem when reading from a GSM-modem on: October 04, 2011, 11:54:54 am
Thank you for answering, after some more trial and error it seems like changing the if to a "while !=0" is working. I'm not sure if it'll always work, but for now it does the job nicely.

Code:
void readSMS()
{
  Serial2.print("at+cmgr=1\r");
  delay(200);
  while(Serial2.available()!=0)
  {
     Serial.print(byte(Serial2.read()));
  }
}
5  Using Arduino / Programming Questions / Re: Problem when reading from a GSM-modem on: October 04, 2011, 11:10:57 am
Well sorry about that, I seem to have copied the code from when I was testing.
It's supposed to be like this:
Code:
void readSMS()
{
  char sms;
  Serial2.print("at+cmgr=1\r");
  if(Serial2.available())
  {
     sms=Serial2.read();
     Serial.print(sms);
  }
}
I think I realized what the problem was, Serial2.read() returns the first byte. So I tried this:
Code:
void readSMS()
{
  char sms;
  Serial2.print("at+cmgr=1\r");
  delay(200);
  if(Serial2.available())
  {
    for(int j=0;j<=Serial2.available();j++)
    {
     sms=Serial2.read();
     Serial.print(sms);
    }
  }
}

Now i get about half the message, but still not all of it. Serial.available is supposed to return the number of bytes ready to send, and since one letter is one byte, I thought this would work. Any ideas?
6  Using Arduino / Programming Questions / Problem when reading from a GSM-modem on: October 04, 2011, 09:40:37 am
Hello, this is my first post at the Arduino forums smiley

I just started using Arduino, and I've got myself a Mega 2560. I am interfacing with a GSM-modem, and stumbled upon a few problems when I tried to read an SMS from the modem. I'll go ahead and post a code snippet:

Code:
void setup()
{
  Serial.begin(9600);  // PC
  Serial2.begin(9600); // GSM-modem
  initGSM();
  readSMS();
 
}

void loop()
{
}

void initGSM()
{

  Serial2.print("at+cmgf=1\r");
  delay(100);
  Serial2.print("at+cpin=5934\r");
  delay(200);
  Serial2.flush();
  Serial.flush();
}

void readSMS()
{
  char sms[200];
  Serial2.print("at+cmgr=1\r");
  if(Serial2.available())
  {
    *sms=Serial2.read();
    Serial.print(*sms);
  }
}

As you can see I call readSMS() in void setup(), that is not how it is supposed to be in the final code, but i use it for testing now. The thing is, I want to call readSMS() from anywhere in the program, but not in void loop(). When I do that(call it from anywhere else), I only get part of the output i need, actually only one character, and I don't understand why. If i use a for-loop like this:
Code:
void setup()
{
  Serial.begin(9600);  // PC
  Serial2.begin(9600); // GSM-modem
  initGSM();
  for(int i=0;i<80;i++)
  {
    readSMS();
  }
}

... I do get all of it. Do i really have to run readSMS() in a loop to get all of the output? The size of int i decides how much of the SMS i get.

Am I doing something wrong when reading from the modem?
Pages: [1]