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
For each quarter, calculate and display the beginning principal balance, the interest earned, and the final principal balance for the quarter.For example: The user entered 1000.00 for the beginning principal balance, 5.25 for the interest rate, and 8 for the number of quarters. The output from this part of the program should be similar to the following:
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);
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 );
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.
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.
I have an assignment that calls for a C program using a for loop AND a while loop that will receive an integer (called daNumba) and double it -- Using the integer the program will call the sumFor function and then the sumWhile function. These functions will both sum the values from daNumba to (daNumba * 2) ifdaNumba is positive. If daNumba is not positive it will add the values from (daNumba*2) to daNumba. Both functions will receive the value of daNumba and return a summed value. The only difference between the 2 functions is that sumFor will only use for loops and sumWhile will only use while loops. We are not to use arrays.
The program compiles without error. So far my while loop works for positive integers, but not with a negative integer (I have it commented out) I cannot get the for loop to work properly This is what I have so far -- I am stuck....
Code: #include<stdio.h> #include<stdlib.h> #include<math.h> int main () {
int main ( int argc, char *argv[] ) { int P[150] = {}, i, j; for ( i = 2; i <= 150; i++ ) {
[Code] .....
Using gdb, I noticed that the variable j keep going back to initial value after the interior for loop condition returns false. Why doesn't this for loop terminate right away?
I've just started learning the C language, and I'm stuck on something that is probably quite simple.how to get IF statements working within WHILE loops. My code is below. I am trying to write a program to count the number of words in a sentence, and obviously stop counting after a full stop has been entered. I created a variable called 'spaces' which will increase by one after the user enters a space. However, when the IF statement is in place, the loop never terminates, even if I enter a full stop. When I delete the IF statement, the loop functions correctly.
Code:
#include <stdio.h> int main() { char x; char a; char y; int spaces = 0; }
What output would you expect from this program?" The output was not what I expected. I've psuedo-coded this out and I'm still missing something.
Code:
#include <stdio.h> int main () { int numbers[10] = { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; int i, j; }
[code]....
The output: Code: 1 1 2 4 8 16 32 64 128 256 So when I look at this first loop I see that j = 0, which is less than 10, so then the program statement should commence, which is another for loop. So in this inner for loop I see that i = 0, which is not less than j, so this loop should terminate. Then the value of j increments by 1 and the first go around of the loop has completed.
Now I see that j = 1, so this is less than 10, and the inner for loop commences once again. This time though, i actually is less than j, so numbers[1] = numbers[1] + numbers [0], or numbers[1] = 0 + 1. Now the value of i is incremented by 1 and the first go around of this inner loop has completed. Then the value of j increments by 1 and another go around of that loop has completed.
So now j = 2, i = 1, and numbers[2] ( which is 0 ) = numbers[2] + numbers[1], or numbers[2] = 0 + 1. I was expecting the output to be an array full of 1's. However this is not the case..
I need to make a for loop without: using the math functions like pow, sqrt, etc. or an if-statement.I can only use the basic arithmetic functions like +,-,*, and.The for loop needs to display: 1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192 as the result
How do I make it so my loop works? This is what I have and it doesn't work...and I have no clue how to continue...
k = 0; //k is an int and I have declared it in the beginning of my code for( k = 0; k < 13; k++ ) { printf ( "%d, ",k ); k = k * 2; } printf("%d", x);
I just want to say that I just started learning the language and this is my very first shot at writing a simple program that is not "Hello World" So I recently learnt the basics of the if statement and how to loop in a console application, here's what it looks like:
namespace Testing_IF_Statement { class Program {
[Code].....
And again, this is just what I wrote in a few minutes without putting any thought into it.
Questions: 1)I have heard that the way I'm looping by using the goto statement is considered quite ancient, why is this and how else could I loop the program?
2)I declared a as an integer and asked the user to type 1,2,3,4 to perform mathematical functions, but when I tried declaring a as a string and searching if a == "PLUS" etc it would throw an error. Is there any mistake in how I approached this?
3)I know this is a bit premature to ask, but instead of writing _________ in the console to separate the loop is there any professional way to add a separator?
im trying to make a program which will tell which key i pressed and then it will print in msgbox, but i cant figure out how to read the key in loops, like i tried getasynkey (imported to my c# console app) with value around -32676 or -32767 i ( i found it on internet) and it only shows the key once, i want to do like while my key is pressed, then it will spam my console with key pressed, is there any way to do it?
Here's my game, what do I need to learn to make a basic GUI? (Easiest way possible for now).
--NOTE, the code was a bit too long for me to post. I can add it if it is necessary. Basically all I want are 4 buttons on the main screen, one that says "Arena," "Store," "Stats," and "Exit."
There will of course be sub menus to each option, but we will get to that later.
I have project that is on c++. it runs fine. i want to use it in my C# application as a dll. i have created its dll and but firing exception of "interprocess communication".
Is this a doable task that creating dll of an exe project and using it in C# application?
I am trying to get this to work without arrays. At the moment all I am trying to do is allow it so that when the user presses 1 the board prints with 1 replaced by X, tell me where am i going wrong. I know its not finished.
#include <stdio.h> #include <stdbool.h> char a = '1'; char b = '2'; char c = '3';
Parts of this program are missing. The last few lines are confusing, since the variable 'a' gets incremented then decremented. But there are no loops. I understand that the value of 'a' is passed to 'c' before 'a' is changed in both cases.
But where, and when, do the changes take place? Is the decrement ever processed? Is there a better way to write these lines?
Code: main(){ int a = 21;int b = 10;int c ; c = a++; cout << "Line 6 - Value of c is :" << c << endl ; c = a--; cout << "Line 7 - Value of c is :" << c << endl ; return 0;}
i am trying to write program that prints out full lyrics to 99 bear song. Hoping for explanation or anything
The output would have to look like:
99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 98 bottles of beer on the wall.
My try below:
Code: #include <iostream> using namespace std; int main() { for(int i=99; i>=0 ;i--) cout << i <<""<< " bottles of beer on the wall, "<<i<<" bottles of beer."<<endl; for(int j=98; j>=0 ;j--){ cout <<endl; cout << "Take one down and pass it around," <<j<<" bottles of beer on the wall."<<endl; } return 0; }
I'm trying to make a program that prints a rectangle using "*" asterisks. I am only allowed to use "for loops" and I simply cannot get this to work properly. Here is my code so far...
Code: int main(void) { //RectangleSize represents the area of the rectangle(width*length) int length, width, RectangleSize;