Vous êtes sur la page 1sur 6

1.

Trace the road We can devide our map into three main regions : the black zone ( with white road), the white zone (with black road) and the change zone ( from black to white or from white to black). For each zone, we have different argorithms to trace the road. 1.1 The Black zone In the white zone, the robot have seven main state of sensors as I show in image 1.1

Image 1.1 In the black zone State 1 : 0-1-0 In this state, the robot will go straight State 2 : 0-1-1 As you saw in the picture, in this situation, the robot need to turn right in the small speed State 3 : 0-0-1

In this status, robot are going out of the way so that it need to turn right at the hight speed State 4(7) : 1-1-1 The robot will keep its direction in this state State 5 : 1-1-0 The robot will turn left at small speed in this situation State 6 : 1-0-0 Turning left at hight speed will help robot coming back to the right way 1.2 The White zone In the white zone, robot have some states like you see at image 1.2

Image 1.2 In the White zone The same as black zone, we have different trend for each state of sensors State 1: 1-0-1 go straight State 2 : 1-0-0 turn right at low speed

State 3: 1-1-0 turn right at hight speed State 4(7) : 1-1-1 keep trend State 5: 0-0-1 turn left at low speed State 6: 0-1-1 turn left at hight speed 1.3 The change zone 1.3.1 From white zone to black zone

Image 1.3.1 From white zone to black zone In this situation we take the steps below : 1 ) Set flag=1(exist in 4 seconds) when robot are in state 1-1-1 (change zone) 2) Wait for state 0-1-0 or 0-0-0 3) When state equal 0-1-0 or 0-0-0 : Set status equal black_zone ( robot are in black zone now) 4) If state equal 0-0-0 : Set flag equal 3 (exist in 3 seconds) and turn left

5) 3 seconds after turning left if state= 0-0-0 => turn right 1.3.2 From black zone to white zone

Image 1.3.2 From black zone to white zone 1) If state equal 1-1-1 and status equal black_zone : Set flag=2(in 2s) and status qual white_zone And dont let robot turn right 2) If the sensors touch the road It can find the right way else after 2 seconds, when flag changes from 2 to 0, TURN LEFT 2. Play music with eeprom To play music, we need to know about the frequency of each tone in a melody. The table below show the frequency of some notes in music.

Table 2.1 Frequency of tones


Notes A A# B C C# D D# E F F# G A 55.00 110.00 220.00 58.27 116.54 233.08 61.74 123.48 246.96 65.41 130.82 261.64 69.30 138.60 277.20 73.42 146.84 293.68 77.78 155.56 311.12 82.41 164.82 329.64 87.31 174.62 349.24 92.50 185.00 370.00 98.00 196.00 392.00 103.83 207.66 415.32 Frequency (octaves) 440.00 466.16 493.92 523.28 554.40 587.36 622.24 659.28 698.48 740.00 784.00 830.64 880.00 932.32 987.84 1046.56 1108.80 1174.72 1244.48 1318.56 1396.96 1480.00 1568.00 1661.28

From this table, we will convert frequency to ech tones cycle. We can create a note with a specific cycle by using timer 0 in Pic16f84a.

Image 2.1 The cycle of each note In a melody, each note need to be played for a time. We did this task by using timer0 overflow interrupt to count for the notes duration

Image 2.2 The duration of notes

A melody have some notes with its duration. In our project, we saved notes in order in EEPROM and set its time in the code. When we start to play music, we take note from EEPROM and set the duration of it.

Image 2.3 Play music from EEPROM

Vous aimerez peut-être aussi