Cannot drive two motors at the same time using the Dual VNH5019 Motor Driver Shield for Arduino

Hi Brandon, thanks for your reply. I am not doing closed loop control in this application.

Just to clarify a few points before moving on. How many msec does each md.setM1Speed() statement run? Supposing 3 msec, does having a delay(2.5) statement after md.setM1Speed(400) allows the md.setM1Speed(400) command to execute for 3+5.5 msec? If that is the case:

md.setM1Speed(400)
delay(value)
md.setM1Speed(-400)

will have more overshoot than:

md.setM1Speed(400)
md.setM1Speed(-400)

The larger the delay value, the more overshoot. Am I right?

Once you call md.setM1Speed() the output of the motor channel will stay at the duty cycle you commanded until you change it again. For example, if you call md.setM1Speed(400), followed by delay(50), then md.setM1Speed(-400), the motor output will be at 100% duty cycle for 50ms, then switch to 100% duty cycle in the opposite direction. How this relates to overshoot depends on your motor and system. By the way, the parameter passed to the delay function in Arduino is in terms of milliseconds and is interpreted as an unsigned long, so I suspect it will truncate floats like 2.5.

Brandon

Hi Brandon, thanks for the reply. What happen in the following two cases:

  1. md.setM1Speed(400) immediately followed by md.setM1Speed(-400).
    For how long will md.setM1Speed(400) be executed? From your example, it seems to be 1ms.

  2. md.setM1Speed(400) immediately followed by md.setM1Speed(-400) and repeat. If the output of the motor channel will stay at the duty cycle commanded until I change it again, will the motor oscillate back and forth by 1ms? Will the time be so short that it does not appear to be turning or just vibrate?

How come 50ms becomes 2.5ms?

It sounds like your questions are essentially asking how long it takes the Arduino to execute the commands and for the driver to react to the change in the signal. However, the motor is unlikely to respond to the output that fast, so knowing the intricate timing details is probably not going to solve the problem. Additionally, frequently switching from full-speed in one direction to full-speed in the other direction is likely to cause large current spikes, which as we have already discussed, could cause problems since the VNH5019 shield is underpowered for your motor.

Sorry about the confusion at the end of my last post; I was not saying that 50ms will become 2.5ms, I was referring to your example of 2.5ms. The delay command will likely not accept floating point numbers (e.g. numbers with decimal points), so if you use delay(2.5), it will likely be interpreted as delay(2).

Right now it sounds like you are new to working with microcontrollers and motors, and thus many of your questions do not seem like they would actually be very helpful in putting together your project. If you tell me what the larger project you want to control your motors for is, I might be able to suggest ways to get started and what types of things you will need to research for it.

Brandon

A post was split to a new topic: Strange behavior from VNH5019 driver carrier

A post was split to a new topic: Arduino CNC Shield