Show Posts
Pages: 1 2 3 [4] 5 6 ... 294
46  Using Arduino / Programming Questions / Re: Adjusting the DC motors speed on: September 23, 2014, 09:22:18 am
Quote
Your hardware is fixed so why not make the software match it ?

this point is not clear to me , more info. ?
What I meant was that as you know which direction the encoders are working so you don't need the checks on the value of LeftEncoderIsReversed etc

Quote
In another of your  threads I suggested trying a fixed adjustment factor before refining the technique to use a PID.  Did you try that ?  It would at least ensure that the logic is correct without the complication of having to compute the correction factor in the first instance.

I was wishing to do that but the difference (error) between two speeds is not stable and increases constantly .
The point of adding a fixed adjustment factor is precisely that it is fixed instead of being calculated an varying.  If you use a fixed adjustment factor it is easy to change its value and/or sign (positive/negative), recompile and try again until you know what range of values is sensible for the adjustment.  Once you know that you can move on to calculating the adjustment and reducing it to a minimum as the robot moves nearly in a straight line. 

With a fixed adjustment factor and, say an adjustment to the right being needed then eventually too much adjustment will be applied and a left adjustment will be required and so on but at least you will have something to work on.
47  Using Arduino / Programming Questions / Re: Adjusting the DC motors speed on: September 23, 2014, 06:25:29 am
Quote
But when run the code , at first the difference is small enough but suddenly increases dramatically
That sounds like you have got the logic reversed somewhere and are therefore have positive feedback which leads to the correction factor increasing instead of decreasing.  Your use of
Code:
#ifdef LeftEncoderIsReversed
and similar checks makes the logic of your program more difficult to follow.  Do you really need them in your code, at least at this stage ?  Your hardware is fixed so why not make the software match it ?

In another of your  threads I suggested trying a fixed adjustment factor before refining the technique to use a PID.  Did you try that ?  It would at least ensure that the logic is correct without the complication of having to compute the correction factor in the first instance.

As for the PID, have you looked at the PID library ?
48  Using Arduino / Programming Questions / Re: using multiple counters on 1 arduino on: September 23, 2014, 04:40:54 am
What you describe sounds simple. 
When you detect a coin of a certain colour presumably you do something to push the coin into the appropriate bin.  To count the number of coins of that colour add one to a counter at the same time then update the display to show the counters for each colour.

Post your code here and we can give advice as to where and how to do this.

Please read the 2 sticky posts at the top of this page before posting your code noting the use of code tags to help make your code readable on the forum.
49  Using Arduino / Programming Questions / Re: DHT11 temp sensor combined with ultrasonic sensor code bug? on: September 23, 2014, 02:09:19 am
Code:
  Serial.println("Temperature = " + celciusTemp);
  Serial.println("Speed of sound = " + c);
  Serial.println("Distance = " + distance);
You cannot concatenate text and variables together and print the like this.  Print each one separately or concatenate them first using sprintf()
50  Using Arduino / Programming Questions / Re: Need help with storage of multiple ints on: September 22, 2014, 03:16:46 pm
Code:
int incomingByte;   // for incoming serial data
Can I suggest that you change the name of this variable for sanity's sake

Code:
timeStored[i] = currentTime; //********* I store the time. How would i go about making this with the millis function?
Code:
timeStored[i] = millis();

Code:
    if (timeStored[i] < (currentTime + (60 * 5 * 1000))) //******* if the time stored, is older than 5 minutes
Should be
Code:
    if (millis() - timeStored[i] >=  (60 * 5 * 1000)) //Avoids the problem with the 49 day rollover of millis()
51  Using Arduino / Programming Questions / Re: can I use the monitor to send a word? on: September 22, 2014, 12:27:36 pm
Why are you reading from Serial in setup() and then repeating the code in loop() ?  If you must do it in two places then using a function would be a better solution.

There are many here that suggest that using Strings is wasteful of resources on an Arduino and that C style strings (an array of chars) should be used instead.
52  Using Arduino / Programming Questions / Re: Whats wrong with my nfc code? on: September 22, 2014, 12:17:46 pm
Code:
  else
  {
    digitalWrite(redLED,HIGH);
    delay(1000);
    digitalWrite(redLED,LOW);
  }
