ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 12.06.2025
Просмотров: 8180
Скачиваний: 1
© MCS Electronics, 1995-2007
GETRC
Action
Retrieves the value of a resistor or a capacitor.
Syntax
var = GETRC( pin , number )
Remarks
Var |
The word variable that is assigned with the value. |
Pin |
The PIN name for the R/C is connection. |
Number |
The port pin for the R/C is connection. |
The name of the input port (PIND for example) must be passed even when allthe other pins are configured for output. The pin number must also be passed. This may be a constant or a variable.
A circuit is shown below:
The capacitor is charged and the time it takes to discharge it is measured and stored in the variable. Now when you vary either the resistor or the capacitor, different values will be returned. This function is intended to return a relative position of a resistor wiper, not to return the value of the resistor. But with some calculations it can be retrieved.
See also
NONE
Example
'----------------------------------------------------------------------------- |
|
------------ |
: getrc.bas |
'name |
|
'copyright |
: (c) 1995-2005, MCS Electronics |
'purpose |
: demonstrates how to get the value of a resistor |
'micro |
: AT90S8535 |
'suited for demo |
: yes |
'commercial addon needed |
: no |
'The library also shows how to pass a variable for use with individual port
'pins. This is only possible in the AVR architecture and not in the 8051
'-----------------------------------------------------------------------------
------------
page -510-
© MCS Electronics, 1995-2007 |
|
$regfile = "8535def.dat" |
' specify the used |
micro |
' used crystal |
$crystal = 4000000 |
|
frequency |
' use baud rate |
$baud = 19200 |
|
$hwstack = 32 |
' default use 32 |
for the hardware stack |
' default use 10 |
$swstack = 10 |
|
for the SW stack |
' default use 40 |
$framesize = 40 |
|
for the frame space |
'The function works by charging a capacitor and uncharge it little by little 'A word counter counts until the capacitor is uncharged.
'So the result is an indication of the position of a pot meter not the actual 'resistor value
'This example used the 8535 and a 10K ohm variable resistor connected to PIND.4
'The other side of the resistor is connected to a capacitor of 100nF. 'The other side of the capacitor is connected to ground.
'This is different than BASCOM-8051 GETRC! This because the architecture is different.
'The result of getrc() is a word so DIM one
Dim W As Word
Do
'the first parameter is the PIN register.
'the second parameter is the pin number the resistor/capacitor is connected to
'it could also be a variable! W = Getrc(pind , 4)
Print W
Wait 1
Loop
GETRC5
Action
Retrieves the RC5 remote code from a IR transmitter.
Syntax
GETRC5( address, command )
Uses
TIMER0
Remarks
address |
The RC5 address |
command |
The RC5 command. |
This statement is based on the AVR 410 application note. Since a timer is needed for accurate delays and background processing TIMER0 is used by this statement.
page -511-
© MCS Electronics, 1995-2007
Also the interrupt of TIMER0 is used by this statement.
TIMER0 can be used by your application since the values are preserved by the statement but a delay can occur. The interrupt can not be reused.
GETRC5 supports extended RC5 code reception.
The SFH506-36 is used from Siemens. Other types can be used as well. The TSOP1736 has been tested with success.
For a good operation use the following values for the filter.
Most audio and video systems are equipped with an infra-red remote control.
The RC5 code is a 14-bit word bi-phase coded signal.
The two first bits are start bits, always having the value 1.
The next bit is a control bit or toggle bit, which is inverted every time a button is pressed on the remote control transmitter.
Five system bits hold the system address so that only the right system responds to the code.
Usually, TV sets have the system address 0, VCRs the address 5 and so on. The command sequence is six bits long, allowing up to 64 different commands per address.
The bits are transmitted in bi-phase code (also known as Manchester code).
page -512-