PDA

View Full Version : Write Onewire data toa I2C memory / read ASCI



Eugeniu
- 14th October 2008, 22:34
Hi !

I have a display with leds . If I write a text to a I2C memory (24FC512),I can read and scroll this text on leds display . But...I wish to write the result of measurement from ONEWIRE sensor DS1820 for example :

" temperature = (((temperature >> 1) * 100) - 25) + (((count_per_c - count_remain) * 100) / count_per_c) "


and to read / display ASCI karacter , something like this :

"i2cread I2CDAT , I2CCLK , $A0,adrr,[karacter]" karacter to be ASCI code

I can not know to do this . Can somebody to help me ?

Thank you very much !
PS. Escuse me ! I do not know so well english .

inse
- 15th October 2008, 05:36
Hi Eugeniu,

it's not clear to me what you want to do, maybe point 4.17.7. in the manual is what you should have a look at.

4.17.7 DIG
DIG returns the value of a decimal digit. Simply tell it the digit number
(0 - 4 with 0 being the rightmost digit) you would like the value of, and
voila.
B0 = 123 ‘ Set B0 to 123
B1 = B0 DIG 1 ‘ Sets B1 to 2 (digit 1 of
123)

This allows you to separate each digit from the computed result.

But you can also divide the word into two bytes using the .lowbyte and .highbyte modifiers and write them to the display or memory.

HTH

Regards,
Ingo

Eugeniu
- 15th October 2008, 15:13
Hi Eugeniu,

it's not clear to me what you want to do, maybe point 4.17.7. in the manual is what you should have a look at......................

I will try to explain :

I use in this moment .....writing a text in a I2C memory ........

for adr = 0 to 135
lookup adr,["WELLCOM ! .......................... 5"],c
I2cwrite I2CDAT , I2CCLK , $A0,ADR,[C]
pause 5
next adr

Read text :

i2cread I2CDAT , I2CCLK , $A0,J,[caracter]

Use " case " for select :

SELECT CASE CARACTER
CASE 65: SIR_NO=4 ;A
CASE 66: SIR_NO=9 ;B
CASE 67: SIR_NO=14 ;C
CASE 68: SIR_NO=19 ;D
CASE 69: SIR_NO=24 ;E

and .....go for select what leds are on .....

TABLOU:
LOOKUP OFSET,[_
$3F,$48,$48,$48,$3F,_ ;A 0-4
$36,$49,$49,$49,$7F,_ ;B 4-9
$22,$41,$41,$41,$3E,_ ;C 9-14
$3E,$41,$41,$41,$7F,_ ;D 14-19
$41,$49,$49,$49,$7F,_ ;E 19-24

I wish to write time to time in memory a temperature from a Onewire sensor tip DS1820 and when I read from memory to find there a ASCI CODE to can use same , in my program .

aratti
- 15th October 2008, 15:35
I have difficulty in understanding what you want to do! You should post the complete code to better understand what you have done and what you want to achieve.

Remember that you cannot write and read with the same control!

use:

WriteDev con %10100000
ReadDev con %10100001

Perhaps it will solve your present problem.

Al.

Eugeniu
- 15th October 2008, 16:25
I have difficulty in understanding what you want to do!

You should post the complete code to better understand what you have done and what you want to achieve.


Al.

Briefly : Tell me how can write in a I2C memory result from this :



mainloop:
OWOut DQ, 1, [$CC, $44] ' Start temperature conversion

waitloop:
OWIn DQ, 4, [count_remain] ' Check for still busy converting
If count_remain = 0 Then waitloop
OWOut DQ, 1, [$CC, $BE] ' Read the temperature
OWIn DQ, 0, [temperature.LOWBYTE, temperature.HIGHBYTE, Skip 4, count_remain, count_per_c]
temperature = (((temperature >> 1) * 100) - 25) + (((count_per_c - count_remain) * 100) / count_per_c)
'Calculate temperature in degrees C to 2 decimal places (not valid for negative temperature)

******************

adr = xx
i2cwrite I2CDAT, I2CCLK, $A0, adr,[temperature]
pause 5

******************

and how can read from memory something xx,xx (ASCI CODE )

skimask
- 15th October 2008, 16:37
Briefly : Tell me how can write in a I2C memory result from this :
I too am having a bit of difficulty in understanding what you wish to achieve...


adr = xx
i2cwrite I2CDAT, I2CCLK, $A0, adr,[temperature]
pause 5

******************

and how can read from memory something xx,xx (ASCI CODE )

Is 'temperature' a byte or a word value?
Are you wanting to get a fractional value out of the eeprom itself?
Have you put a fractional value into that location of the eeprom?

I2CREAD I2CDAT , I2CCLK , $A0 , adr , [ temp_read ] - would be a command line for starters...

Eugeniu
- 15th October 2008, 17:37
I too am having a bit of difficulty in understanding what you wish to achieve...

" i2cwrite I2CDAT, I2CCLK, $A0, adr,[I do not know what to write here ]".......

and , to can read 2 digits and 2 decimals for example
25,55 grade C

skimask
- 15th October 2008, 17:41
" i2cwrite I2CDAT, I2CCLK, $A0, adr,[I do not know what to write here ]".......

and , to can read 2 digits and 2 decimals for example
25,55 grade C

If you read the PBP manual, you'll find commands in the LCD, I2Cxxxx, SERIN/SEROUT, HSERIN/HSEROUT, and various other sections that will show you have these various commands handle digits, decimals (which PBP does NOT natively handle), numeric characters, ASCII values, etc.etc.etc. DEC DIG HEX BIN, and all sorts of other good information in there...

aratti
- 15th October 2008, 17:47
Split value into two separate bytes

i2cwrite I2CDAT, I2CCLK, $A0, adr,[Byte_integer,Byte_decimal]

Al.

Eugeniu
- 15th October 2008, 17:51
I put all program .

Eugeniu
- 15th October 2008, 17:56
Split value into two separate bytes

i2cwrite I2CDAT, I2CCLK, $A0, adr,[Byte_integer,Byte_decimal]

Al.

You can see in program that I wish to do this . to write at adr. 71 2 digits , and at adr 74, other 2 ( decimals ) But how ?

Eugeniu
- 15th October 2008, 18:06
If you read the PBP manual, you'll find commands in the LCD, I2Cxxxx, SERIN/SEROUT, HSERIN/HSEROUT, and various other sections that will show you have these various commands handle digits, decimals (which PBP does NOT natively handle), numeric characters, ASCII values, etc.etc.etc. DEC DIG HEX BIN, and all sorts of other good information in there...

I know this , and I have used for LCD display , for serin/serout and work , but now I do not know how can use this commands for I2CXXXX. When I use one of this do not accept by MicroCode Studio .

skimask
- 15th October 2008, 18:20
I know this , and I have used for LCD display , for serin/serout and work , but now I do not know how can use this commands for I2CXXXX. When I use one of this do not accept by MicroCode Studio .
You don't have to store them in eeprom in anyway out of the ordinary. If you can display it using those modifiers, then store the data as the raw data. Then recover it as raw data and display it using those modifiers again. You don't have to do anything special to store it.

Eugeniu
- 15th October 2008, 18:33
You don't have to store them in eeprom in anyway out of the ordinary. If you can display it using those modifiers, then store the data as the raw data. Then recover it as raw data and display it using those modifiers again. You don't have to do anything special to store it.

Can you give me a in context example ? Please !

Thank you !

skimask
- 15th October 2008, 18:38
Can you give me a in context example ? Please !


Just exactly what you had...
i2cwrite I2CDAT, I2CCLK, $A0, adr,[Byte_integer,Byte_decimal]
Then read them back the same way and display them on the LCD seperately with a decimal point in between them.

Eugeniu
- 15th October 2008, 19:09
Just exactly what you had...
i2cwrite I2CDAT, I2CCLK, $A0, adr,[Byte_integer,Byte_decimal]
Then read them back the same way and display them on the LCD seperately with a decimal point in between them.

I do not use LCD , I use a 7 X 96 leds panel . With LCD is very simple ! Support all of these "DEC DIG HEX BIN,"

skimask
- 15th October 2008, 19:22
I do not use LCD , I use a 7 X 96 leds panel . With LCD is very simple ! Support all of these "DEC DIG HEX BIN,"

Ahhh....ok....I see now...
Well then...your answer is in post #2...

Eugeniu
- 15th October 2008, 19:35
Ahhh....ok....I see now...
Well then...your answer is in post #2...

I am sorry ! but I do not see in mind the solution for my problem .
I say again : PLEASE ! SHOW ME IN CONTEXT EXAMPLE , in my programme.

skimask
- 15th October 2008, 19:39
I am sorry ! but I do not see in mind the solution for my problem .
I say again : PLEASE ! SHOW ME IN CONTEXT EXAMPLE , in my programme.
Ok, you can't display a byte variable directly because a byte (if larger than 9) contains more than one numeric character right?

Eugeniu
- 16th October 2008, 17:49
Ok, you can't display a byte variable directly because a byte (if larger than 9) contains more than one numeric character right?

I must to read from memory , for example :for 25,55 (grade C ) I must to read from memory ...50 53 44 53 53 , or except " , " 50 53 53 53

skimask
- 16th October 2008, 18:48
I must to read from memory , for example :for 25,55 (grade C ) I must to read from memory ...50 53 44 53 53 , or except " , " 50 53 53 53
Yes, I understand, I think... A bit of a language disconnect here I think :) Not that your English is bad, it's not bad at all, it's far far better than my ______(insert language here)...

Those sequences of numbers above...What are they? Is that how you have it stored? Or is that how you want to display it...
What is 25,55? Is it 25.55? Or is it 25, then 55, and so on (I realize in Europe and other parts of the world the comma ( , ) is used in much the same way that folks in the States use the decimal point)...

Eugeniu
- 16th October 2008, 18:58
Yes, I understand, I think... A bit of a language disconnect here I think :) Not that your English is bad, it's not bad at all, it's far far better than my ______(insert language here)...

Those sequences of numbers above...What are they? Is that how you have it stored?

They are in ACII code . I attach it .



(I realize in Europe and other parts of the world the comma ( , ) is used in much the same way that folks in the States use the decimal point)...

Is not impportant , is a separration sign between 25(integer) and 55(2 decimals)

inse
- 16th October 2008, 20:11
Hi Eugeniu,

as I have already explained in my first post:
use the DIG modifier to separate the single digits of your calculated temperature.
Then simply add 48 to each digit and you will get the ASCII code.

If temperature is 2555 for 25.55°C
n0 = (temperature dig 0) + 48

n0 is 48+5 = 53 = ASCII "5"
...

Regards,

Ingo

Eugeniu
- 16th October 2008, 20:40
Hi Eugeniu,

as I have already explained in my first post:
use the DIG modifier to separate the single digits of your calculated temperature.
Then simply add 48 to each digit and you will get the ASCII code.

If temperature is 2555 for 25.55°C
n0 = (temperature dig 0) + 48

n0 is 48+5 = 53 = ASCII "5"
...

Regards,

Ingo

Dear Ingo ,

I work by many days to do this and in my mind is a black hole. Please if you wish to help me , write a example ,

i2cwrite I2CDAT, I2CCLK, $A0, adr,[TELL ME WHAT i MUST TO WRITE HERE ]

I think that you now formula for temperature measurement with Onewire sensor ( one from others ) :
" temperature = (((temperature >> 1) * 100) - 25) + (((count_per_c - count_remain) * 100) / count_per_c) "

If I will write :

LCDOUT $FE, $C0, DEC TEMPERATURE
I'll be reading 2555

For LCDOUT and to see a comma , I use this formula :
lcdout "temp= " , dec temperature/2 ,"," , dec2 100- (100/16)*(count_remain)," gr.C"

, but ....If I write in EEPROM :

i2cwrite I2CDAT, I2CCLK, $A0, adr,[temperature]

When I will read it with my FORMULA :

i2cread I2CDAT , I2CCLK , $A0,J,[caracter]
in " caracter "will can be read , time to time , a single sign / not a cipher

inse
- 16th October 2008, 21:32
Hi Eugeniu,

your program is a little bit hard to read without knowing Romanian (right?).

If you want to store the temperature value in single ASCII characters, something like this might work:

i2cwrite I2CDAT, I2CCLK, $A0, adr,[(temperature dig 0= + 48, (temperature dig 1) + 48, (temperature dig 2) + 48, (temperature dig 3) +48]

Add the comma where you please or add it after reading back the value.

Correct me if I am talking bull****...

Regards,
Ingo

Eugeniu
- 16th October 2008, 21:52
Hi Eugeniu,

your program is a little bit hard to read without knowing Romanian (right?).

If you want to store the temperature value in single ASCII characters, something like this might work:

i2cwrite I2CDAT, I2CCLK, $A0, adr,[(temperature dig 0= + 48, (temperature dig 1) + 48, (temperature dig 2) + 48, (temperature dig 3) +48]

Add the comma where you please or add it after reading back the value.

Correct me if I am talking bull****...

Regards,
Ingo

Uffff, not work . I see or 88888888 , or 44444444 or 77777777 .......
I'll try to write every DIG , separate . I'll tell you tomorow if work .

Thank you very much ! Good night !

skimask
- 16th October 2008, 23:12
LCDOUT $FE, $C0, DEC TEMPERATURE
I'll be reading 2555
If that's the only thing you are getting out of the temp sensor, then I'm thinking it probably meaning that your connection or your sensor probably isn't working because it's returning a value that's always max'd out for a byte variable...
Put the sensor in some ice water and see if the reading changes...
Get the core working first, then start adding things. You're not even sure if the sensor part is working in the first place!


, but ....If I write in EEPROM :
i2cwrite I2CDAT, I2CCLK, $A0, adr,[temperature]
When I will read it with my FORMULA :
i2cread I2CDAT , I2CCLK , $A0,J,[caracter]
in " caracter "will can be read , time to time , a single sign / not a cipher
Each one of these statements might only be WRITE'ing (or READ'ing) a BYTE, not a WORD. Not sure what the rest of your code says...

aratti
- 17th October 2008, 00:23
You wrote:

"LCDOUT $FE, $C0, DEC TEMPERATURE
I'll be reading 2555 "

Now:

ByteInteger = TEMPERATURE/100

ByteDecimal = TEMPERATURE-(ByteInteger*100)

LCDOUT $FE, $C0, DEC ByteInteger,",",ByteDecimal

You will see on your display 25,55.

You don't need to store the comma (separator) but you will store only ByteInteger and ByteDecimal in a location that can be recalled to read back the values. Than after the reading you will add the separator as above.

Al.

aratti
- 17th October 2008, 00:27
Sorry I have forgotten a Dec. Please read......

LCDOUT $FE, $C0, DEC ByteInteger,",",DEC ByteDecimal

Eugeniu
- 17th October 2008, 08:37
Dear MEN !

I do not use a LCD display . I have make only a comparision .

I use in front of my program this line to write text "

I2Cwrite I2CDAT, I2CCLK, $A0, adr,[" Temperature is _________________ "]

late in program , in free space I wish to write DATA of temperature

adr = 15( where is free space )
I2Cread I2CDAT, I2CCLK, $A0, adr,[ temperature DATA ]

In finish, I wish to can read all - text and temperature DATA as ASCI CODE such as

Temperatura is 25,55(for example) .

from this formula :

i2cread I2CDAT , I2CCLK , $A0,J,[caracter]

program read for every adrress (j) a sign (caracter ) in ASCI Code , and this CODE i'll translate in leds on .But where I write temperature DATA , program read other signs not ASCI CODE for 25,55 ( for example )

Now understand me ?

I 'll try to write only text with quote and temperature DATA except quote

Eugeniu
- 17th October 2008, 10:04
I 'll try to write only text with quote and temperature DATA except quote

Not work . Data from DS1820 temperature sensor is in binary . Do you know how can convert it in decimal and use in formula ? Except use DEC .

aratti
- 17th October 2008, 10:28
YOU WROTE:
-------------------------------------------------------------------------
I do not use a LCD display . I have make only a comparision .
I use in front of my program this line to write text "
I2Cwrite I2CDAT, I2CCLK, $A0, adr,[" Temperature is _________________ "]
late in program , in free space I wish to write DATA of temperature
adr = 15( where is free space )
I2Cread I2CDAT, I2CCLK, $A0, adr,[ temperature DATA ]
------------------------------------------------------------------------

I assume you have grounded pin 1 , pin 2 and pin 3 of your 24LC01 chip and that you have pulled up pin 6 and pin 5 with a 4.7K resistors (see page 85 of the manual)

Just use the following code:

'set these variable

WriteDev con %10100000
ReadDev con %10100001
Celsius VAR BYTE [32]

Fix text in the array

Celsius[0]=84
Celsius[1]=101
Celsius[2]=109
Celsius[3]=112
Celsius[4]=101
Celsius[5]=114
Celsius[6]=97
Celsius[7]=116
Celsius[8]=117
Celsius[9]=114
Celsius[10]=32
Celsius[11]=105
Celsius[12]=115
Celsius[13]=32
Celsius[14]=0
Celsius[15]=44
Celsius[16]=0


Now in your program you read temperature from your device and you have the value in the variable TEMPERATURE!

write:

Celsius[14] = TEMPERATURE/100
Celsius[16] = TEMPERATURE - (Celsius[14]*100)

So you will have the integer part of your value in Celsius[14] and the decimal part in Celsius[16]. Celsius[15]=44 is your separator.

Now write to your memory at address 0
adr=0

I2CWRITE I2CDAT, I2CCLK, WriteDev , adr,[ Str Celsius\32]
PAUSE 10

Now if your hardware works properly, you should have stored in your memory the string and the values.

To recall them back:

adr=0
I2CREAD I2CDAT, I2CCLK, ReadDev , adr,[ Str Celsius\32]
Pause 10

At this point you send the array to your display

For A0=0 to 16
single byte (Celsius[A0]) can be sent to your display
Next A0

If you need to store more than on single value you have to increment your Address (adr) by a multiple of 32, and with two values you have filled one page (64 bytes)

Al.

Eugeniu
- 17th October 2008, 21:10
QUOTE=aratti;
-------------------------------------------------------------------------
I do not use a LCD display . I have make only a comparision .
I use in front of my program this line to write text "
I2Cwrite I2CDAT, I2CCLK, $A0, adr,[" Temperature is _________________ "]
late in program , in free space I wish to write DATA of temperature
adr = 15( where is free space )
I2Cread I2CDAT, I2CCLK, $A0, adr,[ temperature DATA ]
------------------------------------------------------------------------

I assume you have grounded pin 1 , pin 2 and pin 3 of your 24LC01 chip and that you have pulled up pin 6 and pin 5 with a 4.7K resistors (see page 85 of the manual)

I use this display NOW , and scroll a simple text , but a long text , what is writing in a 24FC512 menory . It has pins 1,2,3,4 and 7 to ground .


Just use the following code:

'set these variable

What doing this ?

WriteDev con %10100000
ReadDev con %10100001
Celsius VAR BYTE [32]

Fix text in the array

I use a long text ......with caps.letters only ( you can see this in my programe ).


Celsius[0]=84 = T
Celsius[1]=101 = e
Celsius[2]=109 = m
Celsius[3]=112 = p
Celsius[4]=101 = e
Celsius[5]=114 = r
Celsius[6]=97 = a
Celsius[7]=116 = t
Celsius[8]=117 =u
Celsius[9]=114 =r
Celsius[10]=32 = blank
Celsius[11]=105 = i
Celsius[12]=115 = s
Celsius[13]=32 = blank
Celsius[14]=0 this is not 0
Celsius[15]=44 = ,
Celsius[16]=0


Now in your program you read temperature from your device and you have the value in the variable TEMPERATURE!

write:

Celsius[14] = TEMPERATURE/100
Celsius[16] = TEMPERATURE - (Celsius[14]*100)

So you will have the integer part of your value in Celsius[14] and the decimal part in Celsius[16]. Celsius[15]=44 is your separator.

Now write to your memory at address 0
adr=0

I2CWRITE I2CDAT, I2CCLK, WriteDev , adr,[ Str Celsius\32]
PAUSE 10

Now if your hardware works properly, you should have stored in your memory the string and the values.

To recall them back:

Look back in message , I must to use only this formula , only one .
I2Cread I2CDAT , I2CCLK , $A0 , J ,[caracter]


adr=0
I2CREAD I2CDAT, I2CCLK, ReadDev , adr,[ Str Celsius\32]
Pause 10

At this point you send the array to your display

For A0=0 to 16
single byte (Celsius[A0]) can be sent to your display
Next A0

If you need to store more than on single value you have to increment your Address (adr) by a multiple of 32, and with two values you have filled one page (64 bytes)


Thank you !

skimask
- 17th October 2008, 21:36
Either there is still a serious language barrier here or you're not getting what we're trying to say... In either case, I wish I spoke whatever language you speak so we could get this all straightened out a lot faster...


I use this display NOW , and scroll a simple text , but a long text , what is writing in a 24FC512 menory . It has pins 1,2,3,4 and 7 to ground .
And is it working the way you want it to work?


What doing this ?
Shouldn't have to use 2 different 'codes' for reading and writing to an I2C eeprom. PBP handles the Read/Write bit (bit0 in the 'code') for you. Should only need to use $A0 when addressing a standard 24xxxxx serial eeprom.


I use a long text....with caps.letters only (you can see this in my programe)
Are you storing the entire string, along with the temperature data in the eeprom or just the temperature?


Look back in message , I must to use only this formula , only one .
That may be so, but to store a temperature, with a whole part and a fractional part, along with any other characters, you are going to need more than one byte of storage and will need more than one I2CWRITE command...

Eugeniu
- 17th October 2008, 22:28
skimask;64321 Either there is still a serious language barrier here or you're not getting what we're trying to say... In either case, I wish I spoke whatever language you speak so we could get this all straightened out a lot faster...

I am from Bucharest , ROMANIA .

And is it working the way you want it to work?

It work OK with a simle text . But I wish to add in the fututre more options such : temperature out , temperature in house , time , date ...


Shouldn't have to use 2 different 'codes' for reading and writing to an I2C eeprom. PBP handles the Read/Write bit (bit0 in the 'code') for you. Should only need to use $A0 when addressing a standard 24xxxxx serial eeprom.

Of course , I use this " $A0 "

Are you storing the entire string, along with the temperature data in the eeprom or just the temperature?

I wish to store only result ( I think that I understand exactly what you say ??)

That may be so, but to store a temperature, with a whole part and a fractional part, along with any other characters, you are going to need more than one byte of storage and will need more than one I2CWRITE command...

Is not important how many I2Cwrite command will be use ,if PIC16F876 support lenght of code . Important is to can used only one command I2Cread to read all - text and data -

skimask
- 17th October 2008, 22:54
Is not important how many I2Cwrite command will be use ,if PIC16F876 support lenght of code . Important is to can used only one command I2Cread to read all - text and data
Those 2 comments contradict themselves...
-----Is not important how many I2CWRITE command will be use, if PIC support length of code----
Tells me that you can use I2CWRITE as many times as you need as long as the PIC has enough code space left...

----Important is to can used only one command I2CREAD to read all - text and data -----
Tells me that you MUST read everything you write with one single command.

Which one is it?

Eugeniu
- 18th October 2008, 05:51
Those 2 comments contradict themselves...
-----Is not important how many I2CWRITE command will be use, if PIC support length of code----
Tells me that you can use I2CWRITE as many times as you need as long as the PIC has enough code space left...

It's true .

----Important is to can used only one command I2CREAD to read all - text and data -----
Tells me that you MUST read everything you write with one single command.

And this is true .

Which one is it?

Is not a contradict . I write in memory at diversely address and time sequents, and read all address once .

skimask
- 18th October 2008, 06:08
Is not a contradict . I write in memory at diversely address and time sequents, and read all address once .
Ok, so if I am to understand this correctly, at the moment, you have:
A PIC
A one-wire temp sensor (model number???)
A 24FC512 serial eeprom
A handful of 5x7 LED matrix display units
An LCD for testing (not to be used in the 'final project')

Correct so far?

languer
- 18th October 2008, 06:26
Don't mean to jump in the middle of everything here, but let me see if I can summarize perhaps what you want to do.

You want to write both "TEXT" and digits to the EEPROM using one (or several) I2CWRITE command; and you want to read them, again, using one I2CREAD command correct?

If this is so, I think you really want to revisit what ARATTI said on post #32. Using the STR, [Str Celsius\32], modifier allows to access a whole string (array) which is what you want to do. Let me note though, that this would be an awfull waste of resources. Storing the numeric value in the EEPROM is good, but all additional processing and characters do not need to be on EEPROM.

skimask
- 18th October 2008, 06:56
If this is so, I think you really want to revisit what ARATTI said on post #32. Using the STR, [Str Celsius\32], modifier allows to access a whole string (array) which is what you want to do. Let me note though, that this would be an awfull waste of resources. Storing the numeric value in the EEPROM is good, but all additional processing and characters do not need to be on EEPROM.

He did mention in post #35 that he only wants to store/retrieve the temp results only, not the whole string. But I agree, he should re-visit post #32, as well as post #2, #8, #23, and #25.
And now that he has an LCD to play with, should re-visit those posts along with trying different methods of displaying numbers on the LCD to get a good idea on how those commands and/or modifiers actually work. Then build up to displaying the results using those modifiers to a 5x7 LED matrix.

Eugeniu
- 18th October 2008, 18:40
Ok, so if I am to understand this correctly, at the moment, you have:
A PIC
A one-wire temp sensor (model number???)
A 24FC512 serial eeprom
A handful of 5x7 LED matrix display units
An LCD for testing (not to be used in the 'final project')

Correct so far?

I have a 7 line X 96 columns leds display , and an other board with LCD display for testing .

Eugeniu
- 18th October 2008, 19:01
languer;64350] Don't mean to jump in the middle of everything here, but let me see if I can summarize perhaps what you want to do.

