Commit 7363cced authored by Pontus Giselsson's avatar Pontus Giselsson
Browse files

Added simulink file and matlab scripts

parent 91a6458f
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
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
/***************************************************************
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);
......@@ -299,7 +296,6 @@ int main()
outp(7,UBRRL); // USART: 115200 @ 14.7456MHz
/* AREF (AREF is 5V) pin external capacitor, ADC3 for pendulum angle */
outp(BV(REFS0)|BV(MUX0)|BV(MUX1),ADMUX);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment