![]() |
SetPWM and our IR controls
Hey everybody,
So I got the IR board programmed, got it all wired up to interface with the bot, coded it all out, and nothing happens. I currently only have one of the pins on the board (pin 5) running into the Digital In/Out (signal pin 1). I'm trying to get this working on a two-motor tank-drive bot with the '07 microcontroller. Here is my IR code: Quote:
Quote:
I was hoping someone could identify what exactly I'm doing wrong, as I am getting zero results from my bot. Thanks, /Taggart, team 1712 |
Re: SetPWM and our IR controls
Whoa there! You should (under most circumstances) NEVER have a loop in the robot code! Especially an infinite one. The only place that should have an infinite loop is in the main method. What you should do is remove the infinite while loop in this function and put a call to this inside the Process_Data_From_Master_uP in user_routines.c between the calls to the Getdata and Putdata functions. After doing that, you should be able to debug your code.
And you don't need the continue statements there... Wait, if you are using EasyC (and it seems that you are), then the call to this function should be placed wherever the data processing function is (once again, without an infinite while loop inside this function). |
Re: SetPWM and our IR controls
Ah, I saw an infinite while in some similar sample code; however, I guess that was a bad idea. So thanks :)
And just to clarify (i'm kind of new to this), the data processing function is the main function? If not, then i'm a bit confused. And I am using easyC Pro for this. |
Re: SetPWM and our IR controls
I would check that the wheels are actually hooked up to pwms 1 and 2 (don't laugh I've done this), and whether the code is actually running, i.e. the the robot is in operator mode and is enabled.
You could also try a simpler loop Quote:
Yes, the data processing function is the operator control mode where you put this code, and it is called automatically from Main(); so you should be good. P.S. Also, I program in EasyC and have never had any problems with infinite loops for testing purposes. |
Re: SetPWM and our IR controls
Im pretty sure you only need the while(1) loop if your programming for the VEX controller, which has all the operator code inside of that loop. For programming the Innovation First RC you don't need the loop.
And on the electronics side of things, make sure the PWMs are the right ways in (black is the ground on both the RC and the spike/victor) Hope this helps. Edit: If you're still stuck, try taking out the continues out. Im not sure if theyre the problem, but you dont need them for if statements. |
Re: SetPWM and our IR controls
In Kevin's FRC code, before processing the data you must call the Getdata function first in order to get the inputs from the controller and place them within a structure. Then after processing the data, you must call Putdata in order to put your outputs to the controller from the output data structure. Maybe the SetPWM does the assembly calls to put the data directly to the controller instead of putting it into a structure that is not directly linked to the actual outputs... I don't know. I have never used the EasyC coding libraries before so I don't know how it appears to do things like that.
|
Re: SetPWM and our IR controls
I'm also new to programming and I am using 2007 default code. I have never done an autonomous before so any help would be appreciated.
Would something ilke this work? Quote:
|
Re: SetPWM and our IR controls
It appears that that may work, except there is no such function as SetPWM in Kevin's code. Instead, use:
Code:
pwm01 = 65; |
Re: SetPWM and our IR controls
Quote:
|
Re: SetPWM and our IR controls
taggartbg, This may sound obvious, but make sure the PWM cable is connected FROM the victor TO the RC on the PWM ports (ports 1 and 2).
Could be you connected it to a spike, and to the best of my knowledge, you can't put half speed when the motor is connected to a spike. As said by others, you don't need the continue statement. And in EasyC pro you do need an infinite loop but put it in the MAIN function (I'm doing it that way). It's not good to put an infinite while loop in your own functions. Just put a while(1) loop in MAIN function, and then drag and drop your OperatorController function into the loop and it should work properly. |
Re: SetPWM and our IR controls
Hey guys, thanks for the help, I think i'm getting there; however, I'm still having some struggles.
I'm begining to think that I'm just doing something really simple wrong. Here is the process I undergo to test my code. 1) Code in easyC Pro in the OperatorControl function (I've also tried in Autonomous) 2) Power up robot 3) Hold down "prog" until the "Program Status" LED turns a solid orange 4) In easyC, I hit Build & Download 5) Once it is loaded, I power down the bot 6) When I power it back up, the code should automatically execute, yes? |
Re: SetPWM and our IR controls
Do you have a operator interface hooked up?
|
Re: SetPWM and our IR controls
Make sure you put your OperatorControl function inside the main function.
And I don't think you have to power down your robot, it should automaticly work well. Make sure you are not programming in competition mode (when it's divided to 3 functions). 'Cause that way I don't think it can work (I think it only works when you are in a competition [when the competition port on the OI is connected]). Just to the following: 1) Open a regular new EasyC pro project. 2) Make your OperatorControl function (in the user functions). 3) Drag and drop the OperatorControl function you just made into a while(1) loop in the main function. 4) Power up the robot. 5) Hold down "prog" until "Program Status" LED turns orange. 6) Press Build and Download in EasyC pro. 7) Now it should work:) I suggest you first build and download a simple program (like putting your motor in half speed) and check if it works well. Again, check if the PWM cables are connected to the victor that is connected to the motor you want to activate. Hope it helped. Team 2217 |
Re: SetPWM and our IR controls
Quote:
|
Re: SetPWM and our IR controls
AHH! I've been creating competition projects :o...I'll post back when I get a chance to create a standalone and try it out.
Thanks again. |
Re: SetPWM and our IR controls
A competition program will work if you plug a switch into the competition port that enables the robot.
|
Re: SetPWM and our IR controls
Quote:
But I'm guessing taggartbg didn't do that either (correct me if I'm wrong). |
Re: SetPWM and our IR controls
Hey everybody,
Thanks for all you're help, our code is up and functional now, thank you :) /Taggart |
| All times are GMT -5. The time now is 18:44. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi