Issues & questions using LSS and Python library

Just a quick update.
create an object myLSS1 = lss.LSS(1), myLSS1.move(0), print(myLSS1.getPosition()) I get None result.
Make a move myLSS1.move(450) and the motor doesn’t move at all.
Do we need to reset after initialize an object? I don’t think so, right?

1 Like

Yes, you need to initialize one object per LSS you wish to control. Of course, if you want to interact with a specific LSS, you’ll need to use the right object.

If you want to use loops and such, you can probably setup all of the LSS objects and then use a structure of some kind to contain them that you can iterate over (arrays, lists, etc.). You can google some generic Python examples on this quite easily.

This example shows using two LSS (one mimicking the other).

I’ll break down that part for clarity below:

Yes, that part sounds fine. As a reference, the encoder itself has some inertia of about 2 tenths of a degree. i.e: the servo is around that position by ±2 tenths of degrees. On top of that, the mechanical system inside the LSS itself has some small amount of play which could lead up to ±4 tenths of a degree. Therefore, the real position and the reported position can be about ±4 tenths of a degree from each other. This is why the on-board control does not try to correct the virtual position to the exact value, as it physically can’t (and trying to do so would just vibrate uselessly).

I assume you are using a second LSS object with a different ID?

You mean it reports the same position as the first LSS for the second LSS getPosition()?

Hmm… I think I have an idea what is going on here. Do you query the position in your code right after asking it to move? It would make sense that you get the previous value if you do not wait between those moves/check status (send Q, 6 = holding, anything else means limp or travelling/moving).
Just as a FYI, the commands (asking the LSS to move) are non-blocking and function asynchronously to your code.
Therefore, if you do:

pos1 = query LSS
move LSS
pos2 = query LSS

Both pos1 and pos2 will either be the same or very similar since the LSS hasn’t really moved yet! :smiley:
Maybe I should add an example to check for status while moving or something… :smiley:
For now though, maybe just try a sleep command between move and query. Maybe set it for 2-3 seconds just to make sure the move is done before querying position? :slight_smile:

For sure! We got you! :wink:

Getting None as a result means your servo is not responding on the bus. Check your connections and maybe reset everything involved! :stuck_out_tongue:

@nodochau Had you updated the ID to something different?

No, I did not.
But if I change myLSS1=lss.LSS(1) to myLSS1=lss.LSS(0) then the motor moves.
It could be something relates to lss config…

Oh yes I query the position right after asking it to move. It could be an issue.
Regarding another issue I change myLSS1 = lss.LSS(0) and it moves per move() command :thinking:
Let me try again then will give you an update.

1 Like

Is it possible that the two servos are set to different baud rates?

Also, if you go in the LSS Config and try to auto detect the LSS on your bus, what does it find? Maybe share a screenshot of the resulting text in the console after the detection completes.

Totally! :smiley:
Try adding a sleep call and see the difference.

Looking forward to it! :slight_smile:

If I have one motor and I create an obj id1 = lss.LSS(1), will it work?
Right now I just have one motor hook up and if I set id1 = lss.LSS(0) then the move command works and if I change to lss.LSS(1) then the move command does not work

And the first issue is solved by adding time.sleep() Thanks a lot

1 Like

Yes, provided you have an (and only one!) LSS on the bus with ID=1! :slight_smile:

Well, you need the ID you initialize the LSS object with to match the actual servo ID on the LSS you are trying to control.
If the LSS’ ID=1, then using lss.LSS(0) won’t work for, I think, obvious reason. Maybe I misunderstood what you mean here? :sweat_smile:

The best would be to query the servo status for a result of “holding” or ‘6’, indicating the movement completed.

OK, example:
id1 = lss.LSS(1)
home_pos = 0
Motor does not move.

Could you give me an example code?
I saw a LSS_CommStatus_ReadNoBus = 6 in but don’t know how to use it.
Using this:
def getStatus(self):
genericWrite(self.servoID, lssc.LSS_QueryStatus)
return (genericRead_Blocking_int(self.servoID, lssc.LSS_QueryStatus))

I see here:

but then:

ad1 would be wrong here, since you called it id1, no?

no that is my typo
Here is the simple code:

Import required liraries

import time
import serial

Import LSS library

import lss
import lss_const as lssc


CST_LSS_Port = “/dev/ttyUSB0”
CST_LSS_Baud = lssc.LSS_DefaultBaud

Create and open a serial port

lss.initBus(CST_LSS_Port, CST_LSS_Baud)

Create an LSS object

id1 = lss.LSS(1)

Initialize LSS to position 0.0 deg

pos1 = id1.getPosition()
pos = id1.getPosition()

Hello Scharette,
I just hook up the two motors together. And the simple program is below. The 2 move as I expected but I can’t get the position. They are always return None.
Please help

import time
import serial

# Import LSS library
import lss
import lss_const as lssc

# Constants
CST_LSS_Port = "/dev/ttyUSB0"      # For Linux/Unix platforms
CST_LSS_Baud = lssc.LSS_DefaultBaud

