C# Commands and vb

Ok, so after a long, long, stressful search i found this thread:

cfinger designed this vb c# test program to control the servo position on port 7 of the rs232 8 servo controller, which in theory should work fine for me as long as i change the servo number (i have the micro maestro usb 6 servo controller). I run the program, my green light flashes once when i click the button but the servo does not move. i have set the controller to usb dual and usb chained and it still does not respond, and im not sure how to set the file to link to the uscmd file. if i could figure this part out this program would be perfect for my project. Any help is appreciated.

Hello,

What “theory” tells you that it should work fine? The Maestro and our older servo controllers use different protocols, so you will need to change the sequence of bytes that get sent.

When you asked your previous question, you also had code for a different servo controller, and I told you that you would have to read about the new protocol in the documentation. I also suggested that you use the serial transmitter if anything goes wrong with your code. It sounds like you have not done either of these things, but after you do, I would be happy to help you with some more specific questions.

By the way, another tip is that you can connect to the Maestro with the Maestro Control Center while you are sending it serial commands and watch exactly what happens when the command gets sent.

-Paul

alright, i won’t ask anymore questions, sorry for bothering you. oh, and yes i did do the steps you suggested but your manual is cryptic and i don’t think that the serial command program does what the example says it does, all it does for me is send a bit.

Hello,

If there is something that you do not understand in the manual, feel free to ask us about it here.

Also, the serial transmitter does work - we use it every day to test things over here, and many of our customers have used it successfully. The whole point of it is that if you cannot even get the command to work with the serial transmitter, you have a problem that you need to solve before writing any code. For example, your Maestro could be configured incorrectly, you could be connecting to the wrong COM port, or the bytes you are trying to send could be wrong. You can get help with all of those by posting your configuration file here, describing your test (was EVERYTHING except USB disconnected from the Maestro?) and the results, explaining how you determined which COM port to connect to, and telling us what bytes you were trying to send.

-Paul

Here is the settings file contents:

<!--Channel 0-->
<Channel name="Mask" mode="Servo" min="3968" max="8000" homemode="Off" home="3968" speed="960" acceleration="232" neutral="6000" range="1905" />
<!--Channel 1-->
<Channel name="Arm" mode="Servo" min="3968" max="8000" homemode="Off" home="3968" speed="0" acceleration="0" neutral="6000" range="1905" />
<!--Channel 2-->
<Channel name="Fire" mode="Servo" min="3968" max="8000" homemode="Off" home="3968" speed="0" acceleration="0" neutral="6000" range="1905" />
<!--Channel 3-->
<Channel name="Shoulder" mode="Servo" min="3968" max="8000" homemode="Off" home="3968" speed="0" acceleration="0" neutral="6000" range="1905" />
<!--Channel 4-->
<Channel name="" mode="Servo" min="3968" max="8000" homemode="Off" home="3968" speed="0" acceleration="0" neutral="6000" range="1905" />
<!--Channel 5-->
<Channel name="" mode="Servo" min="3968" max="8000" homemode="Off" home="3968" speed="0" acceleration="0" neutral="3968" range="1905" />

I determined the com port by looking under device manager, i sent a 128 bit with the maestro connected via usb, com3 and com4, and this is all that it says when i hit send single byte:

12:28:44 PM sent 80

i also tried 120 100 2-byte command and got:

12:29:23 PM sent 78 00

Hello,

I hate to have to keep pushing you on this, but you did not say which COM port you picked or why - you just put “com3 and com4” in a random spot in the middle of a sentence, and I do not know what that means. Are you saying that you do not know which one to use?

Also, 0x80 and 0x78 are not valid command bytes. What do you expect them to do and why? I originally suggested that you start with the example we give for the set target command, but it looks like you are not doing this. Can you either do it or tell me why you do not want to?

-Paul

By the way, I just noticed that twice now you have said “bit” when you should have said “byte”. Maybe you are just being careless, but if you really do not know the difference between a bit and a byte, you are certainly going to be confused by our manual (or any description of serial protocols anywhere.) You could read up on it, for example, at the Wikipedia entry for Byte.

-Paul

I was saying i was doing this on both com3 and com4, and i just sent a 200 command byte and a 255 command byte and got this:
02:10:57 PM sent C8
02:11:02 PM sent FF

and the commands i am sending are based off of this page

https://www.pololu.com/docs/0J40/5.c

so if that is wrong, then let me know. And i am going to stress this again, I have no idea what i am doing, does that help you understand that i am a novice at robotics? or writing pc code? the only thing i remotely know is web code, thats it. thats why i ask for working examples so i can go from there.

Hello,

You did not say that you were a novice before, and it might have helped us if you had started with that. I think you actually do not realize how much of a novice you are, or you are expecting this stuff to be easier than it actually is, and that might be why you are getting annoyed by my questioning. For example, even after I have pressed you on the issue, you do not seem to care about the fact that you do not know which COM port to use. But this guarantees that you will waste at least half of your time sending commands to the wrong COM port! With something like this, you really need to slow down and figure it out or ask us for help. (The serial mode documentation says exactly how to find the COM port.)

Now, as for the command bytes that you are trying, I have looked all over the page you linked to and still do not know where you are getting them. I really need you to answer the questions I asked in my previous post, starting with “What do you expect them to do…” There is an example set target command sitting there in bold text on the page you are linking to, I have told you twice that you should try it, you have a program that you can just type it in to, and instead of trying it, you keep asking for “working examples”. What more do you want?

-Paul

1 Like

Ok, my controller shows up on com3 and on com4, don’t ask why but it shows up as 2 separate devices though its only one, but that is why i was testing on both. I used the 6 byte command and it worked, moved it to 45 degrees, and i was able to change it to move to 90 degrees and 135 degrees but it would not move to an absolute 0 or 180. So the program does work, i was just using the wrong byte command. And i did tell you in an email that i was very new to robotics… i can forward a copy if you’d like.

Hello,

You should be asking why or reading the manual if you don’t get it, or you are definitely going to be wasting your time. The two ports should not be a surprise at all if you would read the documentation that I keep linking you to. For example, the third sentence on that page says “…the Maestro shows up as two virtual serial ports…”

If you have separately contacted us by email, you really need to mention that at the beginning. Do you expect that I will be able to guess that somehow when you are starting a new conversation, in a different medium, under a different name?

If you still have trouble, please post exactly what you are doing (the specific bytes), what you expect to happen, and what actually happens. You can see the exact status of the channels in the Maestro Control Center, so you should be able to tell me exactly what positions they are going to when you send the commands.

-Paul

1 Like

Ok, i figured out the maestro example and i have the code working like i want it to, aside from one thing. I have one question though. What is the byte that sends the servo to absolute 0 or 180 degrees? the code says 4000, which sends it to 45 degrees, and i tried doing 2000 or 0 but it still will only go to 45 degrees.

A serial command argument of 4000 corresponds to a pulse width of 1000us. The typical range of pulses a servo accepts is around 1000-2000us. So if you want it to swing to the other end of its range of motion, try 8000, which corresponds to 2000us. When you send a value of 0 you are just turning off the pulses altogether, and a value of 2000 is below the default channel minimum so it probably just sets the servo to the channel minimum, which is about 4000.

–David

Hello,

Please note that you can change the channel minimum and maximum in the Maestro Control Center. Be careful when adjusting your servo beyond the default 1000-2000us range, since you can destroy most servos this way.

-Paul