News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

Odd counting with float Variables

Started by Jamie, Jun 27, 2023, 09:57 PM

Previous topic - Next topic

Jamie

Good afternoon,

I have a snip of code that increments or decrements each time up and down buttons are pressed.
The odd part is if I start at 2.0 it will count up 2.0, 2.1, 2.2 ect but when i count down it goes 2.2, 2.1, 1.0, 1.8, 1.7

Then if I count up again it goes 1.7, 1.8, 1.0, 2.1, 2.2, 2.3


Thanks for any assistance. I've tried removing float_display_type = large and still the same issue.


Its an 18F46K22
Declare Float_Display_Type = LARGE


heres the basic code snip

DoseONSET:

While ENTER = 0: Wend
While SEL = 0: Wend
DelayMS 200

DoseON = ERead 270
'DoseOFF = ERead 271


Print At 3,1,"                    "
Print At 2,1,"                    "
While 1 = 1
Print At 2,4,">> DoseTIME <<"
Print At 3,1,"DoseON = "
Print At 3,10, Dec1 DoseON," S "
'    If SEL = 0 Then WaterDrain               'go back 1
    If UP = 0 Then
        If DoseON < 20 Then
            DoseON = DoseON + 0.10
            DelayMS 200
        EndIf
    EndIf
    If DOWN = 0 Then
        If DoseON > 0.20 Then
            DoseON = DoseON - 0.10
            DelayMS 200
        EndIf
    EndIf

    If ENTER = 0 Then
        ADDR = 270

        EWrite ADDR,[DoseON]
        DelayMS 15
        Print At 4,6,"< STORED >"
        DelayMS 1500
        Print At 4,6,"          "
        GoTo DoseOFFSET
    EndIf
Wend
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

DoseOFFSET:

While ENTER = 0: Wend
While SEL = 0: Wend
DelayMS 200


DoseOFF = ERead 274


Print At 3,1,"                    "
Print At 2,1,"                    "
While 1 = 1
Print At 2,4,">> DoseTIME <<"
Print At 3,1,"DoseOFF = "
Print At 3,11, Dec1 DoseOFF," S "
'    If SEL = 0 Then WaterDrain               'go back 1
    If UP = 0 Then
        If DoseOFF < 20 Then
            DoseOFF = DoseOFF + 0.10
            DelayMS 200
        EndIf
    EndIf
    If DOWN = 0 Then
        If DoseOFF > 0.20 Then
            DoseOFF = DoseOFF - 0.10
            DelayMS 200
        EndIf
    EndIf

    If ENTER = 0 Then
        ADDR = 274

        EWrite ADDR,[DoseOFF]
        DelayMS 15
        Print At 4,6,"< STORED >"
        DelayMS 4000
        Print At 4,6,"          "
        Reset
    EndIf
Wend



'''''''''''' Heres the Compiled section


DoseONSET
F1_003854 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] While ENTER = 0: Wend
_lbl__1031
    btfsc PORTC,0,0
    bra _lbl__1032
    bra _lbl__1031
_lbl__1032
F1_003855 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] While SEL = 0: Wend
_lbl__1033
    btfsc PORTC,3,0
    bra _lbl__1034
    bra _lbl__1033
_lbl__1034
F1_003856 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] DelayMs 200
    movlw 200
    call __delay_ms_
F1_003858 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] DoseON = Eread 270
    movlw 1
    movwf EEADRH,0
    movlw 14
    movwf EEADR,0
    call __eeread_w_
    movwf DoseON,1
    call __eeread_w_
    movwf DoseONH,1
    call __eeread_w_
    movwf DoseONHH,1
    call __eeread_w_
    movwf DoseONHHH,1
F1_003862 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] Print At 3,1,"                    "
    movlw 128
    movwf BPFH,0
    movlw 148
    call __lcd_cursor_consts_
    movlw ((_strlb__388 >> 8) & 0xFF)
    movwf TBLPTRLH,0
    movlw (_strlb__388 & 0xFF)
    movwf TBLPTRL,0
    call __print_flash_string__
F1_003863 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] Print At 2,1,"                    "
    movlw 128
    movwf BPFH,0
    movlw 192
    call __lcd_cursor_consts_
    movlw ((_strlb__389 >> 8) & 0xFF)
    movwf TBLPTRLH,0
    movlw (_strlb__389 & 0xFF)
    movwf TBLPTRL,0
    call __print_flash_string__
