![]() |
![]() |
![]() |
|
|
|||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) |
|
After playing around with Bills Junebug demo, I thought I'd have a go at getting a DS1820 working on the Unicorn with an LCD.
It worked almost straight away and I would put that down to Swordfish basic. I had not really played with it but, now I have, it is amazingly good. Anyway, here's the code, Code:
// Unicorn 1-Wire test
Device = 18F4550
Clock = 48
Config
PLLDIV = 5,
CPUDIV = OSC1_PLL2,
USBDIV = 2,
FOSC = HSPLL_HS,
VREGEN = OFF
// tell the LCD module where it's connected
#option LCD_DATA = PORTD.4
#option LCD_RS = PORTE.0
#option LCD_RW = PORTE.1
#option LCD_EN = PORTE.2
Include "ow.bas"
Include "convert.bas"
Include "LCD.bas"
// working variables...
Dim Temperature As Word
Dim i As Byte
Dim TempString As String
// program start...
ADCON1 = $0F //All digital
CMCON = $07 //No comparators
High(PORTA.2) //power DS18S20
OW.SetPin(PORTA.3) //One Wire is on A3 - needs pullup
LCD.Cls
If(Reset)Then //returns true if device found
WriteByte(owSkipROM) //Skip ROM
WriteByte($44) //Convert
WaitForHigh() //Wait for conversion to complete
Reset()
WriteByte(owSkipROM) //Skip Rom
WriteByte($be) //Read Scratch Pad
Temperature=ReadByte()
Temperature=Temperature+ReadByte()*256
TempString = DecToStr(Temperature*5) // get temperature * 10
//this is a bodge to display temperature with one decimal place
LCD.WriteAt(1,1,"Temp=",TempString(0),TempString(1),".",TempString(2)," Deg C")
//to just display it normal use this next line
// LCD.WriteAt(1,1,"Temp = ",dectostr(Temperature/2)," Deg C")
Reset()
WriteByte(owReadROM) //read rom
For i=0 To 7
LCD.WriteAt(2,(7-i)*2,HexToStr(ReadByte,2))
Next
Else
LCD.WriteAt(1,1,"No Device Found!")
EndIf
End
![]() Mike. Last edited by Pommie; 6th July 2008 at 04:13 PM. |
|
|
|
|
|
|
(permalink) |
|
Thanks Mike, I've been tinkering with modding the 18B20 module to get it working with the 18S20.
Are you using the Swordfish IDE or did you integrate with MPLAB? PS CON1 is wired with the 4K7 pullup for a DS18S20, I usually put a machine socket there so I can plug one wire devices in. |
|
|
|
|
|
|
(permalink) | ||
|
Quote:
Quote:
Mike. |
|||
|
|
|
|
|
(permalink) |
|
The Junebug, Firefly, Unicorn, Dragonfly all have a 1-wire with 4K7 connector
Have you tried installing any Swordfish IDE plugings? The LCD one is really nice. |
|
|
|
|
|
|
(permalink) | ||
|
Quote:
Quote:
Mike. |
|||
|
|
|
|
|
(permalink) |
|
I understand now why Gramo would soapbox Swordfish BASIC, it's a really well thought out modular & structured BASIC compiler. And it works. I can't fathom why all the BASIC Stamp & PICAxe users haven't made a go of it. Its free SE edition easily outperforms any p-code interpreter.
|
|
|
|
|
|
|
(permalink) |
|
I'm so impressed that I'm thinking of buying a copy. Don't tell Gramo.
I particularly like the way the modules are written. Very simple and yet powerful. Mike. |
|
|
|
|
|
|
(permalink) |
|
Me too, the only thing I HATE is the USB dongle for copy protection. I've only got two free ones on my laptop.
I've never seen a copy protection method that couldn't be defeated so IMHO USB dongles do nothing but add cost and inconvenience to a product. |
|
|
|
|
|
|
(permalink) |
|
Well it was an trivial change but here's the code to enable the backlight and use CON1 with the S18S20
Code:
High(PORTB.3) // enable LCD backlight DelayMS(200) // LCD initialize delay OW.SetPin(PORTC.2) // DS18S20 on C.2 - has 4K7 pullup ![]() |
|
|
|
|
|
|
(permalink) | |
|
Quote:
As for Gramo, I'm afraid he crossed the line on more than one occasion by suggesting that anyone using a development language other than Swordfish BASIC was stupid. I personally find those types of comments and suggestions offensive. There are strengths and weaknesses across all the major development languages and no one should have to tolerate someone suggesting you're an idiot because you're not writing code with his preferred language. Mike |
||
|
|
|
|
|
(permalink) |
|
Mike (Pommie),
Nice job by the way... |
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Latest |
| LCD programmable charater generator for Swordfish BASIC plugin | blueroomelectronics | Micro Controllers | 0 | 29th January 2008 06:39 AM |
| DS1820 Temp.sensor | alpish | Micro Controllers | 4 | 27th October 2007 06:46 PM |
| DS1820 & PIC16F84A subroutine | mabauti | Micro Controllers | 3 | 26th December 2006 02:08 AM |
| PIC code Error checking help (DS1820 temp sensor) | NewGeek | Micro Controllers | 11 | 10th September 2004 07:41 PM |
| DS1820 slave, 16F877 master, picbasic pro, any info? | jessey | Micro Controllers | 5 | 25th September 2003 07:21 AM |