Show Posts
Pages: [1]
1  Using Arduino / Installation & Troubleshooting / Can I swap a 328 for a 168 on a Duemilanove? on: November 05, 2012, 07:40:53 am
Hi guys

For our project, we had to make a funded decision on which microcontroller we would use. We went for the 168(secretly, because we KNOW we can work with it, officially because it meets all our criteria and it's a bit cheaper than the 328). Now I've been prototyping with the UNO and I've also been tinkering with the internal registers to speed things up a little and now I want to test if all works on the 168. Can I just take a Duemilanove with the 328, pull out the microcontroller and slam in a 168 or will Arduino say no or say bye bye? I'd like to know BEFORE I try, because I don't want to wreck the lab-equipment at school, my teacher's been a little edgy lately(he has to substitute another teacher and that totaly screwed up his schedule).

Thanks in advance!
2  Using Arduino / Sensors / Re: How can I speed up the ADC? on: October 16, 2012, 02:21:13 pm
I think your teacher laid out, too clearly in my view, what you needed to do.

.. Read the adc high byte, left aligned, provided you with 8-bit resolution. ..

That's what I ended up doing, as you can see in my code. The 8-bit resolution actually did the trick for me, it drastically reduces the processing time for normalizing the sensor values and translating those values into a line position.

Let me just add one more bit: you may want to think about your implementation. For you to implement a PID on top of a fast adc to just follow a line, either your car is powered by a rocket or your implementation is seriously wrong.


My car has to go 2 m/s, I really wanted some room to play in those 5 ms of cycle time. Now I've done some proper testing, apparently I've got plenty of room, even with a division factor of 128. Still, myAnalogRead is usefull, because I might want to go for fuzzy instead of PID. Once I comfortably get to those 2m/s, I might want to go even faster(but that's never going to happen in this universe smiley-wink )
3  Using Arduino / Sensors / Re: How can I speed up the ADC? on: October 12, 2012, 07:21:15 am
Hi Firemann00b,

Just a few design considerations before you max out on the ADC.
  • Do you really need to sample that fast. Controlling stuff is about controlling or changing the state they are in. Speed is a state. What is important is how fast does your robot CHANGE speed / steer. I take it it is not going to make a U-turn with a radius of 1 cm if it's doing 2 m/s. There is no point in having a very fast controller if the robot cannot comply with the commands its been given. It will cause the controller to oversteer, and can cause stability issues (oscillations)
  • Fast sampling creates noisy readings. You will have to filter the readings.
  • Fast sampling creates lots of data. Arduinos do not have lots of memory to store that information, nor do they have a lot of CPU power to process it in real time.
  • Look ahead. Knowing what's coming gives you more time to react. Faster sampling won't.
regards,

Pieter

I plan to read the interrupts on a cyclic basis. I'm not going to implement it fully, but my aim is to make my program run hard real time(for those who aren't into controller theory, this means there is no jitter on the delay between reading the input and writing the output). So it's of great importance I generate an input fast, so there's enough time left in the cycle to calculate the output. The cycle time for the whole algorithm is about 5 ms to make turns with a minimal radius of 10cm. It's calculated that if the car keeps going forward for 10 cycles, it will have lost the line. For 8 sensors, it takes about 1 ms to read them all with a division factor of 128. This means a fifth of the cycle is lost just to reading the sensors. And I have to use linear interpolation to translate the sensor values to an error and then calculate the motor speeds to compensate for the error.
4  Using Arduino / Project Guidance / Re: Automating Robot Arm on: October 09, 2012, 03:08:25 pm
I'm sorry that I can't help you, but I sure look forward to seeing the endresult of your project smiley-grin. I'm into automation too and I am considering buying this robot after the line follower project for school. Just too bad that it doesn't use servo's or stepper motors...
5  Using Arduino / Sensors / Re: How can I speed up the ADC? on: October 05, 2012, 08:40:02 am
Quote
And for setting the division factor, I wrote this little void:
"void" is the type of the function - you call it a "little function", not a "little void".

To call it a "void" is like Prince singing "Raspberry" or "Little Red"
smiley-roll-sweat Sorry oh master! I shall wash my keyboard and cleanse myself of this noobishness. Anyway, thanks for the help! If you spot anything else that can be improved, please do tell me!

I don't have a proper sensor yet(other teammembers are working on it), but when I do, I'll analyze which is the lowest acceptable division factor.
6  Using Arduino / Sensors / Re: How can I speed up the ADC? on: October 05, 2012, 08:19:57 am
Quote
uint8_t myAnalogRead(uint8_t pin)
{
   uint8_t low;//, high;
  
   // set the analog reference (high two bits of ADMUX) and select the
   // channel (low 4 bits).  this also sets ADLAR (left-adjust result)
   // to 0 (the default).

   /*mask ADMUX see http://www.atmel.com/Images/doc8161.pdf point 23.9!!!
          set refs1 and refs0 by shifting 3(high high) six bits to the left to use the internal voltage reference
          shift high to ADLAR to place the most significant bits in ADCH
          and then mask the last nibble with the channel of the pin
        */
        ADMUX = (0x3 << 6) | (1 << ADLAR) | pin;



   // start the conversion
   sbi(ADCSRA, ADSC);

   // ADSC is cleared when the conversion finishes
   while (bit_is_set(ADCSRA, ADSC));

   // we have to read ADCL first; doing so locks both ADCL
   // and ADCH until ADCH is read.  reading ADCL second would
   // cause the results of each conversion to be discarded,
   // as ADCL and ADCH would be locked when it completed.
   low  = ADCL;
   //high = ADCH;

   // read the high byte
   return ADCH;
}

Then in setup, you can also set the division factor to speed things up.
Quote
void setup()
{
  setDivisionFactor(128);
  
}

And for setting the division factor, I wrote this little void:
Quote
void setDivisionFactor(byte divisionFactor)
{
  switch(divisionFactor)
  {
    case 2 :
    cbi(ADCSRA, ADPS2);
    cbi(ADCSRA, ADPS1);
    sbi(ADCSRA, ADPS0);
    break;
    case 4 :
    cbi(ADCSRA, ADPS2);
    sbi(ADCSRA, ADPS1);
    cbi(ADCSRA, ADPS0);
    break;
    case 8 :
    cbi(ADCSRA, ADPS2);
    sbi(ADCSRA, ADPS1);
    sbi(ADCSRA, ADPS0);
    break;
    case 16 :
    sbi(ADCSRA, ADPS2);
    cbi(ADCSRA, ADPS1);
    cbi(ADCSRA, ADPS0);
    break;
    case 32 :
    sbi(ADCSRA, ADPS2);
    cbi(ADCSRA, ADPS1);
    sbi(ADCSRA, ADPS0);
    break;
    case 64 :
    sbi(ADCSRA, ADPS2);
    sbi(ADCSRA, ADPS1);
    cbi(ADCSRA, ADPS0);
    break;
    case 128 :
    sbi(ADCSRA, ADPS2);
    sbi(ADCSRA, ADPS1);
    sbi(ADCSRA, ADPS0);
    break;
  }
}


I hope someone turns all of this in a special analogReadspeedy or something like that and introduces it into the standard Arduino library!
7  Using Arduino / Sensors / Re: How can I speed up the ADC? on: October 05, 2012, 07:48:57 am
Thanks, I found it. With a lot of help from my teacher, I was able to fix it. I'll soon post myAnalogRead here, for people who want to speed things up on their uno or duemilanove smiley-wink
8  Using Arduino / Sensors / Re: How can I speed up the ADC? on: October 05, 2012, 06:28:24 am
Go to the source in "wiring_analog.c"

Sorry for being a huge noob, but where do I find the source?
9  Using Arduino / Sensors / Re: How can I speed up the ADC? on: October 05, 2012, 06:18:26 am
So how do I change the analogRead? I'm still a bit of a newbie, I haven't tinkered with existing instructions yet.
10  Using Arduino / Sensors / Re: How can I speed up the ADC? on: October 05, 2012, 05:52:27 am
Why do you feel you need to speed up the ADC?
Isn't getting on for 10000 conversions a second fast enough? (That's one conversion every 2/10th of a mm)

Quote
Now, it's just a simple black line so I don't need 10 bits of accuracy.
If it is a simple black line, why do you need any more than one bit?
I want to speed up the ADC, because it takes me about a milisecond to sample my entire sensor array. And I'm aiming for a cylce time of 4 ms (probably less) and I need every µs of that for the PID algorithm. That 4 ms cycle time results in sampling every cm(we have to be able to take turns with a 10 cm radius). I'll probably have to pick a faster µc than the 328, but I want to try if I can stretch it...

And I do need more than a single bit, because I want to be able to read a certain degree of grey, to interpolate  the position of the line between 2 sensors.
11  Using Arduino / Sensors / How can I speed up the ADC? on: October 05, 2012, 05:11:26 am
Hi everyone

I'm making a superfast(2 m/s smiley-eek) PID linefollower for school. Now, it's just a simple black line so I don't need 10 bits of accuracy. My teacher says I could change the accuracy of the ADC to 8 bit, but I don't know how to do that. He told me to look in the datasheet of the µC to see which internal register I need to change. But even IF I'd find that register, I still don't know the syntax to do it.

Does anyone know how I change the 10 bit to 8 bit? Please don't tell me to get an external ADC which is faster, that's the NEXT step. I want to measure the time it takes to sample my sensor array with 8 bits of accuracy.
12  International / Nederlands / Bluetooth problemen on: April 11, 2012, 09:06:02 am
Hallo iedereen

Ik heb een probleem met bluetooth, ik krijg verbinding met de arduino via processing. Ik wil echter ook mijn programma uploaden en serial monitoren via BT. HELP!
13  Using Arduino / Project Guidance / Re: Firetruck/linefollower schoolproject on: February 26, 2012, 12:06:28 pm
Also, I could really use some help with the Bluetooth to TCP/IP part... Anyone?
14  Using Arduino / Project Guidance / Re: Firetruck/linefollower schoolproject on: February 19, 2012, 03:20:42 pm
Quote
So: does anyone have tips, useable code,... Is our hardware choice any good? Are there some specific tutorials on H-bridges, bluetooth,...?

Instead of bluetooth, I'd go with a wireless router. Bluetooth has no chance of providing video from the bot, which would make control very difficult. 

That's where the prof's wit comes in, we HAVE TO use Bluetooth, because he doesn't want us to use a webcam... If we had a webcam, we wouldn't have to make sensors and make the car semi-autonomous... BTW: any tips on the linefollower part of the project? What's a good approach to that?
15  Using Arduino / Project Guidance / Firetruck/linefollower schoolproject on: February 17, 2012, 09:26:08 am
Hi everyone

I'm a bachelor-level student in electromechanics, with a specialization in automation. I'm in the second semester of the second year of my 3 year education. This semester, I have a group project. The basic idea is to make a reconnaissance robot for a fire situation. I'm looking for advice on this project and would like to find some code to recycle into my project.

Of course it's been dumbed down to a linefollower(using the exact same tiles as the Robocup junior,http://www.youtube.com/watch?v=LUvBfAmUm48&feature=fvst). The difference with this one is, when the robot comes at a green square, it has to stop and interface with the user. Then the user will choose which way the robot has to go. Also, we can't use Mindstorms whatsoever. To make it a firetruck, the robot has to notify the user when it detects a tea light. And it also has to produce an audible sound, but it doesn't have to extinguish the fire. To interface with the user, we have to communicate via bluetooth to a base station, which converts the signals to TCP/IP. From there, it goes to the user, who is "outside of the danger zone".

What concerns my experience: I'm completely new to Arduino(as are the other group members). However, we all have had a basic course in Visual Basic and Assembler(with the 80C51 µcontroller). On top of that, I've also taken a basic Java course 2 years ago. One of our team members also has quite a bit of experience with labview and programming.

So far, we've ordered the Arduino UNO Rev3, Bluetooth Mate - Silver, Barrel jack adapter - Male  and a breadboard(not an arduino specific board, just a plain bread board). We intend to use 2 DC motors(+gearbox) from a Nikko Landshark RC-car and to operate them with H-bridges. The car still runs fine, so I assume the motors are fine too.

So: does anyone have tips, useable code,... Is our hardware choice any good? Are there some specific tutorials on H-bridges, bluetooth,...?

Thanks in advance for your help! And please, NO trolling the noob. All of us started out a noob.
Pages: [1]