OK, A few points;
1. Pulsin delivers data to a word variable so b0 needs to be changed to Wx. Would suggest, as a matter of principle, to avoid using b0 or w0 in this manner as it is then available for bitwise use - suggest W6.
2. debug b1. b1 is not used so perhaps you intended b0. However I prefer to sertxd (to the PE serial window when testing with the programming cable connected). Debug does not always (in my experience) behave the way expected.
3. Pulsin measures in 10uS units @ 4MHz which is 1/10th of a degree. Suggest you use a setfreq m8 to improve the sensitivity to 5uS
4. The word variable (Bearing) will contain a value representing the length of the pulse as the number of 5uS units. As the pulse width varies from 1mS to 36.99mS this results in 5uS increments (@ 8MHz clock) from 20 to 20*359.9 + 20 = 7218
The maths should take account of the offsets (1ms for 0 degrees from the compass), and the pulsin count starting at 1 rather than zero.
To avoid hunting, the value used to decide which tenth of a degree to use should target values midway between each tenth rather than the value representing a tenth of a degree.
As each tenth of a degree is represented by 10uS, this will show as an increment of the Pulsin Value of 2 per tenth of a degree.
So halfway between 0 and 0.1 degrees is represented by a pulsin value of 21. Each 1/10th of a degree is then represented by a further increment of 2 to the pulsin value.
Accordingly the Bearing variable needs to have 20 deducted, then be divided by 2 to get the number (up to 4 digits) representing the number of tenths of degrees.
The output to the display then needs to manipulate this number into degrees, decimal point, and tenths.
See attached suggested code producing output in tenths of a degree. Search the forum for examples of how to change the output to degrees and tenths.
Code:
Suggestion only - appears to work in the simulator - BCJ
'For Picaxe 08M
'Filename:- Compass PWM to Picaxe.bas
'Hardware setup
'Input pulse from CMPS03 on 3 (IC pin 4)
'Serial output to LCD on 2 (IC pin 5) LCD is 2x16
[B][I]SETFREQ m8[/I][/B]
'Variables setup
SYMBOL Bearing = [B][I]W6[/I][/B]
[I][B]SYMBOL Degrees = W5[/B][/I]
INPUT 3 'Confirms i/o pin as input (not sure if I need this)
'Serout 2,N2400,(254,1) 'Clear LCD (Run once here instead of in main loop?)
Pause 100 'Delay to let LCD Initialise fully
Main:
PULSIN 3,1,Bearing 'Get reading from CMPS03
[B][I]Degrees = Bearing -20 /2[/I][/B]
'bearing = (Bearing -500)/50 'Calculate Bearing in degrees (Definately wrong!)
Serout 2,N2400,(254,1) 'Clear LCD
Serout 2,N2400,(254,128," Bearing") 'Value of B0 on top line of LCD
Serout 2,N2400,(254,196, #Degrees) 'Text on bottom line
GOTO main
The clear display could be used once only as could the output of the word "Bearing".
Then, only the changing value would need to be send to the LCD.
Search the Forum for techniques to send the full set of data to write the full number of places each time with leading blanks to clear higher numbers of digits when writing lesser numbers of digits, and, a zero for degrees if bearing less than 1 degree.