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: 12 bits ADconv. Max128 Kategorie: Programmierung Basic (von Hans - 28.09.2006 21:57)
 Als Antwort auf Re: 12 bits ADconv. Max128 von H.J.W. - 28.09.2006 20:59
Hans nutzt:  CC1-M-Unit V1.2/2.0
Thank you very much
This is great
I will certainly try this, coming sunday.
then I have mine platine ready
I will let you know if its working.

Hans


> Hello Hans,
> I found a few faults in your software, you must be careful when using goto, gosub, return and for next.
> When using the IIC bus you must initialize the LCD first.
> Also clear the rs232 buffer first.
>
> Just for fun I reworked your software a little, have a look and try it out.
> Success and greetings,
> H.J.W.
>
> DEFINE Var1             BYTE[1]
> DEFINE Var2             BYTE[2]
> DEFINE I                BYTE[3]
> DEFINE D                BYTE[4]
> DEFINE loop             BYTE[5]
> DEFINE Max128adres      &h50
> DEFINE LED              PORT[1]
>
> print"#ON_LCD#";"#INIT#";"#CLR#";"#OFF#"; 'Initialize the LCD before using the IIC bus'
> put 0                                     'Needed because of a bug in the c-control I v2.0x system'
> #clear_rs232_buffer                       'Clear the RS232 buffer'
> if rxd then get d
> if rxd then goto clear_rs232_buffer
>
> #Start
> TOG LED
> FOR I = 1 to 200
> IF not RXD THEN Goto pass
> get d
> if d = 68 then gosub zend 'D is van Excel(Excel is klaar om te ontvangen)
> #pass
> NEXT
> GOTO Start
>
> #Zend
> Print "S";"|";    'S is de Start puls voor Excel
> for loop = 0 to 7
> PRINT"#ON_IIC#";
> PRINT"#START#";
> PUT Max128adres
> PUT &B10001000 or (loop shl 4)'Choose channel'
> PRINT"#STOP#";
>
> PRINT"#START#";
> PUT Max128adres+1
> GET Var1
> GET Var2
> PRINT"#STOP#";
> PRINT"#OFF#";
> print(Var1*16) + (Var2 SHR 4);"|"; 'calculate and print received analog value'
> next
> print "E"           'E is einde VAR. voor Excel
> RETURN
>
>
>
> > Thank You
> >
> > I'll try the progr Zonday
> > I hope that it works
> > does it ???????????????????????
> > Here the programm
> >
> > DEFINE Var1             BYTE[1]
> > DEFINE Var2             BYTE[2]
> > DEFINE I                BYTE[3]
> > DEFINE D                BYTE[4]
> > DEFINE AD1              WORD[3]
> > DEFINE AD2              WORD[4]
> > DEFINE AD3              WORD[5]
> > DEFINE AD4              WORD[6]
> > DEFINE AD5              WORD[7]
> > DEFINE AD6              WORD[8]
> > DEFINE AD7              WORD[9]
> > DEFINE AD8              WORD[10]
> > DEFINE Max128adres      &h50
> > DEFINE LED              PORT[1]
> >
> >
> >
> >
> > 'A Max127 has a adress  0101 A2 A1 A0 RW
> > '01010000 = 50
> > '01010010 = 52
> > '01010100 = 54
> > 'I2C Write Addresses:
> >  '&h50 &h52 &h54 &h56 &h58 &h5A &h5C &h5E
> >  'I2C Read Addresses:
> >  'I2C Read Address = I2C Write Address + 1
> >
> >
> > #Start
> >  TOG LED
> >     FOR I=1 to 50
> >     IF RXD THEN Goto Ontvangst
> >     PAUSE 1
> >  NEXT
> > GOTO Start
> >
> > #Ontvangst
> > GET D
> > IF D=68 THEN GOTO Zend ELSE GOTO Ontvangst     'D is van Excel(Excel is klaar om te ontvangen)
> >
> > #Zend
> > GOSUB Programma
> >  Print "S";"|";    'S is de Start puls voor Excel
> >  Print AD1;"|";
> >  Print AD2;"|";
> >  Print AD3;"|";
> >  Print AD4;"|";
> >  Print AD5;"|";
> >  Print AD6;"|";
> >  Print AD7;"|";
> >  Print AD8;"|";
> >  Print "E"        'E is einde VAR. voor Excel
> > GOTO Start
> >
> > #Programma
> >  PRINT"#ON_IIC#";
> >  PRINT"#START#";
> >  PUT Max128adres
> >  PUT &B10001000    'Channel 1  Scale 0-Vref
> >  PRINT"#STOP#";
> >
> >  PRINT"#START#";
> >  PUT Max128adres+1
> >  GET Var1
> >  GET Var2
> >  Var2 = Var2 SHR 4
> >  PRINT"#STOP#";
> >  PRINT"#OFF#";
> >  AD1 = ((Var1*16) + Var2)
> >
> >  PRINT"#ON_IIC#";
> >  PRINT"#START#";
> >  PUT Max128adres
> >  PUT &B10011000    'CHannel 2
> >  PRINT"#STOP#";
> >
> >  PRINT"#START#";
> >  PUT Max128adres+1
> >  GET Var1
> >  GET Var2
> >  Var2 = Var2 SHR 4
> >  PRINT"#STOP#";
> >  PRINT"#OFF#";
> >  AD2 = ((Var1*16) + Var2)
> >
> > PRINT"#ON_IIC#";
> >  PRINT"#START#";
> >  PUT Max128adres
> >  PUT &B10101000    'CHannel 3
> >  PRINT"#STOP#";
> >
> >  PRINT"#START#";
> >  PUT Max128adres+1
> >  GET Var1
> >  GET Var2
> >  Var2 = Var2 SHR 4
> >  PRINT"#STOP#";
> >  PRINT"#OFF#";
> >  AD3 = ((Var1*16) + Var2)
> >
> > PRINT"#ON_IIC#";
> >  PRINT"#START#";
> >  PUT Max128adres
> >  PUT &B10111000    'CHannel 4
> >  PRINT"#STOP#";
> >
> >  PRINT"#START#";
> >  PUT Max128adres+1
> >  GET Var1
> >  GET Var2
> >  Var2 = Var2 SHR 4
> >  PRINT"#STOP#";
> >  PRINT"#OFF#";
> >  AD4 = ((Var1*16) + Var2)
> >
> > PRINT"#ON_IIC#";
> >  PRINT"#START#";
> >  PUT Max128adres
> >  PUT &B11001000    'CHannel 5
> >  PRINT"#STOP#";
> >
> >  PRINT"#START#";
> >  PUT Max128adres+1
> >  GET Var1
> >  GET Var2
> >  Var2 = Var2 SHR 4
> >  PRINT"#STOP#";
> >  PRINT"#OFF#";
> >  AD5 = ((Var1*16) + Var2)
> >
> > PRINT"#ON_IIC#";
> >  PRINT"#START#";
> >  PUT Max128adres
> >  PUT &B11011000    'CHannel 6
> >  PRINT"#STOP#";
> >
> >  PRINT"#START#";
> >  PUT Max128adres+1
> >  GET Var1
> >  GET Var2
> >  Var2 = Var2 SHR 4
> >  PRINT"#STOP#";
> >  PRINT"#OFF#";
> >  AD6 = ((Var1*16) + Var2)
> >
> > PRINT"#ON_IIC#";
> >  PRINT"#START#";
> >  PUT Max128adres
> >  PUT &B11101000    'CHannel 7
> >  PRINT"#STOP#";
> >
> >  PRINT"#START#";
> >  PUT Max128adres+1
> >  GET Var1
> >  GET Var2
> >  Var2 = Var2 SHR 4
> >  PRINT"#STOP#";
> >  PRINT"#OFF#";
> >  AD7 = ((Var1*16) + Var2)
> >
> > PRINT"#ON_IIC#";
> >  PRINT"#START#";
> >  PUT Max128adres
> >  PUT &B11111000    'CHannel 8
> >  PRINT"#STOP#";
> >
> >  PRINT"#START#";
> >  PUT Max128adres+1
> >  GET Var1
> >  GET Var2
> >  Var2 = Var2 SHR 4
> >  PRINT"#STOP#";
> >  PRINT"#OFF#";
> >  AD8 = ((Var1*16) + Var2)
> >
> > RETURN
> >
> >
> >
> > > Hello,
> > > Yes, there are a total of 8 addresses possible.
> > >
> > > I2C Write Addresses:
> > > &h50 &h52 &h54 &h56 &h58 &h5A &h5C &h5E
> > >
> > > I2C Read Addresses:
> > > I2C Read Address = I2C Write Address + 1
> > >
> > > Greetings,
> > > H.J.W.
> > >
> > > > Thanks  H.J.W
> > > >
> > > > I din't look good
> > > >
> > > > A Max128 has a adress  0101 A2 A1 A0 RW
> > > > '01010000 =&h50
> > > > '01010010 =    52
> > > > '01010100 =    54
> > > > '01011000 =    58
> > > > etc. totaal 8x
> > > >
> > > > Is this alright ??
> > > > or..??
> > > >
> > > > Hans
> > > >
> > > > > Hello,
> > > > > Here is a data sheet - > click me
> > > > > On page 11 is the addressing.
> > > > > Greetings,
> > > > > H.J.W.
> > > > >
> > > > > > Hello,
> > > > > >
> > > > > > I'm working on a 12 bits adconv. the max128 and the munit2.
> > > > > > print and progr. are almost finished.
> > > > > > but what is the adress input from the max128.
> > > > > > A0, A1, A2 are  connectet on minus
> > > > > > I can't find this data on the datasheet.
> > > > > >
> > > > > > Hans.
> > > > > >
> > > > > > Is this  DEFINE Max128adres      &h80
> > > > > > or        DEFINE Max128adres      &h90
> > > > > > or else

 Antwort schreiben

Bisherige Antworten: