Das Open-Control-Projekt - Die Alternative zur C-Control-I


Das Forum zur C-Control-1
Welche C-Control-Varianten existieren?
Übersicht - Suchen - Neueste 50 Beiträge - Neuer Beitrag - Login - Registrieren
INFO - FAQ - CC2-Forum - CCPro-Forum 

 Re: 2 x DS1612 Temperature Kategorie: Programmierung Basic (von Hans - 5.02.2006 17:33)
 Als Antwort auf Re: 2 x DS1612 Temperature von Windt H.J. - 5.02.2006 16:52
Hans nutzt:  CC1-M-Unit V1.2/2.0
Thank you very much for the program
now I buy a second DS1621
I will connect it Tuesday evening
And I shall let you know if it works

Hans

> Hello,
> I canÂ’t test this example but I think it should work.
> Temperature IN is DS1621 addressed at &h90.
> Temperature OUT is DS1621 addressed at &h92
> Let me know how it works.
> Greetings,
> H.J. Windt
>
> '**************** I/O PORTS ****************'
> define lcd_backlight_off port[16]
> '*******************************************'
> '**************** VARIABLES ****************'
> define configuration byte[1]
> define iic_nack bit[7]
> define iic_nack_count byte[2]
> define iic_byte byte[3]
> define ds1621_status byte[4]
> define loop byte[5]
> define temp_in word[4]
> define temp_out word[5]
> '*******************************************'
> '**************** CONSTANTS ****************'
> define ds1621_in_iic_address &h90
> define ds1621_out_iic_address &h92
> '*******************************************'
> '****************** SETUP ******************'
> put 0:print"#ON_LCD#";:print"#INIT#";:print"#CLR#";:lcd_backlight_off = 0:print"#OFF#";
> '*******************************************'
> '***************** PROGRAM *****************'
> #start
> gosub get_ds1621_temperature
> print"#ON_LCD#";
> print"#L101#";:print"T in = ";temp_in/10;",";abs(temp_in-temp_in/10*10);:put&hdf:print"C  ";
> print"#L201#";:print"Tout = ";temp_out/10;",";abs(temp_out-temp_out/10*10);:put&hdf:print"C  ";
> print"#OFF#";
> goto start
> '*******************************************'
> '*************** SUBROUTINES ***************'
> #get_ds1621_temperature
> for loop = 1 to 2
> #ds1621_start_convert
> print"#ON_IIC#";
> print"#START#";
> if loop = 1 then put ds1621_in_iic_address
> if loop = 2 then put ds1621_out_iic_address
> put &hee
> print"#STOP#";
> print"#OFF#";
> gosub check_iic_nack
> if iic_nack_count > 6 then gosub no_ack_from_ds1621
> if iic_nack then goto ds1621_start_convert
> #ds1621_check_conversion_done
> print"#ON_IIC#";
> print"#START#";
> if loop = 1 then put ds1621_in_iic_address
> if loop = 2 then put ds1621_out_iic_address
> put &hac
> print"#STOP#";
> print"#OFF#";
> gosub check_iic_nack
> if iic_nack then goto ds1621_pass_check_conversion_done
> print"#ON_IIC#";
> print"#START#";
> if loop = 1 then put ds1621_in_iic_address + 1
> if loop = 2 then put ds1621_out_iic_address + 1
> get ds1621_status
> print"#STOP#";
> print"#OFF#";
> gosub check_iic_nack
> #ds1621_pass_check_conversion_done
> if iic_nack_count > 9 then gosub no_ack_from_ds1621
> if iic_nack then goto ds1621_check_conversion_done
> if (ds1621_status and 1) = 1 then if (ds1621_status and 128) = 0 then goto ds1621_check_conversion_done
> #ds1621_read_temp
> print"#ON_IIC#";
> print"#START#";
> if loop = 1 then put ds1621_in_iic_address
> if loop = 2 then put ds1621_out_iic_address
> put &haa
> print"#STOP#";
> print"#OFF#";
> gosub check_iic_nack
> if iic_nack then goto pass_ds1621_read_temp
> print"#ON_IIC#";
> print"#START#";
> if loop = 1 then put ds1621_in_iic_address + 1
> if loop = 2 then put ds1621_out_iic_address + 1
> get iic_byte
> if loop = 1 then if iic_byte > 127 then temp_in = (&hff00 + iic_byte) * 10 else temp_in = iic_byte * 10
> if loop = 2 then if iic_byte > 127 then temp_out = (&hff00 + iic_byte) * 10 else temp_out = iic_byte * 10
> get iic_byte
> if loop = 1 then if (iic_byte and 128) = 128 then temp_in = temp_in + 5
> if loop = 2 then if (iic_byte and 128) = 128 then temp_out = temp_out + 5
> print"#STOP#";
> print"#OFF#";
> gosub check_iic_nack
> #pass_ds1621_read_temp
> if iic_nack_count > 9 then gosub no_ack_from_ds1621
> if iic_nack then goto ds1621_read_temp
> if temp_in = -600 then goto ds1621_start_convert
> if temp_out = -600 then goto ds1621_start_convert
> next
> return
>
> #check_iic_nack
> print"#ON_CONFIG#";
> get configuration
> if not iic_nack then goto pass_iic_nack_clear
> iic_nack = 0
> put configuration
> iic_nack = 1
> iic_nack_count = iic_nack_count + 1
> print"#OFF#";
> return
> #pass_iic_nack_clear
> iic_nack_count = 0
> print"#OFF#";
> return
> '*******************************************'
> '******* INITIALIZATION SUBROUTINES ********'
>
> '*******************************************'
> '****************** DATA *******************'
>
> '*******************************************'
> '************* ERROR MESSAGES **************'
> #no_ack_from_ds1621
> beep 1,1,1:beep 10,1,1:beep 1,1,1:beep 10,1,1
> print"#ON_LCD#";
> print"#CLR#";
> print"IIC ERROR:";
> print"#L201#";
> print"DS1621 not found";
> pause 300
> print"#CLR#";
> print"#OFF#";
> return
> '*******************************************'

 Antwort schreiben

Bisherige Antworten:

Re: 2 x DS1612 Temperature (von Windt H.J. - 5.02.2006 17:41)
    Re: 2 x DS1612 Temperature (von Windt H.J. - 6.02.2006 13:17)
        2 x DS1621 v1.3 (von Windt H.J. - 6.02.2006 13:35)
            Re: 2 x DS1621 v1.3 (von Hans - 8.02.2006 17:55)
                Re: 2 x DS1621 v1.4 (von Windt H.J. - 8.02.2006 19:13)
                    Re: 2 x DS1621 v1.4 (von Hans - 8.02.2006 20:00)