woensdag 31 oktober 2012

Primitive IR communication

The actual testprogram

In order to change the Ki,Kp,... values on our robot without touching it we had to establish a IR communication. The program of this communication need to answer automatically. After a long way of research en testing we were able to make a very basic program that reacted to a command by answering "Gelukt".

Here is the code for the robot


#include <SerialCommand.h>

#define arduinoLED 13   // Arduino LED on board

SerialCommand sCmd;     // The demo SerialCommand object


void setup()
{
  Serial.begin(2400);
 
  sCmd.addCommand("K", TestLoop); //test moet hoppa terugsturen
 // sCmd.setDefaultHandler(Fout);      // al de code niet herkend word stuurt hij "homo" terug
 
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);

  // Clear Timer on Compare Match (CTC) Mode
  bitWrite(TCCR1A, WGM10, 0);
  bitWrite(TCCR1A, WGM11, 0);
  bitWrite(TCCR1B, WGM12, 1);
  bitWrite(TCCR1B, WGM13, 0);

  // Toggle OC1A and OC1B on Compare Match.
  bitWrite(TCCR1A, COM1A0, 1);
  bitWrite(TCCR1A, COM1A1, 0);
  bitWrite(TCCR1A, COM1B0, 1);
  bitWrite(TCCR1A, COM1B1, 0);

  // No prescaling
  bitWrite(TCCR1B, CS10, 1);
  bitWrite(TCCR1B, CS11, 0);
  bitWrite(TCCR1B, CS12, 0);

  OCR1A = 210;
  OCR1B = 210;

 
}

void loop() {
 sCmd.readSerial();
}

void TestLoop() {
  Serial.println("R");
}


If this code receives the character "K" it writes "R" back to the PC via the IR communication. The PC processes it further as you can see below.


And the code for the computer:

#include <SerialCommand.h>

#define arduinoLED 13   // Arduino LED on board

SerialCommand sCmd;     // The demo SerialCommand object


void setup()
{
 
  sCmd.addCommand("V", VerzendLoop);
  sCmd.addCommand("R", OntvangLoop);

 
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);

  // Clear Timer on Compare Match (CTC) Mode
  bitWrite(TCCR1A, WGM10, 0);
  bitWrite(TCCR1A, WGM11, 0);
  bitWrite(TCCR1B, WGM12, 1);
  bitWrite(TCCR1B, WGM13, 0);

  // Toggle OC1A and OC1B on Compare Match.
  bitWrite(TCCR1A, COM1A0, 1);
  bitWrite(TCCR1A, COM1A1, 0);
  bitWrite(TCCR1A, COM1B0, 1);
  bitWrite(TCCR1A, COM1B1, 0);

  // No prescaling
  bitWrite(TCCR1B, CS10, 1);
  bitWrite(TCCR1B, CS11, 0);
  bitWrite(TCCR1B, CS12, 0);

  OCR1A = 210;
  OCR1B = 210;

  Serial.begin(2400);
}

void loop() {
 sCmd.readSerial();
}

void OntvangLoop(){
  Serial.println("Gelukt");
}

void VerzendLoop() {
  
  Serial.println("K");
}



If this code receives the caracter "R" and prints "Gelukt" on the serial monitor.

This is a film that tests this project. Please don't mind the language. It's Dutch, we are form Belgium an that is our native language (obviously....)


Short history and information


This communication took us a while to figure out.

At first we discovered the program dirt cheap wireless. This program allowed us to make a 38kHz carrier wave for our led. This meant that we could now successfully modulate the signal to the correct frequency.The program made us (me for the most part) curious. I wanted to know how the set-up managed to create a carrier wave with exactly the right frequency. After I researched the timers on the data sheet of the ATmega I discovered how it al works an I also could make the mathematical link from the 16MHz crystal and the 38kHz carrier wave made by dirt cheap wireless.
Thanks to this knowledge I was able to modify the setup to someting we could use with the 20MHz crystal.

The second thing we discovered was the SerialCommand library. This library allowed us to make commands which, if send over the serial port, would take the program into a specific loop. The library also contained a function that made it possible to process a number send with the initial command.
After a little research on this library I was able to make the test program you can see above. After further research I was able to write loops that could process numbers.

After I put all of this research together in one program I was able to establish a fully working infrared communication on our microcontroller.


Your blogmeister
Giete





woensdag 24 oktober 2012

calculating the minimum sample frequency of our microcontroller

When our robot aproaches a corner, he have to sample in time his sensors so he doesn't miss the corner and just go further in a straight line. So first we calculate the time that the robot needs to miss the corner. A diagram of this situation is shown below.

Data:

radius: 0,1m
line thickness: 0,015m
thickness sensors: 0,07m

X1= 0,1m –  (0,07/2) = 0,065m

