I want to implement the ADC IC MCP3204 in CODESYS Control for BeagleBone SL.
(Preconditions: already operational attached CAN cape for analog input and CAN bus manager and device)
After searching and reading for 8 hours, I couldn't get it. I'm relatively new to CODESYS, but familiar with "package manager" and "library repository". What I have and what I've done:
Still got no result. Can anybody give me (exact instructions) in how to get a working device, or provide a working library and device description, please?
After doing the changes I installed the library and the device description to the corresponding repositories, added the device "SPI master" (and for testing purposes "SPI master (test version)"; but without success), and attached the (newly own created) device "MCP3204".
In the configuration for the SPI master, I tried first with the default entry "'/dev/spidev0.0'" (and _diMode = 0, _diBitsPerWord = 8 and _diMaxSpeed = 1000000; as seen in sample project posted from Erwin Schwellinger https://forge.codesys.com/forge/talk/Runtime/thread/39c439b0c2/?page=2&limit=25#e953), but SPI master wouldn't run with still red warning sign. With "'/dev/spidev0.1'" same.
With "'/dev/spidev1.0'", "'/dev/spidev1.1'", "'/dev/spidev2.0'", "'/dev/spidev2.1'", it's getting me the green sign on the SPI master. So far so good.
Next step was to map variables, that are being read in program to be actualized. But at the end I get stuck with not getting any values other than 0.
Any constructive help is welcome. Hopefully this can help others, getting from similar code samples to working new SPI devices.
The actual archived project file is attached.
I feel with you, i had the same frustration with getting the MCP3208 working.
However i finally cracked it and when you know how to use the SPI function it is really easy to modify however you want (the opcodes for various SPI slaves are different).
Unfortunately im at work now and the example code is in my private pc at home so i wont be able to post it until tonight to give you a little pointers on what to modify to get it working with the MCP3204.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
After spending several hours checking the code, the only missing thing was to enable/pinmux the SPI in the device (BeagleBone Black)
I did:
- changed the library according to the already given MCP3008 (available as a package over CODESYS Forge) and the MCP3202 (thread "Raspberry Pi: List of available drivers / libraries" in CODESYS forum), to fulfill the needs of the MCP3204. In the library code I did (as usual) documented the relevant code by comments.
- changed the device description according to the already given MCP3008 (available as a package over CODESYS Forge), to fulfill the needs of the MCP3204.
After all you can insert a MCP3204 and the map your variables in the register for I/O mapping of the device.
Attached are the library and the device description. If there is any time I#ll put it on CODESYS Forge, because I really want to see to make those efforts and results to be accessible and available as clear as possible
I want to implement the ADC IC MCP3204 in CODESYS Control for BeagleBone SL.
(Preconditions: already operational attached CAN cape for analog input and CAN bus manager and device)
After searching and reading for 8 hours, I couldn't get it. I'm relatively new to CODESYS, but familiar with "package manager" and "library repository". What I have and what I've done:
(but MCP3008 used)
(but don't know how to make it; no development environment in use)
Still got no result. Can anybody give me (exact instructions) in how to get a working device, or provide a working library and device description, please?
In the meantime I grabbed:
- the package "MCP3008" from CODESYS Forge https://forge.codesys.com/drv/mcp3008/home/Home/
- and the library and device description for "MCP3202" https://forge.codesys.com/forge/talk/Runtime/thread/9112cbdb0a/
and adapted the code of the MCP3008 to (hopefully) MCP3204 for both, the library and the device description.
After doing the changes I installed the library and the device description to the corresponding repositories, added the device "SPI master" (and for testing purposes "SPI master (test version)"; but without success), and attached the (newly own created) device "MCP3204".
In the configuration for the SPI master, I tried first with the default entry "'/dev/spidev0.0'" (and _diMode = 0, _diBitsPerWord = 8 and _diMaxSpeed = 1000000; as seen in sample project posted from Erwin Schwellinger https://forge.codesys.com/forge/talk/Runtime/thread/39c439b0c2/?page=2&limit=25#e953), but SPI master wouldn't run with still red warning sign. With "'/dev/spidev0.1'" same.
With "'/dev/spidev1.0'", "'/dev/spidev1.1'", "'/dev/spidev2.0'", "'/dev/spidev2.1'", it's getting me the green sign on the SPI master. So far so good.
Next step was to map variables, that are being read in program to be actualized. But at the end I get stuck with not getting any values other than 0.
Any constructive help is welcome. Hopefully this can help others, getting from similar code samples to working new SPI devices.
The actual archived project file is attached.
I feel with you, i had the same frustration with getting the MCP3208 working.
However i finally cracked it and when you know how to use the SPI function it is really easy to modify however you want (the opcodes for various SPI slaves are different).
Unfortunately im at work now and the example code is in my private pc at home so i wont be able to post it until tonight to give you a little pointers on what to modify to get it working with the MCP3204.
@ ojz0r: Thanks for your offer to help me out.
After spending several hours checking the code, the only missing thing was to enable/pinmux the SPI in the device (BeagleBone Black)
I did:
- changed the library according to the already given MCP3008 (available as a package over CODESYS Forge) and the MCP3202 (thread "Raspberry Pi: List of available drivers / libraries" in CODESYS forum), to fulfill the needs of the MCP3204. In the library code I did (as usual) documented the relevant code by comments.
- changed the device description according to the already given MCP3008 (available as a package over CODESYS Forge), to fulfill the needs of the MCP3204.
After all you can insert a MCP3204 and the map your variables in the register for I/O mapping of the device.
Attached are the library and the device description. If there is any time I#ll put it on CODESYS Forge, because I really want to see to make those efforts and results to be accessible and available as clear as possible
Last edit: laruso 2021-05-19
Good to hear that!
If you have problems, let me know!