BasicMicroUK - Forums

www.basicmicro.co.uk
It is currently Tue Jan 23, 2018 4:57 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 28 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: hardware question with nano28 ds18b20, ds1307, lcd
PostPosted: Wed Nov 20, 2013 5:09 pm 
Offline
Guru

Joined: Sat Mar 30, 2013 10:19 pm
Posts: 51
hi all, I have a hardware question i hope someone can answer. setup on a nano 28 is:
'p0 lcd RS
'p1 lcd enable
'p2 lcd r/w
'p3 BL on/off
'p4 lcd data 4
'p5 lcd data 5
'p6 lcd data 6
'p7 lcd data 7
'p8 switch 1 left
'p9 switch 2 centre
'p10 switch 3 right
'p11 serial clock for rtc DS1307 & AT24C32
'p12 serial data in from rtc DS1307 & AT24C32
'p13 serial data for external DS18B20 serial temp probe
'p14 stepper motor1
'p15 stepper motor2
'p16 stepper motor3
'p17 stepper motor4

the lcd, switches and Ds1307 rtc work fine. the Ds18s20 is (part of the rtc board) on pin13 or pin 8 does not. i know its good, as a test i swapped things around and put lcd rs on pin 8 and the temp probe ds pin0, ran the following code and got a result that still needs work. why can i not use pin 13 for the ds but it works on pin0?
Code:
Pause 1000
   lcdinit p8\p1\p7\p6\p5\p4,p2
   Lcdwrite p8\p1\p7\p6\p5\p4,p2, [lcdclear,homelcd,scr,twoline,"   test "]
 read_temp:
   temp var word
   convert var float
   counter var byte
   main
        owout P0,1,main,[$cc,$44]
   wait   'poss use pause 1000?
        owin P0,0,[temp]
      if temp = 0 then wait
         owout P0,1,main,[$cc,$be]
        owin P0,0,[temp.byte0,temp.byte1]
        convert = tofloat temp/2.0
        'debug ["Temperature = ",real convert," C",13]
      'serout s_out,i9600,["Temperature = ",real convert," C",13]
      'HSEROUT ["Temperature = ", real convert2, " deg C", 13]
      LCDWRITE  p8\p1\p7\p6\p5\p4,p2, [lcdclear,homelcd, "Temperature = ", SCRRAM+40, real convert, " deg C"]

   goto main


note stepper motor is not in use yet

thanks in advance


Top
 Profile  
 
 Post subject: Re: hardware question with nano28 ds18b20, ds1307, lcd
PostPosted: Wed Nov 20, 2013 9:05 pm 
Offline
Master

Joined: Wed Oct 19, 2011 2:28 am
Posts: 123
Hi,
Did you try small program to test the pin 13? Write a small program that test the pin in the way you want to operate. Normally that it is the way I do when I have problem like yours.


Top
 Profile  
 
 Post subject: Re: hardware question with nano28 ds18b20, ds1307, lcd
PostPosted: Thu Nov 21, 2013 4:44 pm 
Offline
Guru

Joined: Sat Mar 30, 2013 10:19 pm
Posts: 51
thanks for your replay that pin seems fine. playing around and going back to the working version, i noticed that on my 2x16 lcd screen it displays
temperature =
176.5000000000 d

i guess the d is the deg c off screen. How do i get the temperature (which is suppose to be room temp) to show to 1 decimal place and the with the correct conversion. Also what does counter var do?
thanks again


Top
 Profile  
 
 Post subject: Re: hardware question with nano28 ds18b20, ds1307, lcd
PostPosted: Thu Nov 21, 2013 8:30 pm 
Offline
Master

Joined: Wed Oct 19, 2011 2:28 am
Posts: 123
Hi,
Are you using floating point? If it is "yesy" then you need to convert it to integer. value = toint (floating point)


Top
 Profile  
 
 Post subject: Re: hardware question with nano28 ds18b20, ds1307, lcd
PostPosted: Thu Nov 21, 2013 8:41 pm 
Offline
Guru

Joined: Sat Mar 30, 2013 10:19 pm
Posts: 51
I believe I am, code posted above, although, wrongly i believed being the sample code in the syntax manual it would give me a result in c or f. I shall play and see what happens. Thanks


Top
 Profile  
 
 Post subject: Re: hardware question with nano28 ds18b20, ds1307, lcd
PostPosted: Fri Nov 22, 2013 3:39 am 
Offline
Master

Joined: Wed Oct 19, 2011 2:28 am
Posts: 123
Hi,
For you communication problem with the Ds18s20 do at the beginning of your program
High P13 if your using it or High P8. I think you have to conditioning the data pin high all the time.


Top
 Profile  
 
 Post subject: Re: hardware question with nano28 ds18b20, ds1307, lcd
PostPosted: Fri Nov 22, 2013 4:08 am 
Offline
Site Admin
User avatar

Joined: Fri Apr 12, 2013 8:38 pm
Posts: 87
Location: Nottingham, England, UK
HI,

What's the hardware set up on this system ?,

The DS18B20 needs a pull up resistor on the One Wire data line DQ to +5V(4.7K-ohm), do you have this on your set-up ?,

Could be the internal pull up in the Nano is enabled on one port letting it work fine but not set on the other port stopping it from working,

Give it a try with the external resistor anyway as the internal resistor will likely be too weak for reliable results,

Dave
BasicMicroUK
http://www.basicmicro.co.uk


Top
 Profile  
 
 Post subject: Re: hardware question with nano28 ds18b20, ds1307, lcd
PostPosted: Fri Nov 22, 2013 1:44 pm 
Offline
Guru

Joined: Sat Mar 30, 2013 10:19 pm
Posts: 51
hi set up is as per the pins above, also using a arduino compatible prebuilt rtc module see link below,it incorporates a space for a ds18b20 which i have added. thanks again

http://www.emartee.com/product/42059/Ti ... Compatible


Top
 Profile  
 
 Post subject: Re: hardware question with nano28 ds18b20, ds1307, lcd
PostPosted: Fri Nov 22, 2013 8:10 pm 
Offline
Site Admin
User avatar

Joined: Fri Apr 12, 2013 8:38 pm
Posts: 87
Location: Nottingham, England, UK
Hi,

YES I can see the circuit diagram from that link and all looks OK on the DS18B20 part of it, is R1 fitted to the PCB ?,

With the DS18B20 being an option maybe the resistor was also optional and needed to be fitted by the user only if the DS18B20 was installed,

If the R1 resistor is fitted then thats not the cause of the problem and we need to look elsewhere,

Can you supply the exact code that does not work when set-up for the DS18B20 connected on pin 13 ?,

How does the fact the program does not work on pin 13 show itself ?, does the program just stop and never show a value on the LCD ?,

Thanks,
Dave
BasicMicroUK

http://www.basicmicro.co.uk


Top
 Profile  
 
 Post subject: Re: hardware question with nano28 ds18b20, ds1307, lcd
PostPosted: Fri Nov 22, 2013 8:18 pm 
Offline
Guru

Joined: Sat Mar 30, 2013 10:19 pm
Posts: 51
Thanks Dave, looking at the board yes it's there, a smr r1, on the schematic it's 3.3k. Unless you guys tell me there's something wrong with the code and that's why I'm getting 176.500000000 then I guess I'll have to change it for a 4.7k. Thanks


Top
 Profile  
 
 Post subject: Re: hardware question with nano28 ds18b20, ds1307, lcd
PostPosted: Fri Nov 22, 2013 8:35 pm 
Offline
Site Admin
User avatar

Joined: Fri Apr 12, 2013 8:38 pm
Posts: 87
Location: Nottingham, England, UK
Hi,

Thats good then, no need to change the value, 3k3 is fine,

Please supply the exact code thats not working on Pin 13 and a description of how its not working for example the program just stops and does not display a value OR it seems to work but displays 00000,

Thanks

Dave
BasicMicroUK

www.basicmicro.co.uk


Top
 Profile  
 
 Post subject: Re: hardware question with nano28 ds18b20, ds1307, lcd
PostPosted: Fri Nov 22, 2013 8:44 pm 
Offline
Guru

Joined: Sat Mar 30, 2013 10:19 pm
Posts: 51
The code is as above. Pin 13 is now fine turns out I had an intermittent jumper on my breadboard. Code works, and sensor works as I can see the value changing up and down if I put my finger on it, just gives me a huge figure with lots of decimal places. are we sure 3k3 is ok as every where I read it should be close to 5k. Thanks


Top
 Profile  
 
 Post subject: Re: hardware question with nano28 ds18b20, ds1307, lcd
PostPosted: Fri Nov 22, 2013 8:52 pm 
Offline
Site Admin
User avatar

Joined: Fri Apr 12, 2013 8:38 pm
Posts: 87
Location: Nottingham, England, UK
Hi,

Glad your up and running with the hardware,

On the resistor then as its just a pull up 3k3 is fine, the DS makers say 4k7 but not worth the effort to change it,

Thanks

Dave
BasicMicroUK

www.basicmicro.co.uk


Top
 Profile  
 
 Post subject: Re: hardware question with nano28 ds18b20, ds1307, lcd
PostPosted: Fri Nov 22, 2013 9:25 pm 
Offline
Guru

Joined: Sat Mar 30, 2013 10:19 pm
Posts: 51
Just to clarify that when I say the code works I mean it runs but gives a strange very long result 176.5000000000


Top
 Profile  
 
 Post subject: Re: hardware question with nano28 ds18b20, ds1307, lcd
PostPosted: Fri Nov 22, 2013 9:44 pm 
Offline
Master

Joined: Wed Oct 19, 2011 2:28 am
Posts: 123
Try it in this way:

you : LCDWRITE p8\p1\p7\p6\p5\p4,p2, [lcdclear,homelcd, "Temperature = ", SCRRAM+40, real convert, " deg C"]

mine : LCDWRITE p8\p1\p7\p6\p5\p4,p2, [lcdclear,homelcd, "Temperature = ", SCRRAM+40, dec toint(convert), " deg C"]


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 28 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO