- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello ,
I have got question about : How can I implementation SHT10 humidity sensor in CY8C27443-24PXI using I2C ? I read a lot of datasheet etc. but I still do not know how.
Thanks for all help.
- Labels:
-
PSoC 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is problem about PSoC 5.2 so this is not good group. Admin can you change my post location ? Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The forum is the correct one, you are talking about PSoC1 and designer 5.2 (which I suggest to get updated to 5.3).
It would help us a lot when you provide us with a link to the datasheet of your sensor, so we could consider how to get it connected.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Have a look to this address : http://www.sensirion.com/en/products/humidity-temperature/download-center/
They give example code to interface with their sensor.
As is explained in their Appnote, it is a twi interface but it's not I2C compliant since the data line move while SCK is high.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
From the datasheet -
The serial interface of the SHT1x is optimized for sensor
readout and effective power consumption. The sensor
cannot be addressed by I2C protocol; however, the sensor
can be connected to an I2C bus without interference with
other devices connected to the bus. The controller must
switch between the protocols.
Looks like you will have to create your own, or port, protocol.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So Can I use this senor to read humidity ? I would like to connet this senor to RF Expansion Card (FTRF) and upload program from PSoC Designer 5.2 by means of PC Bridge (FTCP). I must use I2C protocol. What is your opinion on this topic ?
Thanks for all help 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The datasheet for that sensor specifically states the device can operate on/share an I2C buss, but is
not an I2C addressable device.
So answer is you port/use/write a bit banging protocol for that device, unless I am missing
something.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please refer to this thread on SHT1x - http://www.cypress.com/?app=forum&rID=51642
Also the CY3271 kit page has code examples for all the boards, you might be interested in modifying the code for the USB-I2C Bridge - http://www.cypress.com/?docID=32060
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What kind of moduls I must use ?
Thanks for all help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As Danaa said you will need to use a bit banging protocol. No UM is available for this kind of protocol.
Did you check the link I posted in my previous post, one of the document contain all the code necessary to talk with the sensor. You will have to modify it to reflect your own situation, but it should not be very difficult.
Hope it helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes , I've seen this document but I have no idea on how to do it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Using the code provided in the AppNote configure two pins, one as SCK and the other as Data. Configure the two pins as pull-up. Let's suppose you rename the pin SCK and DATA.
Here is one portion of code you will need to change. Other portions will have to be change using the same procedure.
//----------------------------------------------------------------------------------
char s_write_byte(unsigned char value)
//----------------------------------------------------------------------------------
// writes a byte on the Sensibus and checks the acknowledge
{
unsigned char i,error=0;
for (i=0x80;i>0;i/=2) //shift bit formasking
{ if (i & value) DATA=1; //masking valuewith i , write to SENSI-BUS
else DATA=0;
_nop_(); //observe setuptime
SCK=1; //clk for SENSI-BUS
_nop_();_nop_();_nop_(); //pulswith approx. 5 us
SCK=0;
_nop_(); //observe holdtime
}
DATA=1; //release DATA-line
_nop_(); //observe setuptime
SCK=1; //clk #9 for ack
error=DATA; //check ack (DATA will be pulled down by SHT11)
SCK=0;
return error; //error=1 in case of no acknowledge
}
// End of sample code
You will change the lines containing SCK = 1; by SCK_Data_ADDR |= SCK_MASK;
You will change the lines containing SCK = 0; by SCK_Data_ADDR &= ~SCK_MASK;
The same has to be done for the line refering to the DATA pin.
The next thing required is to change the _nop_(); with a macro you know takes 5us to execute.
You will have to modify every function containing a reference to SCK or DATA. Any other code should compile without or minor modification.
One last thing to take into consideration using this technique is the Read/modify/write issue.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
And I should use Protocol - BootLdrl2C ?
Thanks for all help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What should I do because I do not get it on ??
Thanks for all help or same code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What is the part you have problem with?
Do you have a project you can post ?
What is the part you don't understand?
Please be more precise...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just combines with the code I write something like this put an 🙂
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
EricS , Could You show on the example code you wrote above, it should look like using the command
SCK_Data_ADDR |= SCK_MASK and SCK_Data_ADDR &= ~SCK_MASK ?? I try to use it..
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Everytime you encounter a line stating SCK = 1, you replace it with SCK_Data_ADDR |= SCK_MASK and when it is SCK = 0, you change the line for SCK_Data_ADDR &= ~SCK_MASK
//----------------------------------------------------------------------------------
char s_write_byte(unsigned char value)
//----------------------------------------------------------------------------------
// writes a byte on the Sensibus and checks the acknowledge
{
unsigned char i,error=0;
for (i=0x80;i>0;i/=2) //shift bit formasking
{ if (i & value) Data_Data_ADDR |= Data_MASK; //masking valuewith i , write to SENSI-BUS
else Data_Data_ADDR &= ~Data_MASK;
_nop_(); //observe setuptime
SCK_Data_ADDR |= SCK_MASK; //clk for SENSI-BUS
_nop_();_nop_();_nop_(); //pulswith approx. 5 us
SCK_Data_ADDR &= ~SCK_MASK;
_nop_(); //observe holdtime
}
Data_Data_ADDR |= Data_MASK; //release DATA-line
_nop_(); //observe setuptime
SCK_Data_ADDR |= SCK_MASK; //clk #9 for ack
error=DATA; //check ack (DATA will be pulled down by SHT11)
SCK_Data_ADDR &= ~SCK_MASK;
return error; //error=1 in case of no acknowledge
}
// End of sample code
This is the way the code should look like. You will say I repeated Data twice but it's perfectly correct this way. Have a look at the file named PSocGPIOINT.h under the library header file it defines the IO with the name you gave them.
Using this way of coding, you can change the IO location without changing your code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have only GlobalParams.h I dont see PSocGPIOINT.h. But how do I define SCK_Data_ADDR |= SCK_MASK ,
SCK_Data_ADDR &= ~SCK_MASK and two commend to DATA that there is no error in the compilation ?? The most important question is : How can I set ports for this commend ? I will be very grateful for example.
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok i add and found this libery but what should I change ? Sory for a lot of question but I would try to do something and I have self-denial but my knowledge is not too great. Thanks for all help.
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The library file PSocGPIOINT.h is a compile time generated configuration file. Using the F6 key on your keyboard it will generate this file and all the file needed by the UM.
You don't have anything to change to the file PSoCGPIOINT.h, since it is regenerated everytime you compile. I gave you this file in reference to help you understand where all of what i'm talking is coming from.
regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok but what should I "define" in the beginning of code to use this commend ? How Can I define Port1_5 to SCL line and Port1_7 to SDA line ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can You show explain How Can I change the _nop_(); with a macro ??.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You don't have to define a macro as in the example code to assign P1_5 and P1_7 to the signals you want. The file PSoCGPIOINT.h is doing it for you. The only thing you need to do is give a name and the drive mode of the pin you want to use under the Pinout pane.
A nop macro can be defined this way
#define _nop_() asm ("nop")
It will be used this way _nop_();
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would try but I have got error. This is correct ?
#define DATA Port_1_7
#define SCK Port_1_5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
#include <m8c.h> // part specific constants and macros
#include "PSoCAPI.h" // PSoC API definitions for all User Modules
#include "PSoCGPIOINT.h" /
#include <math.h> //Keil library
#include <stdio.h> //Keil library
typedef union
{ unsigned int i;
float f;
} value;
enum {HUMI};
#define Data P1[7] // SDA line
#define SCK P1[5] // SCK line
#define _nop_()
#define STATUS_REG_W 0x06 //000 0011 0
#define STATUS_REG_R 0x07 //000 0011 1
#define MEASURE_HUMI 0x05 //000 0010 1
#define RESET 0x1e //000 1111 0
char s_write_byte(unsigned char value)
{
unsigned char i,error=0;
for (i=0x80;i>0;i/=2) //shift bit formasking
{ if (i & value) Data_Data_ADDR |= Data_MASK; //masking valuewith i , write to SENSI-BUS
else Data_Data_ADDR &= ~Data_MASK;
_nop_(); //observe setuptime
SCK_Data_ADDR |= SCK_MASK; //clk for SENSI-BUS
_nop_();_nop_();_nop_(); //pulswith approx. 5 us
SCK_Data_ADDR &= ~SCK_MASK;
_nop_(); //observe holdtime
}
Data_Data_ADDR |= Data_MASK; //release DATA-line
_nop_(); //observe setuptime
SCK_Data_ADDR |= SCK_MASK; //clk #9 for ack
error=Data; //check ack (DATA will be pulled down by SHT11)
SCK_Data_ADDR &= ~SCK_MASK;
return error; //error=1 in case of no acknowledge
}
Can you look for this code and if you can correct mistakes ? I have got error in line "error=Data; //check ack (DATA will be pulled down by SHT11)". Compiler say : main.c(56): undeclared identifier `P1'. Thanks for all help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I change error=DATA; to error=Data_Data_ADDR; and i have got 0 errors. So my next problem is how calc ( 8 bit measure humidity ) and sent to hub in PC ?? I put PC Bridge (FTCP) in USB in computer. Put SHT sensor to RF Expansion Card (FTRF). First i must reprogram the microprocesor in RF Expansion Card (FTRF). When I do it. I disconnect FTRF from PC Bridge and connect to power. Whats moduls or what i should use to send this humidity to PC and see result in Cypress Sense and Control
Dashboard ?? Thanks for all help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can anybody help in this problem ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your CY3271 CDROM disc contains several firmware projects that
pass data thru wireless bridge to SCD, Take a look at that code to
see how to format and xmit the data. Also make sure you config
the node to address the format of the data beinmg sent to it. There
is a specific firmware example on the CDROM that takes thermistor
data, passes it over wireless bridge, and plots it. Noite the latest CDROM
ISO of the disk is on the web. http://www.cypress.com/?rID=17672
Use this ap note, page 13, for code naming of pins, although sounds like
you have addressed it. The defines for the pins are incorrect in your code.
http://www.cypress.com/?rID=2900
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Forgot to add -
In the user guide for 3271 there is a node configuration example
for the thermistor firmware that you can follow.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Forgot to add -
In the user guide for 3271 there is a node configuration example
for the thermistor firmware that you can follow.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Lastly on the CDROM is a template file for the node configuration for the
example firmware using Thermistor. So you can open that in the node editor
to see how that was done for the firware example.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can You help me to use this example in my code ? (some code if you Can) Because I dont understend this app note and examples. Thanks for all help.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So I use this code:
#include <m8c.h> // part specific constants and macros
#include "PSoCAPI.h" // PSoC API definitions for all User Modules
#include "PSoCGPIOINT.h" // do obslugi portow
#include <math.h> //Keil library
#include <stdio.h> //Keil library
typedef union // zdefiniowanie zmiennych
{ unsigned int i;
float f;
} value;
enum {HUMI};
#define Data P1[5] // linia danych
#define SCK P1[7] // linia zegarowa
#define _nop_()
#define noACK 0
#define ACK 1
#define STATUS_REG_W 0x06 //000 0011 0
#define STATUS_REG_R 0x07 //000 0011 1
#define MEASURE_HUMI 0x05 //000 0010 1
#define RESET 0x1e //000 1111 0
char s_write_byte(unsigned char value)
{
unsigned char i,error=0;
for (i=0x80;i>0;i/=2) //shift bit formasking
{ if (i & value) Data_Data_ADDR |= Data_MASK; //masking valuewith i , write to SENSI-BUS
else Data_Data_ADDR &= ~Data_MASK;
_nop_(); //observe setuptime
SCK_Data_ADDR |= SCK_MASK; //clk for SENSI-BUS
_nop_();_nop_();_nop_(); //pulswith approx. 5 us
SCK_Data_ADDR &= ~SCK_MASK;
_nop_(); //observe holdtime
}
Data_Data_ADDR |= Data_MASK; //release DATA-line
_nop_(); //observe setuptime
SCK_Data_ADDR |= SCK_MASK; //clk #9 for ack
error=Data_Data_ADDR; //check ack (DATA will be pulled down by SHT10)
SCK_Data_ADDR &= ~SCK_MASK;
return error; //error=1 in case of no acknowledge
}
char s_read_byte(unsigned char ack)
{
unsigned char i,val=0;
Data_Data_ADDR=1; //release DATA-line
for (i=0x80;i>0;i/=2) //shift bit for masking
{ SCK_Data_ADDR |= SCK_MASK; //clk for SENSI-BUS
if (Data_Data_ADDR) val=(val | i); //read bit
SCK_Data_ADDR &= ~SCK_MASK;
}
Data_Data_ADDR=!ack; //in case of "ack==1" pull down DATA-Line
SCK_Data_ADDR |= SCK_MASK; //clk #9 for ack
_nop_();_nop_();_nop_(); //pulswith approx. 5 us
SCK_Data_ADDR &= ~SCK_MASK;
Data_Data_ADDR |= Data_MASK; //release DATA-line
return val;
}
void s_transstart(void)
{
Data_Data_ADDR |= Data_MASK; SCK_Data_ADDR &= ~SCK_MASK; //Inicjalizacja stanow Data=1 SCK=1
_nop_();
SCK_Data_ADDR |= SCK_MASK;
_nop_();
Data_Data_ADDR &= ~Data_MASK;
_nop_();
SCK_Data_ADDR &= ~SCK_MASK;
_nop_();_nop_();_nop_();
SCK_Data_ADDR |= SCK_MASK;
_nop_();
Data_Data_ADDR |= Data_MASK;
_nop_();
SCK_Data_ADDR &= ~SCK_MASK;
}
void s_connectionreset(void)
{
unsigned char i;
Data_Data_ADDR |= Data_MASK; SCK_Data_ADDR &= ~SCK_MASK; //Inicjalizacja stanow
for(i=0;i<9;i++) //9 cyklow SCK
{ SCK_Data_ADDR |= SCK_MASK;
SCK_Data_ADDR &= ~SCK_MASK;
}
s_transstart(); //start transmisji
}
char s_read_statusreg(unsigned char *p_value, unsigned char *p_checksum)
{
unsigned char error=0;
s_transstart(); //transmission start
error=s_write_byte(STATUS_REG_R); //send command to sensor
*p_value=s_read_byte(ACK); //read status register (8-bit)
*p_checksum=s_read_byte(noACK); //read checksum (8-bit)
return error; //error=1 in case of no response form the sensor
}
char s_write_statusreg(unsigned char *p_value)
{
unsigned char error=0;
s_transstart(); //transmission start
error+=s_write_byte(STATUS_REG_W);//send command to sensor
error+=s_write_byte(*p_value); //send value of status register
return error; //error>=1 in case of no response form the sensor
}
char s_measure(unsigned char *p_value, unsigned char *p_checksum, unsigned char mode)
{
unsigned error=0;
unsigned int i;
s_transstart(); //transmission start
switch(mode){ //send command to sensor
case HUMI : error+=s_write_byte(MEASURE_HUMI); break;
default : break;
}
for (i=0;i<65535;i++) if(Data_Data_ADDR==0) break; //wait until sensor has finished the measurement
if(Data_Data_ADDR) error+=1; // or timeout (~2 sec.) is reached
*(p_value) =s_read_byte(ACK); //read the first byte (MSB)
*(p_value+1)=s_read_byte(ACK); //read the second byte (LSB)
*p_checksum =s_read_byte(noACK); //read checksum
return error;
}
void main(void)
{ value humi_val;
unsigned char error,checksum;
unsigned int i;
s_connectionreset();
while(1)
{ error=0;
error+=s_measure((unsigned char*) &humi_val.i,&checksum,HUMI); //measure humidity
if(error!=0) s_connectionreset(); //in case of an error: connection reset
else
{ humi_val.f=(float)humi_val.i; //converts integer to float
}
//----------wait approx. 0.8s to avoid heating up SHTxx------------------------------
for (i=0;i<40000;i++);
//-----------------------------------------------------------------------------------
}
}
and I didn't see anything on the oscilloscope. Where is the error ? Thanks for all help.
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It would help to post the entire project rather than posting a bunch of code. Your problem may be in the code, but it may be in the chip configuration too.
Make sure the drive mode is correct on the needed pin.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is link to download project :
http://www37.zippyshare.com/v/8932512/file.html
I will be very grateful for someone to improve this project and insert a link to download.
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Change the drive mode of your pin from High-z Analog to Pull-up or open drain high. If you select Open drain high you will require an external pull-up.
Change your "#define _nop_()" to "#define _nop_() asm ("nop")".
That should help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I must use some couter or etc. ? I download this folder and add this libary. What do you thing about use this delay ?
link to libery and comment : http://www.planetpsoc.com/programming-assembly-and-c/32-delay-functions.html