Skip to content
This repository has been archived by the owner on Jul 31, 2022. It is now read-only.

Commit

Permalink
Changed a lot..
Browse files Browse the repository at this point in the history
Should work
  • Loading branch information
KenwoodFox committed Oct 16, 2018
1 parent 022585f commit 9b5107c
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 46 deletions.
37 changes: 23 additions & 14 deletions TumbleBot Basic/debug.c
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
#pragma config(Motor, port1, starboardFore, tmotorVex393_HBridge, openLoop, reversed)
#pragma config(Motor, port5, portFore, tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port6, portAft, tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port10, starboardAft, tmotorVex393_HBridge, openLoop, reversed)
#pragma config(Sensor, dgtl1, LED, sensorLEDtoVCC)
#pragma config(Sensor, dgtl12, bumpSwitch, sensorTouch)
#pragma config(Motor, port1, starboardAft, tmotorVex393_HBridge, openLoop, reversed)
#pragma config(Motor, port5, portAft, tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port6, starboardFore, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port10, portFore, tmotorServoContinuousRotation, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

//This function by Joe

void starboardDriveTrain(float speed) //function to drive each of the starboard wheels using value speed,
{
int tune = 1; //tune adjust for the variablity of the wheels
int tune = 1.0000; //tune adjust for the variablity of the wheels

startMotor(starboardFore, speed * tune); //start both motors on this side running
startMotor(starboardAft, speed * tune);
startMotor(starboardFore, (speed * tune)); //Set both motors to the speed given and multiply them by thr tune value
startMotor(starboardAft, (speed * tune));
}

void portDriveTrain(float speed) //function to drive each of the port wheels using value speed,
{
int tune = 1; //tune adjust for the variablity of the wheels
int tune = 1.0000; //tune adjust for the variablity of the wheels

startMotor(portFore, speed * tune); //start both motors on this side running
startMotor(portAft, speed * tune);
startMotor(portFore, (speed * tune)); //Set both motors to the speed given and multiply them by thr tune value
startMotor(portAft, (speed * tune));
}

//this function by joe, remeber to include my drivetrain.c before including this file
Expand All @@ -28,9 +30,9 @@ void easyGas(int targetSpeed, int accelValue, float accelDirection)
{
float speed = 0; //arb value for the current speed

while(speed < targetSpeed) //while you are not at target speed
while(speed != targetSpeed && speed < 127 && speed > -127) //while you are not at target speed OR the speed value is bigger than the max output, THIS WILL TRIGGER IN CASE OF AN ERROR
{
speed = speed + accelDirection; //add 0.5 to the speed value
speed = speed + accelDirection; //add accelDirection to the speed value
delay(accelValue); //delay for this long
starboardDriveTrain(speed); //set the speed
portDriveTrain(speed);
Expand All @@ -39,7 +41,14 @@ void easyGas(int targetSpeed, int accelValue, float accelDirection)

task main()
{
easyGas(100, 10, 0.5); //accelerate at a rate of 0.5 every 5ms to 100 pwm
while(SensorValue[bumpSwitch] != true) //while bumpswitch is not pressed
{
delay(10); //wait 10ms
}

delay(900); //after pressing the bump switch, wait 900ms before starting the program

easyGas(100, 5, 1); //accelerate at a rate of 0.5 every 5ms to 100 pwm
delay(4000); //magic delay for the leangth of the
easyGas(100, 20, -0.5); //accelerate at a rate of -0.5 every 5ms to 100 pwm
easyGas(0, 5, -1); //accelerate at a rate of -0.5 every 5ms to 100 pwm
}
13 changes: 6 additions & 7 deletions TumbleBot Basic/easyGas.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
//this function by joe, remeber to include my drivetrain.c before including this file

void easyGas(int targetSpeed, int accelValue, float accelDirection)
{
float speed = 0; //arb value for the current speed
void easyGas(int robotSpeed, int targetSpeed, int accelValue, float accelDirection)
{ //The speed the robot is going, the speed you want it to go, the value of deacceleration, the direction and magnitude

while(speed != targetSpeed || speed > 127) //while you are not at target speed OR the speed value is bigger than the max output, THIS WILL TRIGGER IN CASE OF AN ERROR
while(robotSpeed != targetSpeed && robotSpeed < 127 && robotSpeed > -127) //while you are not at target speed OR the speed value is bigger than the max output, THIS WILL TRIGGER IN CASE OF AN ERROR
{
speed = speed + accelDirection; //add accelDirection to the speed value
robotSpeed = robotSpeed + accelDirection; //add accelDirection to the speed value
delay(accelValue); //delay for this long
starboardDriveTrain(speed); //set the speed
portDriveTrain(speed);
starboardDriveTrain(robotSpeed); //set the speed
portDriveTrain(robotSpeed);
}
}
14 changes: 0 additions & 14 deletions TumbleBot Basic/junk.c

This file was deleted.

35 changes: 24 additions & 11 deletions TumbleBot Basic/source.c
Original file line number Diff line number Diff line change
@@ -1,23 +1,36 @@
#pragma config(Sensor, dgtl1, bumpSwitch, sensorTouch)
#pragma config(Motor, port6, starboardFore, tmotorVex393_HBridge, openLoop, reversed)
#pragma config(Motor, port10, portFore, tmotorServoContinuousRotation, openLoop)
#pragma config(Sensor, dgtl1, LED, sensorLEDtoVCC)
#pragma config(Sensor, dgtl12, bumpSwitch, sensorTouch)
#pragma config(Motor, port1, starboardAft, tmotorVex393_HBridge, openLoop, reversed)
#pragma config(Motor, port5, portAft, tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port1, starboardAft, tmotorVex393_HBridge, openLoop, reversed)
#pragma config(Motor, port6, starboardFore, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port10, portFore, tmotorServoContinuousRotation, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

#include "drivetrain.h" //include the drivetrain header
#include "easyGas.h" //include the easygas header

int i = 0;

task main()
{
//while(SensorValue[bumpSwitch] != true) //while bumpswitch is not pressed
//{
// delay(10); //wait 10ms
//}
while(SensorValue[bumpSwitch] != true) //while bumpswitch is not pressed
{
delay(50); //wait 50ms
turnLEDOn(LED);
delay(50);
turnLEDOff(LED);
}

delay(900); //after pressing the bump switch, wait 900ms before starting the program
while( i < 6)
{
delay(100);
turnLEDOn(LED);
delay(100);
turnLEDOff(LED);
i++;
}

easyGas(100, 5, 0.5); //accelerate at a rate of 0.5 every 5ms to 100 pwm
easyGas(0, 100, 5, 1); //Accelerate from 0, to 100, in time increments of 5ms, forward.
delay(4000); //magic delay for the leangth of the
easyGas(100, 5, -0.5); //accelerate at a rate of -0.5 every 5ms to 100 pwm
easyGas(100, 0, 5, -1); //Accelerate from 100, to 0, in time increments of 5ms, backward.
}

0 comments on commit 9b5107c

Please sign in to comment.