Simple elevator for my hobby

For my hobby I want to get my simple elevator to move up and down using one mometary push button.
At the bottom and top of the elevator shaft I have reed contacts and on the lift itself a magnet.
I have an Arduino Uno, an LN293D motor shield, DC 6 volt transmission motor and as said 2 reed contacts.
Assuming the elevator is on ground floor...
If the button is pushed the elevator should go up and stop as soon as the top reed contact is activated.
Next time I push the button the elevator should go down (so reverse power to the DC motor) and the stop as soon as the bottom reed contact is activated.
So stopping and prepare to move to the other direction should be inserted in the code.

As I am absolutely new to working with Arduino I hope somebody can help me with the neede code to use these reed contacts correctly, so stop the elevator and make the direction change.
How to turn on and off the DC motor I can find in the examples, but the way I need to make it work (also easy to use for my grandchildren) is to difficult for me (69 years old)
If I understand the way it should work I can extend the code myself I think, as also some LED's should blink on top of the elevator.
This all is used in my modeltrain scenery with a mountain in it, a restaurant on top of the mountain. The elevator is selfmade and approx 30 cm high (just to inform)
Hope somebody can help.

Thank you,
Bob

What do you have (hardware and software) so far?

There are elevators that are pulled from the top and there are ones pushed from the bottom. Which will your be?
Paul

This post is almost tailor made for you.

1 Like

Thanks Bob for taking this on at 69.... I am 65 so can sympathise especially with the high expectation of GKs!
Some things to take into account at this system design stage:

  1. Switch debouncing
    The limit switches and even the PB switch will need to be debounced to avoid unwanted behaviour. Debouncing can be done using hardware or software. By hardware requires each sw input having an external resistor + capacitor. he RC network prevents the unwanted oscillations when the switch contacts mechanically bounce when closed and/or opened.
    The other method is to "debounce" the incoming signal to the micro. This method uses a simple counting routine to determine when you have a valid new signal change as opposed to a spurious Hi or Lo due to EMI or bouncing.
    More help available from forum or me. Happy embedded systems programming!

Further to my post on switch debounce and ways to deal with it. I now believe you can avoid having to anything for the following reasons:

  1. I note you are using reed switches. I was assuming they were mechanical. Reed switches should not bounce due to the hysteris of magnets i.e. the turn on moment is different to the turn off.
  2. The PB switch will bounce but no need to debounce for false and multiple triggering. Just allow a small delay (say) 50ms after the first detection of the elevator at top or bottom before reading the PB. You are safe then to wait for the first active transition of the sw and then send the car up/down. It also ignores PB activation when the car is between floors.
    Hope this helps
1 Like

Hello Bob
The solution for this elevator task can be either coded in C or in C++.
My basic design for this elevator task is done by using C++. C++ is more comfortable by using a none class declaration of objects and services = methods to process these objects. That sounds crazy a little bit, but thus will result into a small compact a good maintaible sketch.
And now the details:
Objekt INPUT: all contacts like push button and reed contacts.
Service INPUT: debouncing, state change detection and start of related process.
Object Motor: all contacts for motor control,
Services Motor: start/stopp and left/right actions
Object Timer: declaration of needed members to do timing.
Service Timer: a time handler takes care about input debouncing, blinking of Leds and if needed a emergency shoot down in case of the cabine will not reach the target in time.
In case you like this basic design for your project you may send a PM to start the detailed design for the elevator project.
Have a nice day and enjoy coding in C++.

1 Like

I am away today and will answer questions as soon as I am back.
Found afterwards a mistake in my describtion, so I must correct it.
The elevator itself I have from somebody no longer working with it, he build it.
The Arduino Uno lost it's programm and I must make a new one with some more features.
I just did see there are three reed contacts and I don't know where the one is for I discovered early this morning.
As said, I will tell more later today, maybe with a picture or so.
So far thanks to all for answering...
Bob

All info I received today I will study and see if it helps me further.
But as asked by some you and as promised by me, here some more info.

This is the hardware:
Arduino UNO R3
MK Electronics Motor Control Shield L293D (4 motors / 2 servo-stepper (spare one is from Iduino))
DC - 6V / 50RPM motor with gear
3 reed contacts
pushbutton (momentary) with integrated illumination (LED)
4 mini LED's (on top of the elevator)

