~Page http://www.piclist.com/techref/io/ibutton.htm Modified by:JMN-EFP-786 replace-to: Please title this page. (ibutton.htm)

Dr. Imre Bartfai  says:

[this is my] iButton reader routine, especially for [PIC type] processors having only 2-level stack. The dialect is the Parallax Assembler one. 4MHz clock is assumed. When routine returns with zero, the iBData structure is filled with the appropriate data. The routine seems to be pretty robust. Please note, that the copyright is retained for me, even if the use [of] the routine is free.
;---------------------------------------------------
; This code fragment handles the Dallas iButton(TM)
;---------------------------------------------------
;
;Line must be equated as a bit also: LPort.LBit

LFloat  =       IOCfg		; line bit as input
LOut    =       1 << LBit ^ LFloat ; all bits input but LBit
iButOrg	=	$

	Org	iBData

Cnt	DS	1		; counter
TCnt	DS	1		; delay counter	
SSave	DS	1		; STATUS save cell
FamCod	DS	1		; Family code   \
SerNo	DS	6		; serial number } do not separate!
CRC	DS	1		; CRC value	/
Cmd	DS	1		; command/data cell
Acc	DS	1		; virtual accumulator

CSave	EQU	SSave.0

iBEnd	EQU	$

	Org	iButOrg

iButton Call	_Init		; reset prom
	Or	W,#0		; check for zero
	SZ			; skip if good
	RetW	1		; otherwise return
	Mov	W,#0Fh		; Read ROM command
_SndCmd	Mov	Cmd,W		; store command
	Mov	Cnt,#8		; # of bits
:loop	Rr	Cmd		; LSB first
_SendC	Mov	SSave,STATUS    ; send Cy
        Mov     !LPort,#LOut    ; turn line to output
	ClrB	Line		; low pulse
	Jmp	$+1             ; tlow1
	Jmp	$+1
	Jmp	$+1             ; tlow1
	Jmp	$+1
	JNB	CSave,:Slot     ; if zero, do not float
        Mov     !LPort,#LFloat
:Slot	Mov	Acc,#20		; for 1 usec / instruction!
:loopi	Nop                     ; loopi makes 80 usec
	DJNZ	Acc,:loopi	; sampling window
	JB	CSave,:cont	; continue if 1
        Mov     !LPort,#LFloat
:cont	DJNZ	Cnt,_SndCmd:loop
	Call	_GetByt		; receive byte
	Mov	FamCod,Cmd	; save family code
	Mov	Cnt,#6		; length of serial number
	Mov	FSR,#SerNo	; serial number address
:loop1	Call	_GetByt		; Receive SerNo
	Mov	INDF,Cmd	; received value
	Inc	FSR
	DJNZ	Cnt,:loop1
	Call	_GetByt		; receive CRC

; ----  
; From here compare received CRC in Cmd with that to be calculated
; upon FamCod & SerNo
;
CRCChk
	Mov	FSR,#FamCod	; start:
	Mov	Cnt,#7		; length
	Clr	CRC		; clear initial CRC
:loop2	Mov	W,INDF		; fetch the byte
	Mov	SSave,W		; save bits to be shifted
	Mov	TCnt,#8		; set shift=8bits
	Mov	W,SSave		;; restore result
:loop	XOr	W,CRC		; calculate CRC
	Mov	Acc,W		;; last CRC value
	Rr	Acc		; move it to carry
	JNC	:Zero		; skip if data=0
	XOr	CRC,#18h	; update the CRC value
:Zero	Rr	CRC		; position the new CRC
	Rr	SSave		; position the next bit
	Mov	W,SSave		; use the remaining bits
	DJNZ	TCnt,:loop
	Inc	FSR		; next pointer
	DJNZ	Cnt,:loop2
;------	now xchg CRC & Cmd
	Mov	W,CRC
	XOr	W,Cmd		; here exchange Cmd with W
	XOr	Cmd,W
	XOr	W,Cmd
	Mov	CRC,W
;------
	Clr	Wdt	
	CSE	CRC,Cmd		; received==calculated
	RetW	2
	RetW	0		; good
;---------------------------------------------------
_Init	Mov     !LPort,#LOut    ; turn port to output
	ClrB	Line		; master reset
	Mov	TCnt,#125	; about 500 usec
:loopi	NOp             	; loopi makes about 500 usec
	DJNZ	TCnt,:loopi
        Mov     !LPort,#LFloat
	Mov	Acc,#7		; for 1 usec / instruction!
:looph	NOp       		; looph makes 30 usec for Tpdh
	DJNZ	Acc,:looph

	Clr	Cnt		; clear counter
:pres	Mov	Acc,#3		; for 1 usec / instruction!
        NOp
:loop	NOp
	DJNZ	Acc,:loop	; 15 usec waiting
	
	JB	Line,:eoi	; if high again, end of init
	Inc	Cnt		; count length of presence pulse
	CJAE	Cnt,#20,:bad	; too long: shortcut
	Clr	Wdt
	Jmp	:pres
:eoi	CJB	Cnt,#1,:bad
	RetW	0		; iButton found
:bad	RetW	1		; iButton not found
;---------------------------------------------------
_GetByt	Mov	Cmd,#128	; hibit as exit condition
:loop	Mov     !LPort,#LOut
	ClrB	Line		; low pulse
	Jmp	$+1		; short pulse (8 usec)
	Jmp	$+1
	Jmp	$+1
	Jmp	$+1
        Mov     !LPort,#LFloat
	Jmp	$+1		; tRDV = 15 ęsec
	Jmp	$+1
	Jmp	$+1
	Jmp	$+1
	Jmp	$+1
	Jmp	$+1
	Jmp	$+1
	MovB	C,Line		; line state
	Rr	Cmd		; put received bit
	Mov	SSave,Status	; save status register

	Mov	Acc,#14		; for 1 usec / instruction!
:loopi	NOp
	DJNZ	Acc,:loopi	; 60 usec waiting
	
	JNB	CSave,:loop	; hibit not reached yet?
	Ret


See also:

http://www.piclist.com/techref/io/magcard.htm Modified by:JMN-EFP-786 replace-to: Please title this page. (magcard.htm)

Books:

See also

http://www.piclist.com/techref/io/steppers.htm Modified by:JMN-EFP-786 jamesnewton@efplus.com preview-to: http://www.cs.uiowa.edu/~jones/step/index.html http://www.cs.uiowa.edu/~jones/step/index.html http://204.210.50.240/techref/io/musics.htm Modified by:JMN-EFP-786 replace-to: Please title this page. (musics.htm)

C. Wayne Buhrman says:

 Middle C     261.63 Hz
        D     293.66 Hz
        E     329.63 Hz
        F     349.23 Hz
        G     391.99 Hz
        A     440.00 Hz
        B     493.88 Hz
        C     523.25 Hz

Harley L. Miller hmiller@sound.net says:

The theorem underlying the modern scale was set forth by Pythagoras, a Greek philosopher/mathemetician in the 6th century B.C. He discovered that the major consonances (sounds that harmonize well) were the octave, perfect fifth and perfect fourth. Perfect fourth and fifth being the notes four and five up from the fundamental. The length of the strings relate to the fundamental in the ratios of 1:2 (octave), 3:2 (fifth) and 4:3 (fourth).

The perfect scale was found to not be workable when used in a number of different keys, and J.S. Bach demonstrated the versatility of the equal-tempered scale when he wrote 'The Well-Tempered Clavier', a series of pieces written in a succession of keys.

Dave Johnson says:

The current scale is the equal tempered scale (which just means that the intervals between all adjacent notes are equal). Originally the notes were based on the "ideal" frequencies exhibited by vibrating strings or columns of air - it came from physics - but the modern scale has been shifted around slightly to even up the intervals. In fact, it was during Bach's time that the changeover occurred: Bach was one of the main proponents of using equal temperament, but many people at the time thought it was an abomination. In fact, Bach wrote the Well-Tempered Clavier in part to demonstrate how useful equal temperament could be: you can play a piece in any key on the same instrument without re-tuning. In "true" temperament, instruments had to be tuned to a particular key, so you coouldn't, for instance, change keys in the middle of a piece.

Bob McClure says

Ideally, the ratio between the frequency of two adjacent notes should be 2**-12 (twelth root of 2). The problem is that there is an ever so slight difference between 2**-12 (going up) and 1/2**-12 (going down). Equal tempering splits the difference. It takes a very good ear to hear the difference in most music.

Darrel Johansen says:

For an excellent book on this topic see "On the Sensations of Tone" by Herman Helmoholtz. Equal temperament is possible on the piano, and is exactly reproducible on a keyboard synthesizer, but most piano tuners "fine tune" the equal temperament and end up with something a little in-between, especially for the higher notes on the piano. When playing a wind instrument or singing, without piano accompaniment, often the tuning will vary from equal temperament because the harmonies will be much more satisfying (again, see Helmholtz).

Other temperaments are heard not just in avant garde music, but in other cultures including native American. Middle-Eastern music divides the tones up even more divisions. That allows closer harmonies to the "ideal" physically derived ratios than equal temperament, as well as providing nuances that are not notated (which doesn't mean they aren't used, consciously or not) in Western music.

Harold Hallikainen harold@hallikainen.com says:

Herman Von Helmholtz published what we know as Thevenin's Theorem in 1853, while Thevenin did not publish it until 1883.

PWM@ Digital to Analog@

See also:

vijays69@yahoo.com says:

Could anyone please help me locate the may & april 1991 issues of elektor electronics (U.K)- I am on the lookout for the article on Audio amplifier. If you can e-mail me the article I would be very grateful and thankful- or give me the link where I can find the article?

ON 20010226@7:56:50 PM http://204.210.50.240/techref/io/pid.htm Modified by:JMN-EFP-786 jamesnewton@efplus.com to See also:http://www.hugoordonez.com/pid.html