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
81cbe23a
Commit
81cbe23a
authored
18 years ago
by
Florian Pose
Browse files
Options
Downloads
Patches
Plain Diff
Adjusted examples to EtherLab starter kit hardware.
parent
a3c12d46
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/mini/mini.c
+12
-7
12 additions, 7 deletions
examples/mini/mini.c
examples/rtai/rtai_sample.c
+15
-7
15 additions, 7 deletions
examples/rtai/rtai_sample.c
with
27 additions
and
14 deletions
examples/mini/mini.c
+
12
−
7
View file @
81cbe23a
...
@@ -41,7 +41,7 @@
...
@@ -41,7 +41,7 @@
#define FREQUENCY 100
#define FREQUENCY 100
#define KBUS
//
#define KBUS
/*****************************************************************************/
/*****************************************************************************/
...
@@ -58,11 +58,11 @@ void *r_inputs;
...
@@ -58,11 +58,11 @@ void *r_inputs;
void
*
r_outputs
;
void
*
r_outputs
;
#endif
#endif
void
*
r_
ana_in
;
void
*
r_
dig_out
;
#if 1
#if 1
ec_pdo_reg_t
domain1_pdos
[]
=
{
ec_pdo_reg_t
domain1_pdos
[]
=
{
{
"2"
,
Beckhoff_EL
3102_In
put
1
,
&
r_
ana_in
},
{
"2"
,
Beckhoff_EL
2004_Out
put
s
,
&
r_
dig_out
},
{}
{}
};
};
#endif
#endif
...
@@ -82,6 +82,7 @@ void run(unsigned long data)
...
@@ -82,6 +82,7 @@ void run(unsigned long data)
// process data
// process data
// k_pos = EC_READ_U32(r_ssi);
// k_pos = EC_READ_U32(r_ssi);
EC_WRITE_U8
(
r_dig_out
,
blink
?
0x0F
:
0x00
);
if
(
counter
)
{
if
(
counter
)
{
counter
--
;
counter
--
;
...
@@ -98,7 +99,11 @@ void run(unsigned long data)
...
@@ -98,7 +99,11 @@ void run(unsigned long data)
// send
// send
spin_lock
(
&
master_lock
);
spin_lock
(
&
master_lock
);
ecrt_domain_queue
(
domain1
);
ecrt_domain_queue
(
domain1
);
spin_unlock
(
&
master_lock
);
ecrt_master_run
(
master
);
ecrt_master_run
(
master
);
spin_lock
(
&
master_lock
);
ecrt_master_send
(
master
);
ecrt_master_send
(
master
);
spin_unlock
(
&
master_lock
);
spin_unlock
(
&
master_lock
);
...
@@ -111,7 +116,7 @@ void run(unsigned long data)
...
@@ -111,7 +116,7 @@ void run(unsigned long data)
int
request_lock
(
void
*
data
)
int
request_lock
(
void
*
data
)
{
{
spin_lock
_bh
(
&
master_lock
);
spin_lock
(
&
master_lock
);
return
0
;
// access allowed
return
0
;
// access allowed
}
}
...
@@ -119,14 +124,14 @@ int request_lock(void *data)
...
@@ -119,14 +124,14 @@ int request_lock(void *data)
void
release_lock
(
void
*
data
)
void
release_lock
(
void
*
data
)
{
{
spin_unlock
_bh
(
&
master_lock
);
spin_unlock
(
&
master_lock
);
}
}
/*****************************************************************************/
/*****************************************************************************/
int
__init
init_mini_module
(
void
)
int
__init
init_mini_module
(
void
)
{
{
#if
1
#if
0
ec_slave_t *slave;
ec_slave_t *slave;
#endif
#endif
...
@@ -166,7 +171,7 @@ int __init init_mini_module(void)
...
@@ -166,7 +171,7 @@ int __init init_mini_module(void)
}
}
#endif
#endif
#if
1
#if
0
if (!(slave = ecrt_master_get_slave(master, "2")))
if (!(slave = ecrt_master_get_slave(master, "2")))
goto out_release_master;
goto out_release_master;
...
...
This diff is collapsed.
Click to expand it.
examples/rtai/rtai_sample.c
+
15
−
7
View file @
81cbe23a
...
@@ -47,7 +47,7 @@
...
@@ -47,7 +47,7 @@
/*****************************************************************************/
/*****************************************************************************/
// RTAI task frequency in Hz
// RTAI task frequency in Hz
#define FREQUENCY
10
000
#define FREQUENCY
4
000
#define INHIBIT_TIME 20
#define INHIBIT_TIME 20
#define TIMERTICKS (1000000000 / FREQUENCY)
#define TIMERTICKS (1000000000 / FREQUENCY)
...
@@ -64,13 +64,10 @@ ec_master_t *master = NULL;
...
@@ -64,13 +64,10 @@ ec_master_t *master = NULL;
ec_domain_t
*
domain1
=
NULL
;
ec_domain_t
*
domain1
=
NULL
;
// data fields
// data fields
void
*
r_ana_out
;
void
*
r_dig_out
;
// channels
uint32_t
k_pos
;
ec_pdo_reg_t
domain1_pdos
[]
=
{
ec_pdo_reg_t
domain1_pdos
[]
=
{
{
"2"
,
Beckhoff_EL
4132
_Output
1
,
&
r_
ana
_out
},
{
"2"
,
Beckhoff_EL
2004
_Output
s
,
&
r_
dig
_out
},
{}
{}
};
};
...
@@ -78,6 +75,9 @@ ec_pdo_reg_t domain1_pdos[] = {
...
@@ -78,6 +75,9 @@ ec_pdo_reg_t domain1_pdos[] = {
void
run
(
long
data
)
void
run
(
long
data
)
{
{
static
unsigned
int
blink
=
0
;
static
unsigned
int
counter
=
0
;
while
(
1
)
{
while
(
1
)
{
t_last_cycle
=
get_cycles
();
t_last_cycle
=
get_cycles
();
...
@@ -87,13 +87,21 @@ void run(long data)
...
@@ -87,13 +87,21 @@ void run(long data)
rt_sem_signal
(
&
master_sem
);
rt_sem_signal
(
&
master_sem
);
// process data
// process data
//k_pos = EC_READ_U32(r_ssi_input
);
EC_WRITE_U8
(
r_dig_out
,
blink
?
0x0F
:
0x00
);
rt_sem_wait
(
&
master_sem
);
rt_sem_wait
(
&
master_sem
);
ecrt_domain_queue
(
domain1
);
ecrt_domain_queue
(
domain1
);
ecrt_master_run
(
master
);
ecrt_master_run
(
master
);
ecrt_master_send
(
master
);
ecrt_master_send
(
master
);
rt_sem_signal
(
&
master_sem
);
rt_sem_signal
(
&
master_sem
);
if
(
counter
)
{
counter
--
;
}
else
{
counter
=
FREQUENCY
;
blink
=
!
blink
;
}
rt_task_wait_period
();
rt_task_wait_period
();
}
}
...
...
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