Motorsheild stepper speed control

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
TStark
 
Posts: 42
Joined: Tue Sep 08, 2015 6:06 pm

Re: Motorsheild stepper speed control

Post by TStark »

Just to add... I've been using the two shield together for a while now, however, I've been avoiding using "i" due to the LCD reference. At this point I use the two shields combined on so many projects that I wanted a master template and the code question was there....

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: Motorsheild stepper speed control

Post by adafruit_support_bill »

Sounds like probably leftover from an earlier iteration. If you can comment it out and everything still compiles, then it is not needed.

User avatar
TStark
 
Posts: 42
Joined: Tue Sep 08, 2015 6:06 pm

Re: Motorsheild stepper speed control

Post by TStark »

Hello support…

To summarize past posts…

I previously had a problem getting higher speeds with the Nema 17 stepper motor and displaying various status displays on the RGB Shield. The result was to change the placement of the IC2 clock time “TWBR = ((F_CPU /400000l) - 16) / 2; “ so that it is AFTER the motorshield and RGB shield set- up.

Everything at that point was working fine. I had a higher speed Accelstepper code with RGB display working.

When I was first experimenting with the code combining the motorshield v2 codes with the RGB LCD Helloworld code, I removed the button references for breakdown. Now I am adding the button calls back into the code for various functions. I am finding that the “lcd.readButtons();” sub-routine is causing a big delay in the motor speed. Obviously, there are delays (probably for debouncing) in that sequence. I have read that previous boards use “analogRead(A0)” to read the “up/down/left/right/select” status. I’ve tried reading that pin (and others) and I believe that since the display board is IC2 the pins are now different. I have also read in your instructions that A4 and A5 are taken.

How or what can I “read” to get the values that represent the “up/down/left/right/select” buttons without using “lcd.readButtons();”?

Any code or input methods that you are aware of is appreciated.

As a side note, when I call “buttons = lcd.readButtons();” and read the “buttons” value, the following values return (Select – 1, Right – 2, Down – 4, Up – 8, Left -16). By getting some value reading when pushing a button and avoiding the “lcd.readButtons();” I hope to be able to keep the motor running at high speed and still accept a button change.

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: Motorsheild stepper speed control

Post by adafruit_support_bill »

The only access to the buttons is via i2c. I believe there is some debounce logic in the code which may account for the delays. You might be able to hack the library to remove that.

User avatar
TStark
 
Posts: 42
Joined: Tue Sep 08, 2015 6:06 pm

Re: Motorsheild stepper speed control

Post by TStark »

Hi Support...

I have looked into the libraries for understanding how the IC2 communications is working, but there is a lot there. Is there any sample code that you may provide that helps me in reading if a button is pushed? Again, my goal is to avoid the "lcd.readButtons()" sub-routine and directly read the button.

User avatar
TStark
 
Posts: 42
Joined: Tue Sep 08, 2015 6:06 pm

Re: Motorsheild stepper speed control

Post by TStark »

Ohh.. also , I have noticed "i2c.digitalRead" in the code and am trying to compare that to analogRead, but I don't know what has to be declared prior and what numbers are to be read for the pins that correspond to the buttons... If that is the proper way to go...

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: Motorsheild stepper speed control

Post by adafruit_support_bill »

readButtons is pretty simple. It does one read of the MCP23017 for each of the 5 buttons and performs a bitwise logical AND of the complement to return a bitmask containing all 5 button states. If you want to read the state of a single button, just do one digitalRead.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”