readadc accuracy

alband

Senior Member
@BB: tried some 1k8's and it had no effect on the communication except raising the logic level. And yes, I found it didn't work when I took them out, although I only took out the SDA but both lines stopped working; is that normal?

@Dippy: Err, I'm using I2C so no. I have accel SDA connected to "leg 15" (28X2) and accel SCL connected to "leg 14".

It should definitely be enabled properly. The enable pin is controlled by C.5 on the PICAXE so I put it high 1s after the system is switched on. It's voltage level is 5.06V, the general VDD is 5.08V from a new 7805.

The accel is stated many times as a 3.3V device, but in the datasheet it gives min = 1.8V, typ = 3.3V, max = 5.25V so I assume it is fine to run it at 5V.

I've attached a clearer, trace of what is happening.

Huh, just refreshed, before I posted and got hippy and BB's replies, so luck would have it I had prepared a better scope image.
I'll see if I can find a few other register.
 

Attachments

Last edited:

hippy

Ex-Staff (retired)
I've just checked a 24LCxx datasheet and my R/W understanding was wrong, Read is an abortive Write then Read, not the other way round ...

To write, it's "S xxxxxxx0 A aaaaaaaa A dddddddd A P"

To read, it's "S xxxxxxx0 A aaaaaaaa A S xxxxxxx1 A dddddddd N P"

So that fits with what you are seeing on the scope trace. So basically it seems that the I2C device is not acknowledging itself as at device address 0011001.

I'd double check your wiring and connections, try device address 0011000 ( %00110000 in I2CSLAVE ). It is possible that as you had it mis-wired then the device has been damaged and won't work.

What do B.4 and B.5 lines do ? These will be input at reset; should they have pull-downs, or be taken low before brought high ? It would be a good idea to post a circuit of what you have.

Unfortunately there's not a lot more anyone can do looking over your shoulder; I2C seems to be working fine with Eeprom, the header looks correct and the accelerometer should respond. That it doesn't suggests incorrect wiring / configuration or damaged accelerometer.
 

alband

Senior Member
My connections are good, alas. I've checked them many times now.
I tried using 0011000.

B.4 and B.5 control the interrupts the accel gives. There are already pull down 10k's on both :(.

It would seem all that's left is that the chip is bust. I'll have to order another and see what happens:(

Addit: oh an I tried a few other register and stuff, but nothing worked.
 

hippy

Ex-Staff (retired)
The enable pin is controlled by C.5 on the PICAXE so I put it high 1s after the system is switched on.
Yet you use B.5 in the program - one of the two is wrong :)

I'd suggest also making sure enable is low at start-up, delay, bring it high, dleay.
 

alband

Senior Member
Sorry, I confuse myself for a minute there. B.4 controls the FF/MOT interrupt and B.5 controls the enable. Both are held low with 10k's.

One thing that struck me though is this:

If you look at the attachment in post 72 (change it to .ppt) it show reading an writing to the EEPROM. If you examine the traces for both the read and write procedures just after the EEPROM ACK's for the fist time, the PICAXE then lengths the clock pulse once.
In the first example (writing) the PICAXE lengthens the lower clock pulse after the first ACK is received.
In the second example (reading) the PICAXE lengthens the higher clock pulse after the fist ACK is received (it doesn't show well on that example, but I've just scoped it at a slower speed and attached the result).

If you then look at the most recent accel scope (post 81) you can see that the clock pulse in lengthened in the low state, just like when writing to the EEPROM.

This is just a thought.

Something else is this:
If SDA is being pulled low then that suggests the ACK is present
In this case, I don't think it can be, because that tiny low is still present when I remove the accel's SDA line.

Anyway, I think a new chip is a good direction at this point, especially since they're only £3, it's just the wait I don't like.
 

Attachments

alband

Senior Member
Oh one, thing.

I'm now designing a new, smaller better etc. circuit for the next accel. Are the capacitors on each analogue output strictly necessary?

Page 3 on this seems to have the most info on them. It gives some values and tips, but It also states that the chip has internal capacitors. Also out of the three capacitor options they give, it would seem the internal ones are better than all three.
 

Dippy

Moderator
I've never used that chip so I can only guess that you would use those capacitors as a 'filter' to change the response of the device.
If you only want slow response you increase C.
You may, for example, want to 'filter' out some low amplitude high speed vibration - that's my guess.
So, I would assume, you choose the values to suit your application - and that's down to you and some time experimenting.

I've seen similar options on current sensing chips.

I don't know what you mean by "better" ???
 

alband

Senior Member
I assumed quicker = better.

I've got a bunch of SMT capacitors from an old TV (this Tv has supplied so many of my parts (EEPROM comes to mind) it should have a medal) but they don't have markings on them. Is the PICAXE circuit I can set up that can measure discharge time or something so I can find their values. Like if I put one in a 555 circuit, measure the pulse length, I could work out the cap's rating - except I don't have a 555.
 

Dippy

Moderator
"I assumed quicker = better."
- might be... might not be. Depends on your app.
Would you normally design an op-amp circuit which has a flat gain response to 10MHz if you were making a low-pass audio filter? (If so, don't give up the day job :) )
You really have got to think what you want to acheive.

Capacitors.
Oh Lordy... well you could make an osc circuit assuming you have some R's with markings on them.
Or you go and buy a multimeter with capacitance - assuming it covers the range.
You could use a PIC to do an RC time function.
Or you could CHUCK the darned things away and buy ones with known values.... after all, you may have damaged them when removing - always the problem with hacking around.
No-one in their right mind prototypes using hacked (relatively sensitive) components.
And when you consider how much time you will have to spend faffing about working out what is what versus their penny level costs then it's largely pointless.
 

hippy

Ex-Staff (retired)
There are many ways to measure an unknown capacitance ... the easiest option is a DVM which tells you directly what it is. Maplins etc sell them and you may be able to use one of their shelf models to "test its performance".

Don't go fitting capacitors willy-nilly. Best to see how it performs first.
 

alband

Senior Member
I'll probable leave it for now then and see how it goes.

@electic: guess which exact web page I had up when I asked ;)
I certainly wouldn't buy them now, but if noone bids it looks worth it. Still a day.. whoa, thats in hours not days, I see your point.
Thanks,
Got to go, I'm etching again :D
 

alband

Senior Member
The new chip has arrived and I've soldered I'd to the board I made. I used a lot of flux like last time to make sure the connections are good which the look like they are. However there is now a lot of flux stuck to the board. I fryer getting it off with some 40% gin but it had very little affect. Any advise?
I still need to solder the connectors on so I'll do that now but I have quite a big problem. The computer I normally use for electronics stuff (that has all my .bas files on:eek:) has flashed up with the following message apon start-up.
Code:
Windows could not start because the following file is missing or corrupt:
System32\Drivers\Ntfs.sys

You can attempt to repair this file by starting Windows Setup using the original Setup CD-ROM.
Select 'r' at the first screen to start repair.
Does anyone recognize this and/or have any better advise than the setup CD?

Thanks,
David.
 

hippy

Ex-Staff (retired)
I've seen similar. You could see if it lets you start in Safe Mode. If not ( and I expect it won't as ntfs.sys is likely an essential driver ) the Repair option is the next best thing. If it comes to the worse it's reinstall Windows and restore your Basic and other files from backup.

If you have a dual-boot system you can try booting into another OS and backing up latest copies of files - create new backups ( ie, leave previous somewhere safe ) because if an essential file has gone other corruption may have occured. If you don't have a dual-boot system you can try a Live-CD of Linux or something to get at them that way.
 

RexLan

Senior Member
Use rubbing alcohol to remove the flux.

Get another hard drive that will boot with the same OS. Boot with it then you can read the other drive.

Or you can boot from a Windows CD to the command prompt then you should be able to read the files on the HD and copy them.
 

papaof2

Senior Member
Get another hard drive that will boot with the same OS. Boot with it then you can read the other drive.
There are very few of us who actually have a spare hard drive with a bootable OS. Mine is an old 30GB with XP and all the updates - made spare when I replaced it with a MUCH larger drive. I also have a spare DSL modem and wireless router. No, I'm not paranoid - when you work from home, you need the proper configuration - including a one hour UPS for the network equipment.

I expect shipping and customs would make getting the 30GB drive to the UK prohibitively expensive...

John
 

boriz

Senior Member
I used to measure capacitors using a simple 555 circuit. The output charged/discharged the capacitor through a known resistance and the resultant curve was 'scoped.
 

alband

Senior Member
Hmmm,
I haven't got a backup HD, or the recovery disk. Could I simply move the faulty HD onto this (vista) PC and copy and paste the driver into it. (or something like that).

