View previous topic :: View next topic |
Author |
Message |
andys
Joined: 23 Oct 2006 Posts: 175
|
DS1621 problem |
Posted: Sun Feb 02, 2014 6:46 pm |
|
|
I tried to use ds1621 driver but i can not receive any data from the sensor
the main (for use the driver ) is presented below :
Code: |
void main()
{
float value1;
init_temp();
while(1)
{
value1= read_full_temp();
printf("TEMP.(F)-FULL %.1g",value1);
}
} |
Is this a good way to use driver ?
I connect the A0,A1,A2 to ground and i use 2.2K as pull up resistors(datasheet don't say anything about pull up resistors).
Is anybody who can help? what is going wrong ? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Feb 02, 2014 6:53 pm |
|
|
Try this CCS example file. It shows how to call the ds1621.c driver:
Quote: | c:\program files\picc\examples\ex_temp.c |
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19589
|
|
Posted: Mon Feb 03, 2014 6:49 am |
|
|
As a comment, though the data sheet itself does not mention pull-ups, it says 'open drain I/O lines', and refers to the 'bus specification'. Read the I2C specs...
Best Wishes |
|
|
andys
Joined: 23 Oct 2006 Posts: 175
|
DS1621 problem |
Posted: Mon Feb 03, 2014 4:08 pm |
|
|
To be honest i didn't see anything about pull-up resistors but i think when we speak about i2c the pull-up resistors are necessary.
Anyway i use the driver and the example(how to use the driver) without resistors and i receive the value :
TEMP:32 and then a strange symbol.
How to remove the strange symbol ????? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Feb 03, 2014 4:22 pm |
|
|
Quote: | Anyway i use the driver and the example(how to use the driver) without resistors. |
You must have pullup resistors on SDA and SCL. Put them back in. |
|
|
andys
Joined: 23 Oct 2006 Posts: 175
|
DS1621 problem |
Posted: Mon Feb 03, 2014 5:52 pm |
|
|
You are right PCM programmer.
The status is as follow ( an lcd with 2 lines screens is used):
1)If I don’t use pull-up resistors I can not see anything to the lcd displayer.
2)If I use only 1 pull-up resistor connected to SCL I can see at both lines TEMP:32 with a strange symbol at the end.
3) If I use 2 pull-up resistors I receive at the first line TEMP:32 with a strange symbol at the end. At the second line I receive : TEMP:255 with a strange symbol at the end
what is going wrong ???? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9269 Location: Greensville,Ontario
|
|
Posted: Mon Feb 03, 2014 6:13 pm |
|
|
You haven't shown us the entire program, but I'm wondering how you're talking to an LCD module using just printf(...).All 2x16 LCD modules need a 'driver'( either the CCS example or the 'flex' one).
Normally printf(..) will send data to the UART( #use rs232(.....)).
Odd looking data on the LCD screen is puzzling to me
... printf("TEMP.(F)-FULL %.1g",value1);
looks like 14-15 characters before value1 is displayed.
I don't know where the semicolon ( after TEMP comes from either!
Please post your entire program,as well as compiler version.
The more you show and tell, the better/quicker we can figure it out !
hth
jay |
|
|
andys
Joined: 23 Oct 2006 Posts: 175
|
DS1621 problem |
Posted: Mon Feb 03, 2014 6:31 pm |
|
|
i am using the flex driver
Code: |
#include <33fj128GP802.h>
#FUSES NOPROTECT
#FUSES NOIESO
#FUSES FRC
#FUSES NOWDT
#use delay(clock=7.37MHz)
#PIN_SELECT U1RX=PIN_B15
#PIN_SELECT U1TX=PIN_B14
#USE RS232(UART1,ERRORS,BAUD=9600)
#define DAL_SCL PIN_B8
#define DAL_SDA PIN_B9
#use i2c(Master, sda=DAL_SDA, scl=DAL_SCL)
#include <ds1621.c>
#include "flex_lcd.c"
void main() {
BYTE value;
lcd_init();
init_temp();
do {
value = read_temp();
//printf("TEMP:%u\r\n",value);
printf(lcd_putc, "TEMP:%u\r\n\n",value);
printf("TEMP:%u\r\n",value);
delay_ms(1000);
} while (TRUE);
}
|
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9269 Location: Greensville,Ontario
|
|
Posted: Tue Feb 04, 2014 6:22 am |
|
|
hmm. add a delay_ms(500); before calling the init_lcd() function.
LCD modules are 'slow' and need some time to get 'organized' before you can access them properly.
hth
jay |
|
|
Jim90
Joined: 27 Apr 2013 Posts: 55
|
DS1621 problem |
Posted: Tue Feb 04, 2014 3:25 pm |
|
|
unfortunatelly if i add a
delay_ms(500); before lcd_init();
i received TEMP:255 all the time !!!
What else can i try ? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19589
|
|
Posted: Tue Feb 04, 2014 3:45 pm |
|
|
Temp=255, is what you would get if the device was not on the address the code is trying to talk to.
The DS1621 driver assumes you have pins A0, A1, and A2 all pulled low. You say this is the case, but are you sure?.
Run the I2C bus scanner program from the code library:
<http://www.ccsinfo.com/forum/viewtopic.php?t=49713>
Does it find your device?. What address is it on?.
Do a search on what 'open collector outputs' means:
<http://en.wikipedia.org/wiki/Open_collector>
This is why resistors are required.
Best Wishes |
|
|
andys
Joined: 23 Oct 2006 Posts: 175
|
DS1621 problem |
Posted: Tue Feb 04, 2014 4:15 pm |
|
|
The A0,A1,A2 is connected to ground.
When i use the scanner function the only thing which is printed is the start: nothing else. What is going wrong ??? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19589
|
|
Posted: Wed Feb 05, 2014 1:54 am |
|
|
The device is not being seen on the bus.
Something is wrong with the connections, or the chip itself.
Now, 'step back'. You are using a 33J chip. So Same rail to both chips?. 3.3v?. Same GND connected to both chips?. How long is the connection?. Pull up's to 3.3v?.
The "pull up's" are a classic example of not fully reading a data sheet. Manufacturers often don't give you simple 'you must use pull up resistor' type instructions, but instead simply use the technical description 'open collector' (which means the chip outputs have NPN transistors, to pull the line 'down', but the collector of the transistor is left 'open', so you must supply a pull up...). They do refer you also to the I2C bus specification, and reading this part of the reason they don't talk about pull up resistors then becomes explained, since you can use either resistors (for simple busses at relatively low speeds), or 'active pull ups', with transistors accelerating the rising edge on the bus. Lesson is that if reading a data sheet, and they use a term like 'open collector', make sure you go and find out what this actually means. If a reference is made to a particular bus, then you need to read it's data as well. You can't just skip over things in a data sheet.....
Now, the value for Rp (the pull up resistors), depends on your bus capacitance, clock speed used, and the supply voltage. 2.4KR, should be OK, provided you only have a little capacitance on the bus. Hence the question about your connections.
On your connections, _check_. Don't assume that because you have a wire from pinA, to pinB, that it actually connects. Take the time to sit down with a meter, and test that each connection does get physically to the pin on the chip, and then that it doesn't short to the pin next door. 'Old hands' here will often sit down with a meter, and a magnifying glass, doing such tests, and then searching for whiskers between pins as well. It is one of the commonest problems. Even if you are using a manufactured PCB, unless you paid for 'electrical testing' as the final stage of manufacture, assume there _will_ be whisker shorts sometimes....
PCM_programmers test program really is always the starting point for I2C, simply testing for the chip acknowledging on it's address. This is something that all I2C devices are required to do, and until it is seen by this, there is no point in trying anything else!...
Best Wishes |
|
|
|