If...then...????
Archiver
Posts: 46,084
Matt-
I think you want to read the course values (integer parts) directly
into your word variables using the DEC modifier (see SERIN). Then
you can compare and do arithmetic on the values directly. I'm not
clear on how you're using an array, but I don't think you need one.
Anyway, assuming wp1 and tr1 will each have a value >= 0 and < 360,
you might do something like:
readGPS:
SERIN...[noparse][[/noparse]...,DEC wp1,...DEC tr1,...]
IF wp1 < tr1 THEN bearLeft
course_correction = wp1 - tr1
DEBUG CR,"Bear right ",DEC course_correction, " degrees"
GOTO readGPS
bearLeft:
course_correction = tr1 - wp1
DEBUG CR,"Bear left ",DEC course_correction, " degrees"
GOTO readGPS
You'll have to fill in the blanks on the SERIN instruction to
make it match your input stream.
Incidentally, you could use the tenths of a degree easily by just
storing your bearings as 0 <= course < 3600. Just keep the 10 x's
factor in mind. You can always artificially put the decimal back in
for display purposes or whatever. But...the tenths may be
meaningless anyway if the GPS doesn't really have that kind of
accuracy or tenths of a degree don't matter for your application
anyhow.
Regards,
Steve
I think you want to read the course values (integer parts) directly
into your word variables using the DEC modifier (see SERIN). Then
you can compare and do arithmetic on the values directly. I'm not
clear on how you're using an array, but I don't think you need one.
Anyway, assuming wp1 and tr1 will each have a value >= 0 and < 360,
you might do something like:
readGPS:
SERIN...[noparse][[/noparse]...,DEC wp1,...DEC tr1,...]
IF wp1 < tr1 THEN bearLeft
course_correction = wp1 - tr1
DEBUG CR,"Bear right ",DEC course_correction, " degrees"
GOTO readGPS
bearLeft:
course_correction = tr1 - wp1
DEBUG CR,"Bear left ",DEC course_correction, " degrees"
GOTO readGPS
You'll have to fill in the blanks on the SERIN instruction to
make it match your input stream.
Incidentally, you could use the tenths of a degree easily by just
storing your bearings as 0 <= course < 3600. Just keep the 10 x's
factor in mind. You can always artificially put the decimal back in
for display purposes or whatever. But...the tenths may be
meaningless anyway if the GPS doesn't really have that kind of
accuracy or tenths of a degree don't matter for your application
anyhow.
Regards,
Steve
Comments
The variables are wp1 var word and tr1 var word, currently I am trying to use an array and cannot figure out how to subtract a whole array from another array. If I am totally off base somewhere in here please tell me so, I am just learning PBasic and this type of programming, I used to use basic a bit but never this way. Thanks for any help.
Matt Klarich
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices