cleaned up software and implemented (untested) servo control
This commit is contained in:
parent
ed8753a873
commit
12f32ff3bf
|
@ -3,6 +3,7 @@
|
|||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<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_v2/powerboard_v2.iml" filepath="$PROJECT_DIR$/powerboard_v2/powerboard_v2.iml" />
|
||||
</modules>
|
||||
|
|
|
@ -2,16 +2,18 @@
|
|||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<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="MODIFICATION" beforePath="$PROJECT_DIR$/powerboard_v2/src/main.c" afterPath="$PROJECT_DIR$/powerboard_v2/src/main.c" />
|
||||
<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$/atlassian-ide-plugin.xml" afterPath="" />
|
||||
<change type="DELETED" beforePath="$PROJECT_DIR$/displayboard_servo/displayboard.iml" afterPath="" />
|
||||
<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/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
|
||||
</list>
|
||||
<ignored path="bikegenerator.iws" />
|
||||
<ignored path=".idea/workspace.xml" />
|
||||
<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="/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" />
|
||||
|
@ -75,6 +77,28 @@
|
|||
<component name="FavoritesManager">
|
||||
<favorites_list name="bikegenerator" />
|
||||
</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">
|
||||
<FindUsagesManager>
|
||||
<setting name="OPEN_NEW_TAB" value="false" />
|
||||
|
@ -91,8 +115,6 @@
|
|||
<component name="IdeDocumentHistory">
|
||||
<option name="changedFiles">
|
||||
<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/Makefile" />
|
||||
<option value="$PROJECT_DIR$/displayboard/src/main.h" />
|
||||
|
@ -107,9 +129,12 @@
|
|||
<option value="/usr/lib/avr/include/avr/sfr_defs.h" />
|
||||
<option value="$PROJECT_DIR$/powerboard_v2/src/main.c" />
|
||||
<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>
|
||||
</option>
|
||||
</component>
|
||||
<component name="PhpWorkspaceProjectConfiguration" backward_compatibility_performed="true" />
|
||||
<component name="ProjectFrameBounds">
|
||||
<option name="x" value="1596" />
|
||||
<option name="width" value="1928" />
|
||||
|
@ -210,7 +235,45 @@
|
|||
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
|
||||
</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" />
|
||||
</PATH_ELEMENT>
|
||||
</PATH>
|
||||
|
@ -223,10 +286,6 @@
|
|||
<option name="myItemId" value="displayboard" />
|
||||
<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>
|
||||
</subPane>
|
||||
</pane>
|
||||
|
@ -242,7 +301,7 @@
|
|||
<property name="MemberChooser.sorted" value="false" />
|
||||
<property name="recentsLimit" value="5" />
|
||||
<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="MemberChooser.copyJavadoc" value="false" />
|
||||
<property name="GoToClass.toSaveIncludeLibraries" value="false" />
|
||||
|
@ -450,7 +509,6 @@
|
|||
<editor active="true" />
|
||||
<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="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="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" />
|
||||
|
@ -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="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="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="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" />
|
||||
|
@ -571,6 +630,73 @@
|
|||
</JiraViewConfigurationBean>
|
||||
</option>
|
||||
</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">
|
||||
<states>
|
||||
<state key="ArtifactsStructureConfigurable.UI">
|
||||
|
@ -623,7 +749,7 @@
|
|||
</state>
|
||||
<state key="ModuleStructureConfigurable.UI">
|
||||
<settings>
|
||||
<last-edited>displayboard</last-edited>
|
||||
<last-edited>displayboard_servo</last-edited>
|
||||
<splitter-proportions>
|
||||
<option name="proportions">
|
||||
<list>
|
||||
|
|
|
@ -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>
|
Binary file not shown.
|
@ -10,20 +10,21 @@
|
|||
|
||||
#define BUFSIZE 40
|
||||
#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 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
|
||||
uint16_t voltage = 0;
|
||||
int16_t current_in = 0;
|
||||
int16_t current_out = 0;
|
||||
uint8_t dumpsw = 0; //TODO: make bitfield
|
||||
uint8_t loadsw = 0; //TODO: make bitfield
|
||||
uint8_t gensw = 0; //TODO: make bitfield
|
||||
uint8_t dumpsw = 0;
|
||||
uint8_t loadsw = 0;
|
||||
uint8_t gensw = 0;
|
||||
uint16_t display = 0;
|
||||
|
||||
uint16_t power_gen = 0;
|
||||
|
@ -33,62 +34,22 @@ unsigned char data_count = 0;
|
|||
unsigned char data_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] = {
|
||||
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) {
|
||||
static void timer_init(void) {
|
||||
// clock is 8MHz
|
||||
//TCCR1B |= _BV(WGM12) | _BV(CS11) | _BV(CS10) ; // CTC Mode for Timer 1 (16Bit) with prescale of 64
|
||||
//OCR1A = 250; // 500Hz
|
||||
//TIMSK = _BV(OCIE1A);
|
||||
//sei(); // enable interrupts
|
||||
//}
|
||||
// Timer init
|
||||
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
|
||||
TCCR1B |= _BV(WGM12) | _BV(CS11) | _BV(CS10); // CTC Mode for Timer 1 (16Bit) with prescale of 64
|
||||
OCR1A = 2312; // Neutralposition ((2500-2312)*0.008ms)=1,5ms)
|
||||
TIMSK = _BV(OCIE1A);
|
||||
TCCR1A = (1<<COM1A0); // Togglen bei Compare Match
|
||||
|
||||
sei(); // enable interrupts
|
||||
}
|
||||
|
||||
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) {
|
||||
// we have an A and B (from check in work_uart()
|
||||
// so our message should be complete and consist of:
|
||||
|
@ -143,9 +104,9 @@ void process_command() {
|
|||
}
|
||||
}
|
||||
|
||||
static void work_uart(){
|
||||
unsigned int c = uart_getc();
|
||||
}
|
||||
static void work_uart() {
|
||||
|
||||
uint8_t c = uart_getc();
|
||||
|
||||
if ( !(c & UART_NO_DATA) ) {
|
||||
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
|
||||
display = value;
|
||||
/// magic end
|
||||
OCR1A = display;
|
||||
sei();
|
||||
static void set_servo(uint8_t power) {
|
||||
|
||||
uint8_t display = 0;
|
||||
|
||||
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) {
|
||||
|
||||
for(uint8_t i = 0; i< 16;i++) {
|
||||
leddigitbuffer[0] = bigbar_translate[i][0];
|
||||
leddigitbuffer[1] = bigbar_translate[i][1];
|
||||
for(uint8_t i = 0; i< 30;i++) {
|
||||
set_servo(i*10);
|
||||
wait(5);
|
||||
}
|
||||
|
||||
for(uint8_t i = 0; i< 9;i++) {
|
||||
leddigitbuffer[2] = smallbar_translate[i];
|
||||
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;
|
||||
}
|
||||
for(uint8_t i = 30; i> 0;i--) {
|
||||
set_servo(i*10);
|
||||
wait(5);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
|
||||
ports_init();
|
||||
timer_init();
|
||||
uart_init(UART_BAUD_SELECT(19200,F_CPU));
|
||||
memset(data_in, 0, BUFSIZE);
|
||||
|
||||
|
||||
demo_display();
|
||||
|
||||
while(1) {
|
||||
|
||||
work_uart();
|
||||
|
||||
if(syscounter >= 100) {
|
||||
if(syscounter >= 10) {
|
||||
uart_putc('a'); // send a to receive values
|
||||
set_servo(power_gen)
|
||||
|
||||
|
||||
|
||||
set_servo(power_gen);
|
||||
syscounter = 0;
|
||||
}
|
||||
}
|
||||
|
@ -233,22 +173,12 @@ int main(void) {
|
|||
return(0);
|
||||
}
|
||||
|
||||
// system timer
|
||||
SIGNAL(TIMER1_COMPA_vect) {
|
||||
syscounter++;
|
||||
|
||||
// output to sevensegment and leds
|
||||
// make this here to reduce display flicker
|
||||
digit++;
|
||||
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);
|
||||
OCR1A = 2500-OCR1A; // Das Servosignal wird aus der Differenz von
|
||||
// Periodenlänge (2500*0,008ms=20ms) und letztem
|
||||
// Vergleichswert (OCR1A) gebildet
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,28 +1,7 @@
|
|||
#ifndef _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
|
||||
|
|
Loading…
Reference in New Issue