You want to write both "TEXT" and digits to the EEPROM using one (or several) I2CWRITE command; and you want to read them, again, using one I2CREAD command correct?

I want to write on memory : simple text ,( letters and ciphers) , data for 2 temperature ,( inside and out ), day , month , year , houre , minutes .And in this monent I do not know to convert hexa result from DS1820 to ASCII to can be some as text .


If this is so, I think you really want to revisit what ARATTI said on post #32. Using the STR, [Str Celsius\32], modifier allows to access a whole string (array) which is what you want to do.

Why ? I have a program that work . Do you read it ? I'll try to translate in englesh for easily understand . What you say is to do an other program .

Let me note though, that this would be an awfull waste of resources. Storing the numeric value in the EEPROM is good, but all additional processing and characters do not need to be on EEPROM

Is not true , I must to have all in eeprom to can read together ( in my idea and in program what I use now )

Eugeniu
- 18th October 2008, 20:58
Hi !

Here is some informations about DS 1820 "

TEMPERATURE/DATA RELATIONSHIP Table 2
TEMPERATURE DIGITAL OUTPUT DIGITAL OUTPUT
_______________(Binary)_____________(Hex)

+85.0°C*____ 0000 0000 1010 1010___00AAh
+25.0°C ____ 0000 0000 0011 0010___0032h
+0.5°C______ 0000 0000 0000 0001 __0001h
0°C_________0000 0000 0000 0000___0000h
-0.5°C______1111 1111 1111 1111____FFFFh
-25.0°C_____1111 1111 1100 1110____FFCEh
-55.0°C_____1111 1111 1001 0010____FF92h

only right byte I use , but I must to conver it in decimal . The left byte I use only to put "-" sign when it is = FFh .For right side of comma , I use byte 6 from sensor - COUNT REMAIN- . Tell me how convert right byte in decimal

skimask
- 18th October 2008, 23:03
Might I suggest that you back up in your process just a bit and practice/learn how to convert and display various types of numbers in general before trying to convert and display a result from a temperature sensor.
You don't seem to understand that the references to the earlier posts that we are giving you have the some of the information and answers you need to finish your project, DIG is on of those, if not the only one you'll need to convert your data from the binary format to the ASCII format (along with a bit of simple addition) to send to your display subroutine.
We do not have the hardware you have. We do not have the same 'vision' of the final project that you have, therefore, I think it is relatively unreasonable to ask others to write code FOR you, since that code that is written probably won't work for YOUR particular setup in the end. One thing that DOES work almost everytime though is trying to give a person the building blocks to start somewhere and end up somewhere else...

Eugeniu
- 19th October 2008, 08:53
Might I suggest that you back up in your process just a bit and practice/learn how to convert and display various types of numbers in general before trying to convert and display a result from a temperature sensor............................................ ...

OK ! I ' ll do , be sure . Thank you all , for your help . If have you a new idea , pleace , let me know it .

PS. I have tried all your ideas , and DIG , but they do not work .

