# Getting a 3x digit output to a calculation using a SINGLE. Oshonsoft.

#### camerart

Joined Feb 25, 2013
2,129
Hi,
I'm READing a compass on an 18F4431, which needs to be TXed to an 18LF4620, which then will be PARSED.
There is a calculation, so a SINGLE is used as a variable for 'DEG'
Cheers, C.

#### Attachments

• 3.6 KB Views: 1
Last edited:

#### ericgibbs

Joined Jan 29, 2010
11,156
hi C.
I do not want the Code, just a data example.
E

#### camerart

Joined Feb 25, 2013
2,129
hi C.
I do not want the Code, just a data example.
E
Hi E,

parStr= mid$tr(10,2) '' 22 parStr="000"+parStr '' 00022 parStr=rightStr(parStr,3) '' 022 Thread Starter #### camerart Joined Feb 25, 2013 2,129 Hi Check Oshonsoft, this is one option. you could combine the steps to give a shorter text code E example:$COMPDEG,22,W

parStr= mid$tr(10,2) '' 22 parStr="000"+parStr '' 00022 parStr=rightStr(parStr,3) '' 022 Hi E, Thanks for that, but the CODE where this is PARSED is quite complicated, and written by another member, so I'm reluctant to change it. Each of the PARSED$sentences must be the correct length.
Previously, almost the same set-up was for an Incremental encoder which outputted 2xBYTEs, which combined into a WORD that was always 3Digits, but WORD now doesn't do the same, as thre is a calculation before it.

Here is the relevent line: [ Const ixCOMPDEG_W = 13 ]
C

Last edited:
jjw

#### JohnInTX

Joined Jun 26, 2012
4,344
IIRC there is code in the stuff we worked on that fakes up the padding of small numbers with leading zeroes. I’ll take a look when I can but I’m pretty sure it was in the compass message if you want to look yourself

#### camerart

Joined Feb 25, 2013
2,129
IIRC there is code in the stuff we worked on that fakes up the padding of small numbers with leading zeroes. I’ll take a look when I can but I’m pretty sure it was in the compass message if you want to look yourself
Hi JT,
Ok, I'll have a look, and report back.
Thanks.
C.

#### camerart

Joined Feb 25, 2013
2,129
Hi JT,
NOTE: The 18F4431 PIC where the Compass is now READ doesn't PARSE but SENDs it's READng [\$COMPDEG,XXX,W] to the PARSE PIC 18LF4620.

I've just been testing WORD, SINGLE and STRING combinations, and none of the are giving even READing and calculating properly, so it looks like I'm going to go back a bit, and re-try.
C

#### JohnInTX

Joined Jun 26, 2012
4,344
Hi JT,
Ok, I'll have a look, and report back.
Thanks.
C.
It was something like:

degrees is an integer 0-359

Code:
'output ddd, 0dd or 00d depending on value of degrees integer

if degrees < 100 then

if degrees <10 then

Hserout #degrees ' output 1,2 or 3 remaining significant digits
Also recall that the fixed known length requirement was part of the checks on data integrity absent any checksum or CRC.

Last edited:

#### camerart

Joined Feb 25, 2013
2,129
It was something like:

degrees is an integer 0-359

Code:
'output ddd, 0dd or 00d depending on value of degrees integer

if degrees < 100 then

if degrees <10 then

Hserout #degrees ' output 1,2 or 3 remaining significant digits
Also recall that the fixed known length requirement was part of the checks on data integrity absent any checksum or CRC.
Hi Jt,
You have a much better memory than I do.
I did a search and found this: https://forum.allaboutcircuits.com/...errupts-and-parse.168960/page-16#post-1530066 #311 #312

I don't think it registered with me

As the 18F4431 was empty, I'll start again and incorporate this section.
"and may be some time", said Captain Oates.
Thanks, C.

#### camerart

Joined Feb 25, 2013
2,129
Hi JT,
A bit bewildered, but it appears to be working
Better leave it today, and see what we've done tomorrow, when my head stops spinning
Cheers, C.
____________________________________________________

#### Attachments

• 88.1 KB Views: 3
Last edited: