Merge them

This commit is contained in:
BlubbFish 2020-09-17 10:08:59 +00:00
parent 3e35d28612
commit 49ba6e0942
30 changed files with 500 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1 @@
<AVRStudio><MANAGEMENT><ProjectName>Beleuchtung</ProjectName><Created>29-Jun-2012 19:04:48</Created><LastEdit>01-Jul-2012 23:09:24</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>29-Jun-2012 19:04:48</Created><Version>4</Version><Build>4, 19, 0, 730</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile>default\Beleuchtung.elf</ObjectFile><EntryFile></EntryFile><SaveFolder>D:\Doc's\Basteleien\Beleuchtung\Beleuchtung\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET>JTAGICE mkII</CURRENT_TARGET><CURRENT_PART>ATtiny24</CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM>USB</COM><COMType>2</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>Beleuchtung.c</SOURCEFILE><OTHERFILE>default\Beleuchtung.lss</OTHERFILE><OTHERFILE>default\Beleuchtung.map</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>NO</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE></EXTERNALMAKEFILE><PART>attiny24</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>Beleuchtung.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>0</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>E:\Programme\AVR Toolchain\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>E:\Programme\AVR Toolchain\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files><File00000><FileId>00000</FileId><FileName>Beleuchtung.c</FileName><Status>1</Status></File00000></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio>

View File

@ -0,0 +1,271 @@
#include <avr/interrupt.h>
#include <avr/io.h>
#define L_NORM PA0
#define L_HORN PA1
#define L_DAYL PA2
#define B_LEFT PA3
#define B_RIGH PA4
#define R_NORM PA5
#define R_BREK PA6
#define R_TBRK PA7
// L_NORM L_HORN L_DAYL B_LEFT B_RIGH R_NORM R_BREK R_TBRK
volatile uint8_t ofdim[8] = { 40, 10, 10, 1, 1, 10, 5, 5};
volatile uint8_t ofdis[8] = { 0, 0, 0, 0, 0, 0, 0, 0};
volatile uint8_t ondim[8] = { 15, 5, 4, 10, 10, 2, 40, 40};
volatile uint8_t ondis[8] = { 0, 0, 0, 0, 0, 0, 0, 0};
volatile uint8_t bltia[8] = { 0, 0, 0, 40, 40, 0, 0, 100};
volatile uint8_t bltib[8] = { 0, 0, 0, 30, 30, 0, 0, 1};
volatile uint8_t bltis[8] = { 0, 0, 0, 0, 0, 0, 0, 0};
volatile uint8_t bltit[8] = { 0, 0, 0, 0, 0, 0, 0, 0};
volatile uint8_t isson = 0b00000000;
volatile uint8_t trfla = 0b00000000;
// PB1 PB2 PB3
volatile uint8_t servo[3] = { 5, 5, 5};
volatile uint8_t servc[3] = { 0, 0, 0};
//volatile uint8_t servi[3] = { 0, 0, 0};
//volatile uint8_t servt[3] = { 0, 0, 0};
volatile uint8_t seton = 0b00000000;
volatile uint8_t blink = 0b00000000;
void dimmen(uint8_t i) {
if(seton & (1<<i)) {
if (isson & (1<<i)) {
if(ondim[i] == ondis[i]) {
PORTA &= ~(1<<i);
ondis[i] = 0;
isson &= ~(1<<i);
} else {
ondis[i]++;
}
} else {
if(ofdim[i] == ofdis[i]) {
PORTA |= (1<<i);
ofdis[i] = 0;
isson |= (1<<i);
} else {
ofdis[i]++;
}
}
} else {
if (isson & (1<<i)) {
if(ondim[i] == ondis[i]) {
PORTA &= ~(1<<i);
ondis[i] = 0;
isson &= ~(1<<i);
} else {
ondis[i]++;
}
} else {
if(ofdim[i] == ofdis[i]) {
PORTA &= ~(1<<i);
ofdis[i] = 0;
isson |= (1<<i);
} else {
ofdis[i]++;
}
}
}
}
void blinken(uint8_t i) {
if(blink & (1<<i)) {
if(seton & (1<<i)) {
if(bltia[i] == bltis[i] && bltib[i] == bltit[i]) {
seton &= ~(1<<i);
bltis[i] = 0;
bltit[i] = 0;
} else {
if(bltia[i] == bltis[i]) {
bltit[i]++;
bltis[i] = 0;
} else {
bltis[i]++;
}
}
} else {
if(bltia[i] == bltis[i] && bltib[i] == bltit[i]) {
seton |= (1<<i);
bltis[i] = 0;
bltit[i] = 0;
} else {
if(bltia[i] == bltis[i]) {
bltit[i]++;
bltis[i] = 0;
} else {
bltis[i]++;
}
}
}
} else {
if(seton & (1<<i)) {
if(bltia[i] == bltis[i] && bltib[i] == bltit[i]) {
seton = seton;
bltis[i] = 0;
bltit[i] = 0;
} else {
if(bltia[i] == bltis[i]) {
bltit[i]++;
bltis[i] = 0;
} else {
bltis[i]++;
}
}
} else {
if(bltia[i] == bltis[i] && bltib[i] == bltit[i]) {
seton = seton;
bltis[i] = 0;
bltit[i] = 0;
} else {
if(bltia[i] == bltis[i]) {
bltit[i]++;
bltis[i] = 0;
} else {
bltis[i]++;
}
}
}
}
}
void ausgabe() {
for(uint8_t i = 0; i < 8; i++) {
dimmen(i);
blinken(i);
}
}
/*void eingabe() {
for(uint8_t i = 0; i < 3; i++) {
if (PINB & (1<<i) ) { //Ein
if(trfla & (1<<i)) {
servc[i]++;
} else {
trfla |= (1<<i);
servc[i] = 0;
}
} else {
if(trfla & (1<<i)) {
trfla &= ~(1<<i);
servt[i] = servt[i] + servc[i];
if(servi[i] >= 5) {
servo[i] = servt[i];
servt[i] = 0;
servi[i] = 0;
} else {
servi[i]++;
}
}
}
}
}*/
void verarbeitung() {
if(servo[0] >= 50 && servo[0] < 60) {
ofdim[0] = 8;
ondim[0] = 3;
ofdim[1] = 8;
ondim[1] = 3;
seton |= ((1<<L_NORM) | (1<<L_HORN) | (1<<R_NORM));
} else if(servo[0] >= 60) {
ofdim[0] = 1;
ondim[0] = 20;
ofdim[1] = 1;
ondim[1] = 20;
seton |= ((1<<L_NORM) | (1<<L_HORN) | (1<<R_NORM));
} else {
seton &= ~((1<<L_NORM) | (1<<L_HORN) | (1<<R_NORM));
}
//Servo 2 (Blinker):
if(servo[1] <= 43) {
if(!(blink & (1<<B_LEFT))) {
seton |= (1<<B_LEFT);
}
blink |= (1<<B_LEFT);
blink &= ~(1<<B_RIGH);
seton &= ~(1<<B_RIGH);
} else if(servo[1] >= 50){
if(!(blink & (1<<B_RIGH))) {
seton |= (1<<B_RIGH);
}
blink |= (1<<B_RIGH);
blink &= ~(1<<B_LEFT);
seton &= ~(1<<B_LEFT);
} else if(servo[2] > 34) {
blink &= ~((1<<B_LEFT) | (1<<B_RIGH));
seton &= ~((1<<B_LEFT) | (1<<B_RIGH));
}
//Servo 3 (Bremse):
if(servo[2] <= 45 && servo[2] > 34) {
seton |= ((1<<R_BREK) | (1<<R_TBRK));
blink &= ~(1<<R_TBRK);
} else if(servo[2] <= 34) {
seton |= (1<<R_BREK);
blink |= (1<<R_TBRK);
if(!(blink & (1<<B_RIGH))) {
seton |= ((1<<B_LEFT) | (1<<B_RIGH));
bltis[3] = 0;
bltis[4] = 0;
bltit[3] = 0;
bltit[4] = 0;
}
blink |= ((1<<B_LEFT) | (1<<B_RIGH));
} else {
seton &= ~((1<<PA6) | (1<<PA7));
blink &= ~(1<<PA7);
}
}
ISR (TIM0_OVF_vect)
{
/* Interrupt Aktion alle
(8000000/1)/256 Hz = 31250 Hz
bzw.
1/31250 s = 0,032 ms
*/
/*if(PORTA & (1<<L_NORM)) {
PORTA &= ~(1<<L_NORM);
} else {
PORTA |= (1<<L_NORM);
}*/
//asm volatile ("nop");
for(uint8_t i = 0; i < 3; i++) {
if (PINB & (1<<i) ) {
if(trfla & (1<<i)) {
servc[i]++;
} else {
trfla |= (1<<i);
servc[i] = 0;
}
} else {
if(trfla & (1<<i)) {
trfla &= ~(1<<i);
servo[i] = servc[i];
}
}
}
}
int main (void) {
cli();
DDRA = 0xFF; //A komplett auf Ausgang
PORTA = 0x00; //A komplett Auschalten
DDRB = 0x00; //B komplett auf Eingang
PORTB = (1<<PB0) | (1<<PB1) | (1<<PB2); //Alle Pullups weg
TCCR0B |= (1<<CS00);
TIMSK0 |= (1<<TOIE0);
//TCCR0B |= (1<<CS02) | (1<<CS00);
sei();
seton |= (1<<L_DAYL);
while(1) {
//eingabe();
verarbeitung();
ausgabe();
}
}

View File

@ -0,0 +1,140 @@
#include <avr/interrupt.h>
#include <avr/io.h>
#define OUTPUT_PORT PORTB
#define OUTPUT_DDR DDRB
#define LIGHT_FRONT 0
#define LIGHT_FOG 1
#define LIGHT_FAR 2
#define LIGHT_SIGN_L 3
#define LIGHT_SIGN_R 4
#define LIGHT_BACK 5
#define LIGHT_BRAKE 6
#define LIGHT_BRAKE_M 7
#define MODE_OFF (0<<0)
#define MODE_ON (1<<0)
#define MODE_BLINK (1<<2)
#define BLINK_SPEED 32 //lower is faster: range 0..255 //where 0 is longer than 255!!!
volatile uint8_t lightModes[8] = {MODE_OFF, MODE_OFF, MODE_OFF, MODE_OFF | MODE_BLINK, MODE_OFF | MODE_BLINK, MODE_OFF, MODE_OFF, MODE_OFF};
volatile uint8_t lightValue[8] = {255, 255, 255, 255, 255, 255, 32, 255};
volatile uint8_t timeCounter = 0;
volatile uint8_t blinkCounter = 0;
volatile uint8_t blinker = 0;
void updateOutput()
{
uint8_t outputState = 0;
for(uint8_t i = 0; i < 8; i++) //go through all 8 lights
{
if(lightModes[i] & MODE_ON)
{
if(lightModes[i] & MODE_BLINK)
{
if(blinker)
{
outputState |= (lightValue[i] >= timeCounter) << i;
}
}
else
{
outputState |= (lightValue[i] >= timeCounter) << i;
}
}
}
OUTPUT_PORT = outputState;
//OUTPUT_PORT = 1;
}
ISR(TIM0_OVF_vect)
{
timeCounter++;
if(timeCounter == 0) //overflow
{
blinkCounter++;
if(blinkCounter == BLINK_SPEED) //when blink-speed steps are reached
{
blinker = 1-blinker; //toggle blinker-state
blinkCounter = 0;
}
}
updateOutput();
}
void setUpDimmer()
{
OUTPUT_DDR = 255; //set all bits to output
OUTPUT_PORT = 0; //set all zero
//TCCR0B |= (1<<CS02) | (1<<CS00); //set 1024 as prescaler for timer0
TCCR0B |= (1<<CS00); //set no prescaler for timer0
TIMSK |= (1<<TOIE0); //enable timer/counter0 overflow interrupt
sei();
}
int main(void)
{
setUpDimmer();
//set lighs:
//lightModes[LIGHT_FRONT] = MODE_ON;
//lightModes[LIGHT_SIGN_L] = MODE_ON | MODE_BLINK;
//Test-Environment, use PORTA/D for 8bit input
DDRD = 0; //input
DDRA = 0;
PORTD = 0b00111111; //pullup
PORTA = 0b00000011;
uint8_t curInput;
while(1)
{
//push input from both ports into one byte
curInput = PIND & 0b00111111;
curInput |= (PINA << 6);
//thread this as input
for(uint8_t i = 0; i < 8; i++)
{
if(curInput & (1<<i))
{
lightModes[i] &= (0xFF-MODE_ON); //switch light off
}
else
{
lightModes[i] |= MODE_ON; //switch light on
}
}
}
return 0;
}

View File

@ -0,0 +1 @@
<AVRWorkspace><IOSettings><CurrentRegisters><TIMER_COUNTER_0><register register="GTCCR" group="TIMER_COUNTER_0" display="1" locked="0"/></TIMER_COUNTER_0><TIMER_COUNTER_0><register register="OCR0A" group="TIMER_COUNTER_0" display="1" locked="0"/></TIMER_COUNTER_0><TIMER_COUNTER_0><register register="OCR0B" group="TIMER_COUNTER_0" display="1" locked="0"/></TIMER_COUNTER_0><TIMER_COUNTER_0><register register="TCCR0A" group="TIMER_COUNTER_0" display="1" locked="0"/></TIMER_COUNTER_0><TIMER_COUNTER_0><register register="TCCR0B" group="TIMER_COUNTER_0" display="1" locked="0"/></TIMER_COUNTER_0><TIMER_COUNTER_0><register register="TCNT0" group="TIMER_COUNTER_0" display="1" locked="0"/></TIMER_COUNTER_0><TIMER_COUNTER_0><register register="TIFR0" group="TIMER_COUNTER_0" display="1" locked="0"/></TIMER_COUNTER_0><TIMER_COUNTER_0><register register="TIMSK0" group="TIMER_COUNTER_0" display="1" locked="0"/></TIMER_COUNTER_0></CurrentRegisters></IOSettings><part name="ATTINY24"/><Files><File00000 Name="D:\Doc's\Basteleien\Beleuchtung\Beleuchtung\Beleuchtung.c" Position="189 67 676 412" LineCol="257 4" State="Maximized"/></Files></AVRWorkspace>

View File

@ -0,0 +1,77 @@
###############################################################################
# Makefile for the project Beleuchtung
###############################################################################
## General Flags
PROJECT = Beleuchtung
MCU = atxmega16a4
TARGET = Beleuchtung.elf
CC = avr-gcc
CPP = avr-g++
## Options common to compile, link and assembly rules
COMMON = -mmcu=$(MCU)
## Compile options common for all C compilation units.
CFLAGS = $(COMMON)
CFLAGS += -Wall -gdwarf-2 -std=gnu99 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d
## Assembly specific flags
ASMFLAGS = $(COMMON)
ASMFLAGS += $(CFLAGS)
ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2
## Linker flags
LDFLAGS = $(COMMON)
LDFLAGS += -Wl,-Map=Beleuchtung.map
## Intel Hex file production flags
HEX_FLASH_FLAGS = -R .eeprom -R .fuse -R .lock -R .signature
HEX_EEPROM_FLAGS = -j .eeprom
HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings
## Objects that must be built in order to link
OBJECTS = Beleuchtung.o
## Objects explicitly added by the user
LINKONLYOBJECTS =
## Build
all: $(TARGET) Beleuchtung.hex Beleuchtung.eep Beleuchtung.lss size
## Compile
Beleuchtung.o: ../Beleuchtung.c
$(CC) $(INCLUDES) $(CFLAGS) -c $<
##Link
$(TARGET): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)
%.hex: $(TARGET)
avr-objcopy -O ihex $(HEX_FLASH_FLAGS) $< $@
%.eep: $(TARGET)
-avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0
%.lss: $(TARGET)
avr-objdump -h -S $< > $@
size: ${TARGET}
@echo
@avr-size -C --mcu=${MCU} ${TARGET}
## Clean target
.PHONY: clean
clean:
-rm -rf $(OBJECTS) Beleuchtung.elf dep/* Beleuchtung.hex Beleuchtung.eep Beleuchtung.lss Beleuchtung.map
## Other dependencies
-include $(shell mkdir dep 2>NUL) $(wildcard dep/*)

View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Beleuchtung/Transistor.ms11 Normal file

Binary file not shown.

10
Beleuchtung/leds.txt Normal file
View File

@ -0,0 +1,10 @@
F_norm 2 Warm Weiß 30mA 3,8V (8cd) 22Ohm
F_lighthorn 2 Weiß 25mA 3,5V (25cd) 33Ohm
F_Fog 2 weiß 25mA 3,5V (5,5cd) 33Ohm
B_left 3 gelb 20mA 2,1V 56Ohm
B_right 3 gelb 20mA 2,1V 56Ohm
R_norm 2 rot 20mA 2,0V 82Ohm
R_Break 2 rot 20mA 2,0V 82Ohm
R_3break 3 rot 20mA 2,0V 56Ohm