![]() |
General question.
Can you define the 'then' of an 'if then' statement as a set.
and if you have a set within a set is it proper to do if .set ..case ...if ....set ...if ....set ...case ...case i hope you get the point private message me your answer |
Re: General question.
Also, for the gear tooth sensor, what should the input be; analog correct?
|
Re: General question.
Gear tooth sensor is a phased interrupt as I recall, making it digital. It pulses once per tooth, and you count these in an ISR.
as for your original question... I'm not sure what language you're trying to use. In MPLAB/C18 C, syntax would be Code:
if(condition1){ |
Re: General question.
:) sry about that
thats wat im basically doing if (condition) then a list of more conditions that will be followed if the first " if " is true. I belive it is called a " switch (set): " Likewise, there can be more then one condition correct Such as If (Rgear=200 Lgear=210) likewise, if the gear reverse does the counter still count forward to subtract the negative? g2g 2 class |
Re: General question.
I believe the KoP GTSs use a phased output (Phase A/B) one rises before the other dependent on directionality of the passings... Kevin Watson has explained this much better than I can. So short answer, no it doesnt count back down, long answer yes, if you do it right.
The syntax for a switch statement is as follows: Code:
switch(condition){ |
Re: General question.
thank you very much
|
Re: General question.
S'what we're here for. No Problem.
|
Re: General question.
ok here is my question if pseudo-code
code: Quote:
|
Re: General question.
Quote:
Code:
#define Rmotor1 pwm01Quote:
Quote:
It appears you're trying to build a state machine (variable set is your state counter) I think you want something along this line, although, personally, I would just use an if-elseif structure: Code:
switch(autostate){ |
Re: General question.
yes thats basically it. But my orginial question still stands can i have several switchs
Code: PHP Code:
|
Re: General question.
Well, a switch's condition can't be func2 = 1 (the switch is ON func2)
IMO switches are more trouble than they are worth I would just use something like this Code:
if(func1 == 1){ //remember, == is equality test, = is assignment |
Re: General question.
My assuption was that the ir board would connect to the controller by 4 pwm cables.
Each connection would eather get a 1 or 0 (1 signal recieved, 0 no signal) therefore i use that in code. See code: PHP Code:
|
Re: General question.
Yes, you will receive that data in code as 1 or 0 in a variable, but remember, the IR Board only gives a momentary signal.
I suggest something like this to allow the RC to remember which was pushed Code:
int IRSignal = 0; |
Re: General question.
I don't know how much programming experience you have, so I apologize if I'm just telling you stuff you already know...
"If (func1 = 1)" This sets func1, it doesn't check it. A conditional check is always a double equals sign - "==". A switch statement directly reads in a variable, then executes one of a number of commands ("cases") depending on the value of that variable. If you have a number that will be 1, 2, 3, etc. depending on where you are in the code, this may be what you want to use. If you just want to check if you've gone above or below a certain critical value, as with your gear tooth sensor, you probably want to use if-->then-->else statements. Personally, I find if-->then-->else statements easier, so here are a few examples: If you want to check multiple conditions at once: Code:
if(A_ISTRUE && B_ISTRUE){Code:
if(A_ISTRUE || B_ISTRUE){Code:
if(!A_ISTRUE){Code:
if(A_ISTRUE){ |
| All times are GMT -5. The time now is 18:23. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi