More info meastro servo controller

Been playing today. Last night i entered my numbers into the sequencer for a ripple gait which didnt work at first. I blew two Coxa servos and had 2 plugged in wrong. Got up today and it walked just fine.

Also read up on the 5v out and soldered a couple servo leads to one and used it to power my arduino and the arduino powers the wireless PS2 RX. Thats pretty cool but ill need a Higher MaH battery. Its gonna suck my 3s 500mah down quicker.

I dont exactly know what im looking for but i was reading the PSX_lib.h file found here…

github.com/madsci1016/Arduino-P … PS2X_lib.h

About halway down it lists each button and gives its constant. Is this what i need to know in order for my pololu to execute a sequence?

If not could you please give me a link for how to read the signals from the arduino to execute a sequence.

Hello.

I recommend looking at the “Basic” and “Script” examples included in the Pololu Maestro Arduino library to see how to write code for the Arduino that will trigger actions on the Maestro. There is a great deal of flexibility with the way something can be implemented between the two platforms. In general, for more complicated projects like this, I recommend starting with the examples to understand how the functions work, writing pieces of simplified code that do parts of the functionality you want in your project, and then integrating these simplified pieces together to get more complex behavior.

-Nathan

Ok i have been looking at the script examples for pololu and looking at the Maestro\arduino library and im still very confused. What it looks like to me is that its telling you how to make and run subroutine using the arduino. Though i still dont see how its activating the subroutine.

I need to know how to activate a prewritten subroutine.

One thing that would help is knowing and understanding the signals that are passed back and fourth from the arduino to the maestro. I think. I really dont know because i dont understand this stuff. Wish more was written in laymens.

A subroutine is a sequence right?

Looking at the PS2X_lib.H file there are numbers after each button written like this X button 0x1000. Im assuming this is is the Arduinos serial output when X is pressed.

If so how do i convert this number to a number that the Pololu will understand when the signal is sent?

Hello.

If you look at the “Script” example from the Pololu Maestro Arduino library, lines 30 to 51 contain code that is meant to go into the “Script” portion of the Maestro Control Center software and be uploaded to the Maestro. This code contains two different prewritten subroutines (which in these cases are sequences of servo movements that have been put into the script). The execution of the script on the Maestro is controlled by the statements on lines 87, 91, and 99.

The Maestro and the Arduino communicate with each other over TTL Serial. Essentially, the Arduino sends a sequence of digital bits over the line connected to the Maestro when the statements noted above (lines 87, 91, and 99) are executed.

In general, you will probably want to write code for the Arduino that looks at the state of your PS2 controller and if one of the buttons is pressed, executes the maestro.restartScript(i); command, which will send the appropriate serial command from the Arduino to the Maestro.

-Nathan

Ive got a 24 step Ripple sequence ive been using but im not too happy with. I would like to make it a 12 step. Problem is i need to make each leg raise rotate and drop in the same frame. Is there a way to do this with out it being to hard?

Also can i make a seperate script for each sequence or do they all have to be part of the same one.

Is it possible to create movements that start from the last frame executed. Say i release the button with the 3rd leg up and rotated and i push it again it starts from 3rd leg up and rotated?

Hello.

Only one script can be loaded onto the Maestro at a time. Is there a reason separating your code into subroutines and calling the subroutines would not work? The last example I pointed you to shows how to call different Maestro subroutines from the Arduino.

It will probably be difficult to get the Maestro to pick up movements where it left off previously. You might be able to break your movements into smaller steps and have the Arduino call them more frequently so that if you interrupt a movement in your Arduino code, you will have a better idea of where it was interrupted.

-Nathan

No reason thought it might be easier to write several different sequences to keep them seperate. IDK my filing system is weird. i can still work with it.

I was actually thinking of a read call to see where the servos are then an if statement to execute from where it last read.

Can the sequencer go faster than 100ms? I noticed it would allow me to type in under 100 but didnt try to do anything with it. 100ms i know is pretty fast at 10th a second but most of the other bots i see seem to move faster.

Hello.

The getPosition command in the Maestro library will return the current target position the Maestro is sending to the specified channel, so that might also help you determine where your script was stopped. Also, it might help you to know that if a movement command like 6000 0 servo is executed in a script and then the script is stopped immediately, the Maestro will continue commanding the servo to move toward this target.

To change the length of time to wait for a movement to occur for a frame in a sequence, simply double click the frame in the “Frames” portion of the “Sequence” tab, and type in a new duration in the dialog box that appears. However, you should know that this does not affect the movement speed of the servo, only the length of time the Maestro waits before beginning the next action.

For more information on how the Maestro controls servo speed, you can look at the Speed and Acceleration headings under the Channel Settings section of the Maestro user’s guide. To learn how to change the speeds on a channel as the program runs, you can look at the Set Speed and Set Acceleration headings under the Serial Servo Commands section or the Servo, LED, and other output commands table of the Command Reference section of the same user’s guide.

Finally, please note that there is some physical speed limit on the servos themselves as well and even if the Maestro is sending a faster move command, the servo will still be limited by this physical limit.

-Nathan

I was getting a lil ahead of myself there with “if” statements right now. I think i need to concentrate on my PS2 controller dilemma.

Ok so after doing some reading and some looking up i found out that the numbers after the buttons on the library.h for the arduino part are the byte packets sent through the serial.

My question is… If the bytes sent are in this exampl… 0x0000 and the pololu needs commands like this example 0x00. Do i need to set the byte packets sent the latter protocol or will the Pololu automatically understand the command.

Ok the first byte sent should be the Baud rate in Pololou protocol?

In my PS2 handle code it sets the serial baud rate to 57600, does this number need to be changed to pololu command protocol or does it always have to recieve 0xAA

[quote=“nathanb”]Hello.

If you look at the “Script” example from the Pololu Maestro Arduino library, lines 30 to 51 contain code that is meant to go into the “Script” portion of the Maestro Control Center software and be uploaded to the Maestro. This code contains two different prewritten subroutines (which in these cases are sequences of servo movements that have been put into the script). They execution of the script on the Maestro is controlled by the statements on lines 87, 91, and 99.

The Maestro and the Arduino communicate with each other over TTL Serial. Essentially, the Arduino sends a sequence of digital bits over the line connected to the Maestro when the statements noted above (lines 87, 91, and 99) are executed.

In general, you will probably want to write code for the Arduino that looks at the state of your PS2 controller and if one of the buttons is pressed, executes the maestro.restartScript(i); command, which will send the appropriate serial command from the Arduino to the Maestro.

-Nathan[/quote]

Ok you said lines 87, 89 and 99 are my activation functions, the integer in the parameters would be the subroutine im calling. Ok so do i call a serial read Function call to listen for each button press?

Ok been doing alot of reading and came up with the code im posting below. Please dont make fun of me ive never actually written my own code before so o know it might be a lil mixed up.

Basically im opening the pololu serial and telling it listen for a byte with the serial.read function. If it reads 0x0008 or the up button on the PS2 cotroller it activates subroutine 1. If it reads no signal then it stops subroutine 1.

[code]
#include <PololuMaestro.h>

#ifdef SERIAL_PORT_HARDWARE_OPEN
#define maestroSerial SERIAL_PORT_HARDWARE_OPEN
#else
#include <SoftwareSerial.h>
SoftwareSerial maestroSerial(10, 11);
#endif

void setup() {
maestroSerial.begin(9600);

}

void loop() {

Serial.read(); //open serial port

if (serial.input = 0x0008); // up button Ps2 handle

maestro.restartScript(1); // starts subroutine 1
delay(4000);

else if (serial.input = 0x0000); // when buuton is released stop script

maestro.stopScript(1 maestro.restartScriptWithParameter(1, 2000);
delay(4000););

} [/code]

It looks like you have the right idea of reading an input from your controller and then sending a command to start the appropriate script on the Maestro, but I would not expect that code to work. The language that the Arduino uses is C++ and it might be helpful for you to find an online tutorial or course for that. For instance, boolean comparisons like the ones you are using in your if statements in C++ require the ‘==’ operator since ‘=’ is the assignment operator (to make one thing take the value of the other).

-Nathan

Oh i have been using a C++ tutorial. Is there some links to the code library for the pololu. Something with the keywords and definitions and stuff?

Ive been reading the basics but it would make it easier if i could look at all the commands and functions. Then i wouldnt have to make guesses.

There is documentation for the Maestro Arduino library on its GitHub page. You can click the “Classes” tab at the top to see the available objects, methods, and functions.

-Nathan

We will come back to the PS2 support.

Ok when using the sequencer, there is always a pause between each frame which makes it jerky when i moves.

Is there a way using the sequencer to say take each leg and lift and rotate it and drop it then have it come full reverse at a specific amount of time then do each other leg the same so theres no pause between each movement.

Tell you what.

Since there is no current code to support the PS2 handle, i will give yall my code or share it so any one wanting to do the same can do it with out all the hassle.

I just need a lil extra help. Maybe we can get some team action going?

I followed the link you gave but its for the arduino pololu libraries. You said the code needed to be C++. Where are the C++ libraries.

Just wondering but the scriptino code (that goes in the script) used to activate the subroutines needs libraries to work right. Are the arduino libraries already included with the software. How does that work?

I do not know of anything inherent in the Maestro that would require motion to pause between frames. I made a post in this thread earlier that discusses how to adjust the length of time between starting frames.

The Arduino libraries I linked to in my previous posts are written in C++ and there should be no need to find separate libraries. The Maestro script code is native to the Maestro and does not require any special libraries.

-Nathan