Hello,
I need to reed states from 3 encoders using LM4F120. I built a circuit and wrote some code to handle this. When I was in school I checked it via oscilloscope. When phototransistor was off I had something around 3.4V and when phototransistor was on I had something around 300 mV. Please take a look on circuit and my code, and please tell me, is it likely to succeed ?
Thanks in advance for reply.
// Macros
#define ENCODERS_PORT GPIO_PORTD_BASE
#define XENCODER GPIO_PIN_0
#define ZRENCODER GPIO_PIN_1
#define XRENCODER GPIO_PIN_2
void initGPIOs()
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
GPIOPinTypeGPIOInput(ENCODERS_PORT, XENCODER | ZRENCODER | XRENCODER );
GPIOPortIntRegister(ENCODERS_PORT, PortDIntHandler);
GPIOIntTypeSet(ENCODERS_PORT,XENCODER | ZRENCODER | XRENCODER, GPIO_FALLING_EDGE );
GPIOPinIntEnable(ENCODERS_PORT,XENCODER | ZRENCODER | XRENCODER);
}
void PortDIntHandler()
{
if ( !GPIOPinRead(ENCODERS_PORT, XENCODER))
{
if ( xDir == LEFT ) --xDesirablePos;
else if ( xDir == RIGHT ) ++xDesirablePos;
GPIOPinIntClear(ENCODERS_PORT,XENCODER);
}
if ( !GPIOPinRead(ENCODERS_PORT, ZRENCODER))
{
if ( xDir == LEFT ) --zrDesirablePos;
else if ( xDir == RIGHT ) ++zrDesirablePos;
GPIOPinIntClear(ENCODERS_PORT,ZRENCODER);
}
if ( !GPIOPinRead(ENCODERS_PORT, XRENCODER))
{
if ( xDir == LEFT ) --xrDesirablePos;
else if ( xDir == RIGHT ) ++xrDesirablePos;
GPIOPinIntClear(ENCODERS_PORT,XRENCODER);
}
}
I also added apropierate code to **startup_ccs.c