bmegli / xv11lidar-test

Test for XV11 lidar (character/raw binary synchronized output)
GNU General Public License v3.0
6 stars 2 forks source link

Unable to spin the motor from bash #1

Closed bmegli closed 8 years ago

bmegli commented 8 years ago

cxqzhou wrote:

Hi, I happened to find your article on how to use a LIDAR sensor on ev3dev.org and I became very interested in it, having a hobby for building robots. I followed your instructions on setting up the LIDAR sensor (I own the 5V version) for the EV3 here, but when I tried to follow your instructions on running your xv11lidar-test program, I ran into a few problems. Firstly, when I tried to start the motor through bash, it wouldn't start spinning, even though I know that the motor works since I got it to start spinning with a Python script. Here is screenshot of my terminal window to show you what I did:

t1

Secondly after failing to get the motor to start spinning, I tried to run your xv11lidar-test program, but the program did nothing, and I waited five minutes before terminating it. Here is another picture, where I tried to run your program:

png2

So is there anything I can do to solve my issues? Thank you!

bmegli commented 8 years ago

Hi cxqzhou,

Secondly after failing to get the motor to start spinning, I tried to run your xv11lidar-test program, but the program did nothing, and I waited five minutes before terminating

The LIDAR doesn't output any data if the motor is not spinning, xv11test on the other hand waits for the input to start synchronising so this behaviour is expected if the motor is not spinning. We have to solve the motor issue.

I know that the motor works since I got it to start spinning with a Python script

Great - this means it's soldered correctly

It seems that you are loading dc-motor driver for a diffrent port from the one that the LIDAR motor is plugged in. It's possible to load this driver even for port that nothing is plugged in.

You can check the port with (in motor directory):

cat address

Make sure it's the output that you have plugged in the motor.

Almost always the mapping is following:

But in theory this depends on the order the kernel loads the drivers of ports.

So summing up:

echo dc-motor > /sys/class/lego-port/port4/mode #for output A, otherwise adjust the port number
dmesg | tail #you can see here which number the dc-motor  was created with
cat /sys/class/dc-motor/motorX/address # where X is the motor number, make sure the address matches the port

Now, there also other possibility.

Setting the port mode has to be done only once after boot.

I mean the line echo dc-motor > /sys/class/lego-port/portX/mode

Considering that you have motor15 it means that you have changed the mode at least 16 times. It's possible that you are trying to set duty_cycle_sp for a different motor/port (again, dc-motor mode is kind of manual in ev3dev, nothing has to be plugged to port to set it and create dc-motor device)

So again, you can make sure you are setting duty_cycle_sp for the correct motor with just the same commands:

echo dc-motor > /sys/class/lego-port/port4/mode #for output A, otherwise adjust the port number
dmesg | tail #you can see here which number the dc-motor  was created with
cat /sys/class/dc-motor/motorX/address # where X is the motor number, make sure the address matches the port the motor is plugged in

Let me know if this helps!

Kind regards

cxqzhou8 commented 8 years ago

Hi @bmegli, Thanks for replying so quickly to my questions! I followed the your instructions above on setting the mode Output A port and now the LIDAR sensor's motor is spinning! (though I think the duty_cycle_sp should be set to -40 not 40) However when I tried to run the xv11test program again, it again did not do anything. Is there something else that I could possibly be doing wrong? Thanks again @bmegli!

bmegli commented 8 years ago

Hey, wait, we have solved the problem with the motor!

I am moving this to separate issue #2 for troubleshooting LIDAR data

So let's continue here #2