ARDUINO PROGRAMMING, AND INTERFACING HELP

Basic electrical and electronics, such as DC/Analog control.
Paul-H
Posts: 244
Joined: Fri Jun 05, 2009 3:00 pm

Re: ARDUINO PROGRAMMING, AND INTERFACING HELP

Post by Paul-H »

Hi

Thank you for taking the time to help me with this project, I hope I am up-to following your instructions.

Can I ask a couple of starter questions, do I connect the servo directly to the Mega or are we going to use the shield I linked to, or is it not needed for what I would like to achieve.

Re the variable resistor , I have had to order one so it will be a couple of days before it arrives but as they all had 3 connectors which ones connect to which pins on the Mega, sorry but I am going to need a bit of spoon feeding to get my aging brain around this.

It would be nice if you could include connections for LED's on the mimic panel or I could atca push use micro switches on the servo mount to achieve this but using the mega would be a neater solution.

Thanks again for all the help, hope I don't turnout to be one of those PITA types you regret ever offering to help.

Thanks again

Paul
timbologist
Posts: 372
Joined: Wed Sep 18, 2013 6:39 am
Location: Hazeldene Victoria Australia ( in the bush )

Re: ARDUINO PROGRAMMING, AND INTERFACING HELP

Post by timbologist »

Hi Paul

I'll start of by saying I've been involved with Electronics and computers for about 50 years now so have gathered a lot of knowledge and experience in this time.
But the forgotten fact is 50 years ago I was like you I knew nothing about any of this, and only with the help of other people making time to guide me and share there knowledge and experience that I am as I am now. It is my turn to do what others have done for me. So don't worry about what questions you ask I know I have been there. The same goes to anybody else have a question please ask.

Paul as for the question of the connections you will use the shield you have bought as it makes it easy to hook up just plug the servos in.
with the variable resister one of the outer pins connects to 5 Volts the other outer pin connects to ground, and the centre pin will connect to the Pin marked A0. As for the LEDS the switches you have for this are they SPDT ( Single Pole Double Throw ) they have 3 terminals on the back, or are they DPDT ( Double Pole Double Throw ) they have 6 terminals on the back. If they are DPDT the LEDS can be wired straight of the switch. otherwise you can use the Mega.

You mention about using Micro Switches on the servos, this has the advantage that you get positive feedback from the points that they have actually moved to the selected position. With the Panel switch and the Mega method both actually assume that the servo has actually moved.
I would recommend you get a copy of the software called Fritzing which is free software http://www.fritzing.org as that is what I use to make the diagrams I use. I can then include any diagrams in the downloads so they can be loaded into the software to make it easier for you to look at.
timbologist
Posts: 372
Joined: Wed Sep 18, 2013 6:39 am
Location: Hazeldene Victoria Australia ( in the bush )

Re: ARDUINO PROGRAMMING, AND INTERFACING HELP

Post by timbologist »

Ok for those following the Crossing flasher I have not forgotten about it, I have just got a bit ahead of myself as I have been playing with the sound, and currently have a couple of ways of having the ringing of bells in time with the flashing of the lights all done from the Arduino.
So I will get back to the other methods of connecting to the layout.
Paul-H
Posts: 244
Joined: Fri Jun 05, 2009 3:00 pm

Re: ARDUINO PROGRAMMING, AND INTERFACING HELP

Post by Paul-H »

Thanks for the prompt reply

Sounds like using DPDT or the Micros switch option will be the may to go got some on order as we type

Downloaded the Fritzing software, thanks for the link so will be able to view your diagrams as you post them.

Thanks again for all the help, will post back with any results once all the bits arrive in the post

Paul
Paul-H
Posts: 244
Joined: Fri Jun 05, 2009 3:00 pm

Re: ARDUINO PROGRAMMING, AND INTERFACING HELP

Post by Paul-H »

So hoping I have this all connect up correctly I get the following results for the servo travel, end to end with a couple of glitches giving erroneous results

download/file.php?mode=view&id=30844

Let me know if this looks like I have a connection wrong

Paul
Attachments
Servo Output.jpg
timbologist
Posts: 372
Joined: Wed Sep 18, 2013 6:39 am
Location: Hazeldene Victoria Australia ( in the bush )

