![]() |
Re: Automatic counter-Encoder
So it was all in the programming. I dont know how it happened, but I think there is a conflict with my codes. At the very bottom of the code, I have an else statment, and under tthat all the pwms would become 127, all the relays, solenoids would become off. But when I changed that to all being on.
and loaded the program into the RC. I got tthis super fast clicking response. all my relays were firing like a buzzer and so were the solenoids!!! freeky!! I think the problem is from all my if's .... if .... { blah blah blah } if..... { robot is hungry: Go to macD's } if..... { The rise of machines, assimilation !=1 } else { shut down everything } Thats pretty much what my code looks like..... if..... |
Re: Automatic counter-Encoder
You need to walk through your code step-by-step and make a logic table of what the code will do at each step. It sounds as if your logic is doing one of your "if"'s when it goes through your statements, then the very next time through it's deciding to do something different.
You'll get a pulsing as fast as your code changes it's mind. On the EDU this loop of your's can change it's mind 59 times a second in user_routines.c. Quote:
For example: Code:
if .... |
Re: Automatic counter-Encoder
would it still be correct if I did it in this way:
if..... else if..... else if..... else if..... else...... Are there any limits on how many else if's I can use? |
Re: Automatic counter-Encoder
That's correct.
There isn't a limit on how many you string together. After a couple of pages it will become unreadable though... |
Re: Automatic counter-Encoder
Quote:
Quote:
After a couple of pages, you might want to figure out how to do this with a switch-case structure or something else. Switch-case structures are especially nice for implementing a state machine to simplify things like this. Assuming you're using this to make certain moves at certain distances traveled, you can make all the moves relative to the last one. So if you discover you need to travel 5 more inches halfway through your 20 step sequence, you only have to change 1 number, not 10. |
Re: Automatic counter-Encoder
Sounds good! Thanks for all the help :p
|
| All times are GMT -5. The time now is 20:26. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi