Arduino and motor Shield help

Topics and questions about AMC, h-bridges, JRK's etc.

Re: Arduino and motor Shield help

Postby motiondave » Wed 26. Sep 2012, 00:32

tronicgr wrote:From quickly studying the code pieces shared here, I see terrible update rates, 10ms in some cases... I might try some of this code sometime to see if it takes any improvement.

There is simply not enough processing power (MIPS) in these microcontrollers for more than 1 or 2 motors at the same time to meet almost realtime requirements.

Thanos



I mentioned this before and I will mention it again, Show me a motor that can ACTUALLY reproduce a 1ms well enough to notice a difference, if 10 ms is "too" slow.
User avatar
motiondave
 
Posts: 997
Images: 1
Joined: Tue 20. Mar 2012, 16:36
Location: Sydney Australia
Has thanked: 11 times
Been thanked: 13 times

Re: Arduino and motor Shield help

Postby tronicgr » Wed 26. Sep 2012, 17:27

I said "Almost realtime" ...

And its not like motors have to respond to 1ms direction change. Let me give you an example:

Almost any kind of motor has some delay to react and accelerate to full speed that can be from 10ms to 100ms or even more in some cases.

Now if you have a 10ms delay in reaction time from the controller it will add up to the delay of the reaction of the motor exponentially. Here are some calculations:

10ms * 10ms = 100ms total delay
10ms * 100ms = 1sec total delay
10ms * 200ms = 2sec delay!!!

This will also introduce huge stepping in the position feedback of the motor since it will not react in time for accurate positioning, PID will need larger values and slow slew rate to avoid overshooting.


With 1ms delays things are alot better in terms of transferring the introduced delay to the already delayed reaction time of the motor.
1ms * 10ms = 10ms delay....

So to be more specific, while the first controller with 10ms delay provided only 1 position or speed setting during the 10ms delay of the motor, the 1ms controller already delivered 10 possible positions that could perform micro-fine adjustments to the acceleration speed or even command reverse direction if needed before the motor starts its wasted cycle.

Less delay, more samples, fine adjustments!


I also have to mention here that the motion data coming from PC games are almost in realtime, why should we introduce more delay in between? We need to process this positions and transfer them to the motors as fast its possible. Have you even played with a force-feedback steering wheel with 100ms or 10ms delay? Did it feel ok? No??

Thanos
User avatar
tronicgr
 
Posts: 624
Images: 11
Joined: Tue 20. Mar 2012, 22:10
Location: San Diego, CA
Has thanked: 130 times
Been thanked: 50 times

Re: Arduino and motor Shield help

Postby motiondave » Thu 27. Sep 2012, 01:41

Thanks Thanos, thats good info. That make sense.
anywhoo....lets see how you go forward with the controller testing.
Good luck to you . :D
User avatar
motiondave
 
Posts: 997
Images: 1
Joined: Tue 20. Mar 2012, 16:36
Location: Sydney Australia
Has thanked: 11 times
Been thanked: 13 times

Re: Arduino and motor Shield help

Postby Riton » Thu 27. Sep 2012, 08:39

tronicgr wrote:I said "Almost realtime" ...

And its not like motors have to respond to 1ms direction change. Let me give you an example:

Almost any kind of motor has some delay to react and accelerate to full speed that can be from 10ms to 100ms or even more in some cases.

Now if you have a 10ms delay in reaction time from the controller it will add up to the delay of the reaction of the motor exponentially. Here are some calculations:

10ms * 10ms = 100ms total delay
10ms * 100ms = 1sec total delay
10ms * 200ms = 2sec delay!!!

This will also introduce huge stepping in the position feedback of the motor since it will not react in time for accurate positioning, PID will need larger values and slow slew rate to avoid overshooting.


With 1ms delays things are alot better in terms of transferring the introduced delay to the already delayed reaction time of the motor.
1ms * 10ms = 10ms delay....

So to be more specific, while the first controller with 10ms delay provided only 1 position or speed setting during the 10ms delay of the motor, the 1ms controller already delivered 10 possible positions that could perform micro-fine adjustments to the acceleration speed or even command reverse direction if needed before the motor starts its wasted cycle.

Riemann_sum_convergence.png


I also have to mention here that the motion data coming from PC games are almost in realtime, why should we introduce more delay in between? We need to process this positions and transfer them to the motors as fast its possible. Have you even played with a force-feedback steering wheel with 100ms or 10ms delay? Did it feel ok? No??

Thanos



this is very interesting!
eg: my time acceleration / deceleration at my frequency inverters is set at minimum 0.1s
with your card (1ms) it is 1ms*100ms=100ms.

The real question now is to know the reaction time of the electric motors to move and change direction at full speed.

Engines used on 180° they have a lower resolution than the linear actuators with ball screw?
motor equivalent for example.
User avatar
Riton
X-Sim Supporter
 
Posts: 291
Images: 70
Joined: Mon 7. May 2012, 16:05
Location: France
Has thanked: 1 time
Been thanked: 16 times

Re: Arduino and motor Shield help

Postby tronicgr » Thu 27. Sep 2012, 15:13

BobBuilt wrote:So the big question do you think we can get the ard down to a 1ms controller even if we set them up for one motor per controller.?


With current libraries for communication (serial stream) and PWM, I'm not so sure. It needs a lot tweaking and maybe writing custom library for fast and accurate communication with x-sim.

With the standard arduino libraries I got my "Digital dashboard with TM1638 and Arduino Nano v3" to run with 10ms delay. Anything less than that, the arduino was resetting. I even used Binary format for the data for better transmission speed.

Also the PWM of the current libraries is only 8-bit. Needs custom code for 9 or 10-bit size pulses. Not to mention the ADC needs similar tweaking to get 10-bit resolution.


Thanos
User avatar
tronicgr
 
Posts: 624
Images: 11
Joined: Tue 20. Mar 2012, 22:10
Location: San Diego, CA
Has thanked: 130 times
Been thanked: 50 times

Re: Arduino and motor Shield help

Postby kbssa » Thu 27. Sep 2012, 17:08

Hi Thanos !

I need your help and I hope you can help me !!

I am doing a force feedback wheel and I am using an arduino to do the force feedback controller.

Now I am stucked on the arduino code, I need to get the lateral force value from x-sim and read it with arduino (I can do that !), but I need to take the x-sim and pot feedback values do a PWM to control the h-bridge.

The problem is that I have no idea on how to do a PID control or something like that to move the motor in the right direction, so it can be called a real force feedback control.

The question is: Can you help me with it ?

I just need to treat the values that arduino get from x-sim and transfoms it in a FFB !

Regards,

Bruno Martins.
kbssa
 
Posts: 120
Images: 16
Joined: Thu 19. Apr 2012, 21:03
Has thanked: 5 times
Been thanked: 3 times

Re: Arduino and motor Shield help

Postby sirnoname » Thu 27. Sep 2012, 18:08

This thread gets a little bit messed.

@kbssa: There is a anounced PID software for the arduino after the delivery of the H-Bridges is done (2 Weeks left I think).
There is no change to the statement I did. This arduino uno code will have the anounced features and with high update rates.
This will do the job and you can for now download and use the code I have collected out of the internet here:
viewtopic.php?p=2310#p2310
It is not the best one but working for the first try. There you will find a PID code. No mirracles here about howto get it working. This older code is used for X-Sim by other peoples.

For your wheel question: A wheel does not use PID, it is using force in form of PWM. This means you give a Power into one direction and no PID regulation will stop the motor. Your motor will give force according the ingame forces and not controlled by a feedback pot. It is a constant force.
If a answer is correct or did help you for a solution, please use the solve button.
User avatar
sirnoname
Site Admin
 
Posts: 1829
Images: 45
Joined: Thu 1. Sep 2011, 22:02
Location: Munich, Germany
Has thanked: 35 times
Been thanked: 128 times

Re: Arduino and motor Shield help

Postby kbssa » Thu 27. Sep 2012, 18:54

Hi sirnoname !!

Thanks for replying !

I understood what do you mean about PID control, PID is just for positioning the motors.

So if I take the value from x-sim and transform it into a PWM value, it can be called FFB !? is that ?

If yes, it is so simple and I can do that !!! (I think)

I was thinking about PID control, cuz I will not use mechanical stops for the wheel, I intend to use software stop, so I need a feedback pot or an enconder to know the wheel position and limit its rotation, but I think PID is not the right way to do that. I think if I set "high" the right pins of the h-bridge it will stops the motor. Am I right ?

And about some vibration on the wheel in low RPM, Can I do that ?

Thanks !
kbssa
 
Posts: 120
Images: 16
Joined: Thu 19. Apr 2012, 21:03
Has thanked: 5 times
Been thanked: 3 times

Re: Arduino and motor Shield help

Postby tronicgr » Thu 27. Sep 2012, 19:30

Well. things are not so easy for you my friend...

To implement proper FFB you need to add a way to measure the load on the motor, to maintain the proper force and allow the user to turn the wheel against the feedback force.

The key here is not PID but control loading. One of the sensors you can use to sense this loading is a current sensor

You could use a potentiometer or other positioning device also just for position reference or self-centering during calibration.

Other than that, good luck with it!

PS. Open a new thread about it so we can brainstorm on this matter. Don't highjack other threads...!


Thanos
User avatar
tronicgr
 
Posts: 624
Images: 11
Joined: Tue 20. Mar 2012, 22:10
Location: San Diego, CA
Has thanked: 130 times
Been thanked: 50 times

Re: Arduino and motor Shield help

Postby kbssa » Thu 27. Sep 2012, 21:57

tronicgr wrote:Well. things are not so easy for you my friend...

To implement proper FFB you need to add a way to measure the load on the motor, to maintain the proper force and allow the user to turn the wheel against the feedback force.

The key here is not PID but control loading. One of the sensors you can use to sense this loading is a current sensor

You could use a potentiometer or other positioning device also just for position reference or self-centering during calibration.

Other than that, good luck with it!

PS. Open a new thread about it so we can brainstorm on this matter. Don't highjack other threads...!


Thanos


Thanks for replying man !

I opened a thread as you said, please take a look there.

Bruno
kbssa
 
Posts: 120
Images: 16
Joined: Thu 19. Apr 2012, 21:03
Has thanked: 5 times
Been thanked: 3 times

PreviousNext

Return to Controllers and Drivers

Who is online

Users browsing this forum: No registered users and 1 guest