F1_003864 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] While 1 = 1
_lbl__1035
F1_003865 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] Print At 2,4,">> DOSETIME <<"
    movlw 128
    movwf BPFH,0
    movlw 195
    call __lcd_cursor_consts_
    movlw ((_strlb__390 >> 8) & 0xFF)
    movwf TBLPTRLH,0
    movlw (_strlb__390 & 0xFF)
    movwf TBLPTRL,0
    call __print_flash_string__
F1_003866 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] Print At 3,1,"DoseON = "
    movlw 128
    movwf BPFH,0
    movlw 148
    call __lcd_cursor_consts_
    movlw ((_strlb__391 >> 8) & 0xFF)
    movwf TBLPTRLH,0
    movlw (_strlb__391 & 0xFF)
    movwf TBLPTRL,0
    call __print_flash_string__
F1_003867 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] Print At 3,10, Dec1 DoseON," S "
    movlw 128
    movwf BPFH,0
    movlw 157
    call __lcd_cursor_consts_
    movff DoseON,PP_AARG
    movff DoseONH,PP_AARGH
    movff DoseONHH,PP_AARGHH
    movff DoseONHHH,PP_AARGHHH
    movlw 1
    call __float__ASCII__out
    movlw 32
    call __print_
    movlw 83
    call __print_
    movlw 32
    call __print_
F1_003869 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] if UP = 0 Then
    btfsc PORTC,5,0
    bra _lbl__1038
F1_003870 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] if DoseON < 20 Then
    movff DoseON,PP_AARG
    movff DoseONH,PP_AARGH
    movff DoseONHH,PP_AARGHH
    movff DoseONHHH,PP_AARGHHH
    clrf PP_BARGHHH,0
    clrf PP_BARGHH,0
    movlw 32
    movwf PP_BARGH,0
    movlw 131
    movwf PP_BARG,0
    call __fpgreaterequal_32__
    sublw 1
    bz _lbl__1040
F1_003871 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] DoseON = DoseON + 0.10
    movlw 205
    movwf PP_AARGHHH,0
    movlw 204
    movwf PP_AARGHH,0
    movlw 76
    movwf PP_AARGH,0
    movlw 123
    movwf PP_AARG,0
    movff DoseON,PP_BARG
    movff DoseONH,PP_BARGH
    movff DoseONHH,PP_BARGHH
    movff DoseONHHH,PP_BARGHHH
    call __fpadd_32__
    movff PP_AARG,DoseON
    movff PP_AARGH,DoseONH
    movff PP_AARGHH,DoseONHH
    movff PP_AARGHHH,DoseONHHH
F1_003872 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] DelayMs 200
    movlw 200
    call __delay_ms_
F1_003873 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] endif
_lbl__1040
F1_003874 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] endif
_lbl__1038
F1_003875 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] if DOWN = 0 Then
    btfsc PORTC,1,0
    bra _lbl__1042
F1_003876 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] if DoseON > 0.20 Then
    movlw 205
    movwf PP_AARGHHH,0
    movlw 204
    movwf PP_AARGHH,0
    movlw 76
    movwf PP_AARGH,0
    movlw 124
    movwf PP_AARG,0
    movff DoseON,PP_BARG
    movff DoseONH,PP_BARGH
    movff DoseONHH,PP_BARGHH
    movff DoseONHHH,PP_BARGHHH
    call __fpgreaterequal_32__
    sublw 1
    bz _lbl__1044
F1_003877 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] DoseON = DoseON - 0.10
    movlw 205
    movwf PP_BARGHHH,0
    movlw 204
    movwf PP_BARGHH,0
    movlw 76
    movwf PP_BARGH,0
    movlw 123
    movwf PP_BARG,0
    movff DoseON,PP_AARG
    movff DoseONH,PP_AARGH
    movff DoseONHH,PP_AARGHH
    movff DoseONHHH,PP_AARGHHH
    call __fpsub_32__
    movff PP_AARG,DoseON
    movff PP_AARGH,DoseONH
    movff PP_AARGHH,DoseONHH
    movff PP_AARGHHH,DoseONHHH
F1_003878 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] DelayMs 200
    movlw 200
    call __delay_ms_
F1_003879 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] endif
_lbl__1044
F1_003880 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] endif
_lbl__1042
F1_003882 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] if ENTER = 0 Then
    btfsc PORTC,0,0
    bra _lbl__1046
