Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
mramos1 said:And with 50 lines of code And all the options you mention it has how can one try it? One part At a time maybe.
Device = 16F877A
XTAL = 4
ALL_DIGITAL = False
PORTB_PULLUPS = True
LCD_DTPIN = PORTB.4
LCD_RSPIN = PORTB.2
LCD_ENPIN = PORTB.3
LCD_INTERFACE = 4 ' Setup the LCD
LCD_LINES = 2
LCD_TYPE = 0
Declare SCL_PIN PORTC.0
Declare SDA_PIN PORTC.1
Dim Result As Float ' Create a register accurate from -2147483646.999 to +2147483646.999
Dim Sign As Byte
Dim Cnt As Byte
Dim Count_Per_Deg As Byte
Dim Temp As Word
Dim Temp_Dec As Byte
Symbol DQ=PORTD.1 'Place the DS1820 on bit 1 of PORTD
DelayMS 150
Cls
Print At 2, 1, "Power is On"
TRISA = %11111111
ADCON1 = %10000000
Main:
Result = ADIn 0
EWrite 00, Result
Print At 1,1, DEC2 Result * 5 / 1023, "V"
BStart ' Send the start command on I2C
BusOut %10100010,$00,[Result] ' Send the byte to the eeprom
BStop ' Send the stop command on I2C
OWrite DQ, 1,[$55,$10,$92,$1F,$05,$01,$08,$00,$6B,$44] 'Send calculate temperature command
' FF I1 I2 I3 I4 I5 I6 CRC ' FF - Family, Ix - Address byte, CRC - checksum
Repeat
DelayMS 25 'Wait until conversion is compleate
ORead DQ,4,[Cnt] 'Keep reading low puses until
Until Cnt <> 0 'the DS1820 is finished
OWrite DQ,1,[$55,$10,$92,$1F,$05,$01,$08,$00,$6B,$BE] 'Send read scratcpad command
' FF I1 I2 I3 I4 I5 I6 CRC ' FF - Family, Ix - Address byte, CRC - checksum
ORead DQ,2,[Temp.LowByte,Temp.HighByte,Cnt,Cnt,Cnt,Cnt,Cnt,Count_Per_Deg]
Temp_Dec = (6.25 * Cnt) ' Each Cnt is 1/16 of a degree, therefor 100/16 = 6.25, and thats our decimal value
If Temp.8=1 Then ' Bits 8-15 are 1 for a negative temperature and 0 for a positive
Temp=(Temp.LowByte ^ $FF) >> 1 ' If negative then drop the first bit, and invert the value
If Cnt = 0 Then Temp = Temp + 1 ' If Cnt = 0 then increment Temp, as the 1820 does not do this
Sign = "-" ' Change the sign to a negative
Else
Temp=(Temp >> 1) ' If positive then drop the first byte
Temp_Dec = 100 - Temp_Dec
Sign = "+" ' And change the sign value to positive
EndIf
Print At 1,6, Sign, Dec2 Temp, ".", Dec1 Dig Temp_Dec, 1, " DegC "
GoTo Main
mramos1 said:MikroBASIC does all that for me for simple projects. OK for all of them so far.
If I need to buy other peoples stuff in the price, I guess I am still out. That is not right.. I will not by a PC that has to come loaded with Windows unless I need Windows.
Do you work for them or have buddies there and just really like the product that much??
If I make Unix machines I do not need Windows. If I want a BASIC compiler, I to not need Proteus/Simulator.
And your comments on .ASM. I get it. I will use the demo and write the subs in .ASM format since they do not count in the 50 lines. And some of the main in .ASM format to save lines.
Proton is good but you have to buy a simulator that adds a lot to the price. I do not need that part.
So it looks like I need MPLABS at this point if I use the .ASM. so much (Nigel is laughing again). And need to find someone that will share some good macros.