CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum
Deutsche Version English version russian version 
It is currently Thu Nov 23, 2017 10:30 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 16 posts ]  Go to page 1 2 Next
Author Message
 Post subject: SPI Device
PostPosted: Sun Nov 01, 2015 9:02 am 
Offline

Joined: Thu Oct 29, 2015 9:58 am
Posts: 11
Hi,
How can I create a new device? I need to make communication between RasPi and my board through SPI port. There is an example for device MCP3008 but I can't find the way how to modify it


Top
   
 Post subject: Re: SPI Device
PostPosted: Sun Nov 01, 2015 9:25 am 
Offline
Site Admin

Joined: Mon Sep 05, 2005 9:42 am
Posts: 2253
HI,

see the documentation here for details:

"c:\Users\YourWindowsUsername\CODESYS Control for Raspberry PI\2.2.0.2\DataSheet\RaspberryPI_en.pdf"

The devices and libraries which you could use as startpoint are here:
"c:\Users\YourWindowsUsername\CODESYS Control for Raspberry PI\2.2.0.2\Devices"
"c:\Users\YourWindowsUsername\CODESYS Control for Raspberry PI\2.2.0.2\Libraries"

BR
Edwin


Top
   
 Post subject: Re: SPI Device
PostPosted: Wed Nov 04, 2015 12:11 pm 
Offline

Joined: Thu Oct 29, 2015 9:58 am
Posts: 11
There are examples good for startpoint overview, but now I want to create my own device for my own board with some binary IO. Is there any way to create a new device?


Top
   
 Post subject: Re: SPI Device
PostPosted: Wed Nov 04, 2015 3:08 pm 
Offline

Joined: Thu Oct 29, 2015 9:58 am
Posts: 11
Ok, I got it, this pdf, page 17
Thanks


Top
   
 Post subject: Re: SPI Device
PostPosted: Thu Nov 05, 2015 11:29 am 
Offline

Joined: Thu Oct 29, 2015 9:58 am
Posts: 11
I work around IoDrvPiFace a and I trying to change channels in "SPI devices I/O Mapping". What is the way to do it? In method "IoDrvUpdateConfiguration" is part:
Code:
   //Setup I/O area
   pParameter := IoMgrConfigGetParameter(m_pConnector, 1000);      (* inputs *)
   IF (pParameter <> 0) THEN
      pParameter^.dwDriverSpecific := 0;               (* Device offset 0 *)
   END_IF
   pParameter := IoMgrConfigGetParameter(m_pConnector, 2000);      (* outputs *)
   IF (pParameter <> 0) THEN
      pParameter^.dwDriverSpecific := 0;               (* Device offset 0 *)
   END_IF

In pdf "Creating own Runtime System Components and I/O Drivers" on page 12 is:
  • Inputs: 1000-1999 (type:DWORD)
  • Outputs: 2000-2999 (type:DWORD)
but after modifying this values, in project nothing was change, I want to add some IO bytes more.

V.


Top
   
 Post subject: Re: SPI Device
PostPosted: Fri Nov 06, 2015 1:55 pm 
Offline

Joined: Thu Oct 29, 2015 9:58 am
Posts: 11
Maybe it is not easy to understand what I need. So, can someone add an input or outbut byte in IoDrvPiFace.library? I need to see it in SPI Devices IO Mapping.

Thanks, Viktor


Top
   
 Post subject: Re: SPI Device
PostPosted: Wed Nov 11, 2015 2:36 pm 
Offline

