Hi Folks,
Just introducing myself (and my problems!)
I am a complete beginner at programming and thought I would start with PBP as it was recommended to me. I am using 2.43.
I am a pcb layout guy by day, and avid rally fan by any other time.
It's my hobby that brought me the need to program. I am trying to create a set of gauges for my car. Boost, oil pressure, oil temp, EGT, etc etc.
I am just starting out on my first project which is the boost gauge.
I've read what i can so far about setting up program structure and finding out how to get an ADC value from the pin into a word. I thought i had got the idea, but when i tried to complie what i had done so far i got a bunch of errors that i dont understand.
Here is a copy of the code:
11 INCLUDE 16F628.BAS
12 DEFINE OSC 20
13 DEFINE ADC_BITS 10
14 DEFINE ADC_CLOCK 3
15 DEFINE ADC_SAMPLEUS 10
16 TRISA = %00000001 'set portA pin 1 only
17 ADCON1 = %10000010 'read as analog
18 RAW VAR WORD 'Set ADC value to name of RAW
19 ADCIN 0, RAW 'READ ADC store value to RAW
Here are the errors:
line 11 bad variable modifier:.bas
line 11 syntax error
I removed the include and got this:
error[113] D:\progra~1\pbp\pbppic14.lib 5741 : symbol not previously defined (ADCON0)
I got this error for \pbppic14.lib 5775, 5780 and 5781.
I aslo got more "symbols not previously defined" for ADCON1, GO_DONE, ADRESH, ADRESL all with different numbers attached.
Could someone shed some light on my ramblings??
Jusat to check i ran this:
'************************************************* ****************************
'* MICROCODE STUDIO TIPS *
'* *
'* (1) : To get context sensitive help, move your cursor to a PICBasic *
'* : command and then press F1. *
'* (2) : Program assumes the PIC is running at 4MHz. To change the default *
'* : setting (for example, to 20MHz) simply add DEFINE OSC 20 at the *
'* : top of your program. *
'* *
'* This sample program is supplied courtesy of microEngineering Labs Inc *
'************************************************* ****************************
' PicBasic Pro program to display result of
' 10-bit A/D conversion on LCD
' Connect analog input to channel-0 (RA0)
' Define LCD registers and bits
Define LCD_DREG PORTD
Define LCD_DBIT 4
Define LCD_RSREG PORTE
Define LCD_RSBIT 0
Define LCD_EREG PORTE
Define LCD_EBIT 1
' Define ADCIN parameters
Define ADC_BITS 10 ' Set number of bits in result
Define ADC_CLOCK 3 ' Set clock source (3=rc)
Define ADC_SAMPLEUS 50 ' Set sampling time in uS
adval var word ' Create adval to store result
TRISA = %11111111 ' Set PORTA to all input
ADCON1 = %10000010 ' Set PORTA analog and right justify result
Low PORTE.2 ' LCD R/W line low (W)
Pause 500 ' Wait .5 second
loop:
ADCIN 0, adval ' Read channel 0 to adval
Lcdout $fe, 1 ' Clear LCD
Lcdout "Value: ", DEC adval ' Display the decimal value
Pause 100 ' Wait .1 second
Goto loop ' Do it forever
End
I got the same errors as before, plus a bunch more for the LCD
What am I doing wrong????
Best regards,
James
Bookmarks