Acetronics2
- 20th February 2009, 10:12
Hi,
Finally ... I got it !!!
The famous waiting loop
While DQ : WEND
never loops !!!
You comment it ... the reading continues to work as it ... Strange ???
NO,
In fact, you ask for the conversion ... and read the scratch pad.
Two different things : you'll read the same value on the scratchpad UNTIL the end of conversion ... overwrites the scratchpad.
Asking for a new conversion while previous still running do not disturb the chip at all ... it ignores the command !!!
so, no waiting required ... but it's not "real time measurement"
How to be sure what you read is the result of the last demand ???
You must ASK the device for "still busy" by sending it a short LOW "request pulse" ... and then you have 15 µs for reading the bus ... NO MORE !!!
Externally ... the bus is released as soon as the convert command has been sent ... so you must send request pulses as long as the chip answer is NOT "0".
see :
'************************************************* ****************************
' Check for still busy converting
'************************************************* ****************************
waitloop:
LOW DQ ' Pulls the bus LOW
INPUT DQ ' Releases the bus and prepare reading
IF NOT DQ THEN ' If bus kept low
PORTC.4 = 1 ' Show it
GOTO Waitloop ' Go on asking device state
ENDIF
PORTC.4 = 0 ' clear marker
Here ... what's printed is what you have asked for ... not previous readings ...
This one Works fine too
waitloop:
OWIn DQ, 4, [Busy] ' Check for still busy converting
If Busy = 0 Then
PORTC.4 = 1
GOTO waitloop
ENDIF
PortC.4 = 0
Alain
Finally ... I got it !!!
The famous waiting loop
While DQ : WEND
never loops !!!
You comment it ... the reading continues to work as it ... Strange ???
NO,
In fact, you ask for the conversion ... and read the scratch pad.
Two different things : you'll read the same value on the scratchpad UNTIL the end of conversion ... overwrites the scratchpad.
Asking for a new conversion while previous still running do not disturb the chip at all ... it ignores the command !!!
so, no waiting required ... but it's not "real time measurement"
How to be sure what you read is the result of the last demand ???
You must ASK the device for "still busy" by sending it a short LOW "request pulse" ... and then you have 15 µs for reading the bus ... NO MORE !!!
Externally ... the bus is released as soon as the convert command has been sent ... so you must send request pulses as long as the chip answer is NOT "0".
see :
'************************************************* ****************************
' Check for still busy converting
'************************************************* ****************************
waitloop:
LOW DQ ' Pulls the bus LOW
INPUT DQ ' Releases the bus and prepare reading
IF NOT DQ THEN ' If bus kept low
PORTC.4 = 1 ' Show it
GOTO Waitloop ' Go on asking device state
ENDIF
PORTC.4 = 0 ' clear marker
Here ... what's printed is what you have asked for ... not previous readings ...
This one Works fine too
waitloop:
OWIn DQ, 4, [Busy] ' Check for still busy converting
If Busy = 0 Then
PORTC.4 = 1
GOTO waitloop
ENDIF
PortC.4 = 0
Alain