• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PICBASIC Code question

Status
Not open for further replies.

joellee

New Member
Hello guys,
i just got the proton IDE which helps me do BASIC coding, and thinking of creating a simple programme

that takes predetermined bits from a data stream, and outputs the predetermined bits

so the code goes something like:



DEFINE OSC 20

Device = 16F877
Dim Position[24] As Byte
TRISA = %00000010
Declare RSIN_PIN PORTA.0
Declare SERIAL_BAUD 4800

Loop:
RSIn Wait ("GPGGA"), [Position]
SerOut PORTA.1, 16780, [Position]
GoTo Loop



So what I want to do from the code is
1) Take the next 24 bytes after i detect the string "GPGGA"
2) Store it to the variable Position
3) and then transmit it at a lower bit rate, i.e. 2400baud (which is 16780)

I was looking through the help files, I see how they take ONE byte after GPGGA
I also can see how they take in strings

but when i combine the two together (Taking in string after a string) my programme cant compile due to some syntax error in the lines:

RSIn Wait ("GPGGA"), [Position]
SerOut PORTA.1, 16780, [Position]

Any ideas whats going on and how can i get it running?

(i have changed the lines a few times) This programme below works ( Position is changed from a string to just one byte), but the top one doesn't...

DEFINE OSC 20

Device = 16F877
Dim Position As Byte
TRISA = %00000010
Declare RSIN_PIN PORTA.0
Declare SERIAL_BAUD 4800

Loop:
RSIn Wait ("GPGGA"), Position
SerOut PORTA.1, 16780, [Position]
GoTo Loop
Thanks!
 

Pommie

Well-Known Member
Most Helpful Member
I don't use Proton and so this is just a guess and probably wrong.

Try using a for next loop to read/write your strings. Something like,
Code:
Dim Position[24] As Byte
TRISA = %00000010
Declare RSIN_PIN PORTA.0
Declare SERIAL_BAUD 4800 

Loop:
    RSIn Wait ("GPGGA")
    for i= 0 to 23
        RSIn Position[i]
    next i
    for i= 0 to 23
        SerOut PORTA.1, 16780, Position[i]
    next i
GoTo Loop

Eric is pretty good on Proton and should be along later to correct my guess.

Mike.
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top