Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
processer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anders Blomdell
processer
Commits
3394fa63
Commit
3394fa63
authored
6 years ago
by
Anders Blomdell
Browse files
Options
Downloads
Patches
Plain Diff
Change to fast PWM
parent
114a55bb
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
ball_and_beam-2018/avr/ball_and_beam-2018.c
+20
-11
20 additions, 11 deletions
ball_and_beam-2018/avr/ball_and_beam-2018.c
with
20 additions
and
11 deletions
ball_and_beam-2018/avr/ball_and_beam-2018.c
+
20
−
11
View file @
3394fa63
...
@@ -7,7 +7,8 @@
...
@@ -7,7 +7,8 @@
/*
/*
* Serial I/O assignments:
* Serial I/O assignments:
*
*
* DI 0 -- Motor Overtemp
* DI 0 -- Ball On Beam
* DI 1 -- Motor Overtemp
*
*
* DO 0 -- Motor Brake
* DO 0 -- Motor Brake
* DO 1 -- Accelerometer Self-Test
* DO 1 -- Accelerometer Self-Test
...
@@ -124,18 +125,18 @@ SIGNAL(USART_RXC_vect)
...
@@ -124,18 +125,18 @@ SIGNAL(USART_RXC_vect)
switch
(
serialio_RXC
(
ch
))
{
switch
(
serialio_RXC
(
ch
))
{
case
serialio_clearbit
:
{
case
serialio_clearbit
:
{
switch
(
serialio_channel
)
{
switch
(
serialio_channel
)
{
case
0
:
{
PORTB
&=
~
0x08
;
}
break
;
case
0
:
{
PORTB
&=
~
0x08
;
}
break
;
// motorBrake
case
1
:
{
PORTC
&=
~
0x80
;
}
break
;
case
1
:
{
PORTC
&=
~
0x80
;
}
break
;
// accelerometerSelfTest
}
}
}
break
;
}
break
;
case
serialio_setbit
:
{
case
serialio_setbit
:
{
switch
(
serialio_channel
)
{
switch
(
serialio_channel
)
{
case
0
:
{
PORTB
|=
0x08
;
}
break
;
case
0
:
{
PORTB
|=
0x08
;
}
break
;
// motorBrake
case
1
:
{
PORTC
|=
0x80
;
}
break
;
case
1
:
{
PORTC
|=
0x80
;
}
break
;
// accelerometerSelfTest
}
}
}
break
;
}
break
;
case
serialio_pollbit
:
{
case
serialio_pollbit
:
{
if
(
serialio_channel
<
1
)
{
if
(
serialio_channel
<
2
)
{
serial_readbits
|=
(
1
<<
serialio_channel
);
serial_readbits
|=
(
1
<<
serialio_channel
);
}
}
}
break
;
}
break
;
...
@@ -176,15 +177,15 @@ int main()
...
@@ -176,15 +177,15 @@ int main()
serial_readconfig
=
0
;
serial_readconfig
=
0
;
PORTA
=
0x00
;
// PortA, pull-ups
PORTA
=
0x00
;
// PortA, pull-ups
DDRA
=
0x00
;
// PortA, all inputs
DDRA
=
0x00
;
// PortA, all inputs
PORTB
=
0x
0
0
;
// PortB, pull-ups / initial values
PORTB
=
0x
1
0
;
// PortB, pull-ups / initial values
DDRB
=
0x0a
;
// PortB, bits 1 & 3 outputs
DDRB
=
0x0a
;
// PortB, bits 1 & 3 outputs
PORTC
=
0x00
;
// PortC, pull-ups / initial values
PORTC
=
0x00
;
// PortC, pull-ups / initial values
DDRC
=
0x80
;
// PortC, bit 7 output
DDRC
=
0x80
;
// PortC, bit 7 output
PORTD
=
0x00
;
// PortD, pull-ups / initial values
PORTD
=
0x00
;
// PortD, pull-ups / initial values
DDRD
=
0x20
;
// PortD, bit 5 output
DDRD
=
0x20
;
// PortD, bit 5 output
TCCR0
=
0x05
;
// Timer0, Clock / 1024
TCCR0
=
0x05
;
// Timer0, Clock / 1024
TCCR1A
=
0x83
;
// OC1A 10 bit PWM (
Phase Correct), clear A on matc
h
TCCR1A
=
0x83
;
// OC1A 10 bit PWM (
fast), active hig
h
TCCR1B
=
0x0
1
;
// Clock / 1
TCCR1B
=
0x0
9
;
// Clock / 1
OCR1A
=
0
&
0x3ff
;
OCR1A
=
0
&
0x3ff
;
UCSRA
=
0x00
;
// USART:
UCSRA
=
0x00
;
// USART:
UCSRB
=
0x98
;
// USART: RxIntEnable|RxEnable|TxEnable
UCSRB
=
0x98
;
// USART: RxIntEnable|RxEnable|TxEnable
...
@@ -215,9 +216,17 @@ int main()
...
@@ -215,9 +216,17 @@ int main()
if
(
channels
&
0x08
)
{
serialio_putchannel
(
3
,
local
.
accelerometerY
);
}
if
(
channels
&
0x08
)
{
serialio_putchannel
(
3
,
local
.
accelerometerY
);
}
if
(
channels
&
0x10
)
{
serialio_putchannel
(
4
,
local
.
accelerometerZ
);
}
if
(
channels
&
0x10
)
{
serialio_putchannel
(
4
,
local
.
accelerometerZ
);
}
if
(
channels
&
0x20
)
{
serialio_putchannel
(
5
,
local
.
motorEncoder
);
}
if
(
channels
&
0x20
)
{
serialio_putchannel
(
5
,
local
.
motorEncoder
);
}
if
(
bits
&
0x01
)
{
serialio_putbit
(
0
,
PORTB
&
0x10
);
}
// thermalFlag
if
(
bits
&
0x01
)
{
// ballOnBeam
serialio_putbit
(
0
,
PINB
&
0x01
);
}
if
(
bits
&
0x02
)
{
// thermalFlag
serialio_putbit
(
1
,
!
(
PINB
&
0x10
));
}
if
(
config
)
{
if
(
config
)
{
CONF_DIGITAL_IN
(
0
,
CONF_RESOLUTION
(
1
));
// motorTemp
CONF_DIGITAL_IN
(
0
,
CONF_RESOLUTION
(
1
));
// ballOnBeam
CONF_DIGITAL_IN
(
1
,
CONF_RESOLUTION
(
1
));
// motorTemp
CONF_DIGITAL_OUT
(
0
,
CONF_RESOLUTION
(
1
));
// motorBrake
CONF_DIGITAL_OUT
(
0
,
CONF_RESOLUTION
(
1
));
// motorBrake
CONF_DIGITAL_OUT
(
1
,
CONF_RESOLUTION
(
1
));
// accelerometerSelfTest
CONF_DIGITAL_OUT
(
1
,
CONF_RESOLUTION
(
1
));
// accelerometerSelfTest
...
...
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