Pages: [1]   Go Down
Author Topic: Arduino & SSC32  (Read 837 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello everyone,

I'm pretty new to arduino and robotics in general.
I'm moving a servo using the arduino Mega and an SSC32 controler without any issue. My question though is how to obtain the "Position" of the servo at mid-way of the movement. I've checked the manual and it says to perform a query like QP but I don't know how to implement it. See below code with 3 usages of command QP (none works). Also I will like to know how to implement the value obtained to use it later on. Something like Serial.println("#0 QP T500).

void setup() {

Serial.begin(115200);
}

void loop() {
 
  Serial.println("#0 P750 T500");
  delay(250);
  Serial.println("QP0");   //Not good
  Serial.println('QP#0');  //Not good
  Serial.println('QP0');   //Not good
  delay(750);
  Serial.println("#0 P2200 T500");
  delay(1000);
}

Thanks a lot,
Marcos
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 553
Posts: 46300
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I've checked the manual
You want to send us all copies? Or maybe post a link?

Logged

Norfolk UK
Offline Offline
Edison Member
*
Karma: 52
Posts: 2214
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Not sure if it matters but your sending a CR & LF at end of command but document says just send CR. What if you try Serial.print("QP0\r");
Logged

Handle every stressful situation like a dog. If you can't eat it or hump it. Piss on it and walk away.

New Hampshire
Offline Offline
God Member
*****
Karma: 13
Posts: 779
There are 10 kinds of people, those who know binary, and those who don't.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
Serial.println("QP0");   //Not good
  Serial.println('QP#0');  //Not good
  Serial.println('QP0');   //Not good

How do you know none of these work?  I don't see any code to receive the response to the command.
Logged


UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11196
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't know anything about that protocol (and my attempt to download the user manual myself took me to a broken link) but the first and last messages you send seem to have a different structure to the ones that are "Not good". Do you need to send something line "#0 QP" rather than start with QP? Reading back the responses would be sensible in any case, but especially since the commands are apparently not being accepted. What responses are you actually getting?
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Guys,

Thanks for the quick answers!

Please sere below link to the manual

http://www.bizoner.com/download/USB-SSC32_Command_Formatting.pdf

On page 3 is were is said about queries.

I say that is not working because the text in the serial monitor says lines like:

QP0
9008
20528

These numbers I don't think are the value I'm after as it should be something like 625 (half movement between 500 and 750 as the minimun pulse width on my servo is 500). Also when changing the delay 250 to a different value the serial monitor shows same numbers.

Riva, I've tried your command and still doesn't work.
Commands like "#0 QP" not working either

Any more thoughts?

Thanks
Marcos
« Last Edit: August 14, 2012, 02:52:46 pm by margomael » Logged

the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 149
Posts: 2790
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I've not used the SSC32, but it's a serial port device, which I believe means you
have to connect the SSC32 to a different serial port than you are using to
communicate between the Arduino and your PC. Otherwise, the signals from
the USB port and the SSC32 will conflict.

I've also not used the Mega board, so I can't give better details than that about
the 2nd serial port.

So, your code should reflect using something other than Serial.print() to communicate
with the SSC32. It also needs a bunch of Serial.read() commands to receive
data back from the SSC32, although also for the 2nd port.

Also, be sure to include the <cr> at the end of the sent commands.
Logged

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11196
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The manual you linked to says that the correct command is "QP <arg> <cr>" where <arg> is the servo number and <cr> is a carriage return.

The use of whitespace in this protocol is unclear. The examples seem to use whitespace between tokens, but this isn't mentioned in the protocol description.

You say that you can move the servo OK. Does this mean that this statement moves the servo OK?

Code:
Serial.println("#0 P750 T500");

If so, I would expect the command to read the position of a servo to be like this:

Code:
Serial.println("QP 0");

Note that the response comes back as a binary value not a printable ASCII character. I don't see code to read or display the response so I can't say whether you're doing that correctly, but if you're just using a terminal program to send the textual commands it is unlikely to handle binary responses correctly.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I'm still struggling with this...
Let's see...

Quote
SSC32, but it's a serial port device, which I believe means you
have to connect the SSC32 to a different serial port than you are using to
communicate between the Arduino and your PC. Otherwise, the signals from
the USB port and the SSC32 will conflict.
I'm powering both arduino and SSC32 separetely and conecting them together using TX/RX and Gnd to Gnd. I'm moving multiple servos at same time with no issues but I struggle to read the position of a servo at a certain time. In the manual (which is for the Botboard and SSC32 instead of arduino)says that I should use a query like QP but I don't know how to implement it or to make it readable to me.

Serial.read() doesn't give me anything in the serial display.

I also beleive <cr> is taken care with println.

This
Code:
Serial.println("#0 P750 T500");
works well and your suggested line
Code:
Serial.println("QP 0");
makes sense but either it doesn't work or I don't know how to read it.

Quote
Note that the response comes back as a binary value not a printable ASCII character. I don't see code to read or display the response so I can't say whether you're doing that correctly, but if you're just using a terminal program to send the textual commands it is unlikely to handle binary responses correctly.

Not sure what you mean with this. Manual says a pulse width of 1500us will return 150 (binary) (because of a 10us resolution) but the values I get from my "not good" queries are 9008 & 20528 (not binary)

Thanks
« Last Edit: August 15, 2012, 09:11:39 am by margomael » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 553
Posts: 46300
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
but the values I get from my "not good" queries are 9008 & 20528 (not binary)
I'm calling bullshit, here. You have provided no proof that you are reading ANY response from the servo, nor have you demonstrated any way of knowing what the value is that you do get back.

If the servo shield is connected to RX/TX, then using RX/TX to talk to the serial monitor is going to confuse the hell out of your servo shield.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I'm calling bullshit, here. You have provided no proof that you are reading ANY response from the servo, nor have you demonstrated any way of knowing what the value is that you do get back.

As I said in my previous post...

Quote

Code:

Serial.println("QP 0");
makes sense but either it doesn't work or I don't know how to read it.
Do you know how I can read it?
Logged

the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 149
Posts: 2790
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@margo

1. as I mentioned before, it appears you have the SSC32 connnected to the same serial port
    as the Ardiuno IDE uses. You need to connect it to a different serial port. See following
    from Arduino Serial info page:

The Arduino Mega has three additional serial ports: Serial1 on pins 19 (RX) and 18 (TX), Serial2 on pins 17 (RX) and 16 (TX), Serial3 on pins 15 (RX) and 14 (TX). To use these pins to communicate with your personal computer, you will need an additional USB-to-serial adaptor, as they are not connected to the Mega's USB-to-serial adaptor. To use them to communicate with an external TTL serial device, connect the TX pin to your device's RX pin, the RX to your device's TX pin, and the ground of your Mega to your device's ground. (Don't connect these pins directly to an RS232 serial port; they operate at +/- 12V and can damage your Arduino board.)

2. the mega board RS232 pins are logic level, so you need to be sure the RX/TX signals from SSC32 are also
    logic-level.

3. I'm not sure if Serial.println() sends an 0x10 or an 0x13 at the end. You need <cr> = 0x13.

4. In regards "reading" the info from the SSC32, your code should look something like the example in the
    IDE Examples > Communications > MultiSerialMega sketch:

Code:
/*
  Mega multple serial test
 
 Receives from the main serial port, sends to the others.
 Receives from serial port 1, sends to the main serial (Serial 0).
 
 This example works only on the Arduino Mega
 
 The circuit:
 * Any serial device attached to Serial port 1
 * Serial monitor open on Serial port 0:
 
 created 30 Dec. 2008
 by Tom Igoe
 
 This example code is in the public domain.
 
 */


void setup() {
  // initialize both serial ports:
  Serial.begin(9600);
  Serial1.begin(9600);
}

void loop() {
  // read from port 1, send to port 0:
  if (Serial1.available()) {
    int inByte = Serial1.read();
    Serial.write(inByte);
  }
}


5. make sure you have the baudrates set to match on both ends.
« Last Edit: August 15, 2012, 01:25:17 pm by oric_dan(333) » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 553
Posts: 46300
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Do you know how I can read it?
Use Serial.available() to see how much data is available to read, and use Serial.read() to read it one byte at a time.

The fact that you claim to know some (bogus) values returned implies that you do know how to read data from the board.
Logged

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11196
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm moving a servo using the arduino Mega and an SSC32 controler without any issue.

It may be moving the servo, but I suspect it's premature to say it's without any issue. As others have said, you can't connect the Arduino hardware serial to your host PC and the motor controller at the same time. If you're using the hardware serial to send debug/trace output to the PC, you need to use a different port to connect to the controller. You should be able to use a software serial port for that, although exactly how to do that will depend on the Arduino IDE version that you are using. If you are sharing the same serial port between multiple devices as it appears from your sketch, I think you're wasting your time.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Pages: [1]   Go Up
Jump to: