The oscillator is 7.37, not 7.5 MHz. So the baud should be 191 instead of 194. Not a big difference, but who knows, combined with the oscillator error of 2%, might be enough to screw up.
http://www.microchip.com/wwwproducts/en/dsPIC33EP32MC202
The thing is designed to run motors. There's also a huge variety of similar products (bigger, smaller etc.)
No. Regardless of the nibble you feed to it, it tests each of the 4 bits only once. This makes 4 tests. You can run it in the debugger and count the tests.
If you think some of the branches take longer, please let me know what nibble should we feed to it to make more than 4 tests.
I do know what I'm talking about. Just look at my code in post #5. I think it's clear enough to understand. There are 4 bits. My code tests each bit once. And that is enough to separate the execution into 16 branches, which are marked with "do here what you want for code such and such".
Since...
Why not? My code which I posted in post #5 does bit-test and works faster than the nibble-compares or even decrement and compare. Its execution time is from 9 to 13 cycles (not including return) - 10.5 average and 13 worst case. For comparison, the code you posted in post #7 takes 6 to 90 cycles...
You could use a jump table, but if you want something easily understandable then do something of that sort. It's called "binary tree":
; assume the code is stored in the variable called "CODE"
; use: call ProcessCode
ProcessCode:
banksel CODE
CASE_xxxx:
btfsc CODE,3
goto CASE_1xxx...
I usually do one small change at a time. Then, if something breaks, I know that this was my last change which caused this and nothing else. If you do three or four changes, then it's getting hard to guess which change caused the problem.
So, I would go back to the connection and program which...
If you want GP5 to turn on when both channels are present you need:
if ((temp_peak >= 80)&&(temp_peak1 >= 80)) // both are on
...
if ((temp_peak <= 60)||(temp_peak1 <= 60)) // at least one is off
If you want GP5 to turn on when either of the two channels is present you need:
if ((temp_peak...
You probably need to move the ADC acquisition code (marked "Start ADC conversion process") inside the "while (count < 64)" loop.
The 2 and 3 second delays (when you turn GP5 on or off) stop the whole processes, so GP4 stops blinking while these delays are performed. If you want it to blink...
Exactly, therefore the temp_peak is not working very well when you update it continuously.
Another measure, such as exponential average, which doesn't require re-setting would work better. For example, you could read a value and calculate x = abs(v-512)*a + x*(1-a). "a" is between 0 and 1 here...
If you get your temp_peak between 70 and 144 at any point after count > 120 and the load is off, then temp_peak will neither decrease (because min and max won't reset) nor increase (because there's no power). Thus, none of your "if" statements involving temp_peak will be called.
If you want to...