Skip to content
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

When working with spi again, a delay of at least 4 seconds is required. #27

Open
DenyaS opened this issue Sep 20, 2023 · 2 comments
Open

Comments

@DenyaS
Copy link

DenyaS commented Sep 20, 2023

The first time "device.transfer(message, cb)" works well, when called again "device.transfer(message, cb)" is not read or written.
I tried changing the parameters: microSecondDelay: 10 - 10000, etc.
Does not help! The only solution is to wait 4 seconds before repeating "device.transfer(message, cb)".
Cannot be used while device is polling.

@fivdi
Copy link
Owner

fivdi commented Sep 20, 2023

device.transfer(message, cb) works fine for me. The stress test tmp.js calls device.transfer(message, cb) successfully over 500 times a second to determine the temperature using a TMP36 analog temperature sensor wired to an MCP3008 SPI A/D converter on a Raspberry Pi 2.

Here is an example of the output from tmp36.js:

pi@raspberrypi:~/test/node_modules/spi-device/test/stress $ time node tmp36
606 606 223 21.935483870967744
556 1162 223 21.935483870967744
581 1743 223 21.935483870967744
585 2328 223 21.935483870967744
585 2913 223 21.935483870967744
582 3495 223 21.935483870967744
583 4078 223 21.935483870967744
592 4670 223 21.935483870967744
592 5262 223 21.935483870967744
590 5852 223 21.935483870967744
585 6437 223 21.935483870967744
595 7032 223 21.935483870967744
599 7631 223 21.935483870967744
584 8215 223 21.935483870967744
587 8802 223 21.935483870967744
588 9390 223 21.935483870967744
588 9978 223 21.935483870967744
586 10564 223 21.935483870967744
^C

real	0m19.077s
user	0m2.968s
sys	0m2.102s

I would suggest carefully studying the datasheet of the SPI device that you wish to use to confirm that it is being used correctly.

@DenyaS
Copy link
Author

DenyaS commented Sep 21, 2023

Thank you very much for your quick response!
When cs1 is manually controlled, the second poll passes without errors.
I'm still researching the problem. I'm using a custom cs1 overlay.
My board nanoPi Neo.
Thanks for your hard work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants