cleaned up software and implemented (untested) servo control

This commit is contained in:
Lucas Pleß 2014-03-25 19:27:15 +01:00
parent ed8753a873
commit 12f32ff3bf
7 changed files with 181 additions and 151 deletions

View File

@ -3,6 +3,7 @@
<component name="ProjectModuleManager"> <component name="ProjectModuleManager">
<modules> <modules>
<module fileurl="file://$PROJECT_DIR$/displayboard/displayboard.iml" filepath="$PROJECT_DIR$/displayboard/displayboard.iml" /> <module fileurl="file://$PROJECT_DIR$/displayboard/displayboard.iml" filepath="$PROJECT_DIR$/displayboard/displayboard.iml" />
<module fileurl="file://$PROJECT_DIR$/displayboard_servo/displayboard_servo.iml" filepath="$PROJECT_DIR$/displayboard_servo/displayboard_servo.iml" />
<module fileurl="file://$PROJECT_DIR$/powerboard/powerboard.iml" filepath="$PROJECT_DIR$/powerboard/powerboard.iml" /> <module fileurl="file://$PROJECT_DIR$/powerboard/powerboard.iml" filepath="$PROJECT_DIR$/powerboard/powerboard.iml" />
<module fileurl="file://$PROJECT_DIR$/powerboard_v2/powerboard_v2.iml" filepath="$PROJECT_DIR$/powerboard_v2/powerboard_v2.iml" /> <module fileurl="file://$PROJECT_DIR$/powerboard_v2/powerboard_v2.iml" filepath="$PROJECT_DIR$/powerboard_v2/powerboard_v2.iml" />
</modules> </modules>

View File

@ -2,16 +2,18 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="9fad4545-a424-4a82-86dc-76602cf3eef3" name="Default" comment=""> <list default="true" id="9fad4545-a424-4a82-86dc-76602cf3eef3" name="Default" comment="">
<change type="DELETED" beforePath="$PROJECT_DIR$/powerboard_v2/powerboard.iml" afterPath="" /> <change type="DELETED" beforePath="$PROJECT_DIR$/atlassian-ide-plugin.xml" afterPath="" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/powerboard_v2/src/main.c" afterPath="$PROJECT_DIR$/powerboard_v2/src/main.c" /> <change type="DELETED" beforePath="$PROJECT_DIR$/displayboard_servo/displayboard.iml" afterPath="" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/powerboard_v2/src/main.h" afterPath="$PROJECT_DIR$/powerboard_v2/src/main.h" /> <change type="DELETED" beforePath="$PROJECT_DIR$/displayboard_servo/src/.main.c.swp" afterPath="" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/displayboard_servo/src/main.c" afterPath="$PROJECT_DIR$/displayboard_servo/src/main.c" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/displayboard_servo/src/main.h" afterPath="$PROJECT_DIR$/displayboard_servo/src/main.h" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/modules.xml" afterPath="$PROJECT_DIR$/.idea/modules.xml" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/modules.xml" afterPath="$PROJECT_DIR$/.idea/modules.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
</list> </list>
<ignored path="bikegenerator.iws" /> <ignored path="bikegenerator.iws" />
<ignored path=".idea/workspace.xml" /> <ignored path=".idea/workspace.xml" />
<file path="/Makefile" changelist="9fad4545-a424-4a82-86dc-76602cf3eef3" time="1371032328243" ignored="false" /> <file path="/Makefile" changelist="9fad4545-a424-4a82-86dc-76602cf3eef3" time="1371032328243" ignored="false" />
<file path="/Dummy.txt" changelist="9fad4545-a424-4a82-86dc-76602cf3eef3" time="1392331539190" ignored="false" /> <file path="/Dummy.txt" changelist="9fad4545-a424-4a82-86dc-76602cf3eef3" time="1395767588573" ignored="false" />
<file path="/main.c" changelist="9fad4545-a424-4a82-86dc-76602cf3eef3" time="1371265283096" ignored="false" /> <file path="/main.c" changelist="9fad4545-a424-4a82-86dc-76602cf3eef3" time="1371265283096" ignored="false" />
<file path="/uart.c" changelist="9fad4545-a424-4a82-86dc-76602cf3eef3" time="1371164805619" ignored="false" /> <file path="/uart.c" changelist="9fad4545-a424-4a82-86dc-76602cf3eef3" time="1371164805619" ignored="false" />
<file path="/a.java" changelist="9fad4545-a424-4a82-86dc-76602cf3eef3" time="1371206947114" ignored="false" /> <file path="/a.java" changelist="9fad4545-a424-4a82-86dc-76602cf3eef3" time="1371206947114" ignored="false" />
@ -75,6 +77,28 @@
<component name="FavoritesManager"> <component name="FavoritesManager">
<favorites_list name="bikegenerator" /> <favorites_list name="bikegenerator" />
</component> </component>
<component name="FileEditorManager">
<leaf>
<file leaf-file-name="main.c" pinned="false" current="true" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/displayboard_servo/src/main.c">
<provider selected="true" editor-type-id="text-editor">
<state line="34" column="0" selection-start="726" selection-end="726" vertical-scroll-proportion="0.31337327">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="main.h" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/displayboard_servo/src/main.h">
<provider selected="true" editor-type-id="text-editor">
<state line="3" column="0" selection-start="37" selection-end="37" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FindManager"> <component name="FindManager">
<FindUsagesManager> <FindUsagesManager>
<setting name="OPEN_NEW_TAB" value="false" /> <setting name="OPEN_NEW_TAB" value="false" />
@ -91,8 +115,6 @@
<component name="IdeDocumentHistory"> <component name="IdeDocumentHistory">
<option name="changedFiles"> <option name="changedFiles">
<list> <list>
<option value="$PROJECT_DIR$/powerboard/src/adc.c" />
<option value="$PROJECT_DIR$/powerboard/src/uart.h" />
<option value="$PROJECT_DIR$/displayboard/src/utils.h" /> <option value="$PROJECT_DIR$/displayboard/src/utils.h" />
<option value="$PROJECT_DIR$/displayboard/Makefile" /> <option value="$PROJECT_DIR$/displayboard/Makefile" />
<option value="$PROJECT_DIR$/displayboard/src/main.h" /> <option value="$PROJECT_DIR$/displayboard/src/main.h" />
@ -107,9 +129,12 @@
<option value="/usr/lib/avr/include/avr/sfr_defs.h" /> <option value="/usr/lib/avr/include/avr/sfr_defs.h" />
<option value="$PROJECT_DIR$/powerboard_v2/src/main.c" /> <option value="$PROJECT_DIR$/powerboard_v2/src/main.c" />
<option value="/usr/lib/avr/include/stdint.h" /> <option value="/usr/lib/avr/include/stdint.h" />
<option value="$PROJECT_DIR$/displayboard_servo/src/main.h" />
<option value="$PROJECT_DIR$/displayboard_servo/src/main.c" />
</list> </list>
</option> </option>
</component> </component>
<component name="PhpWorkspaceProjectConfiguration" backward_compatibility_performed="true" />
<component name="ProjectFrameBounds"> <component name="ProjectFrameBounds">
<option name="x" value="1596" /> <option name="x" value="1596" />
<option name="width" value="1928" /> <option name="width" value="1928" />
@ -210,7 +235,45 @@
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" /> <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT> </PATH_ELEMENT>
<PATH_ELEMENT> <PATH_ELEMENT>
<option name="myItemId" value="displayboard" /> <option name="myItemId" value="powerboard" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="bikegenerator" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="powerboard" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="src" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="bikegenerator" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="displayboard_servo" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="bikegenerator" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="displayboard_servo" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="src" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT> </PATH_ELEMENT>
</PATH> </PATH>
@ -223,10 +286,6 @@
<option name="myItemId" value="displayboard" /> <option name="myItemId" value="displayboard" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT> </PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="src" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH> </PATH>
</subPane> </subPane>
</pane> </pane>
@ -242,7 +301,7 @@
<property name="MemberChooser.sorted" value="false" /> <property name="MemberChooser.sorted" value="false" />
<property name="recentsLimit" value="5" /> <property name="recentsLimit" value="5" />
<property name="options.lastSelected" value="File.Encoding" /> <property name="options.lastSelected" value="File.Encoding" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" /> <property name="last_opened_file_path" value="$PROJECT_DIR$/displayboard_servo/displayboard_servo.iml" />
<property name="project.structure.side.proportion" value="0.2" /> <property name="project.structure.side.proportion" value="0.2" />
<property name="MemberChooser.copyJavadoc" value="false" /> <property name="MemberChooser.copyJavadoc" value="false" />
<property name="GoToClass.toSaveIncludeLibraries" value="false" /> <property name="GoToClass.toSaveIncludeLibraries" value="false" />
@ -450,7 +509,6 @@
<editor active="true" /> <editor active="true" />
<layout> <layout>
<window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3243626" sideWeight="0.5" order="11" side_tool="false" content_ui="tabs" /> <window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3243626" sideWeight="0.5" order="11" side_tool="false" content_ui="tabs" />
<window_info id="Atlassian " active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="12" side_tool="false" content_ui="tabs" />
<window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" /> <window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
@ -467,6 +525,7 @@
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.2497332" sideWeight="0.67563736" order="0" side_tool="false" content_ui="combo" /> <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.2497332" sideWeight="0.67563736" order="0" side_tool="false" content_ui="combo" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" /> <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Atlassian " active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="12" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32893288" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" /> <window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32893288" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
@ -571,6 +630,73 @@
</JiraViewConfigurationBean> </JiraViewConfigurationBean>
</option> </option>
</component> </component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/displayboard_servo/displayboard_servo.iml">
<provider selected="true" editor-type-id="text-editor">
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/powerboard_v2/powerboard_v2.iml">
<provider selected="true" editor-type-id="text-editor">
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/powerboard/powerboard.iml">
<provider selected="true" editor-type-id="text-editor">
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/displayboard_servo/src/uart.c">
<provider selected="true" editor-type-id="text-editor">
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="-1.3650151">
<folding>
<element signature="n#!!doc" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/powerboard/src/main.c">
<provider selected="true" editor-type-id="text-editor">
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="-0.8083832">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/displayboard_servo/src/uart.h">
<provider selected="true" editor-type-id="text-editor">
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="-1.2005988">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/displayboard_servo/src/main.h">
<provider selected="true" editor-type-id="text-editor">
<state line="3" column="0" selection-start="37" selection-end="37" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/powerboard_v2/src/main.c">
<provider selected="true" editor-type-id="text-editor">
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="-0.5838323">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/displayboard_servo/src/main.c">
<provider selected="true" editor-type-id="text-editor">
<state line="34" column="0" selection-start="726" selection-end="726" vertical-scroll-proportion="0.31337327">
<folding />
</state>
</provider>
</entry>
</component>
<component name="masterDetails"> <component name="masterDetails">
<states> <states>
<state key="ArtifactsStructureConfigurable.UI"> <state key="ArtifactsStructureConfigurable.UI">
@ -623,7 +749,7 @@
</state> </state>
<state key="ModuleStructureConfigurable.UI"> <state key="ModuleStructureConfigurable.UI">
<settings> <settings>
<last-edited>displayboard</last-edited> <last-edited>displayboard_servo</last-edited>
<splitter-proportions> <splitter-proportions>
<option name="proportions"> <option name="proportions">
<list> <list>

View File

@ -1,6 +0,0 @@
<atlassian-ide-plugin>
<project-configuration id="1">
<servers id="2" />
<default-jira-server id="3">a36e3af5-abd2-4783-a6a6-3383b8cb560f</default-jira-server>
</project-configuration>
</atlassian-ide-plugin>

View File

@ -10,20 +10,21 @@
#define BUFSIZE 40 #define BUFSIZE 40
#define CURRENT_MAX 30000 // 30 Ampere is max #define CURRENT_MAX 30000 // 30 Ampere is max
#define POWER_MAX 300
#define SERVO_NEUTRAL 2312
#define SERVO_MIN 2312
#define SERVO_MAX 2312
volatile uint16_t syscounter = 0; volatile uint16_t syscounter = 0;
volatile uint8_t digitbuffer[6] = { 0,0,0,0,0,0 };
volatile uint8_t leddigitbuffer[4] = { 0,0,0,0 };
uint8_t digit = 0;
uint8_t leddigit = 0;
// values send over uart from powerboard // values send over uart from powerboard
uint16_t voltage = 0; uint16_t voltage = 0;
int16_t current_in = 0; int16_t current_in = 0;
int16_t current_out = 0; int16_t current_out = 0;
uint8_t dumpsw = 0; //TODO: make bitfield uint8_t dumpsw = 0;
uint8_t loadsw = 0; //TODO: make bitfield uint8_t loadsw = 0;
uint8_t gensw = 0; //TODO: make bitfield uint8_t gensw = 0;
uint16_t display = 0; uint16_t display = 0;
uint16_t power_gen = 0; uint16_t power_gen = 0;
@ -33,62 +34,22 @@ unsigned char data_count = 0;
unsigned char data_in[BUFSIZE]; unsigned char data_in[BUFSIZE];
char command_in[BUFSIZE]; char command_in[BUFSIZE];
const uint8_t segment_translate[10] = {
63, 6, 91, 79, 102, 109, 125, 7, 127, 111
};
const uint8_t smallbar_translate[9] = { static void timer_init(void) {
0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff
};
const uint8_t bigbar_translate[15][2] = {
{ 0x00, 0xc0},
{ 0x00, 0x60},
{ 0x00, 0x30},
{ 0x00, 0x18},
{ 0x00, 0x0c},
{ 0x00, 0x06},
{ 0x00, 0x03},
{ 0x01, 0x01},
{ 0x03, 0x00},
{ 0x06, 0x00},
{ 0x0c, 0x00},
{ 0x18, 0x00},
{ 0x30, 0x00},
{ 0x60, 0x00},
{ 0xc0, 0x00}
};
//static void timer_init(void) {
// clock is 8MHz // clock is 8MHz
//TCCR1B |= _BV(WGM12) | _BV(CS11) | _BV(CS10) ; // CTC Mode for Timer 1 (16Bit) with prescale of 64 TCCR1B |= _BV(WGM12) | _BV(CS11) | _BV(CS10); // CTC Mode for Timer 1 (16Bit) with prescale of 64
//OCR1A = 250; // 500Hz OCR1A = 2312; // Neutralposition ((2500-2312)*0.008ms)=1,5ms)
//TIMSK = _BV(OCIE1A); TIMSK = _BV(OCIE1A);
//sei(); // enable interrupts TCCR1A = (1<<COM1A0); // Togglen bei Compare Match
//}
// Timer init sei(); // enable interrupts
ISR( TIMER1_COMPA_vect ) // Interruptbehandlungsroutine
{
OCR1A = 2500-OCR1A; // Das Servosignal wird aus der Differenz von
// Periodenlänge (2500*0,008ms=20ms) und letztem
// Vergleichswert (OCR1A) gebildet
} }
static void ports_init(void) { static void ports_init(void) {
// make column / digit driver pins to output
DDRB = 0b11111100;
PORTB = (1<<PB1) | (1<<PB0); // Pullup für PB0 und PB1
TCCR1A = (1<<COM1A0); // Togglen bei Compare Match
TCCR1B = (1<<WGM12) | (1<<CS11); // CTC-Mode; Prescaler 8
TIMSK = (1<<OCIE1A); // Timer-Compare Interrupt an
// make data ports to output
} }
void process_command() { static void process_command() {
if(strstr(command_in,"A") != NULL) { if(strstr(command_in,"A") != NULL) {
// we have an A and B (from check in work_uart() // we have an A and B (from check in work_uart()
// so our message should be complete and consist of: // so our message should be complete and consist of:
@ -143,9 +104,9 @@ void process_command() {
} }
} }
static void work_uart(){ static void work_uart() {
unsigned int c = uart_getc();
} uint8_t c = uart_getc();
if ( !(c & UART_NO_DATA) ) { if ( !(c & UART_NO_DATA) ) {
data_in[data_count] = c; data_in[data_count] = c;
@ -162,70 +123,49 @@ static void work_uart(){
} }
} }
} }
static void set_servo(uint16_t value){
/// magic need to happen hear static void set_servo(uint8_t power) {
display = value;
/// magic end uint8_t display = 0;
OCR1A = display;
sei(); display = power * 10; // shift, since we have to divide by 2,4 (24)
display = display / 24; // instead of dividing by 2,4
display = display + 125;
OCR1A = 2500-display;
} }
static void demo_display(void) { static void demo_display(void) {
for(uint8_t i = 0; i< 16;i++) { for(uint8_t i = 0; i< 30;i++) {
leddigitbuffer[0] = bigbar_translate[i][0]; set_servo(i*10);
leddigitbuffer[1] = bigbar_translate[i][1];
wait(5); wait(5);
} }
for(uint8_t i = 0; i< 9;i++) { for(uint8_t i = 30; i> 0;i--) {
leddigitbuffer[2] = smallbar_translate[i]; set_servo(i*10);
wait(5); wait(5);
} }
for(uint8_t i = 0; i< 9;i++) {
leddigitbuffer[3] = smallbar_translate[i];
wait(5);
}
for(uint8_t j = 0; j< 3;j++) {
for(uint8_t i = 0; i< 6; i++) {
digitbuffer[i] = 0xff;
}
wait(20);
for(uint8_t i = 0; i< 6; i++) {
digitbuffer[i] = 0x00;
}
wait(20);
}
for(uint8_t i = 0; i< 3;i++) {
leddigitbuffer[i] = 0x00;
}
} }
int main(void) { int main(void) {
ports_init(); ports_init();
timer_init(); timer_init();
uart_init(UART_BAUD_SELECT(19200,F_CPU)); uart_init(UART_BAUD_SELECT(19200,F_CPU));
memset(data_in, 0, BUFSIZE); memset(data_in, 0, BUFSIZE);
demo_display(); demo_display();
while(1) { while(1) {
work_uart(); work_uart();
if(syscounter >= 100) { if(syscounter >= 10) {
uart_putc('a'); // send a to receive values uart_putc('a'); // send a to receive values
set_servo(power_gen)
set_servo(power_gen);
syscounter = 0; syscounter = 0;
} }
} }
@ -233,22 +173,12 @@ int main(void) {
return(0); return(0);
} }
// system timer
SIGNAL(TIMER1_COMPA_vect) { SIGNAL(TIMER1_COMPA_vect) {
syscounter++; syscounter++;
// output to sevensegment and leds OCR1A = 2500-OCR1A; // Das Servosignal wird aus der Differenz von
// make this here to reduce display flicker // Periodenlänge (2500*0,008ms=20ms) und letztem
digit++; // Vergleichswert (OCR1A) gebildet
if(digit >5) digit = 0;
leddigit++;
if(leddigit >3) leddigit = 0;
SEVENSEG_PORT = digitbuffer[digit];
SEVENSEGDIG_PORT = _BV(digit+DIG0);
LED_PORT = leddigitbuffer[leddigit];
LEDDIG_PORT = _BV(leddigit);
} }

View File

@ -1,28 +1,7 @@
#ifndef _main_h #ifndef _main_h
#define _main_h #define _main_h
#define SEVENSEG_PORT PORTA
#define SEVENSEG_DDR DDRA
#define LED_PORT PORTC
#define LED_DDR DDRC
#define DIG0 PD2
#define DIG1 PD3
#define DIG2 PD4
#define DIG3 PD5
#define DIG4 PD6
#define DIG5 PD7
#define LEDS_MID1 PB0
#define LEDS_MID2 PB1
#define LEDS_LOAD PB2
#define LEDS_GEN PB3
#define SEVENSEGDIG_PORT PORTD
#define SEVENSEGDIG_DDR DDRD
#define LEDDIG_PORT PORTB
#define LEDDIG_DDR DDRB
#endif #endif