Motorcontroller 1065, crash with negative velocity values

Supporting 2.6 and up
porzoo
Phidgetsian
Posts: 5
Joined: Tue Jun 21, 2016 11:22 pm
Contact:

Motorcontroller 1065, crash with negative velocity values

Postby porzoo » Wed Jul 06, 2016 10:17 pm

Hello,

I’m working right now with one of your Phidgets Motorcontroller (1065_0 - PhidgetMotorControl 1-Motor) and the Motor: 3266E_0 - 12V/1.9Kg-cm/175RPM 14:1 DC Gear Motor w/Encoder. I build a PID-controller velocity control for the motor on an Intel NUC with Linux and ROS (Robot Operation System).
My program is written in Python and then implemented in the ROS environment. To calculate the encoder, I use the event handler: OnEncoderPositionChange(int EncoderIndex, int Time, int PositionChange) [event] which gives me the encoder velocity every 8ms. In my main program, I use a PID-loop, which uses the encoder velocity to generate a controlled output for the PWM value of the Motor (motorControl.setVelocity(0, ouput)) at an samplerate of 8ms. When I use positive Values for my velocity demand, everything works fine. But after I put in negative values (up to -100) the motor stops after a couple of seconds and throws out an Exception: Phidget Exception 5: Phidget not physically attached and my application dies.
To find out, if it’s a problem with ROS, I tried it without it.

I modified the example code MotorControl-simple.py with a loop where I could change the loop duration and the motor velocity. In this case I didn’t use the eventhandler. I’m polling the encoder velocity in the loop, by getting the first encoder position, wait 80ms and get the second position, these values are used for the velocity calculation, which I just print out on the screen. The Value for setVelocity, I type in manually.

At first I tried it with a loop time of 8 ms and a velocity of -30:
The first few seconds, the motor spins normally, but after approximately 4 seconds, the encoder velocity drops down to zero and the Exception 5 comes up on the screen. Afterwards the motor starts running again for a longer time and dies again with the same exception. After a couple of times the motor stays at 0 velocity and Exception 17 comes up on the screen.
Loop time of 80 ms and a velocity of -30:
It takes a few seconds more, but the result is the same as before. Except the application does not die. The motor just stops for a second and Exception 5 was dropped out for 10 times, afterwards it works again.
Loop time of 80 ms and a velocity of -100:
The first few seconds, the motor spins normally, but after approximately 10 seconds, the encoder velocity drops down to zero and the Exception 5 comes up on the screen. Afterwards the motor starts running again for a longer time and dies again with the same exception. After a couple of times the motor stays at 0 velocity and Exception 17 comes up on the screen.
Loop time of 80 ms and a velocity of -100 and I commented out the event-handler (which runs at 8ms):
Everything works fine.
Loop time of 80 ms and a velocity of 100:
Everything works fine.

When I run my PID Loop in the ROS environment, the “setVelocity”-Command immediately throws out Exception 5: Phidget not physically attached, after I put in a negative demand, or when I switch from a high positive value like 100 down to 30, because the PID Controller gives a negative output to the setVelocity Command, to reach the new demand value.

My Questions are, is there a problem with my samplerate or the negative Values and how can I fix the problem?

Best regards

User avatar
Patrick
Lead Developer
Posts: 3089
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Motorcontroller 1065, crash with negative velocity value

Postby Patrick » Sun Jul 17, 2016 8:28 am

Sounds like you may be getting EMI or power related detaches. Can you enable logging in the library and post the output?

-Patrick


Return to “Linux”

Who is online

Users browsing this forum: No registered users and 1 guest