Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
etherlabmaster
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ICS Control System Infrastructure
etherlabmaster
Commits
f0df5027
Commit
f0df5027
authored
18 years ago
by
Florian Pose
Browse files
Options
Downloads
Patches
Plain Diff
RTAI sample with optimized jitter.
parent
425e25c5
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/rtai/Makefile
+1
-1
1 addition, 1 deletion
examples/rtai/Makefile
examples/rtai/rtai_sample.c
+27
-9
27 additions, 9 deletions
examples/rtai/rtai_sample.c
with
28 additions
and
10 deletions
examples/rtai/Makefile
+
1
−
1
View file @
f0df5027
...
...
@@ -35,7 +35,7 @@ obj-m := ec_rtai_sample.o
ec_rtai_sample-objs
:=
rtai_sample.o
EXTRA_CFLAGS
:=
-I
/usr/realtime/include
EXTRA_CFLAGS
:=
-I
/usr/realtime/include
-mhard-float
#------------------------------------------------------------------------------
...
...
This diff is collapsed.
Click to expand it.
examples/rtai/rtai_sample.c
+
27
−
9
View file @
f0df5027
...
...
@@ -28,35 +28,46 @@
#include
<linux/timer.h>
#include
<linux/interrupt.h>
// RTAI
#include
"rtai.h"
#include
"rtai_sched.h"
#include
"rtai_sem.h"
#include
"../../include/ecrt.h"
// EtherCAT realtime interface
// EtherCAT realtime interface
#include
"../../include/ecrt.h"
/*****************************************************************************/
// comment this for synchronous IO
#define ASYNC
#define TIMERTICKS 1000000
// RTAI task frequency in Hz
#define FREQUENCY 10000
#define TIMERTICKS (1000000000 / FREQUENCY)
/*****************************************************************************/
// RTAI
RT_TASK
task
;
SEM
master_sem
;
cycles_t
t_last_start
=
0
;
cycles_t
t_critical
;
// EtherCAT
ec_master_t
*
master
=
NULL
;
ec_domain_t
*
domain1
=
NULL
;
// data fields
//
void *r_ssi_input
, *r_ssi_status, *r_4102[3]
;
void
*
r_ssi_input
;
// channels
uint32_t
k_pos
;
uint8_t
k_stat
;
ec_field_init_t
domain1_fields
[]
=
{
{
NULL
,
"3"
,
"Beckhoff"
,
"EL5001"
,
"InputValue"
,
0
},
{
NULL
,
"2"
,
"Beckhoff"
,
"EL4132"
,
"OutputValue"
,
0
},
{
&
r_ssi_input
,
"3"
,
"Beckhoff"
,
"EL5001"
,
"InputValue"
,
0
},
{
NULL
,
"2"
,
"Beckhoff"
,
"EL4132"
,
"OutputValue"
,
0
},
{}
};
...
...
@@ -64,7 +75,9 @@ ec_field_init_t domain1_fields[] = {
void
run
(
long
data
)
{
while
(
1
)
{
while
(
1
)
{
t_last_start
=
get_cycles
();
rt_sem_wait
(
&
master_sem
);
#ifdef ASYNC
...
...
@@ -80,7 +93,7 @@ void run(long data)
#endif
// process data
//
k_pos = EC_READ_U32(r_ssi);
k_pos
=
EC_READ_U32
(
r_ssi
_input
);
#ifdef ASYNC
// send
...
...
@@ -90,7 +103,6 @@ void run(long data)
#endif
rt_sem_signal
(
&
master_sem
);
rt_task_wait_period
();
}
}
...
...
@@ -99,8 +111,12 @@ void run(long data)
int
request_lock
(
void
*
data
)
{
// too close to the next RT cycle: deny access...
if
(
get_cycles
()
-
t_last_start
>
t_critical
)
return
-
1
;
// allow access
rt_sem_wait
(
&
master_sem
);
return
0
;
// access allowed
return
0
;
}
/*****************************************************************************/
...
...
@@ -120,6 +136,8 @@ int __init init_mod(void)
rt_sem_init
(
&
master_sem
,
1
);
t_critical
=
cpu_khz
*
800
/
FREQUENCY
;
// ticks for 80%
if
((
master
=
ecrt_request_master
(
0
))
==
NULL
)
{
printk
(
KERN_ERR
"Requesting master 0 failed!
\n
"
);
goto
out_return
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment