RE:From Basic PIC Pro to Mikro C

Status
Not open for further replies.

rylmv

Newbie level 1
Joined
Nov 26, 2012
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,286
RE:From Basic PIC Pro to Mikro C

Dear Sir

I need help from converting Basic PIC Pro to MikroC language. I've tried many times to solve but i couldnt. Is it possible to help me out? I've tried reading Basic PIC Pro coding but i couldnt follow up.
The coding are:

Code:
DEFINE OSC 8

DEFINE LCD_DREG PORTD;
DEFINE LCD_DBIT 4;
DEFINE LCD_RSREG PORTC;
DEFINE LCD_RSBIT 4;
DEFINE LCD_EREG PORTD;
DEFINE LCD_EBIT 3;
DEFINE LCD_RWREG PORTD;
DEFINE LCD_RWBIT 2;

//Define ADCIN Parameters
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 50
ADCON1=%10000010
TEMP1 VAR WORD

TRISB=%00000000
TRISD=%00000011
TRISC=%11101100
ADCON1=%10000010

SET1=300
SET1 VAR WORD
ADCVA1 VAR WORD
LEFT_FWD VAR PORTB.3
LEFT_REV VAR PORTB.4
RIGHT_FWD VAR PORTB.2
RIGHT_REV VAR PORTB.5
PAUSE 1000
LCDOUT $fe, 1

MAIN:
GOSUB READ_SENSOR
GOSUB DISPLAY
GOSUB COMPARE
GOTO MAIN
END

DISPLAY:
LCDOUT $FE, 2
LCDOUT "SENSOR = ",DEC TEMP1,"  "
LCDOUT $FE, $CO
LCDOUT "SETTING = ",DEC SET1,"  "
PAUSE 100
RETURN

COMPARE:
IF TEMP1 <= SET1 THEN
GOSUB MOTOR_FWD
GOSUB MOTOR_STOP
ENDIF

IF TEMP > SET1 THEN
GOSUB TURN_RIGHT
GOSUB MOTOR_STOP
ENDIF
RETURN

READ_SENSOR:
ADCIN 0, adcval
TEMP1 = adcval
PAUSE 5
RETURN

MOTOR_FWD:
HIGH RIGHT_FWD
HIGH LEFT_FWD
LOW RIGHT_REV
LOW LEFT_REV
PAUSE 100
RETURN

MOTOR_REV:
LOW RIGHT_FWD
LOW LEFT_FWD
HIGH RIGHT_REV
HIGH LEFT_REV
PAUSE 200
RETURN

TURN_RIGHT:
LOW RIGHT_FWD
HIGH LEFT_FWD
HIGH RIGHT_REV
LOW LEFT_REV
PAUSE 200
RETURN

MOTOR_STOP:
LOW RIGHT_FWD
LOW LEFT_FWD
LOW RIGHT_REV
LOW LEFT_REV
PAUSE 10
RETURN
 
Last edited by a moderator:

Re: From Basic PIC Pro to Mikro C

Where exactly is it that you're stuck?

Sometimes it is easier to just write the code from the beginning than to try to convert someone else's code written for another compiler (in this case, another language as well). So, you could try to start from scratch using mikroC.

mikroC PRO for PIC ADC library: https://www.mikroe.com/download/eng/documents/compilers/mikroc/pro/pic/help/adc_library.htm
mikroC PRO for PIC LCD library: https://www.mikroe.com/download/eng/documents/compilers/mikroc/pro/pic/help/lcd_library.htm
mikroC PRO for PIC Libraries: https://www.mikroe.com/download/eng/documents/compilers/mikroc/pro/pic/help/mikroc_pro_libraries.htm
mikroC PRO for PIC Built-in routines: https://www.mikroe.com/download/eng/documents/compilers/mikroc/pro/pic/help/built-in_routines.htm
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…