# Create and open a serial port
lss.initBus(CST_LSS_Port, CST_LSS_Baud)

# Create an LSS object
input("Create objs>")
myLSS1 = lss.LSS(0)
myLSS2 = lss.LSS(1)
# Initialize LSS to position 0.0 deg
input("Move to 0.0 deg >")
pos1 = myLSS1.getPosition()
pos2 = myLSS2.getPosition()
print(f'Pos of LSS1: {pos1}')
print(f'Pos of LSS2: {pos2}')
input("Move to 1800 >")
pos1 = myLSS1.getPosition()
pos2 = myLSS2.getPosition()
print(f'Pos of LSS1: {pos1}')
print(f'Pos of LSS2: {pos2}')
1 Like

Well, lets test a few things first.

Start with using the same code as above but move them to different positions instead of the same. See what the LSS do.
Right now you have .move(0) and .move(1800) for both. Change the values so that all 4 are different but easy to see, something like:
.move(0) and .move(1800) for # 0 and .move(-300) and .move(-600) for # 1 or similar, that way the angles are very different.

Just did a test and found out myLSS1 = lss.LSS(0) and myLSS2 = lss.LSS(1) seem like they have the same port zero.
When the command myLSS1.move() is executed then they both move. And myLSS2.move() command is executed then nothing happen.


1 Like

This most likely indicated that both LSS have the same ID still.

And following up, this would happen (answer : None) because both LSS answer at the same time and garble the answer on the bus (due to bus contention, since they have the same ID).

Agreed. It seems like both of them have the same ID. specially ID zero. If I set one of them at ID=0 then both run and if I set one is 1 and another is 2 or whatever number not zero then they don’t work.
So there are 6 ports on the Adapter board. Do they have their own address or we just need to initialize them? Or does it have the driver…? Just thinking
My program is ready for the project but I am stuck with the issue.
I tried to plug motor to different ports and nothing changed. So any port would be a servoID zero as soon as we initialize the ID for it?

1 Like

Hmm, lots of stuff to unpack here… :slight_smile: Let go through your comments/questions one by one:

Indeed, that seems to be the case.

How do you change its ID?

Same question as above, how do you set their IDs? Through an Arduino application? LSS Config? Something else (like xterm, putty, etc.)?

The 6 ports are simply physical connections to one common bus. There are no special electronics on them to differentiate them and no initialization of any kind is required. They are simply electrical connections to each of the 4 pins of the ports all tied together in parallel, thus creating one bus.

No worries, we’ll get down to the real cause shortly I am certain! You have a working LSS Adapter Board, power supply and LSS so this is most likely a simple configuration/use case issue. I.E.: Your hardware seems fine.

See the answer above concerning the ports and how they work. This indeed would not change anything.

I feel there might be a misconception on your end concerning how the LSS ID work and how they are used in practice.

I figure it is always best to make sure we start on some common ground, so let me get into some details about this and then what steps you’ll need to take to fix this issue. I apologize in advance if most of what I write here you already know!

The first step here is to read the details concerning the protocol and the ID of the LSS. You can do so here.
Simply put:

  • Each LSS on a bus that have the same baud rate should have a unique ID assigned to them.
  • Those IDs can be any value from 0 to 250 (inclusively).
  • All LSS are shipped by default with the ID set to 0.
  • To use two or more LSS on the same bus you need to first change their IDs individually (one at a time on the bus).

Then, lets fix those IDs!
In your setup, do the following:

  1. Optional (but recommended: obtain two post its and a pen/pencil first! :slight_smile:
  2. Make sure you have the LSS Adapter connected to your computer and power supply. Remove all LSS from the bus / connectors.
  3. Open up the LSS Config (make sure you have the latest version) and connect to the proper port.
  4. Turn off the power supply power, connect one LSS (doesn’t matter which one) and turn on the power again.
  5. Scan for the LSS on the bus. This should be pretty quick since there is only one to find.
  6. Check the data on the bottom left. You will see the ID. If it is zero, change it to something else.
    (if you did get a post-it and pen/pencil, write the number on it and stick it to that LSS)
  7. Disconnect form the bus in the LSS Config, power it down and remove that LSS from the bus. Connect the other one, power it up and reconnect in the LSS Config. Then, perform another scan.
  8. Once the LSS is found change its ID to something that is not zero and not the value chosen in step 5.
    (if you did get a post-it and pen/pencil, write the number on it and stick it to that LSS)
  9. Disconnect and power down again. Connect the first LSS to the bus. You should now have both connected at the same time. Power everything up and reconnect in the LSS Config. Scan for the LSS. The process should find two LSS. Make sure they are both available and responsive.

If you hit any issues in these steps please report back here at which one and the details before continuing the process!

Looking forward to your reply!



OK . Will do but still have question.
I connect the LSS adapter to the PC directly? Right now it is connected to the raspberry pi. Or do you mean the pi is a computer…
How to LSS Config? and how do I know I have a latest version?
I thought I change the ID just simply initialize it in creating object by command myLSS = lss.LSS(ID) though :slight_smile:

1 Like