GY-391 Breakout Board ADXL345 Accelerometer problem

Started by Dave-S, Aug 01, 2022, 06:44 PM

Previous topic - Next topic

Dave-S

Have started a new post because the other one's Title is wrong, the problem is the Accelerometer not the clock. The Accelerometer was affecting the clock and LCD on the IC2 Bus.

The problem is the Accelometer on starting the program sometimes shows zero reading and continues with zero readings and then the only way to get it working again is to operate without accessing the DS1307 clock.  Normally the program continully reads the clock so it can read the Accelerometer/Compass every 5 minutes. If I request a reading without accesing the clock it works Ok.

The chip datasheet states:-
"I2C and SPI digital communications are available. In both cases, the
ADXL345 operates as a slave. I2C mode is enabled if the CS pin is
tied high to VDD I/O. The CS pin should always be tied high to VDD
I/O or be driven by an external controller because there is no default
mode if the CS pin is left unconnected. Therefore, not taking these
precautions may result in an inability to communicate with the part."

The GY-391 Module (attached diagram) States that the CS pin is pulled high by 10K, and testing pin there is 3.3 volts on it.  Now I have found if I apply 5 volts to the CS pin it works correctly every time, but this must be applying a higher voltage to the other side of the 3.3 voltage regulator via the 10k, the Datasheet states max 3.9 volts, has been running ok for 12 hours now.

Do not understand why it does not work with the 3.3 volts on it, there are many examples of use of these modules and no mention of CS pin. The original code was by YUKSEL.
Has or is anyone using this model or any suggestions/ideas.

Thanks DavidADXL345-GY291.pngADXL345-GY291.png   



trastikata

Instead of pushing the pin protection diodes with 5v through 10k resistor, see if changing that 10k resistor to VCC with 100 Ohm will solve the issue.

John Lawton


tumbleweed

I agree with trastikata. Connecting anything to 5V on that part is way over the spec.

Dave-S

Very difficult to replace 10K resistor very small board SMT cannot work out which it is. Did manage to solder wire to 3.3 volt output pin of regulator and connect to CS pin hich I thought would put 3.3 volts on it but still just comes up with Zero readings.

The GY-391 datasheet States:-
"Since the I2C interface uses open drain outputs, the interface is compatible with a 5V system.
This is true as the Arduino never drives out 5V it only tristates an output to let the voltage level
pull to 3V3. To generate a zero it outputs a digital zero which is also compatible with the 3V3 interface.

Warning: If you use the chip in SPI mode then you will need level translators (when using a 5V
controller) or a controller board that only uses 3V3 throughout."

Is this True for my PIC 18F47k40 when using IC2 software Protoncompiler?
Or do I need to use the Hardware IC2?

18F47k40 datasheet states:-
"15.2.4 Open-Drain Control
The ODCONx register controls the open-drain feature of the port. Open-drain operation is independently
selected for each pin. When an ODCONx bit is set, the corresponding port output becomes an open-drain
driver capable of sinking current only. When an ODCONx bit is cleared, the corresponding port output pin
is the standard push-pull drive capable of sourcing and sinking current.

Important: It is not necessary to set open-drain control when using the pin for I2C; the I2C
module controls the pin and makes the pin open-drain."

Thanks David

Parmin

Quote from: Dave-S on Aug 02, 2022, 07:00 PMVery difficult to replace 10K resistor very small board SMT cannot work out which it is
Simply solder in a parallel resistor to that one should do the trick.
Often it is easier to solder onto a pad than to replace a component.

tumbleweed

Which software I2C commands are you using (as there are several)?

The software methods do not use the ODCONx registers. They emulate an open-drain pin by manipulating the TRISx registers.

On the K40 with VDD=5V, if you wish to use the I2C pins with 3.3V pullups you should change the INLVLx registers to enable TTL levels. Since they default to ST levels, clearing the INLVLx bits for your I2C pins will lower the Vih input high level to be compatible with the 3.3V signal.