F1_003883 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] ADDR = 270
    movlw 1
    movwf ADDRH,1
    movlw 14
    movwf ADDR,1
F1_003885 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] Ewrite ADDR,[DoseON]
    movff ADDRH,EEADRH
    movff ADDR,EEADR
    movf DoseON,W,1
    call __eewrite_w_
    movf DoseONH,W,1
    call __eewrite_w_
    movf DoseONHH,W,1
    call __eewrite_w_
    movf DoseONHHH,W,1
    call __eewrite_w_
F1_003886 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] DelayMs 15
    movlw 15
    call __delay_ms_
F1_003887 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] Print At 4,6,"< STORED >"
    movlw 128
    movwf BPFH,0
    movlw 217
    call __lcd_cursor_consts_
    movlw ((_strlb__392 >> 8) & 0xFF)
    movwf TBLPTRLH,0
    movlw (_strlb__392 & 0xFF)
    movwf TBLPTRL,0
    call __print_flash_string__
F1_003888 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] DelayMs 1500
    movlw 5
    movwf PP1H,0
    movlw 220
    call __delay_ms_wreg_
F1_003889 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] Print At 4,6,"          "
    movlw 128
    movwf BPFH,0
    movlw 217
    call __lcd_cursor_consts_
    movlw ((_strlb__393 >> 8) & 0xFF)
    movwf TBLPTRLH,0
    movlw (_strlb__393 & 0xFF)
    movwf TBLPTRL,0
    call __print_flash_string__
F1_003890 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] goto DoseOFFSET
    bra DoseOFFSET
F1_003891 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] endif
_lbl__1046
F1_003892 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] Wend
    bra _lbl__1035
_lbl__1036
DoseOFFSET
F1_003899 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] While ENTER = 0: Wend
_lbl__1047
    btfsc PORTC,0,0
    bra _lbl__1048
    bra _lbl__1047
_lbl__1048
F1_003900 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] While SEL = 0: Wend
_lbl__1049
    btfsc PORTC,3,0
    bra _lbl__1050
    bra _lbl__1049
_lbl__1050
F1_003901 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] DelayMs 200
    movlw 200
    call __delay_ms_
F1_003904 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] DoseOFF = Eread 274
    movlw 1
    movwf EEADRH,0
    movlw 18
    movwf EEADR,0
    call __eeread_w_
    movwf DoseOFF,1
    call __eeread_w_
    movwf DoseOFFH,1
    call __eeread_w_
    movwf DoseOFFHH,1
    call __eeread_w_
    movwf DoseOFFHHH,1
F1_003907 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] Print At 3,1,"                    "
    movlw 128
    movwf BPFH,0
    movlw 148
    call __lcd_cursor_consts_
    movlw ((_strlb__394 >> 8) & 0xFF)
    movwf TBLPTRLH,0
    movlw (_strlb__394 & 0xFF)
    movwf TBLPTRL,0
    call __print_flash_string__
F1_003908 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] Print At 2,1,"                    "
    movlw 128
    movwf BPFH,0
    movlw 192
    call __lcd_cursor_consts_
    movlw ((_strlb__395 >> 8) & 0xFF)
    movwf TBLPTRLH,0
    movlw (_strlb__395 & 0xFF)
    movwf TBLPTRL,0
    call __print_flash_string__
F1_003909 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] While 1 = 1
_lbl__1051
F1_003910 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] Print At 2,4,">> DOSETIME <<"
    movlw 128
    movwf BPFH,0
    movlw 195
    call __lcd_cursor_consts_
    movlw ((_strlb__396 >> 8) & 0xFF)
    movwf TBLPTRLH,0
    movlw (_strlb__396 & 0xFF)
    movwf TBLPTRL,0
    call __print_flash_string__
F1_003911 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] Print At 3,1,"DoseOFF = "
    movlw 128
    movwf BPFH,0
    movlw 148
    call __lcd_cursor_consts_
    movlw ((_strlb__397 >> 8) & 0xFF)
    movwf TBLPTRLH,0
    movlw (_strlb__397 & 0xFF)
    movwf TBLPTRL,0
    call __print_flash_string__
