michaelcheng1991 / Golf-Training-Aid-

Using sensors to create a golfer-friendly teaching device
0 stars 0 forks source link

Definitions #11

Open michaelcheng1991 opened 9 years ago

michaelcheng1991 commented 9 years ago

series shift register (SN extra digital output pins most/least significant bit data pin latch pin: after calling shift_out() the shift register internally contains new value. To update output pins you must pull LATCH high. This is sometimes called latching on pulsing the latch. Note that it is not enough to hold LATCH high. Data transfer happens on transition from low to high. This is also called rising edge. Code for a led binary counter from 0 to 65535 would look like the following: int main(void) {

for(uint16_t i = 0; i < 0xffff; i++) {
    /* Shift high byte first to shift registers. */
    shift_out(i >> 8);
    shift_out(i & 0xff);

    /* Pulse latch to transfer data from shift registers */
    /* to storage registers. */
    digital_write(LATCH, LOW);
    digital_write(LATCH, HIGH);

    _delay_ms(50);
}

return 0;

} clock pin : Clock is an constant high- low signal used to synchronize data transfer. Each time Clock goes high 2 things happen. Current value in shift register gets shifted left by one. Last bit is dropped out. First bit will be set to current value of Data. to write a byte to shift register this has to happen eight times in a loop. ( the clock pin is toggled once the data has been received )

define LATCH B0

define CLOCK B1

define DATA B2

void shift_out(uint8_t data) { for(uint8_t i = 0; i < 8; i++) { /* Write bit to data port. */ if (0 == (data & _BV(7 - i))) { digital_write(DATA, LOW); } else { digital_write(DATA, HIGH); }

    /* Pulse clock input to write next bit. */
    digital_write(CLOCK, LOW);
    digital_write(CLOCK, HIGH);
}

}

michaelcheng1991 commented 9 years ago

CMOS: complementary metal oxide semi conductor, just a technology to create integrated circuit

Shift Registers

BCD ( Binary-Coded Decimal):

Relay: 用較小的電流去控制較大電流的一種“自動開關”。故在電路中起著自動調節、安全保護、轉換電路等作用。