Files
Last update 8 years 10 months
by
Raivo Laanemets
Fileshw | |
---|---|
.. | |
adapter.png | |
adapter.sch | |
board.brd | |
board.pdf | |
board.png | |
molex_4pin.png | |
photo.jpg | |
pins.md | |
pins.png | |
schematics.png | |
schematics.sch |
pins.mdAlgorithm
PWM generation
PWM signal is generated by timers.
RPM measurement
RPM is measured by finding time between two RPM pulses using the 16-bit Timer1. Pulses are detected using polling on input pins.
Atmega88 pin allocation
- pin 1: reset, connected to VCC and protected by zener diode
- pin 2: USART RX line (pullup?)
- pin 3: USART TX line
- pin 4: PD2, Error signal output
- pin 5: PD3, OC2B, fan 4 PWM output
- pin 6: PD4, not connected
- pin 7: VCC
- pin 8: GND
- pin 9: XTAL 1
- pin 10: XTAL 2
- pin 11: PD5, OC0B, fan 2 PWM output
- pin 12: PD6, OC0A, fan 1 PWM output
- pin 13: PD7, not connected
- pin 14: PB0, fan 1 enable
- pin 15: PB1, fan 2 enable
- pin 16: PB2, fan 3 enable
- pin 17: PB3, fan 3 PWM output
- pin 18: PB4, fan 4 enable
- pin 19: PB5, not connected
- pin 20: AVCC, connected to VCC through low-pass filter L1/C13
- pin 21: AREF, analog reference, decoupled with 100nF cap C10
- pin 22: GND
- pin 23: PC0, ADC0, temperature sensor 1 input, low-pass filter R5/C7
- pin 24: PC1, ADC1, temperature sensor 2 input, low-pass filter R3/C8
- pin 25: PC2, fan 1 RPM input, pull-up, low-pass filter R10/C9
- pin 26: PC3, fan 2 RPM input, pull-up, low-pass filter R9/C11
- pin 27: PC4, fan 3 RPM input, pull-up, low-pass filter R8/C12
- pin 28: PC5, fan 4 RPM input, pull-up, low-pass filter R7/C14
Port directions
Port B
- PB0 - output (fan 1 enable)
- PB1 - output (fan 2 enable)
- PB2 - output (fan 3 enable)
- PB3 - output (fan 3 PWM)
- PB4 - output (fan 4 enable)
- PB5 - output (not connected)
- PB6 - output (overriden by xtal)
- PB7 - output (overriden by xtal)
Port C
- PC0 - input (ADC)
- PC1 - input (ADC)
- PC2 - input (fan 1 RPM, pull-up)
- PC3 - input (fan 2 RPM, pull-up)
- PC4 - input (fan 3 RPM, pull-up)
- PC5 - input (fan 4 RPM, pull-up)
- PC6 - input (default reset config)
- PC7 - not in circuit/registry
Port D
- PD0 - output (overriden by USART)
- PD1 - output (overriden by USART)
- PD2 - output (error)
- PD3 - output (fan 4 PWM)
- PD4 - output (not connected)
- PD5 - output (fan 2 PWM)
- PD6 - output (fan 1 PWM)
- PD7 - output (not connected)
Fuses
Clock selection: full swing crystal
- CKSEL 0111
- SUT 11 (slow raising power)
- Low fuse result: 0xf7
Registers
- OSCCAL - Oscillator calibration register - NO CHANGE
- CLKPR - Clock prescale register - NO CHANGE
- SMCR - Sleep mode control register - NO CHANGE
- PRR - Power reduction register - NO CHANGE
- MCUSR - MCU status register - NO CHANGE
- WDTCSR - Watchdog timer control register - NO CHANGE
- MCUCR - MCU control register - interrupts through
sei()
- EICRA - External interrupt control register A - NO CHANGE
- EIMSK - External interrupt mask register - NO CHANGE
- EIFR - External interrupt flag register - NO CHANGE
- PCICR - Pin change interrupt control register - NO CHANGE
- PCIFR - Pin change interrupt flag register - NO CHANGE
- PCMSK2 - Pin change mask register 2 - NO CHANGE
- PCMSK1 - Pin change mask register 1 - NO CHANGE
- PCMSK0 - Pin change mask register 0 - NO CHANGE
- PINB - The port B input pins address - NOT USED
- PIND - The port D input pins address - NOT USED
- GTCCR - General timer/counter control register - NO CHANGE
- SPCR – SPI control register - NO CHANGE
- SPSR – SPI status register - NOT USED
- SPDR – SPI data register - NOT USED
Port B
- DDRB - The port B data direction register. As port B is configured as output then all bit are set to 1.
- PORTB - The port B data register. Used for controlling the fans.
Port C
- DDRC - The port C data direction register- As port C is used as input then no change is needed as it is configured as input by default.
- PORTC - The port C data register. Some bits need to be written 1 to enable pull-ups.
- PINC - The port C input pins address. Used for polling fans PWM.
Port D
- PORTD - The port D data register. Used for error signal. Other functions are overriden (USART, PWM).
- DDRD - The port D data direction register. As port B is configured as output then all bit are set to 1.
Timer 0
Timer 0 needs to be configured in phase-correct PWM mode.
- TCCR0A - Timer/counter control register A.
- TCCR0B - Timer/counter control register B.
- TCNT0 - Timer/counter register.
- OCR0A - Output compare register A.
- OCR0B - Output compare register B.
- TIMSK0 - Timer/counter interrupt mask register - NO CHANGE
- TIFR0 - Timer/Counter0 interrupt flag register - NO CHANGE
Timer 1
Timer 1 is used for counting time between RPM pulses and detecting timeout.
- TCCR1A – Timer/Counter1 control register A.
- TCCR1B – Timer/Counter1 control register B.
- TCCR1C – Timer/Counter1 control register C - NO CHANGE
- TCNT1H and TCNT1L – Timer/Counter1.
- OCR1AH and OCR1AL – Output compare register 1 A.
- OCR1BH and OCR1BL – Output compare register 1 B.
- ICR1H and ICR1L – Input capture register 1. NO CHANGE/NOT USED
- TIMSK1 – Timer/Counter1 interrupt mask register
- TIFR1 – Timer/Counter1 interrupt flag register
Timer 2
Timer 2 needs to be configured in phase-correct PWM mode.
- TCCR2A – Timer/counter control register A.
- TCCR2B – Timer/counter control register B.
- TCNT2 – Timer/counter register.
- OCR2A – Output compare register A.
- OCR2B – Output compare register B.
- TIMSK2 – Timer/Counter2 interrupt mask register - NO CHANGE
- TIFR2 – Timer/Counter2 interrupt flag register - NO CHANGE
- ASSR – Asynchronous status register - NO CHANGE
USART
TODO
ADC
ADC reference is set to AVcc.
- ADCSRB – ADC Control and Status Register B - NO CHANGE
- ACSR – Analog Comparator Control and Status Register - NO CHANGE
- DIDR1 – Digital Input Disable Register 1 - NO CHANGE
- ADMUX – ADC Multiplexer Selection Register
- ADCSRA – ADC Control and Status Register A
- ADCL and ADCH – The ADC Data Register
- ADCSRB – ADC Control and Status Register B
- DIDR0 – Digital Input Disable Register 0
FIXME - use watchdog? http://www.embedds.com/using-watchdog-timer-in-your-projects/