Saturday, December 19, 2015

As been requested by many people that have difficulties to use the
MPU6050 Modules, I've done a more detailed ESP8266 Video Tutorial
related with the MPU6050 GY-521 Module initialisation and basic usage.

It is a detailed, step-by-step tutorial, showing all the needed init stages and tests for a proper and smooth usage of the MPU6050 GY-521 module.

These ones seems to work OK connected directly to the 3.3V power on the ESP8266 nEXT EVO board Bus and looks to have some very low dropout voltage regulator. This are the good news about.
Now some bad news: it seems to be sold different types/flavours of modules (maybe old/new batches with various BOM) under the same name code so your experience may vary and might be necessary to use 5V power input for the GY-521. Or just bypass the Voltage Regulator to avoid any wiring around :).

MPU-60X0 Overview

The MPU-60X0 is the world’s first integrated 6-axis MotionTracking device that combines a 3-axis gyroscope, 3-axis accelerometer, and a Digital Motion Processor™ (DMP) all in a small 4x4x0.9mm package.
With its dedicated I2C sensor bus, it directly accepts inputs from an external 3-axis compass to provide a complete 9-axis MotionFusion™ output. It is also designed to interface with multiple non-inertial digital sensors, such as pressure sensors, on its auxiliary I2C port.

So, it can act as a I2C master for other I2C devices. That's cool!

For power supply flexibility, the MPU-60X0 operates from VDD power supply voltage range of 2.375V-3.46V. Additionally, the MPU-6050 provides a VLOGIC reference pin (in addition to its analog supply pin: VDD), which sets the logic levels of its I2C interface. The VLOGIC voltage may be 1.8V±5% or VDD.

The MPU-6000 and MPU-6050 are identical, except that the MPU-6050 supports the I2C serial interface only, and has a separate VLOGIC reference pin. The MPU-6000 supports both I2C and SPI interfaces and has a single supply pin, VDD, which is both the device’s logic reference supply and the analog supply for the part.

MPU-60X0 Features

1. Gyroscope Features

The triple-axis MEMS gyroscope in the MPU-60X0 includes a wide range of features:

The MPU-60X0 collects gyroscope and accelerometer data while synchronizing data sampling at a user defined rate. The total dataset obtained by the MPU-60X0 includes 3-Axis gyroscope data, 3-Axis accelerometer data, and temperature data. The MPU’s calculated output to the system processor can also include heading data from a digital 3-axis third party magnetometer.

The FIFO buffers the complete data set, reducing timing requirements on the system processor by allowing the processor burst read the FIFO data. After burst reading the FIFO data, the system processor can save power by entering a low-power sleep mode while the MPU collects more data.

For programming and uploading the driver and the software we will continue to use the LuaUploader as before.

Connection with the ESP8266 nEXT EVO Board is very easy, asMPU6050 GY-521 Moduleconnector
is fully compatible with the nEXT Bus connector. Depending on how to you
choose you socket type, you can install it on TOP or Bottom of the ESP8266 nEXT EVO Board :

MPU6050 GY-521 Module on top of the ESP8266 nEXT Evo Board

Driver implementation

1. Init I2C bus/interface

Standard I2C Bus Initialisation function:

function init_I2C() i2c.setup(bus, sda, scl, i2c.SLOW)end

2. READ MPU6050 Register

Before reading data from MPU6050, you must tell it which of its internal addresses you want to read
A read starts off by writing to the MPU6050

Procedure:

Send a start sequence.

Send I2C address of the device with the R/W bit low (i2c.TRANSMITTER)

Send the Internal register address

Stop sequence

Send a start sequence again (repeated start)

Send the I2C address of the device with the R/W bit high (i2c.RECEIVER)

Thursday, December 10, 2015

In this part we will talk a bit about the nEXT Bus I²C
protocol and we will
start also a longer, multi-part discussion about testing procedures and
software programming for the AN1 Board devices and functions (I/O
Expansion port, Temperature, ADC, DAC, Voltage measurements,etc.

--------------------------------------------------------------------------------------------------------------------------For any new CBDB orders/requests please feel free to use as usual: tech at esp8266-projects.com.

(**)
- Actually you have there 2 Boards for the price of one, a ESP8266 nEXT
Evo together with a AN1 nEXT Analog Extension Board that brings you a
18Bit ADC (autoscale 0-40V input!), 4x12Bit DAC, Precison Temperature
measurement, 8bit I/O port, etc. -------------------------------------------------------------------------------------------------------------------------

Today topic

First let's have a very quick look at the nEXT bus protocol: I²C What is I²C?

Only two bus lines are required; a serial data line (SDA) and a serial clock line (SCL).

Each device connected to the bus is software addressable by a unique address and simple master/slave relationships exist at all times; masters can operate as master-transmitters or as master-receivers.

It is a true multi-master bus including collision detection and arbitration to prevent data corruption if two or more masters simultaneously initiate data transfer.

Serial, 8-bit oriented, bidirectional data transfers can be made at up to 100 kbit/s in the Standard-mode, up to 400 kbit/s in the Fast-mode, up to 1 Mbit/s in Fast-mode Plus, or up to 3.4 Mbit/s in the High-speed mode.

On-chip filtering rejects spikes on the bus data line to preserve data integrity.

The number of ICs that can be connected to the same bus is limited only by a maximum bus capacitance. More capacitance may be allowed under some conditions.

SDA and SCL signals

Both SDA and SCL are bidirectional lines, connected to a positive supply voltage via a current-source or pull-up resistor:

When the bus is free, both lines are HIGH. The output stages of devices connected to the bus must have an open-drain or open-collector to perform the wired-AND function. Data on the I²C-bus can be transferred at rates of up to 100 kbit/s in the Standard-mode, up to 400 kbit/s in the Fast-mode, up to 1 Mbit/s in Fast-mode Plus, or up to 3.4 Mbit/s in the High-speed mode. The bus capacitance limits the number of interfaces connected to the bus.

For a single master application, the master’s SCL output can be a push-pull driver design if there are no devices on the bus which would stretch the clock.

SDA and SCL logic levels

Due to the variety of different technology devices (CMOS, NMOS, bipolar) that can be connected to the I²C-bus, the levels of the logical ‘0’ (LOW) and ‘1’ (HIGH) are not fixed and depend on the associated level of VDD.

Input reference levels are set as 30 % and 70 % of VDD; VIL is 0.3VDD and VIH is 0.7VDD.

Timing Diagram for F/S-mode devices on the I²C-bus

Some legacy device input levels were fixed at VIL= 1.5 V and VIH= 3.0 V, but all new devices require this 30 %/70 % specification.

For a more deep and extensive I²C protocol undestanding ( Data Validity, START and STOP conditions, Byte format, Acknowledge (ACK) and Not Acknowledge (NACK), Clock synchronisation, etc,etc please take a look at the official NXP I²C Protocol datasheet. I²C protocol it is quite a serious separate topic to discuss :).

Before going further with our main topic I will insist only one one more thing, as it looks it creates a lot of confusion sometime:

The slave address and R/W Bit (7 bit mode)

Data transfers follow the format shown in the picture below:

A full data transfer

After the START condition (S), a slave address is sent. This address is seven bits long followed by an eighth bit which is a data direction bit (R/W) — a ‘zero’ indicates a transmission (WRITE), a ‘one’ indicates a request for data (READ):

The first byte after the START procedure

A data transfer is always terminated by a STOP condition (P) generated by the master.
However, if a master still wishes to communicate on the bus, it can generate a repeated START condition (Sr) and address another slave without first generating a STOP condition. Various combinations of read/write formats are then possible within such a transfer:

Master-transmitter transmits to slave-receiver. The transfer direction is not changed and the slave receiver acknowledges each byte:

Master reads slave immediately after first byte. At the moment of the first acknowledge, the master-transmitter becomes a master-receiver and the slave-receiver becomes a slave-transmitter. This first acknowledge is still generated by the slave. The master generates subsequent acknowledges. The STOP
condition is generated by the master, which sends a not-acknowledge (A)
just before the STOP condition:

Combined format. During a change of direction within a transfer, the START condition and the slave address are both repeated, but with the R/W bit reversed. If a master-receiver sends a repeated START condition, it sends a not-acknowledge (A) just before the repeated START condition:

A fist step in testing the AN-1 available functions and devices will
be to scan the nEXT I²C Bus and see if all the existing ones are alive
and responding to the I²C Master requests. Also will list any new added devices, if alive.

- From the Hardware point of view, as been a Display with a native I2C interface, it is very easy to connect thru the CBDB EVO nEXT Bus (no extra wires, PSU, etc)

- From the Software point of view, even more good news:

if you want to use NodeMCU in your projects, a driver for SSD1306 is already there, based on the u8glib library.

if you want your Arduino IDE also the u8glib driver is there!

Full Datasheet available, so you can also implement your own driver very easy.

The SSD1306 is a 128x64 Dot Matrix Driver/Controller manufactured by Solomon Systech.
Controller Power Supply for IC Logic is between 1.65V to 3.3V so we have here a 3.3V compatible device, no need for any kind of logical levels converter.

I will not insist too much about the SSD1306 controller, just one thing that might worth to explain a bit, as it looks that it is creating a lot of confusion for many people:

If you look on the back of the module you can see a jumper option for the Display I2C address: 0x7A or 0x78, with default selected on 0x78:

If you will try to use it like that, with the addresses from above, it will not work, as many people has already found it.

Why?

The I2C communication interface consists of slave address with set bit SA0, I2C-bus data signal SDA (SDAOUT/D2 for output and SDAIN/D1 for input) and I2C-bus clock signal SCL (D0). Both the data and clock signals must be connected to pull-up resistors.

SSD1306 has to recognize the slave address before transmitting or receiving any information by theI2C-bus. The device will respond to the slave address following by the slave address bit (“SA0” bit)and the read/write select bit (“R/W#” bit) with the following byte format:

b7 b6 b5 b4 b3 b2 b1 b0 0 1 1 1 1 0 SA0 R/W#

“SA0” bit provides an extension bit for the slave address.
Either “0111100” or “0111101”, can be selected as the slave address of SSD1306.
D/C# pin acts as SA0 for slave address selection, and actually this is a Address Select pin from the above.

So, if we take the 7 Bit I2C address representation from above we will have:

0 1 1 1 1 0 0 - > 0x3C (default)
OR0 1 1 1 1 0 1 - > 0x3D (alternate)

The 8th bit is the “R/W#” bit and is used to determine the operation mode of the I2C-bus interface:

Wednesday, December 2, 2015

Part 3 of the ESP8266 nEXT Evolution Board SeriesAnalog Extension Board - AN1

--------------------------------------------------------------------------------------------------------------------------For any new CBDB orders/requests please feel free to use as usual: tech at esp8266-projects.com.CBDB nEXT Evo bare PCB has also been made available directly at Dirty PCBs, our preferred PCB House for experimenting (**):http://dirtypcbs.com/view.php?share=9699&accesskey=91d782fd4a10943fd36ecc371c7ff2cd(**)
- Actually you have there 2 Boards for the price of one, a CBDB nEXT
Evo together with a secondary nEXT Extesion Board that brings you a
18Bit ADC (autoscale 0-40V input!), 4x12Bit DAC, Precison Temperature
measurement, 8bit I/O port, etc.

More about this Extension Board in thearticle below. -------------------------------------------------------------------------------------------------------------------------

CBDB nEXT A1 Extension Board - TOP

CBDB nEXT A1 Extension Board -Bottom

Basic default functions of the CBDB nEXT A1 Extension Board:

INPUT :

0-40V Autorange Analog frontend

18 Bit ADC

OUTPUT :

4x12 BIT DAC

TEMPERATURE :

I2C Temperature sensor, standard or high precision options

I/O :

8 Bit I/O Port

Analog frontend input

With the default resistor divider values you can have 4 different autoranging scales as below:

0 - 20V

0 - 10V

0 - 20 V

0 - 40 V

Analog to digital conversion

For this board, the choosen ADC is the MCP3421 from Microchip.

The MCP3421 is a single
channel, low-noise, high accuracy delta-sigma A/D converter with
differential inputs and up to 18 bits of resolution in a small SOT-23-6
package.The on-board precision 2.048V reference voltage enables an
input range of ±2.048V differentially.

The device uses a two-wire I2C
compatible serial interface and operates from a single power supply
ranging from 2.7V to 5.5V.

This device has an onboard programmable gain amplifier (PGA). User can
select the PGA gain of x1, x2, x4, or x8 before the analog-to-digital
conversion takes place. This allows the MCP3421 device to convert a
smaller input signal with high resolution.

The I/O expander port is based on the PCF8574, a 8-bit remote I/O port for the I2C-bus.

The device consists of an 8-bit quasi-bidirectional port and an I2C-bus interface. The PCF8574 has a low current consumption and includes latched outputs with high current drive capability for directly driving LEDs.

Another interting feature is the interrupt line (INT) which can be connected to the interrupt logic of the microcontroller. By sending an interrupt signal on this line, the remote I/O can inform the microcontroller if there is incoming data on its ports without having to communicate via the I2C-bus. This means that the PCF8574 can remain a simple slave device, even for data input, keyboard scanning, etc.

That's all for now, next times we will continue testing and exploring step-by-step each function of the ESP8266 nEXT Evo Extension Board

Tuesday, November 24, 2015

--------------------------------------------------------------------------------------------------------------------------For any new CBDB orders/requests please feel free to use as usual: tech at esp8266-projects.com.CBDB nEXT Evo bare PCB has also been made available directly at Dirty PCBs, our preferred PCB House for experimenting (**):http://dirtypcbs.com/view.php?share=9699&accesskey=91d782fd4a10943fd36ecc371c7ff2cd(**)
- Actually you have there 2 Boards for the price of one, a CBDB nEXT
Evo together with a secondary nEXT Extesion Board that brings you a
18Bit ADC (autoscale 0-40V input!), 4x12Bit DAC, Precison Temperature
measurement, 8bit I/O port, etc. But more about this one in the next articles. -------------------------------------------------------------------------------------------------------------------------

First thing to see is how easy is the process to configure and start
using CBCB nEXT EVO Board. It will come preconfigured
with NodeMCU, so, if LUA is your desired programming language you can
just start using it.

In
case of firmware update needed or if you want to change the
environment, it is a very easy process, almost similar with the one used for
MPSM Board for example.

Go back on Operation tab. Power off your CBDB Module. Press FLASH
Button. power ON quick CBDB module. It will be recognised and will start
flashing. Give it a second try if necessary.

When finished succesfully A green OK checkmark will appear

Power Off CBDB Module, Remove yellow jumper. Power back ON. Your nEXT EVO Board should be now programmed with the new NodeMCU Firmware.

If you have trouble to keep pressed both PROG and RESET buttons ,you can use a jumper from GPIO to GND as a replacement for PROG button and press just RESET when necessary:

For further programming in LUA, it might be possible to do it directly
in your Serial Terminal Program but I will recomend you to use a more
dedicated program for that, like ESPlorer or LuaUploader. I will stay with the latest one, for it's great flexibility and simplicity.

To run a quick test, you can just use the code snippets provided by LuaUploader
at start-up. Select the piece of code that you want to run and press
"Execute Selection" button.

// the setup function runs once when you press reset or power the boardvoid setup() { // initialize digital pin 2 as an output - GPIO2 pinMode(4, OUTPUT);}

// the loop function runs over and over again forevervoid loop() { digitalWrite(2, HIGH); // turn the LED on (HIGH is the voltage level) delay(500); // wait for a second digitalWrite(2, LOW); // turn the LED off by making the voltage LOW delay(500); // wait for a second}

If you want to use it without RESET + PROG buttons control, then just solder the back jumpers as in the picture below and No manual reset needed , no
buttons to press, just press Upload in Arduino IDE and that's it!

Tuesday, November 17, 2015

--------------------------------------------------------------------------------------------------------------------------For any new CBDB orders/requests please feel free to use as usual: tech at esp8266-projects.com.

(**) - Actually you have there 2 Boards for the price of one, a CBDB nEXT Evo together with a secondary nEXT Extesion Board that brings you a 18Bit ADC (autoscale 0-40V input!), 4x12Bit DAC, Precison Temperature measurement, 8bit I/O port, etc. But more about this one in the next articles. -------------------------------------------------------------------------------------------------------------------------

This simple ESP8266 Board is the result of searching for a smaller and somehow a more flexibile hardware configuration than the previous CBDB Evolution DevBoard. CBDB v2 Evo is perfect for it's Development (like the Battery Monitor System for example) and Educational purposes, you have there all-in-one-board, ADC, DAC, Voltage, Temperature and Current measurement, RTC, LCD Display, buttons, everything. BUT sometime you want to keep is as simple as possible. Just a core. A small one. And you don't want a external/separate USB adapter. And you want to be able to extend the Board capabilities easy with other functions, as you wish and when you wish.

For USB adapter we will use a CH340G chip. As been in a SOP16 package it is also very easy to solderat home.

CBDB nEXT EVO - USB adapter schematic

Voltage RegulatorBecause I want to be able to run the board also from a Li-Ion or Li-Po Battery, for the voltage regulator decided to use something with better specifications than the usual LD1117.

The choosen one was MCP1825S . I've use it before in many other projects and it's very good LDO: - Input Operating Voltage Range: 2.1V to 6.0V
- 500 mA Output Current Capability
- Low Dropout Voltage: 210 mV Typical at 500 mA ! - > you have about 1V for LD1117 !
- Low Supply Current: 120 μA

CBDB nEXT EVO - Voltage Regulator

Extension interface

The choosen nExtensions Bus Interface that will be used for connecting the ESP8266 Main Board with the other compabile available modules is very simple one, based on the I2C standard interface.

In the same time, you have full access to all the pins thru JP1 and JP2 pin headers. You can even use this headers to directly connect the CBDB nEXT Board to a Breadboard as they are at a breadboard friendly distance!Putting together all the bits and pieces, this is the final result:

Wednesday, November 4, 2015

Because many people have encountered lots of issues with the installation, mainly r8188eu WIFI chipset driver issues or strange compile problems, I was thinking to give a chance also to the new RASPBIAN Jessie, maybe it might be possible to make life easier for many of us.