Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Technical Discussion (http://www.chiefdelphi.com/forums/forumdisplay.php?f=22)
-   -   Rookie help (http://www.chiefdelphi.com/forums/showthread.php?t=31880)

Mark McLeod 21-12-2004 15:48

Re: Rookie help
 
[edit] I confused the issue by mixing up the number of slow loops per second between the EDU (59) and the FRC (38) [/edit]
Well, we’re moving the servo a tiny bit (servo1++; equals approx. 60/255 degrees) each time counter adds up to:
- 59 loops = 1 second (counter < 59)
- 59/2 or ~30 loops = ½ second (counter < 30)
- 59/19 or 1 loop = 17ms (counter < 2)

We don’t have to move servo1 (+1) each time. A servo is made to jump immediately to an exact position. It just happened to be convenient for our example to move it slowly through it’s entire range of motion. You could have servo1 make bigger jumps like +5 or +10 if you like.

You will have to become aware of what values the different variable types are made to hold. We declared servo1 to be an unsigned char. An unsigned char is only big enough to store the values 0 through 255. If you try to make it equal something outside this range, such as 300, you won’t get any error message, but you will get what seems to be a random number instead.

doyler 21-12-2004 15:50

Re: Rookie help
 
Ok, i understand the whole counter except how to calculate it

- 38/2 or 20 loops = ½ second (counter < 20)
- 38/19 or 2 loops = .05 sec. (counter < 2)

how do you know counter < 20 is equal to 38/2 and how do you know that is 1/2 a second

[edit]
and how/why is 1 second equal to 38 loops

/************************************************** *****************************
* FUNCTION NAME: Process_Data_From_Master_uP
* PURPOSE: Executes every 17ms when it gets new data from the master
* microprocessor.

[/edit]

Mark McLeod 21-12-2004 16:17

Re: Rookie help
 
The confusion is my fault. I'm mixing the numbers between the FRC and the EDU controller.

The EDU receives radio packets once every 17ms or approx 58.8 times per second.
The FRC receives packets once every 26.2ms or approx 38 times per second.

I'll go back and correct my examples above to reflect:
~59 = 1 second
~30 = 1/2 second
~15 = 1/4 second
etc.

doyler 21-12-2004 16:19

Re: Rookie help
 
So how would i calculate whatever number i put in here

Code:

if (servo1 < 254)
        servo1+=5; // servo1 will slowly step through each of it’s positions //servo1++; will make it move slower, but it is default

how fast it will move

also here:

Code:

if (counter < 2) // about half a second in the slow loop for one 60/255 degree turn (2 = 7 seconds, 20=2 minutes)
counter++;

and how their speeds work in conjunction to make how fast my eyes see the servo move

[edit]
also, where does my output go from

Code:

printf("PWM OUT 7 = %d, PWM OUT 8 = %d\n",(int)pwm07,(int)pwm08); /* printf EXAMPLE */
(some of the default code)

[/edit]

Mark McLeod 21-12-2004 16:35

Re: Rookie help
 
(counter < n) is the time between each distinct movement of the servo. Where n/59 = the time seconds. For example,
n= 59 is 1 second,
n=118 is 2 seconds,
n=30 = ½ second

(servo1 += y) is how large a movement the servo will make each time (according to the above). For example, y=1 position and is the smallest movement the servo can make, y=5 moves 5 servo positions and because of this will appear to be 5 times as fast.
You’ll have to change the limit check “if (servo1 < 254)” to match whatever number you use, to make sure servo1 will never end up greater than 255. For instance,
if y=5 the check should become “if (servo1 < 250)”
if y=10 the check should become “if (servo1 < 240)”

The range of motion depends on the actual servo model you have.

doyler 21-12-2004 16:43

Re: Rookie help
 
Ok, for the servo +=5 is the little movements it makes before it resets?

If so i understand all that

Code:

pwm03 = servo1;
just means that the code for servo1 goes to pwm?

if so then 1 question not pertaining to the servos

how does

Code:

printf("PWM OUT 7 = %d, PWM OUT 8 = %d\n",(int)pwm07,(int)pwm08); /* printf EXAMPLE */
work and where does it go

Mark McLeod 21-12-2004 16:57

Re: Rookie help
 
Quote:

Originally Posted by doyler
Code:

pwm03 = servo1;
just means that the code for servo1 goes to pwm?

Yep. Whatever pwm03 is set to is what goes out of the pwm pins.
Quote:

Originally Posted by doyler
how does
Code:

printf("PWM OUT 7 = %d, PWM OUT 8 = %d\n",(int)pwm07,(int)pwm08); /* printf EXAMPLE */
work and where does it go

printf is a debugging statement. Any printf statement will show up in the IFI_Loader terminal window as long as your computer is still connected to the controller. You can print the value of anything you want, but there are some limitations and it has a few bugs.
In this case the statement probably shows up in the terminal window as:
PWM OUT 7 = 127, PWM OUT 8 = 127

Do a search in Chiefdelpi for printf and you'll get a lot of information about it.
You need to pick up a C programming book. printf is a standard C function.

doyler 21-12-2004 16:59

Re: Rookie help
 
So I can do pwm08 = servo1 and they will both moved if plugged in 3 and 8?

Also, I can just change the 7 and 8 to the 2 i am using and just load ifi loader to see whats happening?

Mark McLeod 21-12-2004 17:01

Re: Rookie help
 
Quote:

Originally Posted by doyler
So I can do pwm08 = servo1 and they will both moved if plugged in 3 and 8?

Also, I can just change the 7 and 8 to the 2 i am using and just load ifi loader to see whats happening?

Yes on all counts:)

Astronouth7303 21-12-2004 18:04

Re: Rookie help
 
Quote:

Originally Posted by doyler
now battery power, program state, and fault status are blinking green while pwn in/radio is a constant red

is this good?

You're fine.

There are some PWM Ins along the top (the female connectors) for a hobby radio (similar to expensive RC cars or planes). Since I don't think you have one, don't worry about it.

[edit]Sorry, that's a little old.[/edit]

doyler 22-12-2004 14:41

Re: Rookie help
 
I was messing with it last night and just got stuck on one thing

How would I make it go to the end, and then reset without stopping in the middle at times

Mark McLeod 22-12-2004 14:57

Re: Rookie help
 
Quote:

Originally Posted by doyler
I was messing with it last night and just got stuck on one thing

How would I make it go to the end, and then reset without stopping in the middle at times

Give me a step-by-step description of what you see happening. I won't be able to test until tonight when I get home (and drop by the school).

What you are seeing could be due to the servo not being given enough time to reach the requested position. The electronic controller operates much faster than the mechanical servo and could be sending position requests too quickly.

doyler 22-12-2004 15:51

Re: Rookie help
 
I wasn't seeing anything

I was just trying to make it go straight to the end and then reset and then loop

Mark McLeod 22-12-2004 15:55

Re: Rookie help
 
Quote:

Originally Posted by doyler
I wasn't seeing anything

I was just trying to make it go straight to the end and then reset and then loop

Do you mean servo1 = 0 followed by servo1 = 255, then repeat?
What kind of delay do you have between changing positions (i.e., counter)?

doyler 22-12-2004 16:05

Re: Rookie help
 
Yeah like that, but i didnt put in a counter because I couldn't figure out how to time it


All times are GMT -5. The time now is 02:29.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi