Idea for a beginners forum challenge. - Page 1
Forum section: electronics / beginners

author: paulca
author_rank: Super Contributor
timestamp: November 22, 2017, 11:43:57 am
content: Flash an LED with the Morse code of SOS. . . . - - - . . .Now obviously a day 2 beginner could just put an LED on a Raspberry PI GPIO pin and use python to switch the LED on, sleep, off and so on.Arduinno solutions and other micro-controller, would also be pretty un-interesting. PWM/PCM and 555 timer solutions more interesting. Cascading RC + Trannies could get very interesting. Can anyone do it with passives only and no transistors?I'm tempted to try the 555 (or multiple 555s) or the Cascaded RC+BJT idea.

author: paulca
author_rank: Super Contributor
timestamp: December 29, 2017, 01:33:47 pm
content: Just for a laugh I did this today:(Adapted from:http://www.instructables.com/id/Command-Line-Assembly-Language-Programming-for-Ard-2/)Code:;************************************; written by: 1o_o7; date: <2014|10|29>; version: 1.0; file saved as: blink.asm; adapted by: Paul C; date: <2017|12|29>; version: 2.0; file saved as: sos.asm; for AVR: atmega328p; clock frequency: 16MHz (optional);************************************; Program funcion:---------------------; blink morse code for SOS: ...---...;; Uses internal D13 LED;--------------------------------------.nolist.include "./m328Pdef.inc".list;==============; Declarations:.def temp = r16 ; general junk register.def overflows = r17 ; overflow counter, counting 1/60.04 seconds.def delay = r18 ; delay routine parameter, no of 1/60 seconds to delay.def morsecount = r19 ; morse pulse counter - always 3 in our case.org 0x0000 ; memory (PC) location of reset handlerrjmp Reset ; jmp costs 2 cpu cycles and rjmp costs only 1; so unless you need to jump more than 8k bytes; you only need rjmp. Some microcontrollers therefore only; have rjmp and not jmp.org 0x0020 ; memory location of Timer0 overflow handlerrjmp overflow_handler ; go here if a timer0 overflow interrupt occurs;============Reset:ldi temp, 0b00000101out TCCR0B, temp ; set the Clock Selector Bits CS00, CS01, CS02 to 101; this puts Timer Counter0, TCNT0 in to FCPU/1024 mode; so it ticks at the CPU freq/1024ldi temp, 0b00000001sts TIMSK0, temp ; set the Timer Overflow Interrupt Enable (TOIE0) bit; of the Timer Interrupt Mask Register (TIMSK0)sei ; enable global interrupts -- equivalent to "sbi SREG, I"clr tempout TCNT0, temp ; initialize the Timer/Counter to 0sbi DDRB, 5 ; set PB5 to output;======================; Main body of program:sos:rcall s ; Display an Srcall o ; Display an Orcall s ; Display an Sldi delay,60 ; Pause for 1 secondrcall delayrjmp sos ; Loop forevers:ldi morsecount, 3 ; 3 pulsess_loop:rcall short ; short pulsedec morsecount ; count down pulsesbrne s_loop ; loop if not zeroreto:ldi morsecount, 3 ; 3 pulseso_loop:rcall long ; long onesdec morsecountbrne o_loopretshort: ; ====== 1/4 second on, 1/4 second offsbi PORTB, 5 ; turn on LED on PB5ldi delay, 15 ; set our on delay to 15/60 seconds ie. 1/4 secondrcall delaycbi PORTB, 5 ; turn off LED on PB5ldi delay, 15 ; pausercall delay ; 1/4 secretlong: ; ====== 3/4 second on, 1/4 second offsbi PORTB, 5 ; turn on LED on PB5ldi delay, 45rcall delay ; delay will be 45/60 seconds or 3/4 secondcbi PORTB, 5 ; turn off LED on PB5ldi delay, 15 ; pausercall delayretdelay: ; *** Note this makes me uncomfortable - it's a "HOT LOOP"; thus it runs the CPU at 100% utilisation and just; generates heat; A better option would be to trigger things from an; interupt routine and put the CPU to sleep hereclr overflows ; set overflows to 0sec_count:cp overflows,delay ; compare number of overflows and $delay registerbrne sec_count ; branch to back to sec_count if not equalret ; if $delay overflows have occured return to blinkoverflow_handler:inc overflows ; add 1 to the overflows variablereti ; return from interrupt

author: Belrmar
author_rank: Regular Contributor
timestamp: December 29, 2017, 03:35:26 pm
content: What is the price if any? can i just simulate it ? I already have some ideas using comparators, RC constants and a few bjt's

author: Cyberdragon
author_rank: Super Contributor
timestamp: December 30, 2017, 01:36:37 am
content: QuoteSure...a motorized rotary contact timer. Or is that cheating on the other end of the spectrum?