Hello Everyone!
I'm trying to write rapidfire code for the Xbox 1, and I'm a but confused. I'm followed SethMods advice he mentioned before:
while( trigger > .20V){ //Dwell until hall is being powered
wait 480uS; //to allow Vout to settle d
readRT(); //Read and store RT voltage
if( rt < setpoint ){
//Execute RF by driving rt high or low for 600uS
}
wait 5ms; //This puts us in the dead part of the frame about 2ms before the trigger is powered again
} //Loop
The main problem I'm having is when the trigger is pulled (trigger voltage is 0V) I'm not able to drive the voltage up with the micro pin. I'm using a PIC16f.
Here is my code, I've steped through it multiple times, and tested each section. The main issue is when the trigger is fully depressed, I cannot get the pin to go high again with RC7. TriggerHandler() is called every 500us.
void TriggerHandler(void)
{
static bool triggerPulled = false;
static uint8_t triggerADC_Cnt = 0;
static uint8_t cnt = 0;
uint16_t triggerADC = 0;
if (false == triggerPulled)
{
if (ADC_IsConversionDone())
{
triggerADC = ADC_GetConversionResult(); //get conversion
ANSELC = 0x80; //set pin to ADC
ADC_StartConversion(RT); //start new conversion
}
//check trigger ADC value if below 400
if (triggerADC < TRIGGER_ADC_THRESHOLD) //threshold is 400 counts
{
triggerADC_Cnt++;
}
else
{
triggerADC_Cnt = 0;
}
//check if counter is above 18 loops
if (triggerADC_Cnt >= TRIGGER_CNT_THRESHOLD) //threshold is 18 (18loops*500us = 9ms)
{
triggerPulled = true; //trigger has been pulled, set pin as an output and control rapid fire
triggerADC_Cnt = 0;
}
}
else //triggerPulled == true
{
if (ADC_IsConversionDone())
{
triggerADC = ADC_GetConversionResult(); //get conversion
if (triggerADC > 180u)//around 0.6V
{
if (cnt < 9)
{
ANSELC &= ~0x80; //turn off adc on pin
TRISC &= ~0x80; //make pin output
LATB |= 0x80; //force it high
cnt++;
}
else if (cnt < 18)
{
ANSELC &= ~0x80; //turn off adc on pin
TRISC |= 0x80; //make pin output
LATB &= ~0x80; //force it low
cnt++;
}
else
{
cnt = 0;
triggerPulled = false;
}
}
ANSELC = 0x80; //set pin to ADC
ADC_StartConversion(RT); //start new conversion
}
}
}
What I've also tried is replaced the inside of "else //triggerPulled == true" code to just pulse the pin HIGH and LOW every 40ms just to see if the trigger will change. I just can't get the pin to go high again when the trigger is pressed. I CAN have firing occur when the trigger is released though, but that doesn't really help lol.
The way I have the micro wired is very simple: RC7 connected to RT. I got this from RDC's post:
https://www.acidmods.com/forum/index.php?topic=43204.0 Maybe this is the issue? Is it supposed to be wired differently?
I'd appreciate any help anyone can provide. This is just a hobby for me, but I'd love to have my own mod working
Thanks in advance!