10 bit datalogger, write/read

sghioto

Senior Member
I want to use the readadc10 values in my datalogger program. How do I write to and read from a 24LC256 using 10 bit data.How can I send this 10 bit data to the PC for storing in a csv file.

 
 

demonicpicaxeguy

Senior Member
the picaxe pdf manuals pretty muhc decribe most of this in fairly good detail
as for the csv part
all you do is have the picaxe send the value out seperated by a "," and you can use somthing like hyperterminal to capture the readings and stick them in a file
 

sghioto

Senior Member
Are you saying every thing I need to know about read/write 10 bit data is in the pdf, or are you refering to just the csv file question? My program as written works fine using the 8 bit adc. Is it possible to use the 18X, i2c bus to read/write 10 bit data?

 
 

demonicpicaxeguy

Senior Member
when you write to the i2c memmory with a word i set the data i want to write to w0 and then use say w6 for the address eg

writei2c w6,(b1)
pause 10
let w6 = w6 + 1
writei2c w6,(b0)
pause 10

as long as your curcuit is setup correctly and the line

i2cslave %1010xxxx,i2cslow,i2cword

has the correct address it should work fine

as for reading stuff out

readi2c w6,(b1)
let w6 = w6 + 1
readi2c w6,(b0)

should suffice

for the CSV part of it
simply setup hyperterminal to capture a text file do this by going transfer>capture text option

then in the picaxe somthing like this
w6 = 0
start:
readi2c w6,(b1)
let w6 = w6 + 1
readi2c w6(b0)
sertxd (w0,",")
goto start

that should give you a rough idea on how it's done


Edited by - demonicpicaxeguy on 10/06/2007 09:18:29
 

sghioto

Senior Member
Still having a problem with my datalogger program. Can't sertxd the 10 bit adc (1 to 1023) to the terminal correctly using the 24lc256 external memory. If I use the internal eeprom on the 18X it works ok.
Here are the two programs, any suggestions?

This program works.
main: pause 2000
high 0
for w2 = 0 to 127
readadc10 1,w0
write w2,b1
w3 = w2 + 128
write w3,b0
pause 10
next w2
low 0
loop: pause 1000
high 7
for w2 = 0 to 127
read w2,b3
w3 = w2 + 128
read w3,b2
sertxd (#w1,13,10)
pause 10
next w2
low 7
goto loop


This one does not.

main: pause 2000
i2cslave %10100000,i2cfast,i2cword
high 0
for w2 = 0 to 127
readadc10 1,w0
writei2c w2,(b1)
w3 = w2 + 128
writei2c w3,(b0)
pause 10
next w2
low 0
loop: pause 1000
high 7
for w2 = 0 to 127
readi2c w2,(b3)
w3 = w2 + 128
readi2c w3,(b2)
sertxd (#w1,13,10)
next w2
low 7
goto loop

 
 

andrewpro

New Member
Uf you read the previous version of this post, I appologize, I read your code wrong.


Why are you writing and reading one byte at a time? I'd hit the data sheet for the memory and brush up on the accessing of the chip.

It auto increments addresses, so you dont need to keep makign separate reads and writes.

Also, why are you storing part of the temperature reading in one spot, then the other part of the reading 128 locations later? I have a feeling you are overflowing the addressing of the EEPROM. That will cause all kinds of issues.

As far as I can tell, you are trying to do the following:

w1=0
<start loop here>
readadc10 1,w0

writei2c w1,(b0,b1)
w1=w1+2
<go back to the loop start>

Then when you read it back, you essentially do the same thing backwards

<start loop here>

readi2c W1,(b0,b1)
sertxt (#w0)

<go back to loop>



--Andy P

Edited by - andypro on 11/06/2007 03:02:48
 

sghioto

Senior Member
Andypro,

Well I have been reading the manual and
archives on this forum over and over and I'm at a standstill.I need someone to write the code for me so I can see what I'm doing wrong and move on. This would be greatly appreciated.


 
 

sghioto

Senior Member
From what I understand, a 10 bit word will require two eeprom locations. The i2c protocol writes in 8 bytes only, so I'm writing the w0 in two parts b1 and b0.
Same thing on the read. They are seperated by the number of writes I need so I don't overwrite any previous locations.

 
 

sghioto

Senior Member
demonicpicaxeguy,

Yes!!!! Just needed to put a "pause 5" between the two writei2c commands.
Thanks everyone for the replys. Life is good again.

 
 
Top