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: Ansteuerung pcf8591 Kategorie: Programmierung Basic (von acer - 10.02.2006 19:50)
 Als Antwort auf Re: Ansteuerung pcf8591 von Windt H.J. - 10.02.2006 19:37
acer nutzt:  CC1-M-Unit V1.2/2.0
Hi H.J.
I'm impressed, will try it out as soon as possible and tell you if it works (probably on Tuesday)! Thank you
Greeez, acer


> Hello,
> Your connections look good.
> I have read through the datasheet of the PCF8591 and just maybe I can help you.
> I have written a test program according to the data sheet.
> I canÂ’t test it but maybe it will work.
> Let me know how it works out.
> Greetings,
> H.J. Windt
>
> '* PCF8591 Example b1.0 for CCIUM2.01 with CCIAB2.0 *'
> '**************** I/O PORTS ****************'
> define lcd_backlight_off port[16]
> '*******************************************'
> '**************** A/D PORTS ****************'
>
> '*******************************************'
> '**************** D/A PORTS ****************'
>
> '*******************************************'
> '**************** VARIABLES ****************'
> define configuration byte[1]
> define iic_nack bit[7]
> define iic_nack_count byte[2]
> define pcf8591_i2c_address byte[3]
> define pcf8591_ad0 byte[4]
> define pcf8591_ad1 byte[5]
> define pcf8591_ad2 byte[6]
> define pcf8591_ad3 byte[7]
> '*******************************************'
> '**************** CONSTANTS ****************'
>
> '*******************************************'
> '****************** SETUP ******************'
> put 0 : print"#ON_LCD#";"#INIT#";"#CLR#";"#OFF#"; : lcd_backlight_off = off
> '*******************************************'
> '***************** PROGRAM *****************'
> #start
> pcf8591_i2c_address = 144
> gosub get_pcf8591_ad_data
> print"#ON_LCD#";
> print"#L101#";"ad0=";pcf8591_ad0;" ad1=";pcf8591_ad1;"    ";
> print"#L201#";"ad2=";pcf8591_ad2;" ad3=";pcf8591_ad3;"    ";
> print"#OFF#";
> goto start
> '*******************************************'
> '*************** SUBROUTINES ***************'
> #get_pcf8591_ad_data
> print"#ON_IIC#";
> print"#START#";
> put pcf8591_i2c_address
> put &b01000100
> print"#STOP#";
> print"#OFF#";
> gosub check_iic_nack
> if iic_nack then goto pass_reading_pcf8591_data
> print"#ON_IIC#";
> print"#START#";
> put pcf8591_i2c_address + 1
> get pcf8591_ad0 'start conversion of ad1'
> get pcf8591_ad1 'start conversion of ad2'
> get pcf8591_ad2 'start conversion of ad3'
> get pcf8591_ad3 'start conversion of ad0'
> get pcf8591_ad0 'read ad0'
> get pcf8591_ad1 'read ad1'
> get pcf8591_ad2 'read ad2'
> get pcf8591_ad3 'read ad3'
> print"#STOP#";
> print"#OFF#";
> gosub check_iic_nack
> #pass_reading_pcf8591_data
> if iic_nack_count > 3 then gosub no_ack_from_pcf8591
> if iic_nack then goto get_pcf8591_ad_data
> 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 ********'
>
> '*******************************************'
> '********* CALIBRATION SUBROUTINES *********'
>
> '*******************************************'
> '****************** DATA *******************'
>
> '*******************************************'
> '************* ERROR MESSAGES **************'
> #no_ack_from_pcf8591
> 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"PCF8591 NACK";
> pause 300
> print"#CLR#";
> print"#OFF#";
> return
> '*******************************************'

 Antwort schreiben

Bisherige Antworten: