I2C Accelerometer

hippy

Ex-Staff (retired)
The hard driven low for enable instead of just relying on pull-down was also suggested way back in the original thread.

As well as possible shorts under the chip, I'm also concerned about whether solder has flowed completely to all pins, particularly pins 1, 14 and 13. If there's a missing Vdd connection that could be preventing one part of the chip from working. May be worth checking if there is internal continuity between those pins on your currently unused chip.
 

alband

Senior Member
Read post 30 by Technical.
Looks like they might be on to something there!
Do you mean about pulsing enable? Should enable be pulsed low then left high or pulsed high then left low? Should there not be a resistor?

I've tried without the resistor and it has the same affect.

I have to mow the lawn then have lunch but I'll see if I can do some checks after that.

Edit: typical situation, you beet me with the answer to my question.
I'll do the checks on the first chip.
 

alband

Senior Member
I've checked the joints and they aren't shorting. I also checked the voltage at both SDA and SCL (without anything else attached) and they produce a small voltage so the must be connected.

I've also checked all the important pads on the accel with their relevant pins on the PICAXE and all are good.

I also changed my code so that both Enable and MOT/FF go to 0V then high. I will probably also attach nCS to an output pin even though the datasheet suggests it can just be held high from the start.

So basically, I can't find any faults, but am still not getting it to respond.
 

Technical

Technical Support
Staff member
If you convert italian to english and 'C' to 'PICAXE BASIC' you get the exact program we used in post #30. And the you tube video proves it works, so it does suggest a hardware issue somewhere with your setup.

http://gplab.blogspot.com/2008/04/arduino-con-accelerometro-kxps5.html


And stop wasting your time with all those slave addresses - the issue is elsewhere (note the C program shown in the link uses the 7 bit address - PICAXE BASIC uses the 8 bit address so is shifted left by one).
 

alband

Senior Member
I agree then. Since that code is proved to work it must be the hardware.
The only differences I can see between that hardware and mine are the different resistor values (appears to be 33k but I can't tell) and that he is using 3.3V whereas I'm using 5V.

The datasheet indicates that VDD can be up to 5.25V and that the I2C lines are relative to that.

With no load my supply is 5.1V so I don't think this can be the problem either. :confused::(

The only thing I can think to do now, is buy another one, but I suspect I would have exactly the same problem.
 

BeanieBots

Moderator
Long shot, but you've tried most other things.

It's a 3.3v nominal device.
Should work OK between 1.8v and 5.25v
7.0v is the destruction voltage. (or -0.3v)

Try it at 3v3. (including the PICAXE, to avoid interface issues).
5.1v + 5% (typ. DVM error) = 5.36v (outside working tollerance)
 

alband

Senior Member
including the PICAXE
It only runs from 4.5-5.5 doesn't it?

I also don't think I have a 3.3v regulator though I have various old electronic devices that might. I can do 3v though.

Anyway I'll see if I can find 3.3v reg.

What is DVM error because that sounded likely as it's something both chips could have sercome to. Although, surely the other fun toons wouldn't work?
 

BeanieBots

Moderator
What is DVM error??

Just because your meter says 5.1234v doesn't mean it really is.
An eBay DVM is probably on eBay because it is out of spec.
Even a good one will have an error. Often 3% but could be 5%.
Check it's spec. Don't have a spec, then assume 10% error until you can get it calibrated. Calibrated means against a known referance and at all expected working temperatures.
Technically, a meter should be calibrated every six months but every couple of years should be OK.

It should run between 1.8v and 5.25v from what I read in the datasheet you posted.
All test data was done at 3.3v. "Typical Vdd = 3.3v".

Running out of voltage spec is unpredictable. Quite possible that some functions could still work.
Like I said, it's a long shot but another thing to eliminate.
 

alband

Senior Member
Oh yes, of course; DVM = multimeter :rolleyes:. I only every recognise that when in-context. What does it actually stand for so I don't forget again?

How can I run the PICAXE at 3.3V?
 

BeanieBots

Moderator
DVM = Digital Volt Meter.
You also see DMM = Digital MultiMeter which is probably more common these days.
DPM = digital panel meter.
DSO = digtital storage oscilloscope
CRO = cathode ray oscilloscope.
 

alband

Senior Member
Right.

How do I run them at 3.3V or do I run the PICAXE at 5v. If I run them at different level's do I need any fancy circuitry for the SDA and SCL lines or just the same as present?
 

BeanieBots

Moderator
See post #47. (PICAXE also at 3v)

If you don't have a 3.3v regulator, just drop the output of your 5v one.
Several ways to do that.
Add a string of diodes. -(~0.6v per diode).
Add a series LED. Drop depends on colour. ~1.2v for red.
Also, add about 470R load resistor on the PICAXE side of the power rail so that the LED (or diode) is passing a few mA to aid with voltage stability.
 

alband

Senior Member
I've brought the VDD down to 3.65v but it's behaving exactly the same. Of course, the I2C section of both accel's could be damaged by a slightly high voltage so the only way to tell would be to buy another one. ergh
 

BeanieBots

Moderator
Shouldn't be damaged unless there were any 'accidents' that you've not mentioned.
Should be safe (damage wise) up to 7v on Vdd but shorts on OP pins or unregulated supply on any pin would be instant death.
 

alband

Senior Member
I'm afraid there haven't been any "incidents" that I'm aware of. :(

By "shorts on OP pins", do you mean connecting the x,y,z outputs to VDD?

I doubt there is much more that can be done. Kionix (company that makes the accel) have tried to help further and have been extremely quite to respond so far, but I'm still awaiting a reply at the moment.

Is there any possibility that the PICAXE's i2c commands wouldn't work with certain devices (although they obviously work for the vast majority)?

Thanks,
David.
 

BeanieBots

Moderator
Yes, I meant SDA and/or SCL connected to Vdd.
That could kill them.

I guess it's possible that PICAXE I2C would not work with it, but can't think of any logical reason why.

Have you tried with the ENTIRE system at 3v3 yet?
 

alband

Senior Member
I though I had tried it at 3.65V but I was just in the process of adding another diode to get it to 3.3V and it was at 3.8V so I must have been wrong in post 54. It is now running at 3.25v and although it gave me a small shock when it appeared to work but was actually running the EEPROM's code, it is in fact, alas, not working :(
 

alband

Senior Member
Incidental, in that Italian site, the person uses a breakout board that seems to be made by kionix, however, kionix don't current'y make a breakout board for the chip I have got, so I think he has a different version, so his success may not be strictly relevant. However, the variants of the KXPS5 are very similar so I doubt there is much difference.
 

Dippy

Moderator
Perhaps its time to admit defeat and use the accelerometer used by SKL BOI.
I'd love to have a play with them myself but no time.
 

hippy

Ex-Staff (retired)
There's no reason PICAXE I2C shouldn't work with any I2C compliant device and it seems the device is I2C compliant. No other example code has done anything special when dealing with it that I can see.

At the moment the device is failing to ACK the I2C Device Address which is early on in the I2C transmission and before anything 'peculiar to this chip' would even come into play. Quite simply the PICAXE says, "Hello?", and gets no response. As far as I2C is concerned, the chip is 'playing dead', yet I2C Eeprom is fine, which suggests it's something at the Accelerometer end rather than anything to do with the PICAXE.

I think you have reached the end of the road on this chip as there's not a lot more to suggest to try.

Maybe you can ship your breakout board with cables attached to Kionix and they can check it works when they use it or spot what the problem is. Or maybe you can find someone who can assemble a chip on breakout board, test it to make sure it works then supply you with that.

Otherwise strip this down, put it to one side until you've forgotten how it's wired-up and try again. If it's a case of not seeing the forest for the trees you may have better success later. Did you try the strip-down and re-build as suggested earlier ?

In the commercial world when a 'black box' doesn't work as expected, whole teams and huge resources are thrown at the problem to get viewpoints and insights from varying perspectives in order to solve the problem. In this case you and the forum don't have such resources to apply.

A ready built I2C Accelerometer board, tested and sold as working, though more expensive, would be the solution in this case; a typical example where the attraction of low cost and 'a bit of DIY' is lost through costs of trying to make it work and the frustration involved.
 

hippy

Ex-Staff (retired)
Two final thoughts ...

Are you taking your scope readings and measurements at the breadboard or from the chip breakout board ? Try the later.

Try swapping the SCL and SDA wires to the accelerometer over.
 

BeanieBots

Moderator
Enough time spent perhaps.
Don't lose sight of the fact that this was just one (possibly not even worthwhile) option. Don't let this little detail stop the project.

You've had the analogue signals working OK.
Go back to plan "A" which was an op-amp solution.

You can re-visit this as Hippy says, once you've forgotten how it's wired and can start again from fresh.
 

alband

Senior Member
Right, I doubt that kionix would be willing to examine my own circuit - they weren't that keen when I told them I got it off flea-bay and have been very helpful give that, so far, so I won’t push my luck with them.

I have however contacted the eBay seller. He has some breakout boards for the component (not sure who made them, but hey) and he said he would try using one of his chips with I2C. If this works then we can narrow it down to my board or perhaps managing to unknowingly destroy two chips (or the PICAXE in some way but as discussed this is very unlikely). This morning I have also asked him whether I could buy one of these breakout boards that is working from him and am awaiting reply (which has been quick so far).

@Hippy, good point, I've been measuring from the breadboard terminals. The continuity between them and the chip is fine, but I suppose I might as well try:rolleyes:.

If the communication between the sell and kionix dies down with still no success, then yes I may need to try the analogue approach.

Thanks for staying with me!
David.
 

BeanieBots

Moderator
Oh, flea-bay!
Probably a batch of seconds. Everything works except I2C. That's why they were cheap.

We'll stick with you. We feel your pain:eek:
I'll try not to mention gyros either. Doh, just did.
 

Dippy

Moderator
Ebay?!
If we'd know that at the start then the answer could have been provided in post #2 :)

It should be mandatory that people say where they got their troublesome-lump from. Teehee.
 

alband

Senior Member
Yep, ebay and I'm pleased (you have no idea how much) to report that after speeking with the seller, he agreed to get a development board working at his end, then send it to me for £5 allong with so 3.3V regs. The buyers ID is crodnet and I highly recommend him for general SMT electrical goods.

IT WORKS!

I'm using this code (which is just a slight alteration of technical's) at a 3.4v supply (obviously I'll use the regs in the real thing but they're SMT):
Code:
symbol MOT_ENABLE = B.4
symbol XOUT_H = %00000000
symbol XOUT_L = %00000001
symbol YOUT_H = %00000010
symbol YOUT_L = %00000011
symbol ZOUT_H = %00000100
symbol ZOUT_L = %00000101
'SetFreq k500
'pokesfr $D3,2


hi2csetup i2cmaster,%00110010,255,i2cbyte
 
init:
		low ENABLE
  		pause 500
  		high ENABLE
  		low  MOT_ENABLE  
  		pause 500
  		hi2cout $0C,($00,$42)
  		pause 500
 
main:  	readi2c XOUT_H,(b0)
		sertxd ("x=",#b0," ")
		readi2c YOUT_H,(b0)
		sertxd ("y=",#b0," ")
		readi2c ZOUT_H,(b0)
		sertxd ("z=",#b0," ")
		sertxd (CR,LF)
		goto main
The only issue now, is that the development board is rather big :confused: I think I'm going to need to get the dremel out and start cutting (so that I keep the original soldering joints).

Interestingly, the mid-point for x & y axis is 128; half of 256. I can't test the end-points yet because it is attached to the BB with a board header.

Anyway, thanks, so much for all the help with this, I really, really appreciate it! :D
 

hippy

Ex-Staff (retired)
Glad to hear you've got it working. I suspect the issue probably was in soldering the chip not making good connections but it could have been any number of things and I guess we'll never know unless you can get a faulty board working.

Excellent service there from the eBay seller, but Caveat Emperor is still the nature of the game.
 

alband

Senior Member
Yes, I suspect it was probably the soldering, but rather than a bad connection, could the I2C I/O section of the chip be more sensitive to heat damage? Otherwise it would be a unfortunate coincidence that both chips had the same two pins not working.

The value still seems to flicker slightly, but only between two numbers and not as badly as it did with the analogue readings.
 

frost

New Member
accelerometers in robotics

hi there kinda new to this but been reading with interest all about the hard work you've put in to this. and if iam honest i dont get alot of it ,but i would like to incorparate an accelerometer within a picaxe project ,a robot , so that it can maintain its balance.
or atleast do something to protect itself..
i should point out that the most technical thing ive done so far ,using 08m device i made a light activated circiut that messured the ambiemt temp of the room (adc pin)then altered to leds (pwm outs) a red one and a blue to show a visual indication of temp ie, red warm, blue cold, purpleish for in betweens ,i had about 10 differant settings for the leds that where changed within the program according to the 0-255 from the temp adc.
i have never used the i2c interface so thats a bit of a hurdle for me..
so i was wondering would it not be possible for me to use a single axis accelerometer device possibly in a voltage differentail configuration connected to an adc pin ??
i believe i may have found some accelerometers that are used in this way.
then to give 3 axis of movement use 3 devices all on seperate adcs on say a 18x device???

am i barkin up the wrong tree??? ,,,just trying to make life simple for myself( i think)
anyhow thanks for reading i expect that my level of knowledge is a little to low.
regards frost
 

BeanieBots

Moderator
Welcome to the forum,
I wouldn't worry too much about this thread. Most of it was trying to make a unit owrk that was not connected. Always a tricky thing to do;)

However, unless you have a fair understanding of control theory, you will struggle with your project. Reading the sensor is the easy part. Once you have a numer in the range 0 to 255 that represents the acceleration in a particular direction, then what?

Might be a good idea to start a new thread with more specific questions when you are ready.
 

hippy

Ex-Staff (retired)
@ alband : Yes, it could have been heat, or maybe an unlucky case of ESD. I know I've got blasé being used to near indestructable PICAXE's.

@ frost : I2C is not at all difficult when you use it if the hardware is working as expected. In the case of a single axis accelerometer it should be a simple case of issuing a "READI2C $nn,(b0)" command and, voila, you have the axis value in b0.
 

alband

Senior Member
I cut the damn thing out of it's development board last night and it nearly gave me a heart attack when it didn't work. Evntually I found a loose wire or something like that and it worked. However, it won't work using "i2cslow" or "i2cfast", only "255" - no matter what frequency I set the PICAXE to. It doesn't work at all when run at 32Mhz though.

@frost: I am actually doing the same kind of thing. I will hopefully b using it to auto-level the gun barrel of an RC tank. If I ever achive it :)eek:) I'll be sure to post the code.
 

hippy

Ex-Staff (retired)
However, it won't work using "i2cslow" or "i2cfast", only "255" - no matter what frequency I set the PICAXE to.
Did the device operate at I2CSLOW or I2CFAST before you removed it from the development board ?

It doesn't work at all when run at 32Mhz though.
That is possible, the internal hardware scaled up to 32MHz being too fast to run at the slowest speed the chip desires. The easiest solution is probably to SETFREQ to a lower speed to do the I2C comms.

But then again, it should work with I2CSLOW I'd have expected, so maybe you have damaged something in removing and re-assembling the chip.
 
Last edited:
Top