The dc motor is located on the ground floor and pulls up/lowers the elevator through the shaft with a strong wire via 2 rollers (one at ground floor, one on the top). The elevator itself (with the 'people' in it) is pretty heavy so going down is easy when the motor turns backwards.
On top of the moving elevator part (sorry I don't know how this is called) is a small but strong magnet.
On the proper locations at the side of the shaft are the 3 reed contacts to get the signal to stop the elevator in time.
One is about 7 cm from the bottom, the second is at about 85/90 percent from the bottom and the last (security one???) is almost on top where the elevator really must stop.

What I understand from the (pretty old) maker of the elevator is this.
At poweron the elevator goes upwards when the last action (also before a powerdown) was down.
It will go downwards when last action was going up. So somehow the last action will always be remembered.
Also there is a delay of about 30 seconds after an upwards movement before it automatically goes down.
Then pressing the momentary (on demand) switch this whole story starts over again.
There are no doors that open or close, it is H0 size for a model train.
The LED's on top are always blinking, the LED in the momentary switch starts blinking some time after an up/down action to let the whole not get overheated and at that moment one can press the switch for a new action.

When it was still working I remember that it looked as if the elevator slowed down reaching the second reed contact and continued to the top floor, but I am not sure about this. It is a pity that one cannot download the code in readable C++ format from the Arduino UNO. I think that the UNO is partially 'defective'. The maker cannot find the sketch code (C++)
Some simple functions work from the UNO, others not. I hope I can get it back to work with new parts, so that my grandchildren and I enjoy this for the rest nice elevator.

Connections as they are now:
DC motor is connected to M4
the analog pins are used!
A0 - LED's inside the momentary switch
A1 - LED's on top of the elevator
A2 - momentary switch
A3 - reed contact on top
A4 - reed contact at ~ 90% heigth
A5 - reed contact at bottom
Gnd wire to the ground pin on the motor shield

Thanks,
Bob

How sure are you that the Arduino is the problem? It is of course quite possible that it is, but I'd be more suspicious about the wiring and other components at the start of the investigation.

The code you will need if you have to replace it should not be too tricky to construct - especially if you can find someone local to work on it for beer or the like.

This web site has a pretty good list of elevator parts and names and how they work: PArts list.

Paul

While that is true, if the Arduino is still somewhat functional, you may be able to pull the compiled version from it. You can then burn that to a new Uno and test with that to ascertain whether the old one had some dead pins or other issues.

A real masochist/expert could likely derive the original code to a certain extent from the extracted binary.

1 Like

I have been testing a bit more and think the hardware of the Arduino is ok.
But somehow the elevator is not functioning any longer as I remember it did.
Wiring I tested but that is all ok, the reed contact work fine as well.
So I wonder if the code is corrupted somehow. I have no experience with Arduino so far, so I don't know if an Arduino with corrupted code can still work a bit with that code.

During my working life I was a field service engineer, last years as a support engineer, fixing Computer pheriperals, later on also software problems.
I did some programming on 8080 and 8085, using low level, so machine, language.
Also I worked with Unix/Linux, Windows from CP/M, DOS and Windows 3 and up and I did use Basic and dBase. A pity, not C++ or so.

I have seen one can extract the code at command level and the result is a hex file I believe.
And until now I haven't met somebody in the neigbourhood using Arduino for a longer period, so who can help me on this.

As soon as I have found a code that can be used as a base for this elevator I can study it and I am sure I understand enough from C++ then to get it working, maybe better than before.

It is just a mini elevator in a model train scenery :wink:.
And the parts are not the problem.
Thanks anyhow

Paul, I will look at your suggested code

I've never heard of the code on an Arduino getting corrupted, though I suppose it's possible.

If you're planning to rewrite anyway, just start with something simple that reads the button and the reed switches and confirm that they're functional and that the Uno is behaving itself.

Which motor shield do you have? Searching shows quite a few matches.

The original motor shield is from MH Electronics

The Arduino is the original UNO, but it seems to be an older type, not the R3

Uno type likely doesn't matter. Do you know what library is needed for the motor driver board?

I have to find out.
First new motor as the current one has broken.
The gear..

Hartelijke groet,
Bob
Verzonden vanaf mijn gsm.

-------- Oorspronkelijk bericht --------