You are here

How do i interface a ds18B20 to a psoc 3 | Cypress Semiconductor

How do i interface a ds18B20 to a psoc 3

Summary: 10 Replies, Latest post by srinavya001_1679961 on 25 Jun 2016 06:51 AM PDT
Verified Answers: 2
Last post
Log in to post new comments.
fawnberrystar's picture
User
2 posts

Can anyone tell how to interface a ds18B20 to a psoc3 i have see many samples for a psoc1 but i can't find a basic sample for the psoc3

user_49271930's picture
User
496 posts

Look at my version.
Unfortunately this is for the old version PSoC Creator
Here primitive library OneWire.cylib
http://mylab.wmsite.ru/moi-razrab/cypress-psoc/psoc-user-module-library/
Here logger to the DS18B20 temperature.
http://mylab.wmsite.ru/moi-razrab/cypress-psoc/temperature-logger/

fawnberrystar75's picture
User
5 posts

Hi thank u, I could not get that working plus I don't have a matrix screen like you have, all I need is the basics with the dev kit 2x16 display

fawnberrystar75's picture
User
5 posts

plus every thing is in Russian

user_49271930's picture
User
496 posts

o display 2x16 I had only example of reading ROM.
Example in the attached archive. I hope he is not too much mistakes.

Attachments: 
fawnberrystar75's picture
User
5 posts

HI thanks for that have you be able to have more then one sensor on the same onewire line

user_49271930's picture
User
496 posts

Component OneWire.cylib has while only 5 commands. Working with multiple sensors are not available. I hope you will be able to add the necessary commands.

andyf's picture
User
2 posts

Hi pavloven,

I have tried your read_rom code and got it working OK in PSoC 5 with a DS18B20 sensor - thanks for posting this.  Now I would like to import your component into another project (it that's OK?!) but I'm having trouble.  Your component seems to use a "virtual pin" - "Pin 1" for the calling code - which isn't physically connected to the 1 wire - the sensor is physically connected to the pin in the OneWire component.  I can't see how this is mapped - there doesn't seem to be aliases used.  It obviously works fine in your application - what am I missing?

I'm relatively new to the PSoC so I hope you can help.  Many thanks.

By the way, I had some trouble actually trying to make a temperature measurement - it was OK reading and writing to the registers.  I solved this by setting the output pin in the OneWire component to "Strong Drive" - I think this was necessary as I had it connected in "parasitic power" mode with no separate Vcc supply.  

Also, it does seem a bit strange that there isn't a built in 1-Wire component in PSoC creator when there is one in PSoC Developer!

andyf's picture
User
2 posts

Hi pavloven,

Update on the previous post.  I have got it working now - I hadn't worked out the reason for "pin 1" in the main schematic before and now think that it is needed to allow the compiler to access the functions in your OneWire component.  Anyway, including this lone "Pin_1" Output Pin mapped to an unused real physical pin allowed it to work within my application.

One additional point I should have mentioned last time.  In order to read temperatures or anything else after the initial device type/serial number read command, it is necessary to first do a bus reset command and then a "skip rom" command as we only have one device on the interface.

Start the temperature measurement: -

    OneWire_BusReset();
    OneWire_Write8(0xCC);  // skip rom command
    OneWire_Write8(0x44);   // measure the temperature - need to allow correct time before read       

Read the measured temperature result bytes: -

    OneWire_BusReset();
    OneWire_Write8(0xCC);   // skip rom command
    OneWire_Write8(0xBE);   // read scratchpad - temperature result has been written here         

    Pin_1_Write(Pin_1_Read()^1);    // set pin 1 to read   

    uint8 TempResultLSB = OneWire_Read8();   // LSB of temperature result - see datasheet to decode (depends on resolution setting of the 18B20
    uint8 TempResultMSB = OneWire_Read8();  // MSB of temperature result

Once this was in place I have now had reliable transactions for 24 hours plus continuous running measuring around 5 times/second.  We have received a very occasional 85 DegC value which means that the device has reset but this is easily filtered out.

Hopefully this helps a little.

Thanks again for the starting code!

srinavya001_1679961's picture
User
1 post

hi i am trying to interface ds18b20 to psoc 3 can you give a detail explanation on how to please. I am new at using psoc. please help.

 

user_342122993's picture
User
804 posts

andyf,

IMHO, reading the DS18B20 at rate of 5Hz is too fast: (i) temperature equilibration time for this sensor is about 1 sec - strobing sensor  any faster will show "smeared" data, (ii) self-heating due to ADC conversion is noticeable already at 1 Hz repetition, e.g. in 12-bit mode (0.1 C resolution) the temperature displayed is typically 0.1C higher as measured at e.g. 0.2 Hz.

You may check also another component for DS18B20 (written for PSoC5 though):

http://www.cypress.com/forum/psoc-community-components/component-read-ds...

 

Log in to post new comments.