Goeden dag,
Als opdracht heb ik met twee anderen het maken van een weerstation met de ds1621.
Het programmeren gebeurd in een demo versie van bascom8051 (demo.......)
Dit is onze eerste bascom opdracht en heel veel begeleiding krijgen we niet, maar we zijn er toch in geslaagd om een programmatje vinden en lichtelijk te bewerken naar onze wensen en het werkt! het probleem enkel, het is de 3poot ds1820 ivp de ds1621 die wij gebruiken... is dit om te bouwen? ik dacht zelf van wel, omdat de 1820 1 wire is en de ds1621 2wire.
Ik zou dit graag weten omdat ik hier anders geen energie meer insteek en iets anders probeer, we hebben nog 6 dagen.
Dank bij voorbaat,
Tim
Roland van Leusden
It's the rule that you live by and die for It's the one thing you can't deny Even though you don't know what the price is. It is justified.
Die DS1621 gebruikt I2C protocol, zit standaard in bascom.
Voor bascom AVR + DS1621 staat hier een project + code
http://www.avrprojects.net/articles.php?lng=en&pg=58
Is vrij simpel naar bascom 8051 om te zetten.
dankje!, ik had deze site al gevonden ( http://www.avrprojects.net/articles.php?lng=en&pg=59 )
als ik deze code invoer in bascom8051(demo) dan geeft hij een error bij portb
is hier een manier voor om dat te omzeilen?
Roland van Leusden
It's the rule that you live by and die for It's the one thing you can't deny Even though you don't know what the price is. It is justified.
I2C Voorbeeld voor 8051. Manual van Bascom al gelezen trouwens ? http://8051help.mcselec.com/index.html
'****************** Compiler directives **************************
'
$regfile = "8951cc03.dat"
$romstart = &H0 ' start address of code for FLASH
$ramstart = &H0 ' start address of external RAM
$ramsize = &H100 ' 256 bytes of external RAM
$crystal = 14745600 ' Microcontroller clock
$baud = 19200 ' RS-232 baud rate
'$large ' 16 bit addressing for jumps
'
'
Config Sda = P2.1 ' I2C serial DATA
Config Scl = P2.0 ' I2C serial CLK
'
'
'****************** Variables declaration **********************
'
Dim Valore As Byte , I As Byte ' Generic use
Dim Slave As Byte ' Slave address
Dim Buf(30) As Byte ' Data to send and receive
Dim Inviare As Byte ' Number of data to send
Dim Ricevere As Byte ' Number of data to receive
'
'
'************************** Main program ******************************
'
Main:
Waitms 1 ' Delay for signals settling
' Initialize demo
Disable Interrupts ' Disabiles interrupts
Auxr = &H0C ' Selects Eram on external data area
Eecon = &H00 ' Disables Eeprom of Micro
Adcf = &H00 ' Sets port 1 as input
Do
Print Chr(12)
Print "Demo I2C BUS on CN8 of GMB HR168"
Print
Print "1) Write"
Print "2) Read"
Print
Print "Select: "
Do
Valore = Inkey
Loop Until Valore = "1" Or Valore = "2"
Print
Input "Slave address (in decimal): " , Slave
Input "Number of data to receive: " , Ricevere
Input "Number of data to send: " , Inviare
If Inviare <> 0 Then
For I = 1 To Inviare
Print "data " ; I ; ") ";
Input Buf(i)
Next I
End If
Select Case Valore
Case "1" :
I2csend Slave , Buf(1) , Inviare
Case "2":
I2creceive Slave , Buf(1) , Inviare , Ricevere
End Select
If Ricevere <> 0 Then
Print "Data received:"
For I = 1 To Ricevere
Print "data " ; I ; ") " ; Buf(i)
Next I
End If
Print "Hit a key to continue..."
Do
Valore = Inkey
Loop Until Valore <> 0
Loop
End
'
'************************ Program end ***************************
'we mogen het anders oplossen wegens tijdgebrek... maar nu we onze pthq21603v-LEDBLUE LCD van batron binnen hebben krijgen we dit simpele test programmatje:
Config Lcd = 16 * 2
Do
Cls
Lcd "dat is 1"
Lowerline
Lcd "en dit is 2"
Waitms 250
Loop
End
niet op onze lcd getoverd :s is er iets wat ik over het hoofd heb gezien?
Dank bij voorbaat,
Tim
Roland van Leusden
It's the rule that you live by and die for It's the one thing you can't deny Even though you don't know what the price is. It is justified.
Welke uC gebruik je, en aan welke poort hangt het LCD ?
Je moet nl. zoiets als dit gebruiken:
' configure lcd display
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = P1.4 , Db5 = P1.5 , Db6 = P1.6 , Db7 = P1.7 , E = P1.3 , Rs = P1.2[Bericht gewijzigd door Roland van Leusden op (64%)]
Microcontroller 2051
pinnen naar de lcd:
P1,7---DB7
P1,6---DB6
P1,5---DB5
P1,4---DB4
P1,3---DB3
P1.2---DB2
P1.1---DB1
P1,0---DB0
Het is gewoon raar, want als we het programma testte op een andere LCD (16x1a) dan deed hij het wel, is onze batron BTHQ-21603v....BLUE WHITE LED LCD anders dan normale LCD's?
alvast bedankt,
Tim
Roland van Leusden
It's the rule that you live by and die for It's the one thing you can't deny Even though you don't know what the price is. It is justified.
Kwestie van het datasheet lezen ...
LCD Module Model No.: BTHQ 21603VSS-05
http://www.farnell.com/datasheets/47101.pdf
Pagina 4:
‘NOVATEK’ NT3881DH-01/AI (Die form) LCD Controller and Driver or equivalent.
‘SAMSUNG’ KS0065B-PCC (Die form) 40-Channel Segment/Common Driver for Dot Matrix LCD or equivalent
Bascom ondersteund HD44780 controller of compatible, dat zullen deze dus wel niet zijn.
Dit soort zaken bekijk je normaal voordat je spullen gaat bestellen ...
Je zou het eens kunnen proberen of hij compatible is met de KS077 controler.
CONFIG LCD = 16*2 , CHIPSET=KS077
en anders is het zoals Roland zegt, dan ondersteund bascom hem niet en is het niet eenvoudig om hem aan de praat te krijgen.