Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
gate-servo-controller
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
Martin Vítek
gate-servo-controller
Commits
88375a77
Commit
88375a77
authored
8 years ago
by
Martin Vítek
Browse files
Options
Downloads
Patches
Plain Diff
Add lock signal sensing
parent
6354eac2
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
SW/Controller.cpp
+9
-0
9 additions, 0 deletions
SW/Controller.cpp
SW/Controller.h
+31
-0
31 additions, 0 deletions
SW/Controller.h
SW/irq.cpp
+10
-0
10 additions, 0 deletions
SW/irq.cpp
SW/irq.h
+2
-0
2 additions, 0 deletions
SW/irq.h
with
52 additions
and
0 deletions
SW/Controller.cpp
+
9
−
0
View file @
88375a77
...
...
@@ -63,6 +63,13 @@ Controller::Controller(): servo(&DDRB, PB1, &OCR1A, blue_servo_data),
TCCR0
=
(
1
<<
CS02
);
//225Hz
TIMSK
|=
(
1
<<
TOIE0
);
//Ext IRQ ini
MCUCR
|=
(
1
<<
ISC11
);
//Falling edge
GICR
|=
(
1
<<
INT1
);
//TCC2 ini
TIMSK
|=
(
1
<<
TOIE2
);
sei
();
}
...
...
@@ -72,5 +79,7 @@ void Controller::print_debug()
uart
.
transmit_dec32
(
current_positive
);
uart
.
transmit_string
(
"
\t
N: "
);
uart
.
transmit_dec32
(
current_negative
);
uart
.
transmit_string
(
"
\t
L: "
);
uart
.
transmit_dec32
((
char
)
lock_signal
);
uart
.
transmit_new_line
();
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
SW/Controller.h
+
31
−
0
View file @
88375a77
...
...
@@ -28,6 +28,9 @@ class Controller
volatile
uint16_t
current_negative
;
volatile
uint8_t
channel
;
volatile
bool
lock_signal
;
volatile
uint8_t
lock_signal_delay
;
//Methods
public
:
Controller
();
...
...
@@ -37,6 +40,34 @@ class Controller
adc
.
start_conversion
();
}
void
lock_signal_delay_handler
()
{
lock_signal_delay
++
;
if
(
lock_signal_delay
>
224
)
//cca 4s
{
if
(
PIND
&
(
1
<<
PD3
))
{
lock_signal_delay
=
0
;
TCCR2
=
0
;
TCNT2
=
0
;
lock_signal
=
false
;
}
else
lock_signal_delay
=
0
;
}
}
void
lock_signal_handler
()
{
if
(
!
lock_signal
)
{
lock_signal
=
true
;
TCCR2
=
(
1
<<
CS22
)
|
(
1
<<
CS21
)
|
(
1
<<
CS20
);
}
}
void
adc_handler
()
{
switch
(
channel
)
...
...
This diff is collapsed.
Click to expand it.
SW/irq.cpp
+
10
−
0
View file @
88375a77
...
...
@@ -10,6 +10,16 @@ ISR(TIMER0_OVF_vect)
controller
.
timer0_handler
();
}
ISR
(
TIMER2_OVF_vect
)
{
controller
.
lock_signal_delay_handler
();
}
ISR
(
INT1_vect
)
{
controller
.
lock_signal_handler
();
}
ISR
(
ADC_vect
)
{
controller
.
adc_handler
();
...
...
This diff is collapsed.
Click to expand it.
SW/irq.h
+
2
−
0
View file @
88375a77
...
...
@@ -3,5 +3,7 @@
#include
<avr/interrupt.h>
ISR
(
TIMER0_OVF_vect
);
ISR
(
TIMER2_OVF_vect
);
ISR
(
INT1_vect
);
ISR
(
ADC_vect
);
ISR
(
BADISR_vect
);
\ No newline at end of file
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