|
|
Elektronika.lt portalo forumas
Jūs esate neprisijungęs lankytojas. Norint dalyvauti diskusijose, būtina užsiregistruoti ir prisijungti prie forumo.
Prisijungę galėsite kurti naujas temas, atsakyti į kitų užduotus klausimus, balsuoti forumo apklausose.
Administracija pasilieka teisę pašalinti pasisakymus bei dalyvius,
kurie nesilaiko forumo taisyklių.
Pastebėjus nusižengimus, prašome pranešti.
Dabar yra 2025 01 01, 18:29. Visos datos yra GMT + 2 valandos.
|
|
|
|
Forumas » Mikrovaldikliai » del programos kodo
|
Jūs negalite rašyti naujų pranešimų į šį forumą Jūs negalite atsakinėti į pranešimus šiame forume Jūs negalite redaguoti savo pranešimų šiame forume Jūs negalite ištrinti savo pranešimų šiame forume Jūs negalite dalyvauti apklausose šiame forume
|
|
|
|
|
|
del programos kodo |
Parašytas: 2008 04 01, 19:39 |
|
|
|
sveiki, dariau robota pagal straipsni "99 botas" turejau namuose atmega16 tad ja naudoju, tap pat neturejau servo varikliu, tai panaudojau paprastu variklius su h-bridge'u. prie 19 ir 18 koju jungiau IR ledus o prie 16 ir 17 tsop1738, prie 22,23,24,25 koju jungiu h-bridge'a kuris valdo du variklius.
teko keist koda, pakeiciau taciau neveikia.. gal kas suprantat basic kalba ir galetu man paaiskinti?
programos kodas:
'Tell the compiler which AVR chip we use
$regfile = "m16def.dat"
'Tell the compiler which crystal frequency was used
$crystal = 10000000
Declare Sub Left_blink
Declare Sub Right_blink
Declare Sub Go_forward
Declare Sub Go_back
Declare Sub Go_left
Declare Sub Turn_left
Declare Sub Go_right
Declare Sub Turn_right
Declare Sub Stop_it
Declare Sub Back_left
Declare Sub Back_right
Dim Led_on As Byte , Led_off As Byte
Dim Object As Byte , I As Byte
Const No_object = 0
Const Right_object = 1
Const Left_object = 4
Const Center_object = 5
Compare1a = 131
Compare1b = 131
Config Pind.3 = Input 'LEFT RECEIVER OUTPUT
Config Pind.2 = Input 'RIGHT RECEIVER OUTPUT
Config Portc.0 = Output
Config Portc.1 = Output
Config Portc.2 = Output
Config Portc.3 = Output
Enable Interrupts
Do
Left_blink
Right_blink
If Object = No_object Then
Go_forward
Elseif Object = Right_object Then
Turn_left : Waitms 200
Elseif Object = Left_object Then
Turn_right : Waitms 300
Elseif Object = Center_object Then
Go_back : Waitms 200 : Turn_right : Waitms 200
End If
Object = 0
Loop
End
Sub Left_blink
Led_on = 0 : Led_off = 0
For I = 1 To 5
Config Timer1 = Timer , Prescale = 1 , Compare A = Toggle , Compare B = Clear , Clear Timer = 1
Waitus 600
Led_on = Led_on + Pind.3
Config Timer1 = Timer , Prescale = 1 , Compare A = Clear , Compare B = Clear , Clear Timer = 1
Waitus 600
Led_off = Led_off + Pind.3
Next I
If Led_on = 0 And Led_off = 5 Then
Object = Left_object
End If
'===============================================================================================
Waitms 10 'THIS IS THE MINIMUM POSSIBLE VALUE
'===============================================================================================
End Sub
Sub Right_blink
Led_on = 0 : Led_off = 0
For I = 1 To 5
Config Timer1 = Timer , Prescale = 1 , Compare A = Clear , Compare B = Toggle , Clear Timer = 1
Waitus 600
Led_on = Led_on + Pind.2
Config Timer1 = Timer , Prescale = 1 , Compare A = Clear , Compare B = Clear , Clear Timer = 1
Waitus 600
Led_off = Led_off + Pind.2
Next I
If Led_on = 0 And Led_off = 5 Then
Object = Object + Right_object
End If
'===============================================================================================
Waitms 10 'THIS IS THE MINIMUM POSSIBLE VALUE
'===============================================================================================
End Sub
Sub Go_forward
Portc.0 = 1
Portc.1 = 0
Portc.2 = 1
Portc.3 = 0
End Sub
Sub Go_back
Portc.0 = 0
Portc.1 = 1
Portc.2 = 0
Portc.3 = 1
End Sub
Sub Stop_it
Portc.0 = 0
Portc.1 = 0
Portc.2 = 0
Portc.3 = 0
End Sub
Sub Go_left
Portc.0 = 0
Portc.1 = 0
Portc.2 = 1
Portc.3 = 0
End Sub
Sub Turn_left
Portc.0 = 0
Portc.1 = 1
Portc.2 = 1
Portc.3 = 0
End Sub
Sub Go_right
Portc.0 = 1
Portc.1 = 0
Portc.2 = 0
Portc.3 = 0
End Sub
Sub Turn_right
Portc.0 = 1
Portc.1 = 0
Portc.2 = 0
Portc.3 = 1
End Sub
Sub Back_left
Portc.0 = 0
Portc.1 = 1
Portc.2 = 0
Portc.3 = 0
End Sub
Sub Back_right
Portc.0 = 0
Portc.1 = 0
Portc.2 = 0
Portc.3 = 1
End Sub |
|
|
|
|
|
|
del programos kodo |
Parašytas: 2008 04 01, 20:32 |
|
|
|
basik nesuprantu todel biski ne i tema ppaklausiu pagal koke schema darei h bridge ir kokie varikliai |
|
|
|
|
|
del programos kodo |
Parašytas: 2008 04 01, 20:46 |
|
|
|
variklius islupau is masineles, h-bridge'as irgi prie ju buvo.. jis valdomas per keturis kontaktus. galeciau pabandyt nupaisyt schema, bet ten vistiek neaiskus tranzistoriai(NEC berods) |
|
|
|
|
|
|
Google paieška forume |
|
|
Naujos temos forume |
|
|
FS25 Tractors
Farming Simulator 25 Mods,
FS25 Maps,
FS25 Trucks |
|
ETS2 Mods
ETS2 Trucks,
ETS2 Bus,
Euro Truck Simulator 2 Mods
|
|
FS22 Tractors
Farming Simulator 22 Mods,
FS22 Maps,
FS25 Mods |
|
VAT calculator
VAT number check,
What is VAT,
How much is VAT |
|
LEGO
Mänguköök,
mudelautod,
nukuvanker |
|
Thermal monocular
Thermal vision camera,
Night vision ar scope,
Night vision spotting scope |
|
FS25 Mods
FS25 Harvesters,
FS25 Tractors Mods,
FS25 Maps Mods |
|
Dantų protezavimas
All on 4 implantai,
Endodontija mikroskopu,
Dantų implantacija |
|
FS25 Mods
FS25 Maps,
FS25 Cheats,
FS25 Install Mods |
|
GTA 6 Weapons
GTA 6 Characters,
GTA 6 Map,
GTA 6 Vehicles |
|
FS25 Mods
Farming Simulator 25 Mods,
FS25 Maps |
|
ATS Trailers
American Truck Simulator Mods,
ATS Trucks,
ATS Maps |
|
|
|