Exploring Edison - Life At 1.8V
Written by Harry Fairhead   
Monday, 04 January 2016
Article Index
Exploring Edison - Life At 1.8V
Level Converters
Bi-directional Level Shift

Bi-directional Bus

The biggest problem in converting from 1.8V to 3.3 or 5V is when you need to work with a bi-directional bus. 

There are, roughly speaking, three types of bi-directional bus - wire or, wire and and tristate.

The most commonly encountered is a wire or or open collector bus. This is used for I2C and many other one wire serial buses. The key idea is that the bus line is connected to a voltage reference via a resistor, generally a pull up resistor. This allows any device connected to the bus to ground it and so pull the bus line down. If more than one device pulls the bus down then no harm is done. However the bus line only pulls up when all of the connected devices 


In the diagram above each of the switches represents a device connected to the bus. In practice the switches would be an active device such as a BJT or an FET but the principle is the same. You can see that closing any one of the switches grounds the pull up resistor which places the bus in low state. 

If you need to connect a 3.3V or 5V open collector bus to a 1.8V Edison input then you can make use of an chip designed to do the job but in many cases a simple classic single transistor level shifter can do the job. For conversion to 3.3V you will often see an FET used but for the low voltage involved in a 1.8V conversion a BJT does the job very well. 

This assumes that the output line is in pull up or open collector mode. The default for the mini-breakout board is pull up using a 50K resistor. The circuits described work in this mode. 

For example:



In practice R2 can be anywhere from 1K to 5K and R3 anywhere from 5K to 10K depending on what is being driven. Notice that this assumes that the GPIO pin is in open collector mode with an external pull up resistor. 

To understand how this works we have to consider what happens when each side of the bus is pulled low. 

If the 1.8V logic input is pulled low then the emitter of the transistor is grounded and as the base is at 1.8V the transistor switches on and saturates so pulling the 3.3 logic bus down.  

The more difficult situation is when the 3.3V logic linput is pulled low. In this case the collector is grounded and the base being at 1.8V [its tje tranistor into reverse active mode i.e. with collector and emittor swapping roles. In this mode the transistor is still a current amplifier but with a much reduced gain (hfe). Given sufficent drive current however the transistor will still saturate and hence pull the 1.8V logic side of the bus low. 

The reason for the capacitor is that as the transistor changes operational mode there is a charge storage effect which causes the voltage to suddenly drop.  An effect you can see clearly:



The blue trace is the 3.3V input signal and the green trace is the 1.8V output. In practice the undershoot can cause the Edison to detect two pulses in place of one. 

With a small capacitance in place the effect is reduced:



Notice that as in the case of the single transistor non-inverting buffer the big problem is that there is no current amplification. When the Edision pulls the bus low it has to sink the current through R1, R2 and R3. and the same is true on the 3.3V side. In this case the total current is less than 1.5mA.

The circuit works just as well at 5V with a slighly higher current.

You might expect the Edison's side of the bus needs to be driven with an open collector i.e. with its own pull up which is the default mode. 

In fact it doesn't make any difference as the Edison is the only device driving the 1.8V logic input. You can use an active high/active low drive as long as the Edison is the only device driving the bus and then the line is changed to an input to read the response from the responding device. If the output line drives the bus both high and low then a problem only arrises when the slave attempts to drive the bus in the opposite direction. In most cases the slave doesn't attempt to drive the bus at the same time as the master and so the type of drive is irrelevant as long as the line reverts to input as soon as a slave starts transmitting data. However it takes time to convert an output line to an input and this is sometimes an additional problem.  

Converting other types of bus are more difficult but follow the same general idea. 

You can build the circuit using a prototyping board or you can built it in-situ on the device you need to convert.  Something like:build

where the device in question is connected to the three wires at the top of the diagram. This is used in the next two chapters to interface bidirectional pull up buses. 




Now On Sale!

You can now buy a print edition of Exploring Intel Edison.
You can buy it from:

USA and World  Amazon.com
Canada              Amazon.ca
UK                      Amazon.co.uk
France                Amazon.fr
Germany            Amazon.de
Spain                  Amazon.es
Brazil                  Amazon.br
Italy                    Amazon.it
Japan                 Amazon.co.jp
Mexico               Amazon.com.mx 

Chapter List

  1. Meet Edison
    In this chapter we consider the Edison's pros and cons and get an overview of its structure and the ways in which you can make use of it. If you have ever wondered if you need an Edison or an Arduino or even a Raspberry Pi then this is the place to start. 

  2. First Contact
    When you are prototyping with the Edison you are going to need to use one of the two main breakout boards - the Arduino or the mini. This chapter explains how to set up the Edison for both configurations. 

  3. In C
    You can program the Edison in Python, JavaScript or C/C+ but there are big advantages in choosing C. It is fast, almost as easy as the other languages and gives you direct access to everything. It is worth the effort and in this chapter we show you how to set up the IDE and get coding. 

  4. Mraa GPIO
    Using the mraa library is the direct way to work with the GPIO lines and you have to master it. Output is easy but you do need to be aware of how long everything takes. Input is also easy but using it can be more difficult. You can use polling or the Edison interrupt system which might not work exactly as you would expect.

  5. Fast Memory Mapped I/O
    There is a faster way to work with GPIO lines - memory mapped I/O. Using this it is possible to generate pulses as short at 0.25 microsecond and read pulse widths of 5 microseconds. However getting things right can be tricky. We look at how to generate fast accurate pulses of a given width and how to measure pulse widths.

  6. Near Realtime Linux 
    You need to be aware how running your programs under a non-realtime operating system like Yocto Linux effects timings and how accurately you can create pulse trains and react to the outside world. In this chapter we look the realtime facilities in every version of Linux. 

  7. Sophisticated GPIO - Pulse Width Modulation 
    Using the PWM mode of the GPIO lines is often the best way of solving control problems. PWM means you can dim an LED or position a servo and all using mraa. 

  8. Sophisticated GPIO -  I2C 
    I2C is a simple communications bus that allows you to connect any of a very large range of sensors. 

  9. I2C - Measuring Temperature  
    After looking at the theory of using I2C here is a complete case study using the SparkFun HTU21D hardware and software. 
  10. Life At 1.8V
    How to convert a 1.8V input or output to work with 5V or 3.3V including how to deal with bidirectional pull-up buses.

  11. Using the DHT11/22 Temperature Humidity Sensor at 1.8V 
    In this chapter we make use of all of the ideas introduced in earlier chapters to create a raw interface with the low cost DHT11/22 temperature and humidity sensor. It is an exercise in interfacing two logic families and implementing a protocol directly in C. 

  12. The DS18B20 1-Wire Temperature 
    The Edison doesn't have built in support for the Maxim 1-Wire bus and this means you can't use the very popular DS18B20 temperature sensor. However with a little careful planning you can and you can do it from user rather than kernel space. 

  13. Using the SPI Bus 
    The SPI bus can be something of a problem because it doesn't have a well defined standard that every device conforms to. Even so, if you only want to work with one specific device it is usually easy to find a configuration that works - as long as you understand what the possibilities are. 

  14. SPI in Practice The MCP3008 AtoD 
    The SPI bus can be difficult to make work at first, but once you know what to look for about how the slave claims to work it gets easier. To demonstrate how its done let's add eight channels of 12-bit AtoD using the MCP3008.

  15. Beyond mraa - Controlling the features mraa doesn't. 
    There is a Linux-based approach to working with GPIO lines and serial buses that is worth knowing about because it provides an alternative to using the mraa library. Sometimes you need this because you are working in a language for which mraa isn't available. It also lets you access features that mraa doesn't make available. 




To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on, Twitter, FacebookGoogle+ or Linkedin.


kotlin book



or email your comment to: comments@i-programmer.info






Last Updated ( Wednesday, 11 May 2016 )