Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you convert this jal code to micro c? for obstacle avoiding robot. pic16f628a -- Pinlerin giri k olarak tanmlanmas pin_a0_direction = input -- sag

Can you convert this jal code to micro c? for obstacle avoiding robot.

pic16f628a

-- Pinlerin giri k olarak tanmlanmas pin_a0_direction = input -- sag r pin_a1_direction = output -- sag al pin_a2_direction = output -- sol al

pin_b0_direction = output -- sag algland k pin_b1_direction = output -- sol algland Led pin_b2_direction = input -- sag algland Led pin_b3_direction = input -- sol algland k pin_b4_direction = output -- sag algland k pin_b5_direction = output -- sol algland Led pin_b6_direction = output -- sag algland k pin_b7_direction = output -- sol algland Led

-- Kullanlan deikenlerin tanmlanmas var byte sol,sag , i ,con

-- sol ve sagdan gnderilen sinyaller iin yazlm 38 Mhz lik sinyal reten modller procedure module_1ms_sol ( byte in x ) is for x loop for 38 loop assembler bsf port_a , 1 -- kare dalge eklinde sinyal reten ksm nop nop nop bcf port_a , 1 nop nop nop end assembler end loop end loop end procedure

procedure module_1ms_sag ( byte in x ) is for x loop for 38 loop assembler bsf port_a , 2 -- kare dalge eklinde sinyal reten ksm nop nop nop bcf port_a , 2 nop nop nop end assembler end loop end loop end procedure

-- Modlleri kullanarak retilen siyallerin dnp dnmediin sayan prosedrler procedure sol_say is i = 0 for 3 loop module_1ms_sol ( 2 ) if pin_a0 == low then i = i + 1 end if end loop sol = i end procedure

procedure sag_say is i = 0 for 3 loop module_1ms_sag ( 2 ) if pin_a0 == low then i = i + 1 end if end loop sag = i end procedure

port_b = 0x00 -- b portunun temizlenmesi con = 1 -- kontrol deikeninin balang deeri atamas -- bu deiken yarm kalan dnlerde aracn ikilem yaamamas ilk -- balad ynde dne devam etmesini salamak amacyla kullanlr

forever loop -- sonsuz dng balangc

sag_say sol_say -- sag ve sol IR lerin taramas yaplyor

if sag > 5 & sol > 5 then -- eer iki taraftada engel varsa if con == 1 then -- nceden herhangi bir tarafa dnyorsa o taraftan dnmeye devam et pin_b0 = high -- 0 ve 1 pinleri klar iin pin_b1 = high -- 4 ve 5 sol motor 6 ve 7 sa motor iin kullanlmtr pin_b4 = low pin_b5 = high pin_b6 = high pin_b7 = low delay_1ms -- motorlarn alt sre pin_b6 = high pin_b7 = high delay_10ms -- sag motorlar durdu demekki 2 eld grmeden nce sadece solda engel var sol motorlar devam ediyor pin_b4 = low pin_b5= low delay_10ms ( 6 ) -- sol motorlarda durdu, VE 60 ms iki motrorda duruyor. BZM FARKEDEMEDMZ BU SRE MOTORU YAVALATIYOR. else -- benzer ynlendirme ilemleri her adm iin geerlidir. pin_b0 = high pin_b1 = high pin_b4 = low pin_b5 = high pin_b6 = high pin_b7 = low delay_1ms pin_b4 = high pin_b5 = high delay_1ms pin_b6 = low pin_b7= low delay_10ms ( 6 ) end if elsif sol > 5 then -- sadece solda engel var ise con = 1 pin_b0 = high pin_b1 = low pin_b4 = low pin_b5 = high pin_b6 = high pin_b7 = low delay_1ms pin_b6 = high pin_b7 = high delay_1ms ( 30 ) pin_b4 = low pin_b5= low delay_10ms ( 6 ) elsif sag > 5 then -- sadece sagda engel var ise con = 2 pin_b0 = low pin_b1 = high pin_b4 = low pin_b5 = high pin_b6 = high pin_b7 = low delay_1ms pin_b4 = high pin_b5 = high delay_1ms ( 30 ) pin_b6 = low pin_b7= low delay_10ms ( 6 ) else -- hi engel yok ise dz git. pin_b0 = low pin_b1 = low pin_b4 = low pin_b5 = high pin_b6 = high pin_b7 = low delay_1ms ( 40 ) pin_b4 = high pin_b5 = high pin_b6 = low pin_b7= low delay_1ms -- Burada ise 1 ms gecikme konarak aracn dz giderken daha hzl gitmesi salanmtr. end if end loop

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What are the determinants of cash cycle ? Explain

Answered: 1 week ago