woensdag 21 november 2012

prototype in solid works

hello

I've created a prototype of our robot in 3D, in solid works. Al the components are on it. The black box is the battery holder, therefore is the print with the microcontroller and in the front the print with the sensorarray. We use the drawning to have an idea of the design of our robot.







greets stef

vrijdag 16 november 2012

dear friends

Previous lesson the teacher mentioned a problem about our batteries. We use 4 times AA batteries,
so: 4 x 1.5V =6V. We need the 6V for our motors, and we convert the 6V to 5V to feed our microcontroller and h-bridge. But these are the values in perfect conditions. If the batteries are a few minutes in use, and has lost some power, it could be that we only have 4x1.2V = 4.8V left. This situation will cause problems. So there are a few solutions, we summarize 3:

1. In place of converting the 6V to 5V, we can also convert it to 3.3V. This will give no problem for our microcontroller, but our h-bridge needs to be feed with 5V. So we have to place another h-bridge. In the worst case scenario (4 x1.2V=4.8V) we also have not enough voltage for our DC motors. So the problem is not completly solved out.

2. We can also use a DC-DC convertor, it will convert the voltage we get from the batteries to the wanted 5V. We can buy a DC-DC convertor in an ic, but they are very expensive. An other solution is to make the circuit ourself. But this will cost us a lot of space on our print, space we don't have.

3. The last solution is to place 6 batteries instead of 4, then we have in perfect conditions 9V, and about 7.2V (6 x 1.2V) in the worst situation. On our print we have a high class voltage convertor who can convert these voltages to 5V. The voltage for our h-bridge and microcontroller is already insured.
Now is the problem that the motors get in the worst situation 9V, which is 3V to much. In fact it's not a big problem, because we are forced to use PWM (pulse width modulation). Our motors will run in freewheel at 4m/s, but the top speed only need to be 2m/s. So it's necessary to use PWM to lower the voltage and speed of the motors. With this in mind, the voltage of the motors will never be a lot higher then the allowed 6V.

The easiest and cheapest solution will be the third, place 6 batteries instead of 4. Another advantage is that the robot will lasts longer without chance the batteries. It seems quit clear that we go for the third solution.

greets
Stef

maandag 12 november 2012

Dear readers,


The following post will show you the completed version of two eagle drawings. You need these to make the PCB's needed for the line follower. There is one for the microcontroller and one for the sensorarray.


This is the one with microcontroller, HBridge,....






This is the sensor array




Your blogmeister
Giete




donderdag 8 november 2012

To detect the line we plan to use 8 lightsensors
Because every sensor got its own property's we have to calibrate them to determine what value the sensor gives when he sees black or white
The program to do this can be found at our colleague's blog : http://3autothespoilers.blogspot.be/

after the sensors are calibrated the value's should be put in our program:
this is an example on 6sensors


void setup(){
Serial.begin(2400);
}

void loop() {
  int sensors[6]={0,0,0,0,0,0};
  int witwaarden[6]={0,0,0,0,0,0};
  int zwartwaarden[6]={0,0,0,0,0,0};
  int i;
  int pin;
  int afwijking=0;
  int total=0;
  int teller=0;
  //read the value's from the analog pins
  for (i=0;i<6;i++){
  pin =A0+i;
  sensors[i]=analogRead(pin);
}
 //put the sensor value's in a range from 0-100
 for (i=0;sizeof(sensors);i++){
 sensors[i]=((sensors[i]-zwartwaarden[i])/(witwaarden[i]-zwartwaarden[i]))*100;
 }
 //calculate the position of the line
for (i=0;sizeof(sensors);i++){
  total=total+sensors[i];
}
teller =(sensors[0]*-25)+(sensors[1]*-15)+(sensors[2]*-5)+(sensors[3]*5)+(sensors[4]*15)+(sensors[5]*25);
afwijking=teller/total;
}



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