Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

simple data logger

Status
Not open for further replies.

dano

New Member
I'm looking for a litle help with a project I'm building.

I repair/setup industrial CNC equipment for a living. There are times I need to check the timing of signals on this equipment. The frequency of me doing this does not warrant purchasing a commercial data logger.

I am building a simple one, using a 4 x 20 LCD display to show the data. I would like to display up to 5 pages of info on the LCD. I don't need to save the data in case of power loss, but if EEPROM is the best way let me know. I'm using a PIC 16f876a.

What I want to do is sample PORTA at pre determined intervals (from .1 to .01 seconds depending on the value in TMR1). I then would like to save PORTA and put it in file1. On the next read I want the value to go into file2, etc., up to file100 Once file100 has been reached the program will loop back to file1. This will continue until a button is pressed or and external trigger is seen. I will then display the info on the LCD.

What I'm looking for is an elegant way to put the info into one file and then incrementing to the next file on the next read. I'm also looking for a way of reading the files in succesion ( to be displayed on the LCD).

Maybe I'm missing something painfully obvious. I'm not a total noob but some days I feel like it.

I'm not looking for someone to write the code but rather a nudge in the best direction.

I'm using assembly. Any suggestions would be appreciated.

Thanks

Dan
 
One suggestion would be to not use assembly, using a higher level language makes writing code much quicker.

That aside, to write to a file in the manner you described, you'd use indirect addressing. First you load FSR with the address of the file, then read/write to INDF (which now contains the addressed file contents). If you can use bank 2 or 3, there is 100 bytes of contiguous memory which will make things easier, otherwise you'll have to check each access whether you're in the right bank.
 
I started working with indirect addressing as suggested by dougy83. Everything appears to work except when I write info into memory address 170h. When I write to this address it also writes to 70h, f0, and 1f0. What am I doing wrong?

Thanks
Dan
 
You're not doing anything wrong. The top 16 bytes of each bank are shared between all banks (see picture from datasheet). If this is a problem for you, you will have to incorporate bank switching to access your 100-byte buffer (or just use 96 bytes in your buffer).
 

Attachments

  • registers.gif
    registers.gif
    35.8 KB · Views: 167
I used external serial RAM or flash memory. I needed mega-amounts of memory and PICs have very little memory.
 
If you use the area at location 0x120 to 0x16f and 0x1a0 to 0x1b3 you can do the following,

Code:
	bsf	STATUS,IRP	;use banks 2 and 3
	movwf	INDF		;store value
	incf	FSR,f		;inc pointer
	movlw	0x70		;reached 0x170 yet
	xorwf	FSR,w		;set Z flag if reached
	movlw	0xa0		;preload W
	btfsc	STATUS,Z	;test result of xor
	movwf	FSR		;reached 0x170 so skip to 0x1a0
	movlw	0xa0+0x14	;reach 100th byte
	xorwf	FSR,w
	movlw	0x20		;as above
	btfsc	STATUS,Z
	movwf	FSR		;wrap back to 0x120

Mike.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top