F1_003912 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] Print At 3,11, Dec1 DoseOFF," S "
    movlw 128
    movwf BPFH,0
    movlw 158
    call __lcd_cursor_consts_
    movff DoseOFF,PP_AARG
    movff DoseOFFH,PP_AARGH
    movff DoseOFFHH,PP_AARGHH
    movff DoseOFFHHH,PP_AARGHHH
    movlw 1
    call __float__ASCII__out
    movlw 32
    call __print_
    movlw 83
    call __print_
    movlw 32
    call __print_
F1_003914 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] if UP = 0 Then
    btfsc PORTC,5,0
    bra _lbl__1054
F1_003915 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] if DoseOFF < 20 Then
    movff DoseOFF,PP_AARG
    movff DoseOFFH,PP_AARGH
    movff DoseOFFHH,PP_AARGHH
    movff DoseOFFHHH,PP_AARGHHH
    clrf PP_BARGHHH,0
    clrf PP_BARGHH,0
    movlw 32
    movwf PP_BARGH,0
    movlw 131
    movwf PP_BARG,0
    call __fpgreaterequal_32__
    sublw 1
    bz _lbl__1056
F1_003916 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] DoseOFF = DoseOFF + 0.10
    movlw 205
    movwf PP_AARGHHH,0
    movlw 204
    movwf PP_AARGHH,0
    movlw 76
    movwf PP_AARGH,0
    movlw 123
    movwf PP_AARG,0
    movff DoseOFF,PP_BARG
    movff DoseOFFH,PP_BARGH
    movff DoseOFFHH,PP_BARGHH
    movff DoseOFFHHH,PP_BARGHHH
    call __fpadd_32__
    movff PP_AARG,DoseOFF
    movff PP_AARGH,DoseOFFH
    movff PP_AARGHH,DoseOFFHH
    movff PP_AARGHHH,DoseOFFHHH
F1_003917 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] DelayMs 200
    movlw 200
    call __delay_ms_
F1_003918 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] endif
_lbl__1056
F1_003919 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] endif
_lbl__1054
F1_003920 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] if DOWN = 0 Then
    btfsc PORTC,1,0
    bra _lbl__1058
F1_003921 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] if DoseOFF > 0.20 Then
    movlw 205
    movwf PP_AARGHHH,0
    movlw 204
    movwf PP_AARGHH,0
    movlw 76
    movwf PP_AARGH,0
    movlw 124
    movwf PP_AARG,0
    movff DoseOFF,PP_BARG
    movff DoseOFFH,PP_BARGH
    movff DoseOFFHH,PP_BARGHH
    movff DoseOFFHHH,PP_BARGHHH
    call __fpgreaterequal_32__
    sublw 1
    bz _lbl__1060
F1_003922 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] DoseOFF = DoseOFF - 0.10
    movlw 205
    movwf PP_BARGHHH,0
    movlw 204
    movwf PP_BARGHH,0
    movlw 76
    movwf PP_BARGH,0
    movlw 123
    movwf PP_BARG,0
    movff DoseOFF,PP_AARG
    movff DoseOFFH,PP_AARGH
    movff DoseOFFHH,PP_AARGHH
    movff DoseOFFHHH,PP_AARGHHH
    call __fpsub_32__
    movff PP_AARG,DoseOFF
    movff PP_AARGH,DoseOFFH
    movff PP_AARGHH,DoseOFFHH
    movff PP_AARGHHH,DoseOFFHHH
F1_003923 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] DelayMs 200
    movlw 200
    call __delay_ms_
F1_003924 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] endif
_lbl__1060
F1_003925 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] endif
_lbl__1058
F1_003927 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] if ENTER = 0 Then
    btfsc PORTC,0,0
    bra _lbl__1062
F1_003928 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] ADDR = 274
    movlw 1
    movwf ADDRH,1
    movlw 18
    movwf ADDR,1
F1_003930 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] Ewrite ADDR,[DoseOFF]
    movff ADDRH,EEADRH
    movff ADDR,EEADR
    movf DoseOFF,W,1
    call __eewrite_w_
    movf DoseOFFH,W,1
    call __eewrite_w_
    movf DoseOFFHH,W,1
    call __eewrite_w_
    movf DoseOFFHHH,W,1
    call __eewrite_w_
F1_003931 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] DelayMs 15
    movlw 15
    call __delay_ms_
