Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Thread Tools Display Modes
Old 27th February 2008, 10:11 AM   (permalink)
Default Unicorn + Swordfish + DS1820

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
And this is what it displays and how the DS is wired. The DS is in the bottom three holes of the user connector with a 4k7 resistor from RA3 to 5V. The second row is the DS's ROM id.



Mike.

Last edited by Pommie; 6th July 2008 at 04:13 PM.
Pommie is online now  
Reply With Quote
Old 27th February 2008, 01:46 PM   (permalink)
Default

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.
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is offline  
Reply With Quote
Old 27th February 2008, 02:12 PM   (permalink)
Default

Quote:
Originally Posted by blueroomelectronics
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?
I used the Swordfish IDE and found it very easy to use. I haven't got a 18B20, but it should be just a matter of reading one more byte if the ID indicates it's a B20.
Quote:
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.
Isn't that the Junebug?

Mike.
Pommie is online now  
Reply With Quote
Old 27th February 2008, 02:18 PM   (permalink)
Default

The Junebug, Firefly, Unicorn, Dragonfly all have a 1-wire with 4K7 connector I think iButtons and 1-wire devices are the bees knees.

Have you tried installing any Swordfish IDE plugings? The LCD one is really nice.
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is offline  
Reply With Quote
Old 27th February 2008, 02:29 PM   (permalink)
Default

Quote:
Originally Posted by blueroomelectronics
The Junebug, Firefly, Unicorn, Dragonfly all have a 1-wire with 4K7 connector I think iButtons and 1-wire devices are the bees knees.
I looked at the circuit diagram and got con1 and J1 confused. As luck (or lack of) would have it I fitted the wrong connector. I also like the 1 wire devices, they work really well.
Quote:
Have you tried installing any Swordfish IDE plugings? The LCD one is really nice.
I haven't. Guess I'll have to look into these.

Mike.
Pommie is online now  
Reply With Quote
Old 27th February 2008, 02:37 PM   (permalink)
Default

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.
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is offline  
Reply With Quote
Old 27th February 2008, 02:48 PM   (permalink)
Default

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.
Pommie is online now  
Reply With Quote
Old 27th February 2008, 04:11 PM   (permalink)
Default

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.
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is offline  
Reply With Quote
Old 27th February 2008, 07:56 PM   (permalink)
Default

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
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is offline  
Reply With Quote
Old 27th February 2008, 10:33 PM   (permalink)
Default

Quote:
Originally Posted by blueroomelectronics
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.
I love Swordfish BASIC and feel Microchip should purchase it and turn it into their B18 product. Their endorsement would certainly go a long way toward legitimizing BASIC as a "professional" development language.

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
Mike, K8LH is offline  
Reply With Quote
Old 27th February 2008, 10:34 PM   (permalink)
Default

Mike (Pommie),

Nice job by the way...
Mike, K8LH is offline  
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
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



All times are GMT. The time now is 11:02 PM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.