From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Hobbyist Toolkit

cancel
Showing results for 
Search instead for 
Did you mean: 

Add an analog IO to Raspberry Pi (bit bang?)

Solved!
Go to solution

I'd like to add a thermistor input an an analog output to my RPi. It looks like if I went I2C I'd have to use a third party library right? On the other hand, I should be able to bit bang out a SPI signal right? Has anyone gone down this path or is everyone trying to do their communications with libraries? Is there an obvious disadvantage to bit banging I'm missing?

0 Kudos
Message 1 of 6
(1,698 Views)
Solution
Accepted by nanocyte

I'm wondering if you are using the wrong term here. Bitbanging means generally to use one or more digital pins and simply bang the protocol out over them yourself by setting the digital IO yourself.

 

But why would you want to do that? (Other than as an educational exercise!).

The Raspberry Pi has two SPI ports, one of them "/dev/spidev0.1" is standard also supported by the Linx Library in LabVIEW. No need to bitbang anything if you can use this supported SPI port.

 

Maybe you rather mean sending commands yourself over SPI rather than using a ready made (C) library for your sensor. That is something that all the Linx examples do anyhow, that deal with an SPI peripheral. Same about the I2C examples.

Rolf Kalbermatter
My Blog
Message 2 of 6
(1,655 Views)

Hey nanocyte,

 

i'd like to add somethings on what rolfk said.

 

You can use I2C without third party libraries. 

 

I usually recommend those with doubt on using I2C to look at datasheet and libraries because it may be easier to understand what is written in the datasheet through an example inside library (for arduino in example).

 

I have posted in this forum community some examples on how i do such things (since i am not profficient on i2c and even LabVIEW). 

we are all learning every day something new.

Jorge Augusto Pessatto Mondadori, PhD
Sistema Fiep
CLAD, CLD
0 Kudos
Message 3 of 6
(1,635 Views)

Thank you for the tips. I did not realize there was support for SPI without using a third party .so. I saw so many other people in the forum trying to compile their own library but maybe they were doing something else. Is there also I2C support? Can you point me to an example (especially if it has the correct pins hard coded)? Many of the examples are targeting the Arduino targets and it's tough to cut through that "noise"

0 Kudos
Message 4 of 6
(1,620 Views)

Yes, Linx also has I2C support.

 

Here is a I2C example Youtube video. I can't vouch for it as my work with Linx so far has been not really about accessing peripherals but rather in the Linx shared library itself. 

 

The problem I see mostly here is that people think it's all LabVIEW plug and play, but that is not how this works. Linx is a building block that lets you control the I2C or SPI bus on a supported device. But how to connect your particular ADC, PWM, Temp measurement sensor or whatever to the right IO pins is something that will often vary depending on the protocol, used chip and needs to be extracted from the datasheet for that chip, and with a basic understanding of the I2C or SPI communication interface on hardware electronics level. And to program it you again need to read the datasheet and figure out which bits and bytes need to be send over the line to address your specific chip.

Rolf Kalbermatter
My Blog
Message 5 of 6
(1,612 Views)

@rolfk  escreveu:

Linx is a building block that lets you control the I2C or SPI bus on a supported device. But how to connect your particular ADC, PWM, Temp measurement sensor or whatever to the right IO pins is something that will often vary depending on the protocol, used chip and needs to be extracted from the datasheet for that chip, a basic understanding of the I2C or SPI communication interface on hardware electronics level. And to program it you again need to read the datasheet and figure out which bits and bytes need to be send over the line to address your specific chip.


This should be pinned in the Hobbyist Toolkit forum home page

Jorge Augusto Pessatto Mondadori, PhD
Sistema Fiep
CLAD, CLD
0 Kudos
Message 6 of 6
(1,609 Views)