Joined: Thu Oct 29, 2015 9:58 am
Posts: 11
No answer :(
I believe anyone want to to help but its not clear what I want.

At first, we are developing control system based on Raspberry Pi and additional FPGA boards. Its mean mainly for cnc controller LinuxCNC but we looking for additional field of use of same hardware. We are done with IO binary board (16inputs/16outputs) and I trying to make IO driver for Codesys. More info about system for LinuxCNC:
https://youtu.be/ZJOIYXu7SeI

It is possible to help me and show how to modify IoDrvPiFace.library and add some more I/O which are visible in SPI Devices I/O Mapping?


Top
   
 Post subject: Re: SPI Device
PostPosted: Mon Nov 30, 2015 7:30 pm 
Offline
Site Admin

Joined: Mon Sep 05, 2005 9:42 am
Posts: 2253
Hi VikTan,

if you want provide an SPI Driver for your device you need to add your library and your devicedescription for your device.
Maybe PiFace_Io_driver is the startpoint you need.
In the device description which you find here:
"c:\Users\<yourWindowsUsername>\CODESYS Control for Raspberry PI\2.2.0.2\Devices\PiFaceIOdrv.devdesc.xml"
library here:
"c:\Users\<yourWindowsUsername>\CODESYS Control for Raspberry PI\2.2.0.2\Libraries\IoDrvPiFace.library"

This documentation for the runtime toolkit is not really useful for adapting Drivers for raspberry pi, this is more or less used if you buy the toolkit
and adapt a driver in C.

This SPI/I2C and other devices are implemented in IEC Code and need additional a devicedescription.
For Information on how to develop IEC libraries see the Store pdf and additional the FAQ section here in the Forum for best practice on
how to devel libraries (two instances on opens the library the second CODESYS instance open the project and test/debug your code even step into the library is possible )

BR
Edwin


Top
   
 Post subject: Re: SPI Device
PostPosted: Tue Dec 01, 2015 11:22 am 
Offline

Joined: Thu Oct 29, 2015 9:58 am
Posts: 11
Hi, thanks for answer

I already tried all this steps what you wrote. Something if working something not.
Consider the example, original PiFace_IO_Driver:
Is it possible to add some new variable by editing PiFaceIOdrv.devdesc.xml or IoDrvPiFace.library?

I assume yes and for someone who are experienced in codesys is it question of few steps and few minutes.
If someone can, pls describe me how to add any variable to this place. Step by step or something in particular what can help me to move to forward, not only general here is examples good for start.

Thank you in advance for any help

Attachment:
codesys_add_io.png


You do not have the required permissions to view the files attached to this post.


Top
   
 Post subject: Re: SPI Device
PostPosted: Thu Dec 03, 2015 7:58 am 
Offline
Site Admin

Joined: Mon Sep 05, 2005 9:42 am
Posts: 2253
Hi VikTan,

give me some time to generate some more documentation for this..
BR
Edwin


Top
   
 Post subject: Re: SPI Device
PostPosted: Thu Dec 03, 2015 8:30 am 
Offline

Joined: Thu Oct 29, 2015 9:58 am
Posts: 11
I'll be very grateful :)


Top
   
 Post subject: Re: SPI Device
PostPosted: Mon Mar 07, 2016 8:23 am 
Offline

Joined: Thu Mar 03, 2016 8:12 am
Posts: 5
I am facing the very same situation as OP.
I want to add interface variables (IO Mapping) but don't know how to to that.
Did someone update the documentation? If yes where to find it?


Top
   
 Post subject: Re: SPI Device
PostPosted: Wed Mar 16, 2016 3:52 pm 
Offline

Joined: Thu Oct 29, 2015 9:58 am
Posts: 11
Quote:
I want to add interface variables (IO Mapping) but don't know how to to that.


Edwin helps me with some points. Here is simple modified program PiFace with added variables.
https://www.dropbox.com/s/c0zie4snrtgyrl2/Example_project.zip?dl=0
Look mainly to "IoDrvReadInputs" and "IoDrvWriteOutputs" there is connection between project and library

Regards
Viktor


Top
   
 Post subject: Re: SPI Device
PostPosted: Tue Nov 29, 2016 9:27 am 
Offline

Joined: Fri Apr 08, 2016 5:12 am
Posts: 1
Hello VikTan,

Your link seems dead, would it be possible for you to repost it ? I am in a similar situation and that would be of great help, I need to develop a SPI library for a raspberry hat in order to use it with codesys and I am a bit confused on how to do it.

Thank you in advance,


Top
   
 Post subject: Re: SPI Device
PostPosted: Thu Dec 15, 2016 12:04 pm 
Offline
User avatar

Joined: Thu Jan 21, 2016 10:58 am
Posts: 26
Hello everybody,

I want to use RC522 rfid IC with raspberry pi:
https://www.amazon.de/gp/product/B00QFD ... UTF8&psc=1

It supports both spi an i2c. Any suggestion where to start?

Thanks,
Gergö


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 16 posts ]  Go to page 1 2 Next

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited