Hey Everyone! It’s Mar here with team 1477. We managed to qualify two robots to our South Texas Regional and found that we are much better off with a linear punch system. We switched over from our previous flywheel system, which even though it qualified, had some major mechanical issue and programming issue with each use. This is also our first year using RobotC after switching over from EasyC, simply because I prefer natural language. I am running vex microcontroller with RobotC ver 4.52 and while I would love suggestions on our linear punch, programming the cortex seems to be the main issue.
Our Setup:
We have a 3, 36-tooth gear system connected to a high strength that has 1/5 of the teeth filed away in order to skip and launch the tension based system.
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Our Program:
#pragma config(I2C_Usage, I2C1, i2cSensors)
#pragma config(Sensor, dgtl1, LimitUp, sensorTouch)
#pragma config(Sensor, dgtl2, Button, sensorTouch)
#pragma config(Sensor, I2C_1, , sensorQuadEncoderOnI2CPort, , AutoAssign )
#pragma config(Motor, port1, FrontLeft, tmotorVex393_HBridge, openLoop, reversed, driveLeft)
#pragma config(Motor, port2, FrontRight, tmotorVex393_MC29, openLoop, reversed, driveRight)
#pragma config(Motor, port3, BackLeft, tmotorVex393_MC29, openLoop, reversed, driveLeft)
#pragma config(Motor, port4, BackRight, tmotorVex393_MC29, openLoop, driveRight)
#pragma config(Motor, port5, BandIntake, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port6, ConveyorIntake, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port7, MotorLeft, tmotorVex393_MC29, PIDControl, encoderPort, I2C_1)
#pragma config(Motor, port8, MotorRight, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port9, MotorMiddle, tmotorVex393_MC29, openLoop, reversed)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
//Variable List for Track encoder calculations.
float diameter=1.5;//Diameter of gear in inches.
float circumference=diameter*PI;//Circumfrence of Gear in inches.
float track=4.0;//Length of track in inches.
float spins=track/circumference;//Number of rotations needed to cover track.
float oneshot=spins*(4/5);//Length needed in order to get to skipped gear. 1/5 of the gear is filed away for skipping mechanism.
float ticks=oneshot*360;//Length turned into degrees for motor encounts.
void autonomousmode()//Autonomous function to avoid powercycling.
{
setMultipleMotors(127,BandIntake,ConveyorIntake);
setMultipleMotors(127,MotorLeft,MotorRight,MotorMiddle);
if(vexRT[Btn7U]==1)//Breaks autonomous function.
stopAllMotors();
}
void shot()
{
//Plays sound to indicate warning for shot.
playSound(soundLowBuzz);
//Sets Intake Motors to full speed.
setMultipleMotors(127,BandIntake,ConveyorIntake);
if(SensorValue[LimitUp]==1)//if Limit switch on top of intake is tripped, fire run motors for one shot equivilant
{
nMotorEncoder[MotorLeft]=0;
if(nMotorEncoder[MotorLeft]<ticks)//Runs motors until encoder is equal to length needed to fire shot.
{
setMultipleMotors(127,MotorLeft,MotorMiddle,MotorRight,);
}
else//resets motors to 0 once target is met.
{
setMultipleMotors(0,MotorLeft,MotorMiddle,MotorRight,);
}
}
}
task main()
{
//Basic Arcade Chassis Control
arcadeControl(Ch3,Ch4);
while(true)//Main while user control loop.
{
if(vexRT[Btn8U]==1)//If button is hit, and held, intake is initiated.
{
setMultipleMotors(127,BandIntake,ConveyorIntake);
}
else
{
setMultipleMotors(0,BandIntake,ConveyorIntake);
}
if(vexRT[Btn5U]==1)//If button is hit, initiate one shot. Mainly used for Human-feeding.
shot();
}
if(vexRT[Btn5D]==1)//Override button for continuous shooting when held down during user-control. NOT AUTONOMOUS!
{
setMultipleMotors(127,MotorLeft,MotorMiddle,MotorRight,);
}
else
{
setMultipleMotors(0,MotorLeft,MotorMiddle,MotorRight,);
}
if(SensorValue[Button]==1)//User-Controlled autonomous initiation in order to avoid power cycling.
autonomousmode();
}
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
I have yet to setup the programming skills function which I will just translate over to the competition template, but I would still love autonomous movement suggestions as I have no experience in moving autonomous in RobotC.
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Our Problems:
1)When I download this program to the cortex and only plug in the 3 motors running the arm, it runs upon turning on. Is my code written incorrectly to where it is continuously running?
2) I am inexperienced with motor encoders and I am not sure if I did my math correctly at the beginning of the code. What or how PID control works and I don’t know what units are associated with the 127 speed value and the encoder values in the debugger.
3)Wireless downloading seems to work pretty well but seems to be a bit buggy. I connect the programming module to the joystick and that to the cortex via VexNet. Once again I don’t know what the majority of the values at the bottom read.
4)I have found loads of code files in the recycle bin coming out of nowhere so I’m not sure what happens when I compile code other than it saving.
5)I want to set it up using touch sensors so that when a ball rolls onto the touch sensor, it fires one instance of one shot, and so that I can run the autonomous function at the press of the bumper switch. I also want it so that I can just press it again to get out of that mode.(I’ve tried using booleans but I feel like there is a better way.)
6)Motor Encoder Counts. I don’t know how to reset the motor encoder nor do I know the proper commands in the Natural Language 2.0 platform. This is CRUCIAL to the system so that we don’t use
7) This year we decided to buy a speaker and I’m just wondering what the file size limit is for custom wave files as I haven’t been able to download custom files due to their large size. Mainly I would like to record sayings such as “Low battery” etc. in order to give us a system of status since we don’t have an LCD.
8)I’d love a way to have the speaker emit a sound when the battery level gets too low. Once again i’m not sure the best way to program this.
I need all you can tell me about how to diagnose a programming problem vs a cortex problem so that when I am able to verify I have good code, I can just go straight to troubleshooting the cortex instead of fiddling with both and wasting precious time that can be used to improve the robot for competition.
I typed this code up on our programming laptop that is very old and has bios problems, so it isn’t the best. I simply retyped it from scratch on the trial version that I downloaded on my main laptop and was wondering if there was a way to transfer licenses from one laptop to the next. We are low on licenses so we’d love to be able to move it to a better computer.
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Pictures:
If you would like pictures of our setup I’ll take some at the next team meeting and hopefully it will give some more insight towards the best way to program it.
****Last Note: We will be competing at the South Texas League City regional on February 27th. I’d love to have as many suggestions as possible and all the help I can get! We’re all excited to meet some of you guys at that competition and maybe even at worlds! 
@jpearman