Y= tan(53°) x 0,065 = 0,08625m

 Time needed so the robot leaves the black line at 2m/s

S = V x t
t = S / V

t = 0,08625 / 2 = 0,043125s
or = 43,12 ms

How more we can sample in these 43.12 ms, how better our robot will drive trough the corners. We can't tell how much we will sample because we have no idea how big our program will be for the PID regulation. We hope to sample 10 times in those 43.12 ms, that corresponds to a sample at each 1.5cm of the corner.


greetz 
Stef Ingels




woensdag 17 oktober 2012

pin lay-out h-bridge

dear friends

Here some information about our h-bridge. The pin lay-out is given in the below diagram:



The pin numbers with their function and a bit information about the connection can be find in the table below:



For more information about the h-bridge, go to:

http://www.farnell.com/datasheets/389117.pdf


greets 

Stef Ingels

In addition to this post I would like to present to you the testfilm of the h-bridge that Stef Ingels and I made.



This video shows you a test program that allowes me to change the speed of the engines. It also showes that the h-bridge works perfectally.

Its in Dutch, sorry but we are from Belgium.. I'm not saying to difficult things. Its mostly like 'I'm now changing the speed' but you can obviously hear that.

Thanks for watching

Giete

zaterdag 13 oktober 2012

What microchip do we need?

Dear reader


We were asked to make an 'educated guess' in how fast our microchip needed to be.


In a project last year we used the atmega 328chip. We think that this chip is suitable for our PID line follower. The chip we used then was mounted on a arduino board. The good thing about this is that we can test our software more easily thanks to the arduino's at our disposal. When we have a finished and working program we should be able to upload it into our SMD atmega328 chip.

We need a microchip that is powerful enough to handle all the calculations. The 20Mhz clock speed of the atmega328 should do the job.

As for the I/O, the atmega has a maximum of 23I/O pins. This is more than enough for our project.

We don't know yet how big the program will be but we figure the the available 32kbytes EEPROM memory will be more than enough.

Thanks to the fact that the bootloader of arduino is easy to find we can use the arduino software to program our line follower. It should be easy programmable with this program software. This high(er) program language is easier to use than a low program language and allows us to write more difficult programs.
(The bootloader can be found at http://www.arduino.cc/en/Hacking/Bootloader)

As for the price, the atmega328-AU cost us 4.19 Euro (about 5.5USD).

Your Blogmeister
Giete



vrijdag 12 oktober 2012

Hello dear reader,

Yesterday we made a video of our ir communication as it is at the moment.
Its basicaly the same program as found here:
http://tthheessiiss.wordpress.com/2009/08/05/dirt-cheap-wireless/

with the only difference in the sendprogram is that we don't write "TESTING TESTING TESTING" every 500ms
In our program we changed that part so the arduino will send what we tell it to trough his serial port

this is the modified sendprogram:
//dirt cheap wireless TX
//generates 38kHz carrier wave on pin 9 and 10
//sends data via TX every 500ms

char incomingByte;
void setup()
{
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);

  // Clear Timer on Compare Match (CTC) Mode
  bitWrite(TCCR1A, WGM10, 0);
  bitWrite(TCCR1A, WGM11, 0);
  bitWrite(TCCR1B, WGM12, 1);
  bitWrite(TCCR1B, WGM13, 0);

  // Toggle OC1A and OC1B on Compare Match.
  bitWrite(TCCR1A, COM1A0, 1);
  bitWrite(TCCR1A, COM1A1, 0);
  bitWrite(TCCR1A, COM1B0, 1);
  bitWrite(TCCR1A, COM1B1, 0);

  // No prescaling
  bitWrite(TCCR1B, CS10, 1);
  bitWrite(TCCR1B, CS11, 0);
  bitWrite(TCCR1B, CS12, 0);

  OCR1A = 210;
  OCR1B = 210;

  Serial.begin(2400);
}

void loop()
{
  if (Serial.available()>0) {
    incomingByte = Serial.read();
  Serial.print(incomingByte);
  }
}

marked red is the loop we changed.

Now we have a one way communication.
The next step would be having the arduino answer something as a response ,such as message received.
To test this out we tried to send back what we received.
Then we had the folowing problem, the message was sent back but because the sender receives the message at his RX-pin, the same pin we use to send commands from our pc to the arduino.
the message that was send back was seen as a command from the pc.. a command to send..
this way we made a loop without end.
another problem is as you will see in the video below is that we receive a certain amount of noise, we keep receiving ÿ in between messages.
We'll have to think about something to filter this out of the data and will probably use a startcharacter and an endcharacter in our message to do this.
Note that the noise is never inside data,its only when no data is being sent.

Link to video:
http://www.youtube.com/watch?v=PKneGq5Sy34

The schematics can be found at dirtcheapwireless,the first link.


woensdag 10 oktober 2012

Assignments + part list [NEW]

Dear readers



We had a second meeting with our teacher on monday.
In this meeting he asked us to:
1) Put our calculations on the blog (that is already done by Stef Ingels)
2) Make an electrical scheme for the PCB we will make. I will do that myself en hope to finish it by or in the coming weekend.
3) Finish our IR transmit and receive software (and put this on the blog with a explanation)
4) Put our parts list on the blog

Here is the result of the fourth assignment:




Part Price Amount Price total Website
Front 'wheel' 4,69 1 4,69 http://www.pololu.com/search?query=954&x=9&y=4
Engine + Gearbox 12,34 2 24,68 http://www.pololu.com/catalog/product/999
Rear Wheels 6,15 1 6,15 http://www.pololu.com/search?query=1420&x=0&y=0
Transistors 0,25 8 2 http://be.farnell.com/fairchild-semiconductor/bc547b/transistor-npn-to-92/dp/1017673
Battery holder 0,92 1 0,92 http://www.pololu.com/search?query=1145&x=9&y=7
Microcontroller 4,19 1 4,19 http://be.farnell.com/atmel/atmega328-au/mcu-8bit-avr-32k-flash-32tqfp/dp/1972086?Ntt=1972086
H-bridge 2,97 1 2,97 http://be.farnell.com/rohm/bd6225fp-e2/h-bridge-driver-18v-0-5a-hsop25/dp/1716263
Resistors 22kohm 0,21 8 1,68 http://be.farnell.com/te-connectivity-cgs/352022kjt/resistor-1-watt-22k-5/dp/1265186
Resistors 680ohm 0,21 8 1,68 http://be.farnell.com/te-connectivity/3521220rft/resistor-2512-2w-220r-1/dp/2117486?Ntt=2117486
IR LED 940nm  0,95 16 15,2 http://be.farnell.com/knowledge-on/kel5002a-a/ir-emitter-5mm-940nm/dp/4890929
Christal 0,37 1 0,37 http://be.farnell.com/abracon/abl-20-000mhz-b2/crystal-20m-18pf-cl-hc49-4h/dp/1611779
Jumpers 0,12 2 0,24 http://www.gotron.be/kortsluitjumper-p2-54.html
Spanningsregelaar 4,92 1 4,92 http://be.farnell.com/national-semiconductor/lp2954ait/ic-v-reg-ldo-5-0v-2954-to-220-3/dp/9494847
Capacitors 1µF 0,26 1 0,26 http://be.farnell.com/avx/08053c105k4z2a/capacitor-0805-x7r-25v-1uf/dp/1833845
Capacitors 2,2µF 0,7 1 0,7 http://be.farnell.com/avx/08053c225kat2a/capacitor-2-2-uf-25v-0805-x7r/dp/1657931
Capacitors 22pF 0,13 2 0,26 http://be.farnell.com/avx/08051a220jat2a/capacitor-0805-22pf-100v/dp/317500



As you can see I kept the number of suppliers as low as possible. This reduces transportation costs which makes the finished product cheaper. It also makes it easier to order, you don't have to visit a lot of different sites. 

I will make the electrical scheme with a program called 'eagle'. I will post the file and a screen shot later this week.

As for out joint venture, as Stef VP said earlier we would take the IR communication an the other team the sensors. Rene will post a short message about the sensors later on.

Your Blogmeister
Giete


(Tis list has been updated on 26/11/2012)


























































calculating the wheels, engine, gearbox and h-bridge

dear friends

I had the assignment to calculate al the specifications considering the engines, gearboxes, wheels and h-bridge of our robot. First we had to chose our wheels. Our chose went to the pololu wheels (60mm x 8mm).
Now we can calculate the speed that the engines need, to drive at a topspeed of 2 m/s.
circumference: 0.06*3.1415 = 0.18849 m
RPM / meter : 1 / 0.18849 = 5.305
so for 2 m/s we find: 5.305 * 2 * 60 = 636.6 RPM

Second we calculate the torque that the engines minimum need to drive at 2 m/s.
We want the robot to accerelate in 2s to the topspeed of 2 m/s and the weight of the robot is calculated about 0.3 kg.

a= v/t    => a= 2 m/s / 2s = 1 m/s²

F= m*a     => F= 0.3kg * 1m/s² = 0.3 N

T= F*r      => T= 0.3N * 0.03m = 0.009Nm = 0.9Ncm

So the engine we search needs al least a torque of 0.9Ncm and a speed of +- 630 RPM. These values are calculated in free-run. To make sure that the engines we order are strong en fast enough, we will order an engine that is faster and has more torque than calculated. We can chose out of 2 engines:

-> 30:1 Micro Metal Gearmotor HP  ( 1000 RPM and 9 oz-in, stall current 1600mA )
-> 10:1 Micro Metal Gearmotor        ( 1300 RPM and 2 oz-in, stall current 360mA )

