programming tutorials

can anyone give me a sample program or a tutorial on how to program the optical shafts and the potentiometers? it would be greatly appreciated. thanks

Which programming language are you looking for a tutorial on? easyC? ROBOTC? Something else like MPLAB?

~Jordan

were using EasyC V4 for the new microcontrollers

drag and drop the block onto your code
and click the “help” button
it should briefly tell you the basics of the sensor
and im not sure where, but there are sample programs included in your files
not too sure where that is though :confused:
maybe jordan can help you out with that :slight_smile:

There are 14 tutorials on how to use easyC V4 in the software. You can also look at all videos posted in the easyC forum for the previous versions as it’s similar.

Yes there are 14 tutorials but they don’t cover everything. That being said, does anyone have any video tutorials for using the potentiometer and the shaft encoder? I am using EasyC V4 for cortex along with the new joystick controllers. If I remember correctly there are test programs for the sensors but i still don’t know how to use them because there isn’t really any type of instructions.
Thanks in advance to anyone who can help me out.

Well what are you using the potentiometer for exactly? Limit for the arm? I don’t know the new EasyC syntax very well because I use RobotC, however I have used the V2 version. For the shaft encoders, I assume you want to move your robot from one place to another…
(I assume you already have variables in place)
(Program to move robot [depends on gearing setup])

StartQuadEncoder(numbers...); // use the syntax to start encoder 
blahblah = GetQuadEncoder(numbers...); // use the syntax to get value for encoder
PresetQuadEncoder(numbers...); // presets the encoder to zero, unsure if this is needed here..
while(variablenameforencoder < whateverthevalueis){
SetMotor(numbers...); //place motor commands here
SetMotor(numbers...);
}
SetMotor(numbers...);  // stop the motors, unsure if this needed here.
SetMotor(numbers...);
StopQuadEncoder(numbers...); // unsure if this is needed here..
PresetQuadEncoder(numbers...); // resets the encoder back to zero, only need this if you are using encoder again.
// then repeat if needed?

The same goes for potentiometer (assuming you want to move the arm with it), just a tweak in the syntax and the presets are not needed. I may be wrong, I haven’t programmed in a while. (:

im sorry but i am having trouble understanding this ^. If you could possibly make a video tutorial it would be greatly appreciated. I am new to programing haha. And yes we are going to use the shaft encoder to drive a certain distance and we are using the potentiometers to raise the arm a certain distance. Thank you but a video tutorial would be the best if possible because like i said before i am new at programing and I’m not that good at it yet.

I think ‘kingofl377’ answered your question pretty nicely:

~Jordan

This video should help: http://www.youtube.com/watch?v=yg6g7RvlaPM&feature=related
You can start from the first part if you want to, but the second video covers the sensor part. The sensor applies to the ultrasonic sensor syntax, but the video may clear some questions generated in my previous post. I always thought the tutorials would explain this…

Not all of the sensors are covered in the tutorials. I understand the optical shaft encoders now but i still need help programing the potentiometers. If anyone could give me a tutorial i would be very happy. I really need to know how to use the potentiometers for my autonomous.
Thank you guys

  • Devin

There are 14 tutorials but they don’t cover everything. I really need a tutorial for the potentiometers. I understand the optical shaft encoders but i still need help with the potentiometers. If someone could please give me a tutorial it would be greatly appreciated.
Thanks

  • Devin

From a programming standpoint all sensors in vex work more or less the same. They return a number and it’s upto you to decide what to do with it. All the sensors have a sample program and a help file that shows you exactly what needs to be done to retrieve this number you should be able to retrieve this information.

What you need to do is write down what you want to do. Then think about how to get from Point A to Point B. Write some sudo code and then write the real code.

Example

Task: I want to stop my arm from going too far up using the potentiometer.

Sudo Code: If I’m telling the arm to go up, and the potentiometer reads greater then a certain value then stop the motor from going up. Otherwise move the arm.

In easyC
Open the online window and look at the value the potentiometer is returning at a certain angle.

Then write the code.


while(1) { //Loop Forever
  ArmJoystick = GetRxInput(1,1); //read the value from the joystick
  PotValue = GetAnalog(1); //Read the analog value of port 1

//If the Arm is going up and pot is higher then a certain value 800
if ( ArmJoystick > 0 && PotValue > 800 ) {
  SetMotor(1,0); //Set The Arm Motor to Stop
} else {
  SetMotor(1,ArmJoystick); //Write the joystick value to the motor
}

}

ok well that helps a little but i still don’t get it :(. If anyone could just make a video or something I would love you guys forever. Also I’m have trouble programing multiple sensors in one autonomous. I really need help with this guys. And just to let you know I’ve only been programing for about 4 days so i’m very new to this.