-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
USB connection not working #63
Comments
Hi @krkol Could you tell me which version of this library you are using? If you issue the command |
Did you install pyusbiss via pip?
Pyusbiss currently works for python 3 not 2.7 at the moment.
Do you have python 3?
…On Thu, 12 Apr 2018, 02:22 David H Hagan, ***@***.***> wrote:
Hi @krkol <https://github.com/krkol> Could you tell me which version of
this library you are using? If you issue the command pip list at your
terminal/command line, it should spit out versions for all libraries. In
addition, could you attach the code in OPCUSBtest.py? It sounds like it
is using python27 to run the code instead of python34; try running with $
python3 OPCUSBtest.py and see what happens? I don't think the python
version is the issue, but it's worth a shot.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#63 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AIB3Vad35lEx8pYBO2q-lDbFQ5tyxmpNks5tnqxJgaJpZM4TQ97y>
.
|
Hi @dhhagan, Thank you for the help! We are using version 1.5.0 of py-opc. And then we are using version 0.2.0 of pyusbiss. I got everything to run through python 3 and it's giving the same errors. I can hear the alphasense fan running, so I know it has power. I installed everything with pip3. The raspberry pi has both python 2.7 and python 3.4 installed. I am using the code pasted below: from usbiss.spi import SPI Build the connectorspi = SPI("/dev/ttyACM0") Set the SPI mode and clock speedspi.mode = 1 alpha = opc.OPCN2(spi) Turn on the devicealpha.on() Read the histogramalpha.histogram() Turn the device offalpha.off() |
Please post the traceback when you run the code through python 3. |
The error message that I get is either: or During handling of the above exception, another exception occurred: Traceback (most recent call last): During handling of the above exception, another exception occurred: Traceback (most recent call last): |
@dhhagan In parsing the version of firmware I think it would be more useful to execute |
@DancingQuanta That's a great idea, in addition, maybe add a |
I do not have Alphasense's version of USB-ISS where they packaged the USB-ISS in a compact case with a wire with a small connector (micro-usb?). @dhhagan do you have such packaged USB-ISS? If you do, can you figure out how to do a SPI loopback test on it? By shorting two of the connector's contacts. I wanted to make sure @krkol have a functioning USB-ISS module with proper connections. A |
I tried using another wrapper that I found written by @dhhagen that is available here: https://www.snip2code.com/Snippet/553675/Run-Alphasense-OPC-N2. There were a few things to edit in the code to match the newest version of all of the libraries. This worked much better. The problem seemed to be that the connection would sometimes happen, but sometimes not. When an error gets thrown, there needs to be a way to try again. Maybe the USB line gets "busy", I know this happens with serial connections. It seemed to work best if I restarted the pi and tried the program fresh. |
You can fairly easily unscrew the cover of the Alphasense USB-ISS converter and test it that way - but it sounds like @krkol got it to work eventually (confirm?). I like all of these suggestions and will implement them ASAP (maybe later this week). @krkol I typically write my firmware in that way (trying several times to ensure the connection is good), but I could add a |
Does this connection problem occurs more with USB than with direct SPI? I do remember that @dhhagan added a |
Hello! I have the same issue as @krkol. Happens almost every time that launching the command My configuration is about a RPi 3 Model B and a OPCN2 connected using the USB-SPI device and Python 3.5.3. Below I have attached the output of pip3 list:
The strange is that after few attemps, I managed to access OPCN2 and show you these outputs. The only thing I do not understand well is because the "LaserDACVal" value (# 115) is different from (# 230) than the one on the py-opc documentation. >>>alpha = opc.OPCN2(spi) >>>alpha >>>alpha.read_firmware() >>>alpha.read_pot_status() Another strange thing but I do not think it is linked with the py-opc problem is that the usbiss library is accessible from python 3.5.3 only with not sudoer. In that case python does not recognize the installed package as well as pyserial. At first I thought the problem was related to the fact that OPCN2 is connected to a powered hub and connected with a 3 meter USB 2.0 A-B cable. I have verified using the Alpasense software in Windows and this is not the cause of the problem. As you can see the histogram values are null, instead using "alpha.pm()" I got some concrete values. >>>alpha.histogram() Thank you |
USB connection: Yes you have to try a number of times before you could connect. I suggest putting
Perhaps a form of this can be incorporated in @dhhagan's library with Sudoer: Can you explain more on this please? Why do you need to use |
I am grateful for the kind reply. The need to be root is not necessarily linked to OPC-N2 but to the fact that the collected data are uploaded to a web server and to do this I must be superuser. In any case, I will solve it in some way. Although I have read the bees I can not understand the difference between alpha.histogram () and alpha.histogram (False). It would seem that alpha.pm () gives PM point values with the corrections obtained from the histogram bin values. As you can see:
|
I suggest opening a new issue on the PMs values, this issue is about USB connectivity and so it will get confusing fast if people ask a lot of different things here. If the vendor supplied software on Windows can fetch the PM values for you then report that in the new issue so the @dhhagan can give his opinion on what ailing you. Unsolicited advice on |
I agree with opening a new issue @DancingQuanta. In other news, changes including logging and retrying connections are now available on the dev branch. I will test here in a few minutes. |
Also, @teokino The difference between the two histograms you were outputting is that you are reading them in different units. Number ConcentrationOutput the binned values in units of # of particles per cubic centimeter.
Bin ValuesOutput the binned values as the number of particles in a given bin since the last time you emptied the bin (i.e. called the histogram function)
I thought I had explained this in the docs (http://py-opc.readthedocs.io/en/latest/#opc.OPCN2.histogram), but if I can make it more clear, please feel free to comment here or to send recommended updates to the documentation. |
Okay, for everyone on this issue, version 1.6 is now released via GitHub (not yet on PyPi). Once a few of you can test/verify the issues are solved, I will issue a new release. Let me know if you have any questions/comments/concerns. |
Hello, I got 6 times the following error message: and then the final: FirmwareVersionError Traceback (most recent call last) /usr/local/lib/python2.7/dist-packages/opc/init.pyc in init(self, spi_connection, **kwargs) /usr/local/lib/python2.7/dist-packages/opc/init.pyc in init(self, spi_connection, firmware, max_cnxn_retries, retry_interval_ms, **kwargs) FirmwareVersionError: Any idea how to solve this? Thanks an dbest regards |
Hi @biogis Could you post the code you used to try this? Specifically interested in the clock speed.. |
Hi, I used the same code on the readme doc: import spidev spi = spidev.SpiDev() alpha = opc.OPCN2(spi) |
Hello, It finally worked, the MOSI and MISO were wrong in the GPIO... Sorry... |
@biogis No worries. Thanks for letting us know! |
I am trying to connect an OPCN2 to a Raspberry pi 3 using the USB-SPI connection. I've checked that the connection is in ACM0, the OPC has firmware version 18, and I've downloaded the pyusbiss version 0.2.0. I think that the problem might be related to the libraries running on python 2.7, but I have python 3.4.2 installed and all of the text files for the program that I open have (3.4.2) after the file extension .py. Here are the errors I am getting:
Traceback (most recent call last):
File "OPCUSBtest.py", line 13, in
alpha = opc.OPCN2(spi)
File "/usr/local/lib/python2.7/dist-packages/opc/init.py", line 238, in init
super(OPCN2, self).init(spi_connection, model='N2', **kwargs)
File "/usr/local/lib/python2.7/dist-packages/opc/init.py", line 64, in init
raise FirmwareVersionError(msg)
opc.exceptions.FirmwareVersionError:
Your firmware version could not be automatically detected. This is usually caused by bad wiring or a poor power supply. If niether of these are likely candidates, please open an issue on the GitHub repository at https://github.com/dhhagan/py-opc/issues/new
or
/usr/local/lib/python2.7/dist-packages/opc/init.py:522: UserWarning: Data transfer was incomplete.
warnings.warn("Data transfer was incomplete.")
I am using the exact same code as Davis has posted on the main page.
Thank you for any advice!
The text was updated successfully, but these errors were encountered: