C :: Self Balancing Robot / PID Terms?

Oct 23, 2013

Im trying to tune my PID loop to make my robot balance but i dont know if im using the right terms for my robot? Im implementing a contemporary filter for my Gyro(98%) and Acc(2%).Is the following right?

output=(Kp*error)+(Ki*(error*dt))+(Kd*((error-prev_error)/dt))
error=robot angle --Balance point at 0deg
prev_error=--Previous error
dt=0.01 --10ms delay

View 2 Replies


ADVERTISEMENT

C :: Making Self Balancing Robot - Using PID Loops

Oct 20, 2013

As the title says im trying to make a self balancing robot.

I am using an accelerometer and a gyro as sensors.

I am just really confused when it comes to programming in a PID loop to actually use feedback from the sensors to control the motors.

I sort of understand what needs to be done concering PID loops, just i dont know how to do it.

View 9 Replies View Related

C++ :: Recursive Function To Evaluate First N Terms In Series Specified

Oct 23, 2014

How to remake the code that i`ve written to have : a recursive function to evaluate the first n terms in series specified y= 1 - x + x^2/2 - x^3/6 + x^4/24 +....+(-1)^n x^n/n!

And this is my code:

#include <iostream>
using namespace std;
double power(int n, double x) {
double d =1;
for (int i = 1 ; i<=n ; i++)

[Code] ....

View 12 Replies View Related

C++ :: Storing 10 Elements In Array And Delete Duplicate Terms

Jul 19, 2014

How to store 10 elements in an array and delete the duplicate terms ? ( its a single dimension array )

View 5 Replies View Related

C :: Reading Pseudo Code For Car Robot?

Sep 12, 2014

I'm doing a practice problem where I need to read pseudo code and understand what it does.

For this code, I believe it will move the robot forward while i<650, so it moves it forward for 650 steps in total. Then it sets the motors to 0 when it's finished.

Code:
while(i<650)
{ rotateCW(2);
rotateCCW(1);
Delay1KTCYx(50);
i++;
LATD=0x00; //Set all Port D to 0
}

This code I'm having the most trouble with. So while(1) the pot(potentiometer) read's the ADC. Then it scales the adc, not 100% sure what the +20 and *.22 mean, I think it has to do with binary conversions?

Now it sets pin 1 of port 1 to 0, delays based on pot above, and sets it back to 1, and delays again. I assume something to do with controlling motor speed based on the potentiometer.

Code:
void main(void){TRISD = 0x00; // Setting port D to outputs
LATDbits.LATD0 = 1; // Setting bit 0 of port D to 1
while(1) {
pot = readADC();
pot = pot * 0.2297 + 20;

[Code] ......

My best guess is: The car moves forward 400 steps, stop, turn right for 230 steps, stop. At this point it would begin moving straight, and it would turn left/right as needed to keep the robot in the center of the track.

Code:
void main(void) {
for(i=0;i<400;i++) {
rotateCW(2,motor); //Rotate motor two (one step)
rotateCCW(1,motor); //Rotate motor one (one step)
Delay1KTCYx(50);

[Code].....

View 5 Replies View Related

C/C++ :: Array Incrementation Of 3PI Robot Program?

Sep 25, 2014

I am attempting to write a simple program and compile it onto a 3pi robot. My problem lies with my array, i need the array to increment by one every time through and whenever i run the code the print out reads "ROOM 0" every time.

#include <pololu/3pi.h> /* allow use of 3pi robot functions */
#include <avr/pgmspace.h> /* allow use of program space */
#include <stdio.h> /* for printf() */
#define NUM_ROOMS 11 /* the number of study rooms */
/* function prototype for battery check */
void bat_check( void );

[code].....

View 4 Replies View Related

C++ :: Write A Calculator - User Will Enter Terms And They Will Be Stored In Arrays

Jun 14, 2013

i'm trying to write a calculator. the user will enter the terms and they will be stored in arrays. i will be storing those terms in string arrays and then later turn them to double to work with them. but the user should be able to enter terms like sin(252) and the program should be able to recognize it and calculate it.

View 4 Replies View Related

C++ :: Arduino Robot - Virtual Controller And Path Map

Jul 14, 2014

I know how to create your basic programm that compiles as a CLI or exports and/or saves data to a .txt file... But how does one build a GUI?

I ask because I am currently working on a programm for my Arduino controlled robot, in which I want to have a virtual on screen controller next to a map of my bots path.

View 4 Replies View Related

C++ :: Measure Sorting Algorithm For Performance In Terms Of Number Of Steps And CPU Running Time

May 13, 2014

I have an school assignment that asks me to measure the most famous sorting algorithms for performance in terms of number of steps and CPU running time. ( Here I'm testing for running time)

I decided to test for bubble sort first:

#include <iostream>
#include <ctime>
using namespace std;
void bubbleSort(int ar[], int size) {
int temp;

[Code] ....

So basically what I want to know is:

1. Is this clock function giving the correct CPU running time?

2. Is there any way to write code that would measure the number of steps for each algorithm?

3.I need to test it for number of integers=100 then 200, then 300... Well you get my point, and I don't want to have to actually input 200 numbers with my keyboard. Is there any way to generate as many entries as I want?

View 4 Replies View Related

C/C++ :: Path Finding For Weighted Cyclic Directed Graph For Robot

Mar 14, 2015

I've been trying to make a program to return node values for the shortest path from one node to another. I've searched up several algorithms like the Bellman Ford, A*, or Dijkstra and tried to think of ways to implement them if I store my map as a matrix. I've considered using a hash table, but since I am only a beginner, I am having trouble trying to understand how the concepts would translate into C.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved