Electronics > Projects, Designs, and Technical Stuff
thoughts on my project
ali6x944:
now I found a weird thing also when I checked the signal on the scope:
1)PHOTO_1:
when RA0 is high and RA1 is low...
and for some reason, RA1 oscillates??
so I was kinda confused so I fired up channel 2 of my scope and here is what I got not that the blue is RA0 and the yellow RA1:
2)PHOTO_2:
is when both are on, they also oscillate.
3)PHOTO_3:
when RA1 is high and RA0 is low, no oscillation??? :wtf:
4)PHOTO_4:
when RA0 is high and RA1 is low, but this frame is with measurement.
Prehistoricman:
--- Code: --- if(BIG_SW)
{
LATAbits.LATA0 = 1; //LED ON
LATAbits.LATA1 = 0; //LED off
}
if(SMALL_SW)
{
LATAbits.LATA1 = 1; //LED ON
LATAbits.LATA0 = 0; //LED off
}
else
{
LATAbits.LATA1 = 0;
LATAbits.LATA0 = 0;
}
--- End code ---
This is where something is probably going wrong.
'else' only pairs up with one 'if'. So the first if statement is not exclusive with the second. In other words, both can happen.
You probably meant to have 'else if' on the second one.
--- Quote from: ali6x944 on March 22, 2020, 05:44:39 pm ---now I found a weird thing also when I checked the signal on the scope:
1)PHOTO_1:
when RA0 is high and RA1 is low...
and for some reason, RA1 oscillates??
so I was kinda confused so I fired up channel 2 of my scope and here is what I got not that the blue is RA0 and the yellow RA1:
2)PHOTO_2:
is when both are on, they also oscillate.
3)PHOTO_3:
when RA1 is high and RA0 is low, no oscillation??? :wtf:
4)PHOTO_4:
when RA0 is high and RA1 is low, but this frame is with measurement.
--- End quote ---
To clarify, in this whole post you were talking about only RA0 and RA1, not RA4 and RA5 (your inputs). You don't mean that, right?
ali6x944:
--- Quote from: Prehistoricman on March 22, 2020, 08:59:52 pm ---
To clarify, in this whole post you were talking about only RA0 and RA1, not RA4 and RA5 (your inputs). You don't mean that, right?
--- End quote ---
correct, this is exclusively the output behavior of RA0 and RA1.
--- Quote from: Prehistoricman on March 22, 2020, 08:59:52 pm ---This is where something is probably going wrong.
'else' only pairs up with one 'if'. So the first if the statement is not exclusive with the second. In other words, both can happen.
You probably meant to have 'else if' on the second one
--- End quote ---
so I did that and it still doesn't enter the else condition:
--- Code: ---while(1)
{
if(BIG_SW)
{
LATAbits.LATA0 = 1; //LED ON
LATAbits.LATA1 = 0; //LED off
}
else if(SMALL_SW)
{
LATAbits.LATA1 = 1; //LED ON
LATAbits.LATA0 = 0; //LED off
}
else
{
LATAbits.LATA1 = 0;
LATAbits.LATA0 = 0;
}
}
--- End code ---
now the oscilations are gone completly, and it turns off when both (RA4,RA5) are low, which is good.
however, it still dose not turn off when both (RA4,RA5) are high, instade RA0 goes high when both (RA4,RA5) are high.
Prehistoricman:
Your buttons probably short the pin to ground.
ali6x944:
--- Quote from: Prehistoricman on March 23, 2020, 01:04:19 pm ---Your buttons probably short the pin to ground.
--- End quote ---
not really, RA4 and RA5 are pulled to ground by 1k resistors and the buttons are jumper wires, so no it is not shorting, but it is always connected to ground via the 1k pulldown resistor...
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version