This why the LED flashes continuously.  This block of code will run every time through loop() regardless of whether a card has been read or not.  It is irrelevant whether a tag has been read and matches or not.

As to your main problem, how are the LEDs wired ?
53  Using Arduino / Programming Questions / Re: AREXX AAR ROBOT - BLUETOOTH HC-06 NEED HELP PLS on: September 22, 2014, 06:58:58 am
i did a programm and i also posted it in my early reply..but its not working
Ignoring for the moment the fact that the program you posted has all the motor control stuff in it, what do you see when you print the bytes received from Bluetooth ?

In your program you have
Code:
  if (mySerial.available())
    Serial.write(mySerial.read());  <<<<Why are you throwing away this incoming byte ?
  if (Serial.available())
    mySerial.write(Serial.read());
  digitalWrite(6,LOW);
  digitalWrite(5,LOW); //stop motors
  digitalWrite(9,LOW);
  digitalWrite(10,LOW); //stop motors 
  if (mySerial.available() > 0)
  {          // if received UART data
    incomingByte = mySerial.read();        // raed byte     <<<<Assuming that more than one byte was available above you are now reading the second byte from Bluetooth

What is the format and type of the data being sent via Bluetooth ?
54  Using Arduino / Programming Questions / Re: Need help with storage of multiple ints on: September 22, 2014, 06:45:57 am
Paul - quite right of course.  When I said delete I had in mind what I suggested in reply #1, although looking back I suggested that entries could not be deleted from the array which is actually not true.
55  Using Arduino / Programming Questions / Re: AREXX AAR ROBOT - BLUETOOTH HC-06 NEED HELP PLS on: September 22, 2014, 06:06:04 am
Quote
I already did a programm ....it also did prgoram that can follow a black line...something like that...
OK then, let's turn the advice on its head.  Take out all of the robot control stuff from your program just leaving the Bluetooth stuff.  What do you see on the Serial monitor when/if data is received via Bluetooth ?
56  Using Arduino / Programming Questions / Re: Keep maximum value with analog reading on: September 22, 2014, 06:02:44 am
Quote
Not comparing to the last value but to the known maximum value ...
As I suggested earlier.....
57  Using Arduino / Programming Questions / Re: Need help with storage of multiple ints on: September 22, 2014, 06:00:35 am
Code:
int time[50];
No.  You need
Code:
unsigned long timeStored[50];
because as I noted earlier millis() returns an unsigned long

Quote
how do i then make it put the time and value together, so that it knows which value entry, has which time entry?
By using the same array index for both.

Quote
Won't millis rollover, after some time?
No, because you will use a construct like
Code:
if (millis() - timeStored[x] >= interval)
to test whether the time has passed to delete entry x from the array of tag numbers.  By using unsigned longs and subtracting them from millis() the rollover problem is avoide.
58  Using Arduino / Programming Questions / Re: AREXX AAR ROBOT - BLUETOOTH HC-06 NEED HELP PLS on: September 22, 2014, 05:00:59 am
As Paul suggests I would start by getting the robot to move under control of the program.  To help this I would create functions to move the robot forward, backward, left, right and stop and call them in sequence from setup() to ensure that each one does what is required.  Then you can move onto control via bluetoooth and possibly passing a speed parameter to each function.
59  Using Arduino / Programming Questions / Re: Keep maximum value with analog reading on: September 22, 2014, 04:50:27 am
Quote
do you have any better approach ?
Set a variable to zero
If the analogue input is greater than the variable then set the variable to the input value

No need for an array
60  Using Arduino / Programming Questions / Re: Need help with storage of multiple ints on: September 22, 2014, 04:46:46 am
Quote
The arduino then has to store 875 for 5 minutes. so that if 875 is scanned again, it can go through the array, and know that exactly this tag, has already been scanned before, within 5 minutes.
In order to know that the number has been stored for 5 minutes you will need to store the time at which it was stored.  Unless you have an RTC you will need to store the value of millis() as the start time.  millis() returns an unsigned long integer which takes 4 bytes to store which increases the storage requirement considerably,
Pages: 1 2 3 [4] 5 6 ... 294