Motor Shield Rev3

Discuss suspected bugs with other users and Sim Innovations Staff

Moderators: russ, Ralph

Message
Author
Pkaser
Posts: 61
Joined: Mon Jul 15, 2019 7:15 pm

Motor Shield Rev3

#1 Post by Pkaser »

So I have an agitator/shaker on one channel of the motor shield and the Hobbs meter on the other. In 3.7 I used an hw_led_add or set to turn them on or off. One is on d11 and the other d3. Since the upgrade, neither do anything.

Any ideas? I created a test instrument to mess with it and neither channel does anything no matter what I tried. Pwm, led, analog out, digital out...all just a big nothin' burger.

Pkaser
Posts: 61
Joined: Mon Jul 15, 2019 7:15 pm

Re: Motor Shield Rev3

#2 Post by Pkaser »

Fyi: I didnt check the voltage because I dont have my voltmeter with me...it could be that, but it would be a coincidence it died the day I upgrade, but I will check it tomorrow just to be sure

User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: Motor Shield Rev3

#3 Post by Sling »

Not sure what your issue is without more detail but one thing to note is you shouldn’t be using the LED functions for these. LED should only be used for LED’s strangely enough and only when you want to alter the brightness of the LED. For simple on/off control for LED’s and other things you should use the digital output functions.
Last edited by Sling on Tue May 04, 2021 7:00 am, edited 1 time in total.

Pkaser
Posts: 61
Joined: Mon Jul 15, 2019 7:15 pm

Re: Motor Shield Rev3

#4 Post by Pkaser »

I didnt realize there was a functional difference in them. I was looking at the end result which got the motor shield to output what I needed with the least amount and the simplest code. There wasnt any documentation on using the motor shield so I was just experimenting.

User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: Motor Shield Rev3

#5 Post by Sling »

There would be no logical reason to create two API function groups named differently but that gave the same functional result in all cases now would there. Have a read of the API pages it has all this basic information.

User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: Motor Shield Rev3

#6 Post by jph »

Hi, @Pkaser (and for info Tony) @Sling - just pondering ;)
Have you got the DIR pins tied for the required direction (presuming you are only using this for a single direction ?) - you would need to ensure that the D12 and D13 pins are tied to either High or Low (5V or 0V (GND)) depending on which direction you require. Looking at the schematic there is no pullup or pulldown resistors on the board and unless the internal weak pullups are set then you need to do this manually of you would potentially end up with floating inputs. For this you can use the hw_ouptut_add https://siminnovations.com/wiki/index.p ... output_add to set the pins for DIR in their correct state for the direction. These are simple logic high / low. NOT pwm. PWM is only used for speed.

The input to the D3 and D11 (speed) need to see a PWM signal as the pulse width determines speed.
I can actually see how the LED 'brightness varying' would 'work' in this case as this - afaik - is a very simple software derived fixed frequency PWM signal that only allows Duty Cycle variation. What resolution I don't know, but it would seem to be the answer to do the job - if using an UNO. . A logic HIGH on those pins should also produce a pseudo 100% PWM signal also (for testing) .... (with one caveat - in sore rare cases 100% PWM - meaning a constant high with not event he slightest - minimal - pulse can, in rare cases cause issues, but I dont think it would here - and, you would only ever use this for testing at full speed). I hope that makes sense ?

hardware PWM offers much more flexibility and it uses the board's on board Hardware PWM generators ! (so runs independently of your main code once set). You have the ability to control all aspects, not just the duty cycle but also the frequency. HOWEVER - it is only possible to actually add a hw_output_pwm_add in AM IF the pins used are as defined in - https://siminnovations.com/wiki/index.p ... rduino_Uno - which doesn't support those pins.

In this case, then the pins you require - D3 and D11 that need PWM are NOT both available for this function. so it is not possible on the UNO, hence, you would have to use 'led' for this and vary the brightness which would offer a basic fixed frequency PWM.
for info, the motor shield rev 3 is fixed to pins 3 and 11 for PWM input.
There is another option of course, which is to use the MEGA which does support those pins but I dont see any reason for it the hw_led to not work on the uno for such a basic function ?.

some board data -
https://store.arduino.cc/arduino-motor-shield-rev3
Schematic -
https://www.arduino.cc/en/uploads/Main/ ... ematic.pdf

Joe.
Joe. CISSP, MSc.

User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: Motor Shield Rev3

#7 Post by jph »

Pkaser wrote: Tue May 04, 2021 6:24 am I didnt realize there was a functional difference in them. I was looking at the end result which got the motor shield to output what I needed with the least amount and the simplest code. There wasnt any documentation on using the motor shield so I was just experimenting.
Hi
There IS loads of DETAILED documentation on the shield !. See some links above.
Can I suggest that you don't experiment without reading the minimal data needed first please ?
Also, the difference between software PWM as used - I believe - in the hardware led is basic, but functional as compared to using the built in hardware PWM drivers on the Arduinos (etc). The Hardware drivers for PWM run constantly and independently of your code when set, whereas, the software PWM suffers slight delays due to the code execution. This is NOT an issue for LED brightness etc, and it would not be an issue here for what you appear to be doing.
If your code with the led 'brightness' driving the PWM input for speed worked in 3.x but not in 4.x then I believe it is probably a case of tying the DIR pins to either high or low logic. Hopefully that is all it is. If, after tying the logic level of the DIR pins, then we can investigate further. in 99% of cases there is ALWAYS some kind of documentation out there. ;) :)
Joe
Joe. CISSP, MSc.

User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: Motor Shield Rev3

#8 Post by Sling »

Turning things on/off with the led function was mentioned and that is not necessary. In fact it has caused some problems doing this in the past. If its a simple on/off then the digital out functionality is the one to use.

As Joe says if using a specific driver/shield then make sure you use it as prescribed.

Pkaser
Posts: 61
Joined: Mon Jul 15, 2019 7:15 pm

Re: Motor Shield Rev3

#9 Post by Pkaser »

No problem I can make those changes. Thanks for your help everyone. I appreciate it

Pkaser
Posts: 61
Joined: Mon Jul 15, 2019 7:15 pm

Re: Motor Shield Rev3

#10 Post by Pkaser »

Ok, so I see in another post someone else is having a problem with the LED function and an UNO, so It's not just me.

The Hobbs was switched to digital output instead of LED and it's working again. I will do my best to swap out the UNO for a Mega or a Leonardo so I can use PWM output instead of the LED. I also verified the direction was set using digital output.

Thanks for the assistance.

Post Reply