dhhagan / py-opc

Python wrapper for the Alphasense OPC-N2 built around py-spidev
MIT License
30 stars 26 forks source link

SPI mode must be 1 #59

Closed Ny4nmaru closed 6 years ago

Ny4nmaru commented 6 years ago

Hi, i have a problem with using this library. i import opc and usbiss successfully, i even create a spi object as written in documentation, but i have problem with "alpha".

when i write opc.OPCN2(spi), it returns error "assert self.cnxn.mode ==1 "SPI mode must be 1"

i am using python 3.5.3, running OPC-N2 via SPI-USB adapter that was supplied with the device. Trying to run it on Raspberry Pi 3 model B.

Do you have any advice ?:)

dhhagan commented 6 years ago

Hey @Ny4nmaru, thanks for reaching out. Could you post the exact code you are using to setup the SPI connection? Could you also post the versions of py-opc and pyusbiss that you have installed? You can grab those by issuing the command pip freeze at the terminal.

DancingQuanta commented 6 years ago

Hi,, I am the author of pyusbiss library. The library has been suffering from my lack of care with releases. As such the documentation I gave to David about pyusbiss is out of date.

Please give me a few days while I get the library under proper versioning and release a stable version then I will update the documentation. In the meantime try the following code

spi = usbiss.USBISS("/dev/ttyACM0", 'spi', spi_mode = 1, freq = 500000)

Please note that the correct code includes the statement

spi_mode = 1

while the old code is

spi_mode = 2

This change was made to bring pyusbiss in line with the official SPI specification.

Ny4nmaru commented 6 years ago

Hi, so, i tried today to change the spi_mode to 1, but it does not work. It says my version of firmware is not supported (i work with 18.2), and it will not let me enter the version manually (tried it). But somehow, i tried to run the old script from yesterday, and it started to work. No idea what happened.

dhhagan commented 6 years ago

Huh. That is strange. Have you had any more issues, or has it been cooperating?

Ny4nmaru commented 6 years ago

Well, i downloaded both needed libraries again, and i found out, that the "SPI mode must be 1" row is deleted in the fully functional library. nothing else is different. And what is really weird is that i dont remember deleting it. But whatever :D its funny, but without that row its working like a charm. OPC-N2 was with few pauses measuring for 12h, without any problem.

Ny4nmaru commented 6 years ago

I guess that sometimes science is more art than science

DancingQuanta commented 6 years ago

I have been working hard behind the scenes. :). If everything works for you then you can close this issue. Also I am releasing a minor update soon that changes the interface which will allow more development into other capacities of the USB-SPI adapter.

DancingQuanta commented 6 years ago

Hello, I have released a new version of pyusbiss 0.2.0 which you can install via pip install pyusbiss. This version is a major revision and so I have updated the instructions in https://github.com/dhhagan/py-opc/pull/61.

DancingQuanta commented 6 years ago

Have you made any progress?