skimask
- 19th October 2008, 17:59
OK ! I ' ll do , be sure . Thank you all , for your help . If have you a new idea , pleace , let me know it .
PS. I have tried all your ideas , and DIG , but they do not work .
I'm trying to help you out. I think in this case, it's a language thing...
DIG should work for you...pulling individual digits out of the results and displaying them one by one. I don't know what else to say how or to say it for that matter that'll make more sense to you.

languer
- 19th October 2008, 18:06
Ok, look at the info below. Most of it came from http://www.rentron.com/PicBasic/one-wire3.htm and your posted program.

This may not be the most elegant method, but it should give you a start. I still do not think there is any real value in adding all the "text" characters to the EEPROM, but that's a different story.


' Additional Variables
Cold_Bit VAR temperature.Bit11 ' Sign-Bit for +/- Temp. 1 = Below 0 deg C
Sign VAR BYTE ' +/- sign for temp display
temperature_int VAR BYTE ' integer part of temperature
temperature_dec VAR BYTE ' fractional part of temperature

' Temperature Readout and manipulation
OWIn DQ, 0, [temperature.LOWBYTE, temperature.HIGHBYTE, Skip 4, count_remain, count_per_c]

IF Cold_Bit = 0 THEN ' If Cold_Bit = 0, positive temperature
Sign = "+"
temperature = temperature & $00FF ' Mask lower byte of temperature
(((temperature >> 1) * 100) - 25) + (((count_per_c - count_remain) * 100) / count_per_c)
ELSE ' If Cold_Bit = 1, negative temperature
Sign = "-"
temperature = temperature & $00FF ' Mask lower byte of temperature
(((temperature >> 1) * 100) - 25) + (((count_per_c - count_remain) * 100) / count_per_c)
ENDIF

'separate interger part from decimal part
temperature_int = ((temperature DIG 4) * 10) + (temperature DIG 3) ' integer part of temperature
temperature_dec = ((temperature DIG 1) * 10) + (temperature DIG 0) ' fractional part of temperature

'write digits to EEPROM
i2cwrite I2CDAT, I2CCLK, $A0, 71,[(temperature DIG 4)+48] 'load EEPROM with integer part
pause 5
i2cwrite I2CDAT, I2CCLK, $A0, 72,[(temperature DIG 3)+48] 'load EEPROM with integer part
pause 5
i2cwrite I2CDAT, I2CCLK, $A0, 74,[(temperature DIG 2)+48] 'load EEPROM with decimal part
pause 5
i2cwrite I2CDAT, I2CCLK, $A0, 75,[(temperature DIG 1)+48] 'load EEPROM with decimal part
pause 5

skimask
- 19th October 2008, 18:12
Ok, look at the info below. Most of it came from http://www.rentron.com/PicBasic/one-wire3.htm and your posted program.

This may not be the most elegant method, but it should give you a start. I still do not think there is any real value in adding all the "text" characters to the EEPROM, but that's a different story.

I think his problem is extracting the individual digits out of the byte values to display on the LED matrix's, by using DIG, and he hasn't figured that part out yet, which is why I suggested earlier since he's got an LCD, to play with that first and get used to everything (and to find out if his temp sensor is actually working in the first place). Then build it all back up to displaying the reading on the LED matrix.

Eugeniu
- 19th October 2008, 18:56
I'm trying to help you out. I think in this case, it's a language thing...
DIG should work for you...pulling individual digits out of the results and displaying them one by one. I don't know what else to say how or to say it for that matter that'll make more sense to you.

Look here , is what I have tried :

adr = 22
i2cwrite I2CDAT, I2CCLK, $A0, adr,[temperature.LOWBYTE dig 4+48 ]
pause 15
adr=25
i2cwrite I2CDAT, I2CCLK, $A0, adr,[temperature.LOWBYTE dig 3+48]
pause 15
adr=28
i2cwrite I2CDAT, I2CCLK, $A0, adr,[temperature.LOWBYTE dig 2 + 48]
pause 15
adr=31
i2cwrite I2CDAT, I2CCLK, $A0, adr,[temperature.LOWBYTE dig 1+ 48]
pause 15
adr = 34
i2cwrite I2CDAT, I2CCLK, $A0, adr,[temperature.LOWBYTE dig 0 + 48]
pause 15

...on display I read 0 0 1 2 1 or 0 0 2 2 2 , and other numbers .

I'll try to explain my program ( this side with display ) :
after read a sign from eeprom program look in SELECT CASE CARACTER for a ASCI code and return a runing number >>>>


SELECT CASE CARACTER

CASE 65: SIR_NO=4 ;A
CASE 66: SIR_NO=9 ;B
CASE 67: SIR_NO=14 ;C
CASE 68: SIR_NO=19 ;D
CASE 69: SIR_NO=24 ;E
CASE 70: SIR_NO=29 ;F
CASE 71: SIR_NO=34 ;G
CASE 72: SIR_NO=39 ;H
CASE 73: SIR_NO=42 ;I
CASE 74: SIR_NO=47 ;J
CASE 75: SIR_NO=52 ;K
CASE 76: SIR_NO=57 ;L
CASE 77: SIR_NO=62 ;M
CASE 78: SIR_NO=67 ;N
CASE 79: SIR_NO=72 ;O
CASE 80: SIR_NO=77 ;P
CASE 81: SIR_NO=82 ;Q
CASE 82: SIR_NO=87 ;R
CASE 83: SIR_NO=92 ;S
CASE 84: SIR_NO=97 ;T
CASE 85: SIR_NO=102 ;U
CASE 86: SIR_NO=107 ;V
CASE 87: SIR_NO=112 ;W
CASE 88: SIR_NO=117 ;X
CASE 89: SIR_NO=122 ;Y
CASE 90: SIR_NO=127 ;Z
CASE 32: SIR_NO=132 ;SPATIU
CASE 48: SIR_NO=137 ;0
CASE 49: SIR_NO=140 ;1
CASE 50: SIR_NO=145 ;2
CASE 51: SIR_NO=150 ;3
CASE 52: SIR_NO=155 ;4
CASE 53: SIR_NO=160 ;5
CASE 54: SIR_NO=165 ;6
CASE 55: SIR_NO=170 ;7
CASE 56: SIR_NO=175 ;8
CASE 57: SIR_NO=180 ;9
CASE 46: SIR_NO=185 ;.
CASE 58: SIR_NO=188 ;:
CASE 61: SIR_NO=193 ;=
CASE 33: SIR_NO=196 ;!
CASE 45: SIR_NO=201 ;-
CASE 44: SIR_NO=204 ; ,
case 42: SIR_no=209 ; *
CASE 59: SIR_NO=212 ; ;

After this go to a tabel and serch for this runing number -OFSET-,from where return a matrix with what leds are on .

