Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
81cccadc
Commit
81cccadc
authored
Jan 19, 2011
by
Claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Arduino, PWM Ao added
parent
a5f9c58c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
115 additions
and
14 deletions
+115
-14
otherio/exp/rt/src/pwr_arduino_uno.pde
otherio/exp/rt/src/pwr_arduino_uno.pde
+36
-9
otherio/lib/rt/src/rt_io_m_arduino_uno.c
otherio/lib/rt/src/rt_io_m_arduino_uno.c
+64
-4
otherio/wbl/mcomp/src/otherio.wb_load
otherio/wbl/mcomp/src/otherio.wb_load
+15
-1
No files found.
otherio/exp/rt/src/pwr_arduino_uno.pde
View file @
81cccadc
...
...
@@ -39,6 +39,8 @@ int i;
int
j
;
int
aiList
[
32
];
int
aiCnt
;
int
aoList
[
32
];
int
aoCnt
;
byte
msgType
;
byte
msgId
;
byte
msgSize
;
...
...
@@ -52,9 +54,10 @@ const int debug = 0;
const
int
MSG_TYPE_WRITE
=
1
;
const
int
MSG_TYPE_DIREAD
=
2
;
const
int
MSG_TYPE_AIREAD
=
3
;
const
int
MSG_TYPE_CONFIGURE
=
4
;
const
int
MSG_TYPE_STATUS
=
5
;
const
int
MSG_TYPE_DEBUG
=
6
;
const
int
MSG_TYPE_AOWRITE
=
4
;
const
int
MSG_TYPE_CONFIGURE
=
5
;
const
int
MSG_TYPE_STATUS
=
6
;
const
int
MSG_TYPE_DEBUG
=
7
;
const
int
ARD__SUCCESS
=
1
;
const
int
ARD__DICONFIG
=
2
;
...
...
@@ -79,14 +82,14 @@ void sendDebug( byte sts)
//
void
resetOutput
()
{
if
(
msgSize
==
doSize
)
{
for
(
i
=
0
;
i
<
doSize
;
i
++
)
{
for
(
j
=
0
;
j
<
8
;
j
++
)
{
if
(
((
1
<<
j
)
&
doMask
[
i
])
!=
0
)
digitalWrite
(
i
*
8
+
j
,
LOW
);
}
}
}
for
(
i
=
0
;
i
<
aoCnt
;
i
++
)
analogWrite
(
aoList
[
i
],
0
);
}
//
...
...
@@ -176,6 +179,19 @@ void loop()
sts
=
ARD__COMMERROR
;
}
}
else
if
(
msgType
==
MSG_TYPE_AOWRITE
)
{
// Write analog outputs
if
(
msgSize
==
aoSize
)
{
for
(
i
=
0
;
i
<
aoCnt
;
i
++
)
analogWrite
(
aoList
[
i
],
msgData
[
i
]);
sts
=
ARD__SUCCESS
;
}
else
{
sts
=
ARD__COMMERROR
;
}
}
else
if
(
msgType
==
MSG_TYPE_DIREAD
)
{
// Read Digital inputs
smsg
[
0
]
=
diSize
+
3
;
...
...
@@ -296,6 +312,17 @@ void loop()
}
}
}
// Create list of configured Ao
aoCnt
=
0
;
for
(
i
=
0
;
i
<
aoSize
;
i
++
)
{
for
(
j
=
0
;
j
<
8
;
j
++
)
{
if
(
((
1
<<
j
)
&
aoMask
[
i
])
!=
0
)
{
aoList
[
aoCnt
]
=
i
*
8
+
j
;
aoCnt
++
;
}
}
}
}
// Send configuration status
...
...
otherio/lib/rt/src/rt_io_m_arduino_uno.c
View file @
81cccadc
...
...
@@ -51,6 +51,7 @@ typedef struct {
int
DiPollId
;
int
DiPendingPoll
;
int
AiIntervalCnt
;
int
AoIntervalCnt
;
io_sChannel
*
DChanList
[
D_MAX_SIZE
*
8
];
io_sChannel
*
AiChanList
[
AI_MAX_SIZE
*
8
];
io_sChannel
*
AoChanList
[
AO_MAX_SIZE
*
8
];
...
...
@@ -86,9 +87,10 @@ typedef enum {
ard_eMsgType_Write
=
1
,
ard_eMsgType_DiRead
=
2
,
ard_eMsgType_AiRead
=
3
,
ard_eMsgType_Configure
=
4
,
ard_eMsgType_Status
=
5
,
ard_eMsgType_Debug
=
6
ard_eMsgType_AoWrite
=
4
,
ard_eMsgType_Configure
=
5
,
ard_eMsgType_Status
=
6
,
ard_eMsgType_Debug
=
7
}
ard_eMsgType
;
#define ARD__SUCCESS 1
...
...
@@ -501,6 +503,7 @@ static pwr_tStatus IoCardRead( io_tCtx ctx,
if
(
EVEN
(
sts
))
{
}
else
{
int
ai_cnt
=
0
;
for
(
i
=
0
;
i
<
local
->
AiSize
;
i
++
)
{
for
(
j
=
0
;
j
<
8
;
j
++
)
{
m
=
1
<<
j
;
...
...
@@ -513,7 +516,7 @@ static pwr_tStatus IoCardRead( io_tCtx ctx,
// Request to calculate new coefficients
io_AiRangeToCoef
(
chanp
);
ivalue
=
rmsg
.
data
[
(
i
*
8
+
j
)
*
2
]
*
256
+
rmsg
.
data
[(
i
*
8
+
j
)
*
2
+
1
];
ivalue
=
rmsg
.
data
[
ai_cnt
*
2
]
*
256
+
rmsg
.
data
[
ai_cnt
*
2
+
1
];
io_ConvertAi
(
cop
,
ivalue
,
&
actvalue
);
// Filter
...
...
@@ -527,6 +530,7 @@ static pwr_tStatus IoCardRead( io_tCtx ctx,
*
(
pwr_tFloat32
*
)
chanp
->
vbp
=
actvalue
;
sop
->
SigValue
=
cop
->
SigValPolyCoef1
*
ivalue
+
cop
->
SigValPolyCoef0
;
sop
->
RawValue
=
ivalue
;
ai_cnt
++
;
}
}
}
...
...
@@ -582,6 +586,62 @@ static pwr_tStatus IoCardWrite( io_tCtx ctx,
sts
=
write
(
local
->
fd
,
&
msg
,
msg
.
size
);
}
if
(
local
->
AoSize
)
{
int
skip_ao
=
0
;
if
(
op
->
AoScanInterval
>
1
)
{
skip_ao
=
local
->
AoIntervalCnt
;
local
->
AoIntervalCnt
++
;
if
(
local
->
AoIntervalCnt
>=
op
->
AoScanInterval
)
local
->
AoIntervalCnt
=
0
;
}
if
(
!
skip_ao
)
{
ard_sMsg
msg
;
int
value
;
memset
(
&
msg
,
0
,
sizeof
(
msg
));
msg
.
size
=
local
->
AoNum
+
3
;
msg
.
id
=
local
->
IdCnt
++
;
msg
.
type
=
ard_eMsgType_AoWrite
;
int
ao_cnt
=
0
;
for
(
i
=
0
;
i
<
local
->
AoSize
;
i
++
)
{
for
(
j
=
0
;
j
<
8
;
j
++
)
{
m
=
1
<<
j
;
if
(
local
->
AoMask
[
i
]
&
m
)
{
io_sChannel
*
chanp
=
local
->
AoChanList
[
i
*
8
+
j
];
pwr_sClass_ChanAo
*
cop
=
(
pwr_sClass_ChanAo
*
)
chanp
->
cop
;
pwr_sClass_Ao
*
sop
=
(
pwr_sClass_Ao
*
)
chanp
->
sop
;
if
(
cop
->
CalculateNewCoef
)
// Request to calculate new coefficients
io_AoRangeToCoef
(
chanp
);
value
=
*
(
pwr_tFloat32
*
)
chanp
->
vbp
*
cop
->
OutPolyCoef1
+
cop
->
OutPolyCoef0
+
0
.
49
;
if
(
value
<
0
)
value
=
0
;
else
if
(
value
>
255
)
value
=
255
;
msg
.
data
[
ao_cnt
]
=
value
;
sop
->
SigValue
=
cop
->
SigValPolyCoef1
*
*
(
pwr_tFloat32
*
)
chanp
->
vbp
+
cop
->
SigValPolyCoef0
;
sop
->
RawValue
=
value
;
ao_cnt
++
;
}
}
}
// logg( "Write Ao");
sts
=
write
(
local
->
fd
,
&
msg
,
msg
.
size
);
}
}
if
(
op
->
ErrorCount
>=
op
->
ErrorSoftLimit
&&
error_count
<
op
->
ErrorSoftLimit
)
{
errh_Warning
(
"IO Card ErrorSoftLimit reached, '%s'"
,
cp
->
Name
);
...
...
otherio/wbl/mcomp/src/otherio.wb_load
View file @
81cccadc
...
...
@@ -2485,7 +2485,7 @@ Volume OtherIO $ClassVolume 0.0.250.10
Object RtBody $ObjBodyDef 1 13-DEC-2010 21:36:40.01
Body SysBody 13-DEC-2010 21:39:07.38
Attr StructName = "Arduino_Uno"
Attr NextAix = "_X2
4
"
Attr NextAix = "_X2
5
"
EndBody
!/**
! Optional description.
...
...
@@ -2634,6 +2634,20 @@ Volume OtherIO $ClassVolume 0.0.250.10
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
!/**
! Specifies, in relation to the scantime of the thread, how often
! the Ao channels of the board are handled. If AoScanInterval is 1 or 0,
! the Ao are handled every scan. If AoScanInterval is for example 10, they
! are handled every 10'th scan, i.e. the scantime for the module
! will be AoScanInterval times the scantime of the thread.
!*/
Object AoScanInterval $Attribute 24 19-JAN-2011 18:24:34.75
Body SysBody 19-JAN-2011 18:24:35.83
Attr PgmName = "AoScanInterval"
Attr Flags = 16777216
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
EndObject
Object IoMethods $RtMethod 144 13-DEC-2010 21:36:40.01
Object IoCardInit $Method 145 13-DEC-2010 21:36:40.01
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment