How do i interface a ds18B20 to a psoc 3

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable
        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   
0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
EvPa_264126
Level 7
Level 7
500 replies posted 250 replies posted 100 likes received
        o display 2x16 I had only example of reading ROM. Example in the attached archive. I hope he is not too much mistakes.   

View solution in original post

0 Likes
10 Replies
EvPa_264126
Level 7
Level 7
500 replies posted 250 replies posted 100 likes received
        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/   
0 Likes
Anonymous
Not applicable
        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   
0 Likes
Anonymous
Not applicable
        plus every thing is in Russian   
0 Likes
lock attach
Attachments are accessible only for community members.
EvPa_264126
Level 7
Level 7
500 replies posted 250 replies posted 100 likes received
        o display 2x16 I had only example of reading ROM. Example in the attached archive. I hope he is not too much mistakes.   
0 Likes
Anonymous
Not applicable
        HI thanks for that have you be able to have more then one sensor on the same onewire line   
0 Likes
EvPa_264126
Level 7
Level 7
500 replies posted 250 replies posted 100 likes received

   

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.

Anonymous
Not applicable

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!

0 Likes
Anonymous
Not applicable

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!

0 Likes
Anonymous
Not applicable

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.

0 Likes
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

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-ds18b20-digital-temperature-se...

0 Likes