I haven't got a 555 either (not a good day for "having" things really) but they aren't expensive so next time I buy something I can get one.
 

boriz

Senior Member
Use a Picaxe :)

Just make sure that the resistor you choose is large enough to keep the maximum charge current below 20mA.
 

nbw

Senior Member
Just out of interest, what software are you using to turn your soundcard into an oscilloscope? Is it some kind of USB oscilloscope or similar? cheers barney
 

hippy

Ex-Staff (retired)
I haven't got a backup HD, or the recovery disk. Could I simply move the faulty HD onto this (vista) PC and copy and paste the driver into it. (or something like that).
Possibly. I don't know much about Vista but worth a try if you run out of other options.

If you've got a version of Vista which works I'd have thought it could generate rescue disks. That's in Control Panel, Add/Remove Programs, Startup Disk in Windows 98SE and I'm sure there's similar in XP, so would expect it in Vista.
 

alband

Senior Member
I don't think it does anymore. I looked in that path and then tried searching the entire control panel for various inflections of "startup disk". Ah well, PC world on Saturday I guess.
 

MartinM57

Moderator
I had good success with Ultimate Boot Cd for Windows - see http://www.ubcd4win.com/

...but it's a bit complex in parts and overall a slow process.

I had a Windows-corrupted 1.8" SATA drive in a laptop with no other means of getting the data off it - I managed to boot the laptop from the CD and copy the most crucial data files onto a USB disk...then re-install Windows, all the laptop-specific drivers and the apps, and then the data files.

But you've got all the crucial stuff on backup media anyway haven't you ;)
 

alband

Senior Member
euy, what a mess!

I've got the PC back but, unfortunately they wiped the hard drive without actually saying :eek: It was in the paperwork but last time they wanted to wipe it, they made a huge fuss. Anyway, thus I have been starting from scratch putting a PC back together. The good thing is there should be a load of stuff that I didn't need on it which I now don't have, so faster performance should follow :)rolleyes: yeah, right).

Thankfully or course, I have posted all the code on here! I've copied it back and I'm back to work.

I tried the new accelerometer and it does the same thing as the old one. It tries to acknowledge but the line doesn't stay low (post 81's attachment).
One thing I have noticed though, in the current trace and the previous traces is this:

When reading from the accel it should be:
Code:
Master:                        S0011001W 00000011 S0011001R         NAP
Slave:                                  A        A         AXXXXXXXX
However, what I missed in post 70, was that it is sending a READ bit ("1") in the slave address, not the required write bit ("0").


Code:
		#PICAXE28X2
pause 1000
high B.5
high B.4
pause 1000
setfreq m1

		i2cslave %00110010,255,i2cword
	
		let b1 = 0
		SERTXD("RESET")
main:		pause 50
		readi2c 3,(b0)
		sertxd (#b0,",")
		goto main
That's my code (I'm going to keep posting it in light of recent events ;))
I would have suspected the slave address but the LSB is already "0" (0=w 1=r).

Thanks in advance as always.

Man it's good to be back to work! :D
 

hippy

Ex-Staff (retired)
I'm afraid I've lost track of what's what but shouldn't that be I2CBYTE not I2CWORD ? -- I2CWORD for Eeprom, I2CBYTE for Accelerometer.

Not that it probably matters because it wasn't getting past the Slave Address part before and I guess you're seeing the same as then; no ACK for the Slave Address ?

Seeing the read part of the I2C comms could just be an issue with scope synchronisation.

Check an I2C Eeprom works correctly again so we know where we stand. If I2C works with I2C Eeprom it should work with this device if configured, connected and accessed correctly.

Your image in post #70 seems to be correct, W=0, and see my comment in post #84.

I've just checked a 24LCxx datasheet and my R/W understanding was wrong, Read is an abortive Write then Read, not the other way round ...

To write, it's "S xxxxxxx0 A aaaaaaaa A dddddddd A P"

To read, it's "S xxxxxxx0 A aaaaaaaa A S xxxxxxx1 A dddddddd N P"

So that fits with what you are seeing on the scope trace. So basically it seems that the I2C device is not acknowledging itself as at device address 0011001.
It's very hard to keep track of a 100+ post thread so a scope snapshot of what you are seeing, a copy of the code you are using, and the complete circuit as it is now will help. I'd actually suggest abandoning this thread and starting a new one with all that information included, along with a link to the device datasheet.
 
Last edited:
Top