
Department of Computer Science and Electronics
27
For(1000 steps)(1000 samples) do:
Watchdog reset
For (8 steps)(for 8 sensors) do:
Read analog data
If (read data bigger than xprima) do:
Increment line counter
Sum_line=Sum_line+read data
Line values average= sum_line/line counter
Else do:
Increment field counter
Sum_field=sum_field/field counter
Field values average= sum_field/field counter
End if
End for
Delay 50m sec.
End for
Read data function
Watchdog reset
Select the channel for read
Enable transistor
Delay 1m sec.
Start conversion
Do nothing until the conversion is finished
Disable transistor
Return value
Function that sends sensor’ state
Initialize variable ‘dades’
For (8 steps)
Read data
If (data read is bigger than the sensor’s threshold) do:
Write logic 1 in the corresponding bit of the ‘dades’ variable
Else do:
Write a logic 0 in the corresponding bit in the ‘dades’ variable
End for
Do nothing until UDR is ready for more data to be written to it
Enable transmit
Transmit ‘dades’
Do nothing until the transmitting is finished
Delay 30u sec.
Disable transmit
Kommentare zu diesen Handbüchern