Re: ARDUINO PROGRAMMING, AND INTERFACING HELP

Post by timbologist »

Hi Paul


Firstly is the servo wired up to a set of points or is it sitting on the bench not connected to anything.
Looks like it is wired up correctly as one direction is linear until it gets to 45 then as you say gets glitches and goes erroneous and it is strange that the max numbers move at the same time.
Did you turn the pot in the other direction to get the max of 97 of was that still going in the min direction.
Did the servo move 180 degrees or did it just move the half a turn as the output indicates.

This may take a couple of days because when you are awake I am a sleep accept like now I am having a pit stop and just checking.
Paul-H
Posts: 244
Joined: Fri Jun 05, 2009 3:00 pm

Re: ARDUINO PROGRAMMING, AND INTERFACING HELP

Post by Paul-H »

Thanks for the quick reply

The Servo is just sat on the bench

I had the pot at one end then when it stopped i moved it the other way, the servo only moved a small amount as shown.

I am using a 10k pot would a different value give more movement.

Thanks

Paul
timbologist
Posts: 372
Joined: Wed Sep 18, 2013 6:39 am
Location: Hazeldene Victoria Australia ( in the bush )

Re: ARDUINO PROGRAMMING, AND INTERFACING HELP

Post by timbologist »

Hi Paul

Attached is the schematic and the wiring diagram.There is not a component of your board in Fritzing so I have wired it without it. Now depending on the brand of servo you have, the wire colours may be different. I have the SG-90 servos from Ebay that have
Red for positive
Brown for negative
Orange for signal which goes to pin 9 on the Mega.

On thing that I did not mention was that the variable resister should be a linear type the 3 main types are as below and there markings.
Taper_______String___Asia (common) Europe America Vishay
Linear_______LIN________B______________A________B________A
Log / Audio__LOG________A______________C________A________L
Anti-log_______–_________–______________F________C________F

As can be seen there is no standard in the markings so be aware and make sure the pack says linear.

Now as for your problem Paul check the wiring as I have shown in the diagrams.As I cannot replicate what you are seeing.
I checked the ATMEL data sheets and could not find anything on the minimum current requirement on the analog inputs, as I was wondering whether 10K was to high. As the current available is only 0.0005 mA through a 10 K pot and may be giving false readings. But I also tried with a 50 k pot and worked ok.
COMPONENT WIRING
COMPONENT WIRING
SCHEMATIC
SCHEMATIC
ARDUINO-SERVO-FRITZING.zip
(205.77 KiB) Downloaded 52 times
Paul-H
Posts: 244
Joined: Fri Jun 05, 2009 3:00 pm

Re: ARDUINO PROGRAMMING, AND INTERFACING HELP

Post by Paul-H »

Hi

It must be something to do with the shield I am using, will double check my connections later.

I followed your diagram and it appears to be working as expected see below and the servo is doing a full end to end sweep

My servos are the Chinese SG90 and the pot is linear
Screenshot (3).png
Paul-H
Posts: 244
Joined: Fri Jun 05, 2009 3:00 pm

Re: ARDUINO PROGRAMMING, AND INTERFACING HELP

Post by Paul-H »

Had a look at the shield wiring and its all working fine now, don't know what I did wrong but now getting full movement on the servo without any glitches
Screenshot (3).jpg
timbologist
Posts: 372
Joined: Wed Sep 18, 2013 6:39 am
Location: Hazeldene Victoria Australia ( in the bush )

Re: ARDUINO PROGRAMMING, AND INTERFACING HELP

Post by timbologist »

Hi Paul glad you sorted it out.

One thing I tried was connecting the positive side of the pot to the 3V3 pin on the Mega and got a reading of 0 to 138.
Paul-H
Posts: 244
Joined: Fri Jun 05, 2009 3:00 pm

Re: ARDUINO PROGRAMMING, AND INTERFACING HELP

Post by Paul-H »

Thanks

I await the next step

Paul
timbologist
Posts: 372
Joined: Wed Sep 18, 2013 6:39 am
Location: Hazeldene Victoria Australia ( in the bush )

Re: ARDUINO PROGRAMMING, AND INTERFACING HELP

Post by timbologist »

Hi Paul and others, here I have a basic set-up for a point controller using an Arduino Mega.

The code has been written in the KISS style so beginners can follow it easier, no advanced programming or magic tricks involved. At the moment it is very basic in operation throw the switch and the servo moves to the opposite end of it's travel quickly. There is no de-bounce or any other routines included. This is a version to get you going, following version will have the slow motion and de-bounce included, I have not ported that over from my version yet. The code is well commented so you should all be able to follow it. and if there are any questions please ask.

I have used the internal pull-up resisters to remove the need for external resisters. The switches are open circuit one direction and pull to ground when closed, when open the internal pull-up holds the input at 5 volts. So the switch attached to A0 controls the servo attached to pin 2, you will notice in the code I always start numbering from 0 as computer code starts from 0, hope that does not cause confusion.

The code window has the bottom section of the config file that contains where the maximum and minimum angles for each servo are placed at the moment the values a test values.

I have not shown any other code as that is a bit to long to post here, the code and the Fritzing files are in the attached zip files.

Code: Select all

const int minPoint00 =   0;      // MINIMUM THROW FOR POINT00
const int maxPoint00 =  90;      // MAXIMUM ANGLE FOR POINT00

const int minPoint01 =  10;      // MINIMUM THROW FOR POINT01
const int maxPoint01 = 100;      // MAXIMUM THROW FOR POINT01

const int minPoint02 =  20;      // MINIMUM THROW FOR POINT02
const int maxPoint02 = 110;      // MAXIMUM THROW FOR POINT02

const int minPoint03 =  30;      // MINIMUM THROW FOR POINT03
const int maxPoint03 = 120;      // MAXIMUM THROW FOR POINT03

const int minPoint04 =  40;      // MINIMUM THROW FOR POINT04
const int maxPoint04 = 130;      // MAXIMUM THROW FOR POINT04

const int minPoint05 =  50;      // MINIMUM THROW FOR POINT05
const int maxPoint05 = 140;      // MAXIMUM THROW FOR POINT05

const int minPoint06 =  60;      // MINIMUM THROW FOR POINT06
const int maxPoint06 = 150;      // MAXIMUM THROW FOR POINT06

const int minPoint07 =  70;      // MINIMUM THROW FOR POINT07
const int maxPoint07 = 160;      // MAXIMUM THROW FOR POINT07

const int minPoint08 =  80;      // MINIMUM THROW FOR POINT08
const int maxPoint08 = 170;      // MAXIMUM THROW FOR POINT08

const int minPoint09 =  90;      // MINIMUM THROW FOR POINT09
const int maxPoint09 = 180;      // MAXIMUM THROW FOR POINT09

const int minPoint10 = 180;      // MINIMUM THROW FOR POINT10
const int maxPoint10 =  90;      // MAXIMUM THROW FOR POINT10

const int minPoint11 = 135;      // MINIMUM THROW FOR POINT11
const int maxPoint11 =  45;      // MAXIMUM THROW FOR POINT11
Attachments
POINT-MOTOR-CONTROLLER-01.FZZ_bb.png
POINT-MOTOR-CONTROLLER-01.FZZ_schem.png
POINT-MOTOR-CONTROLLER-01.zip
(3.23 KiB) Downloaded 54 times
POINT-MOTOR-CONTROLLER-01.FZZ.fzz.zip
(42.44 KiB) Downloaded 55 times
Paul-H
Posts: 244
Joined: Fri Jun 05, 2009 3:00 pm

Re: ARDUINO PROGRAMMING, AND INTERFACING HELP

Post by Paul-H »

Thanks again for doing this

All working fine my end

Paul
timbologist
Posts: 372
Joined: Wed Sep 18, 2013 6:39 am
Location: Hazeldene Victoria Australia ( in the bush )

Re: ARDUINO PROGRAMMING, AND INTERFACING HELP

Post by timbologist »

Hi Paul

Glad to hear all is working ok, will gradually look at putting the slow motion part into the program. But will probably have to change how it is written as it will become very large doing everything 12 times so will have to change it to use advanced programming which I was trying not to do.
Have fun with it and any questions please ask.
Post Reply