Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Anders Blomdell
processer
Commits
7363cced
Commit
7363cced
authored
Feb 19, 2009
by
Pontus Giselsson
Browse files
Added simulink file and matlab scripts
parent
91a6458f
Changes
3
Hide whitespace changes
Inline
Side-by-side
linear_pendulum_2009/avr/compileUploadCurrentControl.sh
View file @
7363cced
avr-gcc
-mmcu
=
atmega16
-g
-Wall
-o
current_control current_control.c
avr-objcopy
-Osrec
current_control current_control.sr
avr-gcc
-mmcu
=
atmega16
-g
-Wall
-o
current_control
.o
current_control.c
avr-objcopy
-Osrec
current_control
.o
current_control.sr
uisp
-dprog
=
stk200
--erase
--upload
if
=
current_control.sr
\ No newline at end of file
linear_pendulum_2009/avr/compileUploadVelControl.sh
View file @
7363cced
avr-gcc
-mmcu
=
atmega16
-O
-g
-Wall
-o
vel_control vel_control.c pccom.c
avr-objcopy
-Osrec
vel_control vel_control.sr
avr-gcc
-mmcu
=
atmega16
-O
-g
-Wall
-o
vel_control
.o
vel_control.c pccom.c
avr-objcopy
-Osrec
vel_control
.o
vel_control.sr
uisp
-dprog
=
stk200
--erase
--upload
if
=
vel_control.sr
\ No newline at end of file
linear_pendulum_2009/avr/vel_control.c
View file @
7363cced
/***************************************************************
Current regulation - Pontus Giselsson, Per-Ola Larsson 18/02/09
for LTH - reglerteknik
/***************************************************************
#include <avr/twi.h>
#include <avr/io.h>
#include <avr/signal.h>
...
...
@@ -136,8 +143,6 @@ SIGNAL(SIG_OUTPUT_COMPARE0) {
sei
();
// enable interrupts from encoder-counter
// Poll UART receiver
uint8_t
status
=
UCSRA
;
if
(
status
&
(
1
<<
RXC
))
{
...
...
@@ -155,8 +160,6 @@ SIGNAL(SIG_OUTPUT_COMPARE0) {
if
(
toSend
>=
0
)
UDR
=
(
char
)
toSend
;
}
TIFR
=
(
1
<<
OCF0
);
// skip pending interrupts from serial comm, (but not from ctrl)
TIMSK
|=
(
BV
(
OCIE0
)
|
BV
(
OCIE1A
));
// reenable communication and ctrl-interrupts
...
...
@@ -183,7 +186,6 @@ SIGNAL(SIG_OUTPUT_COMPARE1A) {
// ref = ref*(1-brake); // emergency stop
sei
();
// control error
e
=
refCtrl
-
((
velEst
+
16
)
>>
5
);
// mm/s
...
...
@@ -225,15 +227,11 @@ SIGNAL(SIG_OUTPUT_COMPARE1A) {
sei
();
// TWI-communication to set current reference on the other atmel
// send start command
outp
(
BV
(
TWINT
)
|
BV
(
TWEN
)
|
BV
(
TWSTA
),
TWCR
);
while
(
!
(
TWCR
&
BV
(
TWINT
)))
{}
// Contact slave
outp
(
0x02
,
TWDR
);
// slave is 0x02 (sla+w)
outp
(
BV
(
TWINT
)
|
BV
(
TWEN
),
TWCR
);
...
...
@@ -260,7 +258,6 @@ int main()
PORTD
=
0x40
;
// pull up on reset switch
/* Timer section */
// Enable timer0, timer1, timer2 compare match interrupts
outp
(
BV
(
OCIE0
)
|
BV
(
OCIE1A
)
|
BV
(
OCIE2
),
TIMSK
);
...
...
@@ -296,8 +293,7 @@ int main()
outp
(
0x18
,
UCSRB
);
// USART: RxEnable|TxEnable
outp
(
0x86
,
UCSRC
);
// USART: 8bit, no parity
outp
(
0x00
,
UBRRH
);
// USART: 115200 @ 14.7456MHz
outp
(
7
,
UBRRL
);
// USART: 115200 @ 14.7456MHz
outp
(
7
,
UBRRL
);
// USART: 115200 @ 14.7456MHz
/* AREF (AREF is 5V) pin external capacitor, ADC3 for pendulum angle */
...
...
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