Serial ports on A20

Started by herter, March 25, 2014, 07:57:12 PM

Previous topic - Next topic

herter

Hello,

I want to connect a microchip DAC(12 bit) with the A20, on debian, by using the spi interface.
I develop with python and I downloaded the spilib but I meet some trouble.
However, my write command consist of 16 bits, but it seems that I can send only one byte at once.
By the way, what are the steps to enable the spi interface? ( first of all, I have to modify my script.bin and that's all?)
yet, I can't find any spi in the /dev.
Moreover, I looking also ADC spi /i2C and I would like to know if somebody has already worked with thermometer controlable by I2C.

Thank you for your help!
Regards.

N8body

Hello,
I havent worked on SPI-Reading,but i have done some research on Spi-Writing and made a BitBang-Spi Library for writing SPI on any Pin.

You can use this if you want to have Hardware-Spi(havent tested it yet):
http://linux-sunxi.org/SPIdev

or look at the Thread with "Olinuxino A20 with Nokia LCD",for my Software-Spi Solution.

KNK

Quote from: herter on March 25, 2014, 07:57:12 PM
Moreover, I looking also ADC spi /i2C and I would like to know if somebody has already worked with thermometer controlable by I2C.
If all you need is a thermometer and 0.5C is enough for you - just use (TC)N75 I2C sensor. Then you can read it even from bash with i2c-tools

herter

Hello,

Thanks a lot for your replies.
Firstly, N8body, I will try this Hardware-spi directly on UEXT connector.
Secondly, KNK,This sensor seems interesting to me. Does it difficult to set up the communication with i2c? Indeed I don't work on this yet...

KNK

#4
It's very easy - check this excellent description

In short all you need is i2c-tools package installed and call i2cget -y 0 0x48 assuming you have connected all address pins to ground and use I2C bus 0

EDIT: Here is a quick C code
#include <stdio.h>
#include <stdlib.h>
#include <linux/i2c-dev.h>
#include <fcntl.h>

#define I2C_DEV         "/dev/i2c-1"
#define N75_ADDR        0x48

int main(int argc, char *argv[])
{
        int i2c_bus, i2c_temp = -1;

        if ( (i2c_bus = open(I2C_DEV, O_RDWR)) < 0 ) {
                printf("Failed to open the bus.\n");
                exit(1);
        }

        if ( ioctl(i2c_bus, I2C_SLAVE, N75_ADDR) >= 0 ) {
                i2c_temp = i2c_smbus_read_word_data(i2c_bus, 0);
        } else {
                printf("Failed to acquire bus access and/or talk to slave.\n");
                exit(1);
        }
        close(i2c_bus);

        if ( i2c_temp != -1 ) {
                printf("%0.1f\n", (i2c_temp & 0xFF) + 0.5 * (i2c_temp >> 15));
        }
}

dave-at-axon

If your speed of DAC output is not fast, I would use one of the I2C DAC's as this will make like things a lot easier. I've found SPI great on microcontrollers but I've never managed to get it working with Android Linux.


herter

Ok, thanks KNK for your link!

Dave-at-axon, yes I totally agree, I have also some experiment in SPI/I2c on µC but I not yet managed it on a20.
By the way, I'm looking for I2C ADC and I saw you have already work on this:
https://www.olimex.com/forum/index.php?topic=2541.msg11009#msg11009
As I need to have many ADC , because I have to digitalize some analog inputs, I'm interesting in the MOD-IO board but I will not use all the IO.
I wonder, if I make my own pcb, with the atmega16, to recuperate the datas of the dac with i2c, if I need to use the arduino IDE, or I will be able to access on the firmware of this µC with the a20 and python.

dave-at-axon

I have an MCP3428 on my custom board that the A20 sits atop and it's very stable. I am feeding it with 4-20mA inputs and on the test bench I have to turn the pots to make sure it's still working as the readings are very stable.

If you do your own PCB, and I would recommend you do if you need stable ADC as the MOD-IO is very poor and noisy for ADC inputs, I would pay attention to the ADC supply. I supply this with a 0.1uF cap on the VCC input with a small inductor from 3.3V and another 0.1uF and 4.7uF cap in the power side. All kept close to the ADC. Also run a ground plan on the top layer if this is a 2 layer board.

Check out DFRobot if you want to get a board made. You should be able to fit this into a 5cm x 5cm board which is cheap and you get 10 boards for this price.

herter

I could use this kind of ADC but it's a bipolar and the FSR is too limited. Indeed, my FSR is about 0-3.3V but I notice that this chip can be used in a single-ended operation.
After I can manage with a differential and amplifier to fit in the FSR.
But, I prefer rather work on a Atmega with minus I/O, because I can also use pwm outputs, what I haven't yet done it with the A20.

Before a pcb, I will use a breadboard and my oscillo:-)