Python library for SPI especially MCP3008

Started by Elecmuso, May 02, 2022, 03:02:10 AM

Previous topic - Next topic

Elecmuso

Hi

I found this

https://pypi.org/project/pyA20Lime2/

and was hoping to use it for reading channels from an MCP3008 via the GPIO port, after all the code is compatible with the MCP3002 (same family of ADCs but uses a 2 byte protocol since it only has 2 inputs, not 8).

However it does not work because the MCP3008 uses a 3 byte serial protocol whereas the MSC3002 uses a 2 byte protocol.

Am I missing something or should it be fairly straight forward to modify the library to accommodate the MCP3008?

Alternatively can someone provide some sample code say in C++?

Elecmuso

Having just looked at it I realise that the library should allow for any number of bytes.

I'm not sure what the problem is as I am not the programmer. I think my colleague is having issues using this library though he has managed to use the equivalent library for a Raspberry Pi (with Raspberry Pi hardware).

Perhaps the easiest way to do this is to have someone provide an example including:
1. How to import the correct library for Olimex A20
2. How to use spi.xfer when specific pins on the olimex GPIO5 port are used (I suppose from my point of view I can't see where the GPIO5 pins are mapped).

Any help getting past this greatly appreciated!