TABLOU:
LOOKUP OFSET,[_
$3F,$48,$48,$48,$3F,_ ;A 0-4
$36,$49,$49,$49,$7F,_ ;B 4-9
$22,$41,$41,$41,$3E,_ ;C 9-14
$3E,$41,$41,$41,$7F,_ ;D 14-19
$41,$49,$49,$49,$7F,_ ;E 19-24
$40,$48,$48,$48,$7F,_ ;F 24-29
$2E,$49,$49,$41,$3E,_ ;G 29-34
$7F,$08,$08,$08,$7F,_ ;H 34-39
$41,$7F,$41,_ ;I 39-42
$40,$7E,$41,$01,$02,_ ;J 42-47
$41,$22,$14,$08,$7F,_ ;K 47-52
$01,$01,$01,$01,$7F,_ ;L 52-57
$7F,$20,$10,$20,$7F,_ ;M 57-62
$7F,$04,$08,$10,$7F,_ ;N 62-67
$3E,$41,$41,$41,$3E,_ ;O 67-72
$30,$48,$48,$48,$7F,_ ;P 72-77
$3D,$42,$45,$41,$3E,_ ;Q 77-82
$31,$4A,$4C,$48,$7F,_ ;R 82-87
$26,$49,$49,$49,$32,_ ;S 87-92
$40,$40,$7F,$40,$40,_ ;T 92-97
$7E,$01,$01,$01,$7E,_ ;U 97-102
$7C,$02,$01,$02,$7C,_ ;V 102-107
$7E,$01,$0E,$01,$7E,_ ;W 107-112
$63,$14,$08,$14,$63,_ ;X 112-117
$70,$08,$07,$08,$70,_ ;Y 117-122
$61,$51,$49,$45,$43,_ ;Z 122-127
$00,$00,$00,$00,$00,_ ;SPATIU 127-132
$3E,$51,$49,$45,$3E,_ ;0 132-137
$01,$7F,$21,_ ;1 137-140
$31,$49,$45,$43,$21,_ ;2 140-145
$46,$69,$51,$41,$42,_ ;3 145-150
$04,$7F,$24,$14,$0C,_ ;4 150-155
$4E,$51,$51,$51,$72,_ ;5 155-160
$06,$49,$49,$29,$1E,_ ;6 160-165
$60,$50,$48,$47,$40,_ ;7 165-170
$36,$49,$49,$49,$36,_ ;8 170-175
$3C,$4A,$49,$49,$30,_ ;9 175-180
$00,$00,$00,$00,$01,_ ;. 180_185
$00,$24,$00,_ ;: 185_188
$28,$28,$28,$28,$28,_ ;= 188_193
$00,$7D,$00,_ ;! 193_196
$00,$08,$08,$08,$00,_ ;- 196_201
$00,$02,$01,_ ;, 201_204
$2A,$14,$3E,$14,$2A,_ ;* 204_209
$00,$0A,$01],DATE

I put this OFSET on a PIC port and scroll to left on display .

Eugeniu
- 19th October 2008, 19:14
Ok, look at the info below. Most of it came from http://www.rentron.com/PicBasic/one-wire3.htm and your posted program.

This may not be the most elegant method, but it should give you a start. I still do not think there is any real value in adding all the "text" characters to the EEPROM, but that's a different story.
...................................[/CODE]

Thank you for link . I do not find your example on this link . Tell me a link for it , or post all example .
I am looking for little time on this program ...and I see that they use LCD display with " DEC " command .

skimask
- 19th October 2008, 20:25
Look here , is what I have tried :
adr = 22
i2cwrite I2CDAT, I2CCLK, $A0, adr,[temperature.LOWBYTE dig 4+48 ]
....and so on and so on....

Right. I understand what you are trying to do, with the EEPROM and the LED matrix's and such. It's a relatively common project.
What you aren't understanding is that you are only writing ONE BYTE at a time with those statements, not 3 at a time as your changing addresses would indicate.
And one other thing is 'precedence'. I'm not sure if it's applicable in this case, but...
In your statement above...

i2cwrite I2CDAT, I2CCLK, $A0, adr,[temperature.LOWBYTE dig 4+48 ]
How does that get interpreted?
Assume temperature.lowbyte = 123
You are trying to retrieve the 4th (actually 5th) digit of a byte value to which there can only be 3 digits.
Another thing, still assuming temperature.lowbyte = 123, and assume that 'dig 4' is actually 'dig 0'...
Will that statement return "3" + 48 or does it try to return the 52nd digit of temperature.lowbyte?
A better way to put that statement might be:


i2cwrite I2CDAT, I2CCLK, $A0, adr,[ ( temperature.LOWBYTE dig 4 ) + 48 ]

And again, trying to retrieve the 4th digit of a 3 digit value (at most) won't work...

Since you have obviously modified your program, could you post the whole thing again, including all the relevant information, PIC type, hardware setup, etc.etc.

Eugeniu
- 19th October 2008, 21:08
skimask;64450]Right. I understand what you are trying to do, with the EEPROM and the LED matrix's and such. It's a relatively common project.
What you aren't understanding is that you are only writing ONE BYTE at a time with those statements, not 3 at a time as your changing addresses would indicate.
And one other thing is 'precedence'. I'm not sure if it's applicable in this case, but...
In your statement above...

i2cwrite I2CDAT, I2CCLK, $A0, adr,[temperature.LOWBYTE dig 4+48 ]
How does that get interpreted?
Assume temperature.lowbyte = 123
You are trying to retrieve the 4th (actually 5th) digit of a byte value to which there can only be 3 digits.

I understand what you say , but I try something , to see what display

Another thing, still assuming temperature.lowbyte = 123, and assume that 'dig 4' is actually 'dig 0'...
Will that statement return "3" + 48 or does it try to return the 52nd digit of temperature.lowbyte?
A better way to put that statement might be:


i2cwrite I2CDAT, I2CCLK, $A0, adr,[ ( temperature.LOWBYTE dig 4 ) + 48 ]


Is not imprtant , + or - paranthesis I see on display the same result .

For the result of " temperature.LOWBYTE " I do not understand what is this number .
If I put

adr = 24
i2cwrite I2CDAT, I2CCLK, $A0, adr,[(temperature dig 2) + 48]
pause 15
adr = 27
i2cwrite I2CDAT, I2CCLK, $A0, adr,[(temperature dig 1) + 48]
pause 15
adr = 30
i2cwrite I2CDAT, I2CCLK, $A0, adr,[(temperature dig 0) + 48]
pause 15

Obtein a number which is a hexa from a teperature ...968 ,975 - 2408,2421
For a LCD display write DEC2 (temperature/100) "," DEC2 (temperature//100). But for me in this moment I do not know what to do !

skimask
- 19th October 2008, 23:40
Ok, so the parenthesis don't make a difference, no problem...Guess we're going to have to build this up from scratch...
Do you have that LCD connected to your project? Is it working as you expect it to work (i.e. displays HELLO if you command it)

EDIT: Never mind, obviously you do have the LCD connected...

In reference to your I2CWRITE statements a few posts ago...


adr = 24
i2cwrite I2CDAT, I2CCLK, $A0, adr,[(temperature dig 2) + 48]
pause 15.......and so on.....

You do NOT need to store temperature in the manner you are storing it. What you are doing in effect is storing the ASCII equivalent of your temperature value in 3 bytes, then retrieving that same result and trying to display the ASCII result of each of those bytes...in effect, display the ASCII values of the ASCII values of the bytes originally stored....sort of like looking at a camera which is looking at you looking at a camera which is looking at you...infinite regression...

It looks to me like you're doing twice as much work as you need to do!
Try to store the temperature like this:


adr = 24
i2cwrite i2cdat, i2cclk, $a0, adr,[temperature.highbyte]
adr = 25
i2cwrite i2cdat, i2cclk, $a0, adr,[temperature.lowbyte]

This will store the WORD variable temperature in two bytes as required.
Then for retrieving that same value:


adr = 24
i2cread i2cdat, i2cclk, $a0, adr, temperature.highbyte
adr = 25
i2cread i2cdat, i2cclk, $a0, adr, tempearture.lowbyte
.............
lcdout DEC2 (temperature/100) , "," , DEC2 (temperature//100)

This should display on the LCD is in fact the temperature sensor and it's code are working properly.

To get the individual digits from this value for display on the LED matrix instead of the LCD:


adr = 24
i2cread i2cdat, i2cclk, $a0, adr, temperature.highbyte
adr = 25
i2cread i2cdat, i2cclk, $a0, adr, tempearture.lowbyte
.............
digit var byte[5]
digit[5] = temperature dig 4
digit[4] = temperature dig 3
digit[3] = temperature dig 2
digit[2] = ","
digit[1] = temperature dig 1
digit[0] = temperature dig 0
............

Eugeniu
- 20th October 2008, 09:28
[QUOTE=skimask;64461]Ok, so the parenthesis don't make a difference, no problem...Guess we're going to have to build this up from scratch...
Do you have that LCD connected to your project? Is it working as you expect it to work (i.e. displays HELLO if you command it)

No , I have not a LCD display on the same leds display , but in my mind is to do this . I have a LCD display on a test plate for differnet programs .
I know very well to work with a LCD display ( is a good "HELP " in MicroBasic Studio Plus :)



EDIT: Never mind, obviously you do have the LCD connected...

In reference to your I2CWRITE statements a few posts ago...

"Obtein a number which is a hexa from a teperature ...968 ,975 - 2408,2421 "

This is wrong . Was a dream ! When I have put my fingers on it , what I can see on leds display was more differnt by my body temperature

..............................................

Is not necesary to use " HIGH BYTE " I use only "LOW BYTE "

This will store the WORD variable temperature in two bytes as required.
Then for retrieving that same value:
[code]
adr = 24
i2cread i2cdat, i2cclk, $a0, adr, temperature.highbyte
adr = 25
i2cread i2cdat, i2cclk, $a0, adr, tempearture.lowbyte
.............

digit var byte[5]
digit[5] = temperature dig 4
digit[4] = temperature dig 3
digit[3] = temperature dig 2
digit[2] = ","
digit[1] = temperature dig 1
digit[0] = temperature dig 0

I'll try this !

skimask
- 20th October 2008, 11:40
No , I have not a LCD display on the same leds display , but in my mind is to do this . I have a LCD display on a test plate for differnet programs .
I know very well to work with a LCD display ( is a good "HELP " in MicroBasic Studio Plus :)
Should use it more often...


Is not necesary to use " HIGH BYTE " I use only "LOW BYTE "
The 'temperature' function will return a WORD result.


digit var byte[5]
digit[5] = temperature dig 4
digit[4] = temperature dig 3
digit[3] = temperature dig 2
digit[2] = ","
digit[1] = temperature dig 1
digit[0] = temperature dig 0

I'll try this !
That's what we suggested back in post #2!!!

languer
- 20th October 2008, 18:03
Eugeniu, below are some ideas on how to modify your code with the help of an LCD. This should provide all the info for the conversion, decoding, and displaying of the temp based on the DS18S20 (which matches your previous posted table). All based on your code, SKIMASK's suggestions, and readily available code on the forum.

modifications to variables

Cold_Bit VAR temperature.Bit11 ' Sign-Bit for +/- Temp. 1 = Below 0 deg C
Half_Deg_Bit VAR temperature.Bit0 ' 0.5deg Bit
Sign VAR temperature.HIGHBYTE ' +/- sign for temp display
temperature_int VAR temperature.LOWBYTE ' integer part of temperature
temperature_dec VAR BYTE ' fractional part of temperature
digit var byte[5]

reading temperature (this is not better than what you had, just short and simple)

'read temperature
OWOut DQ, 1, [$CC, $44] ' Start temperature conversion
pause 1000 ' Wait max conversion time
OWOut DQ, 1, [$CC, $BE] ' Read the temperature
OWIn DQ, 0, [temperature_int, sign] ' Store temperature on variable

storing raw temperature on EEPROM

'store raw value of temperature in EEPROM (like SKIMASK suggested)
adr = 24
i2cwrite i2cdat, i2cclk, $a0, adr,[sign]
adr = 25
i2cwrite i2cdat, i2cclk, $a0, adr,[temperature_int]

reading raw temperature from EEPROM

'read raw temperature from EEPROM
adr = 24
i2cread i2cdat, i2cclk, $a0, adr, sign
adr = 25
i2cread i2cdat, i2cclk, $a0, adr, temperature_int

decoding temperature (including negative temperatures)

'decode temperature as needed (this will decode both positive and negative temperatures)
IF Cold_bit = 1 THEN ' If Cold_Bit = 1, negative temperature
Sign = "-"
temperature_int = (255 - temperature_int) + 1 ' 2s Complement
ELSE ' If Cold_Bit = 0, positive temperature
Sign = "+"
ENDIF
temperature_int = temperature_int / 2 ' Strip LSB from temperature reading
IF Half_Deg_Bit = 1 ' If Half_Deg_Bit = 1, add half degree to result
temperature_dec = 5
ELSE
temperature_dec = 0
ENDIF

displaying decoded temperature on LCD

'to display temperature on LCD
lcdout sign , DEC2 (temperature_int) , "," , DEC2 (temperature_dec)

storing decoded temperature digits

'to extract digits
digit[5] = temperature_int dig 2
digit[4] = temperature dig 1
digit[3] = temperature dig 0
digit[2] = ","
digit[1] = temperature_dec dig 0
digit[0] = 0

P.S. When posting use the "code" tags to wrap the code and display it nice and tidy. Also use the "quote" tags when quoting somebody; again it displays nice and tidy.

skimask
- 20th October 2008, 18:09
One of the key phrases to be taken from this statement:

..........................
All based on your code, SKIMASK's suggestions, and readily available code on the forum...........................


And this might help your post formatting a bit...
http://www.picbasic.co.uk/forum/misc.php?do=bbcode#imgcode

Eugeniu
- 21st October 2008, 18:44
[QUOTE=languer;64516]Eugeniu, below are some ideas on how to modify your code with the help of an LCD.

Thank you for your try to halp me , But remember I do not use a LCD display !



P.S. When posting use the "code" tags to wrap the code and display it nice and tidy. Also use the "quote" tags when quoting somebody; again it displays nice and tidy

I do not use it , becose I do not know it :( . Thanks !

skimask
- 21st October 2008, 18:48
Thank you for your try to halp me , But remember I do not use a LCD display !
But you did say earlier that you do HAVE an LCD, and if you know how to use it, and can make it work, then why not use it to help you find your problem.
And with those code snippets above, you should be able to pull out of them the chunks of code you may and/or may not need to get your project working, whether it be displayed on an LCD (which would be very handy) or LED matrix or on punch cards.


I do not use it , becose I do not know it :( . Thanks !
Which is why I put that link in post #57 above. That way you can learn how to use those 'tags'.

Eugeniu
- 21st October 2008, 18:53
And this might help your post formatting a bit...
http://www.picbasic.co.uk/forum/misc.php?do=bbcode#imgcode

Was very usefully !

Thank you .

PS. I 'll be very bussy for a few day , and after this I'll work again to my project . I 'll tell you what I can doing .

Eugeniu
- 21st October 2008, 19:03
But you did say earlier that you do HAVE an LCD, and if you know how to use it, and can make it work, then why not use it to help you find your problem



I have try , be sure . I use a test program on LCD , bat there it work , on LEDS display not . For LCD are very usefully DEC ; HEX;...commands . I'try to change the kind of writing text ,(in my programme) ,to use " SELECT CASE " for binary or hexa byte .

skimask
- 21st October 2008, 19:25
I have try , be sure . I use a test program on LCD , bat there it work , on LEDS display not . For LCD are very usefully DEC ; HEX;...commands . I'try to change the kind of writing text ,(in my programme) ,to use " SELECT CASE " for binary or hexa byte .

So are you saying that everything works as you want it to work if you are using the LCD?
There is no need to rewrite the entire program!!! Your answers have been practically handed to you in previous posts, with example provided. The only thing left to do is to write the code for you.

Eugeniu
- 23rd October 2008, 21:27
So are you saying that everything works as you want it to work if you are using the LCD?

Yes ! But not on this plate . On this plate (Leds display )I use a PIC 16F876 and I have 3 free pins only on it . I can not install a LCD. Will be very usefully . I am not sure ( in my mind )every time that sensor work . In future I try to change PIC with 16F877 ,to can have together Leds and LCD display for ilk sensor .


There is no need to rewrite the entire program!!! Your answers have been practically handed to you in previous posts, with example provided. The only thing left to do is to write the code for you

I am not sure that I understand what you say !

skimask
- 23rd October 2008, 21:31
Yes ! But not on this plate .
Ok, as long as the code works in one place... I understand you don't have enough pins to run the LCD on this particular board and need to use the matrix'd LEDs...


I am not sure that I understand what you say !
Meaning that the posts referring to the use of the DIG function with bytes/words/whatever are most likely what you need to pull the individual digits out of the bytes/words/whatever to send to the LEDs...

Eugeniu
- 24th October 2008, 18:26
Meaning that the posts referring to the use of the DIG function with bytes/words/whatever are most likely what you need to pull the individual digits out of the bytes/words/whatever to send to the LEDs...

I have made a few changes :

In the first time write a few blanks (16)
I2cwrite I2CDAT , I2CCLK , $A0,ADR,[ ]

I have insert this lines
SELECT CASE CARACTER
................................................
CASE %0000000 : SIR_NO=137 ;0
CASE %0000001 : SIR_NO=140 ;1
CASE %0000010 : SIR_NO=145 ;2
CASE %0000011 : SIR_NO=150 ;3
CASE %0000100 : SIR_NO=155 ;4
CASE %0000101 : SIR_NO=160 ;5
CASE %0000110 : SIR_NO=165 ;6
CASE %0000111 : SIR_NO=170 ;7
CASE %0001000 : SIR_NO=175 ;8
CASE %0001001 : SIR_NO=180 ;9
..................................................

TEMP1 VAR BYTE
TEMP2 VAR BYTE

temp1 = temperature.LOWBYTE /2
temp2 = (100- (100/16)*(count_remain))
(This FORMULAS work very well with LCD display )

and writing
adr = 4
i2cwrite I2CDAT, I2CCLK, $A0, adr,[(temp1)dig 1,(temp1)dig 0,",",temp2 dig 1,temp2 dig 0 ]
pause 15

Now I read on LEDS display

for begining 2000404,0502 ( this ciphers from the right side are more variables)
when I put my fingers on sensor all nubers are modify . More right side
and last ciphra from left side :

200050x,0x0x
200060x,0x0x
..................
200090x,0x0x
200010x,0x0x

" 2 " not change in "3" . And not 25,xx or 26,xx ......and so on

GIVE ME AN OTHERS IDEAS !

skimask
- 24th October 2008, 18:34
adr = 4
i2cwrite I2CDAT, I2CCLK, $A0, adr,[(temp1)dig 1,(temp1)dig 0,",",temp2 dig 1,temp2 dig 0 ]
pause 15

I don't know why you insist on writing individual digits to the eeprom when there is no need to do so...since you can use DIG to get the digits after reading the eeprom...


GIVE ME AN OTHERS IDEAS !
You've got all the ideas you should need...over and over, as referenced above. I'm sure this sort of project has been done by numerous people over the years, with PBP, without PBP, with C, with assembly, etc.etc.etc.
Short of learning Romanian to lower the language barrier even farther, I don't know what else to say or do except write the program for you (not going to happen).
Maybe somebody else can step in to translate the problem and/or answers better than I, or maybe even somebody else will step in and write the code for you. I'm out...

Eugeniu
- 24th October 2008, 18:48
I don't know why you insist on writing individual digits to the eeprom when there is no need to do so...since you can use DIG to get the digits after reading the eeprom...



All are very simple : I DO NOT KNOW OTHER KIND TO CAN CONTINUOUS PROGREAME AND DISPLAY ALL TEXT AND DATA , OTHER THAN HOW IS ROGRAME WRITE NOW ! IT READ DIGIT BY DIGIT .

Eugeniu
- 16th November 2008, 19:19
Hi !

I have find problem and solution .

I have instal and a LCD display together with my LED display and....I understand that my DS sensor is not ok . Data from it was wrong . I have change sensor and I see that work on LCD , and ....

In this moment I use this solution :

In the firs time I define ...

temperature Var word ' Temperature (integr)
count_remain Var Byte ' Count remaining
count_per_c Var Byte ' Count per degree C

tem var word ' Temperature (decimal)

zecimi____________ VAR BYTE ' For decimal
sutimi_____________VAR BYTE ' For decimal

dozen(zeci)________VAR BYTE
units(unitati)_______VAR BYTE

and next ...


mainloop:
OWOut DQ, 1, [$55,$47,$6C,$71,$01,$08,$00,$C1,$44] ' Start conversie temperatura in casa
waitloop:
OWIn DQ, 4, [count_remain] ' Check for still busy converting
If count_remain = 0 Then waitloop
OWOut DQ, 1, [$CC, $BE] ' Read the temperature
OWIn DQ, 0, [temperature.LOWBYTE, temperature.HIGHBYTE, Skip 4, count_remain, count_per_c]
pause 300


if temperature.HighByte > $0000 then ' For " - " temperature DS1820
temperature = ($FF - temperature.LowByte)
tem = (100/16)*(count_remain)
pause 50
LCDOUT $fe, 1
LCDOUT $FE,$80 ,"Temp= -", dec temperature ,",",dec2 (100/16)*(count_remain)," gr.C"


zeci = 48+(temperature //100/10)
unitati = 48+(temperature // 10)
zecimi = 48+(tem/10 )
sutimi = 48+(tem//10)

adr = 2
i2cwrite I2CDAT, I2CCLK, $A0, adr,["TEMPERATURE IS = -",zeci,unitati,".",zecimi,sutimi,"degree C"]
else
temperature = (temperature.LOWBYTE )/2 ' For "+" temperature
tem = 100- (100/16)*(count_remain)
pause 50
LCDOUT $fe, 1
LCDOUT $fe, $80
LCDOUT "temp= " , dec temperature ,"." , dec2 100- (100/16)*(count_remain)," gr.C"

pause 30

sute = 48 +(temperature // 1000/100)
zeci = 48+(temperature //100/10)
unitati = 48+(temperature // 10)
zecimi = 48+(tem/10 )
sutimi = 48+(tem//10)

adr = 2
i2cwrite I2CDAT, I2CCLK, $A0, adr,["TEMPERATURE IS=",zeci,unitati,".",zecimi,sutimi,"degree C"]
pause 100
endif

Thank you for all your help !