F1_003932 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] Print At 4,6,"< STORED >"
    movlw 128
    movwf BPFH,0
    movlw 217
    call __lcd_cursor_consts_
    movlw ((_strlb__398 >> 8) & 0xFF)
    movwf TBLPTRLH,0
    movlw (_strlb__398 & 0xFF)
    movwf TBLPTRL,0
    call __print_flash_string__
F1_003933 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] DelayMs 4000
    movlw 15
    movwf PP1H,0
    movlw 160
    call __delay_ms_wreg_
F1_003934 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] Print At 4,6,"          "
    movlw 128
    movwf BPFH,0
    movlw 217
    call __lcd_cursor_consts_
    movlw ((_strlb__399 >> 8) & 0xFF)
    movwf TBLPTRLH,0
    movlw (_strlb__399 & 0xFF)
    movwf TBLPTRL,0
    call __print_flash_string__
F1_003935 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] reset
    reset
F1_003936 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] endif
_lbl__1062
F1_003937 equ $ ; in [KEG WASHER V3.1 STEPPER_NO STEPPER.BAS] Wend
    bra _lbl__1051
_lbl__1052
F1_EOF equ $ ; KEG WASHER V3.1 STEPPER_NO STEPPER.BAS
_pblb__1063
    bra _pblb__1063
;---------------------------------------------
__eof
;---------------------------------------------
; CONFIG FUSES
config FOSC = HSMP
config PLLCFG = off
config PRICLKEN = on
config FCMEN = off
config IESO = off
config PWRTEN = off
config BOREN = SBORDIS
config BORV = 190
config WDTEN = off
config WDTPS = 32768
config CCP2MX = PORTC1
config PBADEN = off
config CCP3MX = PORTB5
config HFOFST = on
config T3CMX = PORTC0
config P2BMX = PORTD2
config MCLRE = EXTMCLR
config STVREN = off
config LVP = off
config XINST = off
config DEBUG = off
config CP0 = off
config CP1 = off
config CP2 = off
config CP3 = off
config CPB = off
config CPD = off
config WRT0 = off
config WRT1 = off
config WRT2 = off
config WRT3 = off
config WRTC = off
config WRTB = off
config WRTD = off
config EBTR0 = off
config EBTR1 = off
config EBTR2 = off
config EBTR3 = off
config EBTRB = off
    end



RGV250

Hi,
I very rarely use floats like that as I think there is a known error (with the float point format, not just Positron) with small values. https://docs.python.org/3/tutorial/floatingpoint.html
What I would do is increment/decrement by 1 and use that value in calculations and then divide by 10 for the output.

Bob

flosigud


tumbleweed

Quotebut when i count down it goes 2.2, 2.1, 1.0, 1.8, 1.7
There are certainly limitations with floating-point numbers, but it shouldn't be this bad.

This simple test code:
Dim dose As Float
Dim i As Byte

dose = 2.2

For i = 0 To 20
    dose = dose - 0.10
Next
counts down from 2.2 to 0.1 in 0.1 steps like it should, so there's something else going on.
I didn't check the print routines.

Dompie

This is a very old error and as far as I know Les has repaired this one some years ago.
As far as I remember it was a problem with the 0.1 part.
Are you using the newest compiler version?

Johan

Jamie

#5
Thanks for the replies, I am aware of the limitations of floats but I've not seen the issue as stated. for the most part it counts by 0.1 just fine

Code Produced by the Positron8 Compiler. Version 4.0.3.4

Tumbleweed, the first time around it counted normally until i counted up then back down. After that no matter what I did the 2.0 would show as 1.0

Thanks for checking.

Jamie

tumbleweed

Dim dose As Float
Dim i As Byte

dose = 1.0

For i = 0 To 20
    dose = dose + 0.10
Next

For i = 0 To 20
    dose = dose - 0.10
Next

Counts up and back down in 0.1 steps... nothing funny around 2.0

trastikata

Quote from: Jamie on Jun 30, 2023, 04:27 PMCode Produced by the Positron8 Compiler. Version 4.0.3.4
Tumbleweed, the first time around it counted normally until i counted up then back down. After that no matter what I did the 2.0 would show as 1.0


Are you sure it's not a Print or LCD issue? You are constantly printing in a While loop and in my experience things can get corrupted when the LCD is updated with high speed.

While 1 = 1
Print At 2,4,">> DoseTIME <<"
Print At 3,1,"DoseOFF = "
Print At 3,11, Dec1 DoseOFF," S "
...
Wend