The first engine ( 30:1 Micro Metal Gearmotor HP) has a good speed, but the torque that he can generate is very high. this causes that the stall current is (to) high. Also the wheels of the robot will spin with such a high torque.

The second engine (10:1 Micro Metal Gearmotor) has a rather high speed, but the torque of the engine is good for our robot (2 oz-in  ->   1.4123 Ncm). This is a bit more than calculated, but will have no significant causes for us.

We have chosen for the 10:1 Micro Metal Gearmotor. The decisive was the good torque and the much lower stall current of the engine. The speed of the engine can we regulate later with our microship.
10:1 Micro Metal Gearmotor


 data about the motor:
- torque                                            1.4123 Ncm
- speed                                             1300 RPM
- stall current:                                    360 mA
- free-run current                               40 mA
- weight                                             9.63 g
- ratio                                                10:1
- size                                                 24*10/12 mm

The torque of 1.4123 Ncm gives us an accerelation of:

F= M/r  => F= 1.4123Ncm / 3cm = 0.470N

a= F / m  => a = 0.470N / 0.3kg = 1.567 m/s²

In 1.27s we go to our topspeed of 2 m/s

Now we have chosen our DC motor, we can further on by searching a good H-bridge. The stall current of our engine is 360 mA. This  value is important for the choise of our h-bridge. The output current of our h-bridge must be higher than 360 mA.
Our choise went to the l 293D h-bridge, it is al frequently used h-bridge witch we already worked with last year.

Summarized:

-> WHEELS: pololu (diameter 60mm x 8 mm)

-> ENGINE: pololu, 10:1 Micro Metal Gearmotor, ( 1300 RPM and 2 oz-in, stall current 360mA )

-> GEARBOX: pololu, ratio of 10:1, in 2 stages (comes together with the engine)

-> H-BRIDGE: L 293D, output current +- 1A


With these calculations guillaime can finish the part list and order the products we need. I hope that we will recieve them as soon as possible. So we can go on testing en designing our robot.

Greets

Stef Ingels







maandag 8 oktober 2012

Today we worked on the IRcommunication.
We tried to use the same IR library as we used in a previous project,but this didn't seem ideal for this kind of application.
the sent signal was converted into a code wich didn't make a lot of sense,it was good for remote control of a few function but not for actual communication.
Then we tried the example from this website: 
We modified some minor details so we could just type in a message in the serial monitor of arduino to send.
This way we made a kind of chat system between 2arduino's.
After messing around a bit with this new toy we quickly found out that when no messages were send we would pick up noise, mostly the character ÿ.
This didn't interfere with the message itself but could form a problem when we are sending several commands.
Therefor is our next challenge to make some kind of start/stop-byte/char to detect the start and end of the message.
Stef VP

zondag 7 oktober 2012

Dear Reader,

Thursday we had a meeting with our teacher together with 2 other groups.
He gave us 3 jobs:
Make a demonstration where you use IR to communicate between 2 arduino's.
Make a demonstration where you use IR leds to detect white or black.
Make a demonstration where you use normal lightsensors to detect white or black.
Compare the results from the IR test and the lightsensor test to decide whats the best choice.

We got a bit depressed by all this work so we teamed up with the other groups.
By monday we'll make the communication with IR since we had some experience with this from a previous project.
The other groups would make the sensor test because they already made a linefollower with similar sensors.

The next update on this will probably come monday.

Stef VP

woensdag 3 oktober 2012

hello dear friends

Special thanks to giete to invite me to this blog. Now the team is complete, we can start.
It will be al hell of a job but I'm sure we can make it work!

See you later

Stef Ingels
Dear Bloggers


Just ended meeting two. We are restricted to a 50 Euro budget (this budget is only for the finished robot itself, testing en testing parts are not included). This budget is far to small for this kind of project I think.
In this meeting we made up a parts list, in total we would be paying 48 Euro. And we might not have everything yet. The list has yet to be approved by our teacher... Maybe he has a hint or two to cut down our costs.

We are getting most of the parts on www.pololu.com. If anyone has a better proposal (by better I mean cheaper) than your proposals are most welcome. Shipping costs don't matter ;)

Your Blogmeister
Giete

dinsdag 2 oktober 2012

Just joined our blog,
For the random strangers that stumble upon this blog,this will be about a project from school.
We have to make a linefollower that will follow a line using PID
Variables such as Kp,Ki and Kd must be sent wireless to the linefollower.
Today we'll have a second meeting and try to find fitting sensors,wheels,motors gearboxes and a microcontroller.

Stef VP

Eerste vergadering

Beste bloggers


Bij deze vind de eerste vergadering plaats.
Te doen deze vergadering:
-Een blog aanmaken
-Opdracht bespreken
-Eerste stukkenlijst samenstellen

Uw blogmeister
Giete