Notifications
Clear all

Arduino & Stepper motors

12 Posts
4 Users
1 Likes
425 Views
(@spurgian)
Member
Joined: 1 year ago
Posts: 5
Topic starter  

Hello

This is new to me, on a steep learning curve and have been following Bill's 'Using Servo Motors with Arduino' which is very informative and helpful, but I would like to do 2 things

1 - Use a push button to move the servo to one position, and a second input ot push button to move the servo back again

2 - have a simple way to set max and min movement of the servo

 

How can I change the code for the Pot to a push button input please?


   
Quote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
 

@spurgian

Your title says stepper motors not servo motors?

 

 


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6964
 

@spurgian By use push button, do you mean push once, or hold it down while positioning? Also as @robotbuilder pointed out you mention both stepper and servo, which is it. You need to elaborate a lot on your second point of setting min and max.

I hope this is not your first sketch, sort of like jumping in a race car before you learn to drive.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1680
 

Hi @spurgian,

  As Ron @zander and @robotbuilder have pointed out, your question appears a little muddled, so I suggest you describe EXACTLY what you have achieved so far, and (I hope) it will be a little easier for someone to suggest a way forward.

When I say EXACTLY, please bear in mind, each of Bill's excellent videos include several parts, so be very specific as to which part you constructed (provide a link if you can), and did it work as described, as well as any other information you can provide. As Ron asks, be specific as to whether it will need on or two switches, and describe how it should work.

Best wishes,

Dave


   
ReplyQuote
(@spurgian)
Member
Joined: 1 year ago
Posts: 5
Topic starter  

Sorry guys, that's my bad.... I am looking at SERVO motors, I want to control turnouts or points on my model railroad and the full sweep is a bit too far to move so I am wanting to limit the movement. 

I was thinking of 2 switches that give a pulse to the Arduino, one to signal the servo to move one way and the second to move it back to the start position

Not sure if that helps to explain better? (sorry guys, I am dyslexic and sometimes struggle to explain myself very well)


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6964
 

@spurgian What gauge RR? Most servos are way to big for the most popular gauges. I believe there are special linear motors made to do that job.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
(@spurgian)
Member
Joined: 1 year ago
Posts: 5
Topic starter  

the Gauge is OO/HO, using the SG9 servo - used lots on this gauge railways, the thing is with Servo's you can simulate slow motion as well for realism 


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6964
 

@spurgian Ok, it's been a few years since I gave my HO layout to my grandsons and I don't recall seeing anything like an SG90 but my memory is bad. I just pulled an SG90 from my parts bin and am 100% sure the switches on my HO setup were much smaller and were linear switches. I included a picture of a standard HO switch machine. I couldn't find dimensions but I think the attached pictures will help. An SG90 would be big and very cumbersome in crowded switching yards. Are you sure the SG90 is a smart choice? You can do the sane sketches using standard linear motor switches and DCC parts I think.

 

Screenshot 2023 01 11 at 07.08.12
Screenshot 2023 01 11 at 07.04.27

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
(@spurgian)
Member
Joined: 1 year ago
Posts: 5
Topic starter  

Thanks - I am aware of the solenoid type, but the SG90 is also extensively used, mounted below the baseboard with the pin coming up through.  I would be glad if someone could indicate how I can use momentary inputs to the Uno board or even a latched input to send the servo to one end of its travel or the other


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6964
 

@spurgian Ok, but first, how many servos? What arduino were you thinking of?

Will the servo travel distance be a function of a limit switch, or will the switch type determine it as in 30 degree right (sorry, it's been a while but I think that is a usual type)

IMPORTANT: Is this a push the button once and the servo moves the correct amount  or will you be holding the switch (not advised)

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6964
 

@spurgian In order to handle a reasonable number of switches, you will need to employ some additional hardware namely an MCP23017 16bit I/O port expander and a TLC5940 PWM driver.

Let's take them one at a time.

The MCP23017 is needed to handle up to 16 buttons. Since the UNO has 14 digital inputs, we will allocate 5 for output controls, and 8 for buttons leaving one spare. That means you can support 8 x 16 or 128 buttons. That is either 64 switches if two buttons per switch, or 128 switches if one button per switch. Documentation for this approach is HERE . This author is a very famous arduino developer so I totally recommend his work.

For the output side, you can use 5 uno pins (subtract them from the above numbers) to control up to 64 servos using daisy chained TLC5940's. I suspect that may not be enough, so switching to an Arduino MEGA would be advised where we get an extra 40 GPIO's. The code for this is HERE

I really need to put this in a spreadsheet, so e&oe until I do.

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
(@spurgian)
Member
Joined: 1 year ago
Posts: 5
Topic starter  

Upto 8 servos, can also use the Servo Driver board. push button once will work for me

 


   
Ron reacted
ReplyQuote