The Halls are only powered up for a few milliseconds at a time.
VDD is connected to a 3.3v TP point.
VSS is connected to an earth on the thumbstick.
Do you want the controllers schematic? Or how i have wired from the pickit into the controller? I can only find one schematic for the controller and it only covers one pcb, theres two. RT and earth is connected to one, LED and power is connected to the other.
I am powering the chip with 3.3v from the pickit so when the contorller is connected too via batteries, it throws everything off. If i dont power the chip via the pickit, it doesnt program and tells me i need to use the pickit as a power source.
As the halls are only powered up for a few milliseconds, i have rewritten my code slightly.
void main(void)
{
// initialize the device
SYSTEM_Initialize();
ADC_Initialize();
ADC_SelectChannel(RT);
while (1)
{
ADC_StartConversion();
while (ADC_GetConversion(RT) < 300)
{
__delay_us(480); // wait for voltage to settle
}
if (ADC_GetConversion(RT) < 300)
{
LATA = 0;
LATA5 = 0;
TRISA5 = 0;
__delay_ms(500);
TRISA5 = 1;
__delay_us(600);
}
}
}
Again though, this: if (ADC_GetConversion(RT)
< 300)
Gives the same result as this: if (ADC_GetConversion(RT)
> 300)
The led flashes all the time until i pull the trigger in a certain amount (the same amount wether its < or >), i want it to do the opposite but changing < to > gives the exact same result. Which correct me if im wrong is very strange as < is saying if ADC count is below 300 and > is saying if ADC count is above 300. How can that give the same result?
I feel what im trying to do is quite simple but the ADC isnt working as it should. The coding is right its just the outcome is the opposite way round and when i flip the ADC < to > it doesnt change the result for some reason.