I am currently having troubles getting spi to work specifically for a MAX31865. I've attached my project which uses Edwin Schwellinger's SPI_I2ConBBB project from https://forge.codesys.com/forge/talk/Runtime/thread/39c439b0c2/?page=2&limit=25#e953 and am trying to get it to work with the SPI-temp project from Ingo https://forge.codesys.com/drv/spi-temperature/home/Home/. Currently it is only reading 0 values. What modifications do I need to libraries or device descriptions or to the project in order to get this to work. Or are there already similar projects available with documentation similar to raspberry pi projects? How do I know that the chip select is working and is there anyway to use GPIO pins for chip select. I've looked for information at https://forge.codesys.com/forge/talk/Runtime/thread/17852395ce/ but it doesn't seem conclusive
Currently the beaglebone spi works for SPI0 and tested using a spi loop test. And I have used the GPIO mapping for other projects.
The SPI "devices" are specific hardware peripherals in the CPU SoC, meaning you cannot change the CS, MOSI, MISO pins to regular GPIO pins.
While you can bitbang SPI i doubt it will be efficient to code that in Codesys.
Theoretically it should be possible to multiplex the CS line using transistors as gates controlled by GPIO's, however i have not tried this - and it still relies on the specific CS line.
For the raspberry pi there is an example project called "PiFace_FB" that uses the SPI drivers write8 and read8, there you can recreate the specific protocoll used by your MAX31865 chip.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I now have the Raspberry Pi example projects. Its said in raspberrypi_en.pdf "For the communication
use the standard methods of the base FBs i2c (read8, write8, etc.) or spi (transfer)", doesn't this mean that I should be using transfer instead of read8 and write8 or is it because its a FB that read8 and write8 work.
Last edit: User 2021-09-28
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've added the SPIMaster.devdesc.xml file (C/Users/XXX/CODESYS Control for Beaglebone SL/ 4.1.0.0/Devices) to the device repository however it does not come up when I add device from Device (CODESYS Control for Beaglebone SL). This file references a library called Beaglebone Black Peripherals, and has interfaces called BBB.SPIMaster and BBB.SPI. How do I modify the SPI_Template library to link to the Beaglebone Black Peripherals instead of the Raspberry Pi Peripherals. Any help would be greatly appreciated. And what interface do I need to use for the SPI_Template.devdesc.xml.
Last edit: User 2021-09-22
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
When I used the generic SPI master device description I was unable to add the SPI Temperature device to it even though it is in the device repository. I couldn't find a solution on the forge for this.
For the original post in the device tree I get a symbol indicating (The device is not exchanging data; bus error, no configuration, or simulation mod). I am not sure what I've done wrong and included what happens when I run the project and the parameters I've set. I've included the /dev folder of the beaglebone to show its the correct spidev link.
Another issue is how do I link the function blocks for the SPITemperature to the device. I think this is the main problem as its not linked. Any advice would be greatly appreciated, thankyou in advance.
I haven't gotten a response in a while so I wanted to clarify. The project https://forge.codesys.com/drv/spi-temperature/home/Home/ has exactly what I want. However when trying to use it for the Beaglebone Black it doesn't work. What modifications have to be made for it to be compatible any help would be greatly appreciated.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes I am sure I did a spi loop test and the clock works. When testing codesys it doesn't make the cs go low at all which is the problem as it is a low trigger.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Your login probably has permissions but not neccessarily codesys itself. You have to check what permissions (group) codesys belongs to and if that group has permission to the SPI device.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello
I am currently having troubles getting spi to work specifically for a MAX31865. I've attached my project which uses Edwin Schwellinger's SPI_I2ConBBB project from https://forge.codesys.com/forge/talk/Runtime/thread/39c439b0c2/?page=2&limit=25#e953 and am trying to get it to work with the SPI-temp project from Ingo https://forge.codesys.com/drv/spi-temperature/home/Home/. Currently it is only reading 0 values. What modifications do I need to libraries or device descriptions or to the project in order to get this to work. Or are there already similar projects available with documentation similar to raspberry pi projects? How do I know that the chip select is working and is there anyway to use GPIO pins for chip select. I've looked for information at https://forge.codesys.com/forge/talk/Runtime/thread/17852395ce/ but it doesn't seem conclusive
Currently the beaglebone spi works for SPI0 and tested using a spi loop test. And I have used the GPIO mapping for other projects.
Last edit: User 2021-09-21
The SPI "devices" are specific hardware peripherals in the CPU SoC, meaning you cannot change the CS, MOSI, MISO pins to regular GPIO pins.
While you can bitbang SPI i doubt it will be efficient to code that in Codesys.
Theoretically it should be possible to multiplex the CS line using transistors as gates controlled by GPIO's, however i have not tried this - and it still relies on the specific CS line.
For the raspberry pi there is an example project called "PiFace_FB" that uses the SPI drivers write8 and read8, there you can recreate the specific protocoll used by your MAX31865 chip.
I now have the Raspberry Pi example projects. Its said in raspberrypi_en.pdf "For the communication
use the standard methods of the base FBs i2c (read8, write8, etc.) or spi (transfer)", doesn't this mean that I should be using transfer instead of read8 and write8 or is it because its a FB that read8 and write8 work.
Last edit: User 2021-09-28
I've added the SPIMaster.devdesc.xml file (C/Users/XXX/CODESYS Control for Beaglebone SL/ 4.1.0.0/Devices) to the device repository however it does not come up when I add device from Device (CODESYS Control for Beaglebone SL). This file references a library called Beaglebone Black Peripherals, and has interfaces called BBB.SPIMaster and BBB.SPI. How do I modify the SPI_Template library to link to the Beaglebone Black Peripherals instead of the Raspberry Pi Peripherals. Any help would be greatly appreciated. And what interface do I need to use for the SPI_Template.devdesc.xml.
Last edit: User 2021-09-22
You just need to install the Raspberry PI Package from store, which brings the needed libraries.
Even if it's for the BBB. Does the BBB use the Raspberry PI package?
in that case yes - if you use: https://forge.codesys.com/forge/talk/Runtime/thread/e0f8552007/#p24118
these generic devicedescriptions for BBB
When I used the generic SPI master device description I was unable to add the SPI Temperature device to it even though it is in the device repository. I couldn't find a solution on the forge for this.
For the original post in the device tree I get a symbol indicating (The device is not exchanging data; bus error, no configuration, or simulation mod). I am not sure what I've done wrong and included what happens when I run the project and the parameters I've set. I've included the /dev folder of the beaglebone to show its the correct spidev link.
Another issue is how do I link the function blocks for the SPITemperature to the device. I think this is the main problem as its not linked. Any advice would be greatly appreciated, thankyou in advance.
Hello
I haven't gotten a response in a while so I wanted to clarify. The project https://forge.codesys.com/drv/spi-temperature/home/Home/ has exactly what I want. However when trying to use it for the Beaglebone Black it doesn't work. What modifications have to be made for it to be compatible any help would be greatly appreciated.
Are you sure that codesys have (Linux) permissions to access SPI device?
Yes I am sure I did a spi loop test and the clock works. When testing codesys it doesn't make the cs go low at all which is the problem as it is a low trigger.
Your login probably has permissions but not neccessarily codesys itself. You have to check what permissions (group) codesys belongs to and if that group has permission to the SPI device.
hi, I have a similar issue. My code reads value on logins but when i create boor application it cant access the file(one-wire file). How can I check if codesys has certain permissions?
Here is a link to the details: https://stackoverflow.com/questions/73442159/unable-to-open-a-file-on-boot-application