Elevator PI Simulator

Hi All,
I’m a recently retired elevator mechanic and have started a new hobby this week tinkering with an Arduino Uno. I picked this up with a kit I purchased from Inventr.io . As my first project, I have an old elevator building, lobby position indicator, and want to repurpose it for wall art. I’m using strips of WS2812B for my lighting simulation. I have arrived at the point I’d like to create a pause to simulate the elevator stopping at various floors randomly, then continue on to the next stop. Next I need to understand how to run six strips (elevator cars) simultaneously, each doing there own simulation using one Arduino board. I’m on my first week programing in the Arduino environment so I have a lot of questions. What I have so far, as you can see, is the leds moving up and down with a green led when ascending and a red for descending.
Any help or instruction would be immensely appreciated!
Here’s my code thus far:

[color=#1a1a1b]#include <FastLED.h>[/color]
[color=#1a1a1b]
[/color]
[color=#1a1a1b]#define NUM_LEDS  45[/color]
[color=#1a1a1b]#define LED_PIN   6[/color]
[color=#1a1a1b]
[/color]
[color=#1a1a1b]CRGB leds[NUM_LEDS];[/color]
[color=#1a1a1b]
[/color]
[color=#1a1a1b]void setup() {[/color]
[color=#1a1a1b]  FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);[/color]
[color=#1a1a1b]  FastLED.setBrightness(50);[/color]
[color=#1a1a1b]}[/color]
[color=#1a1a1b]
[/color]
[color=#1a1a1b]void loop() {[/color]
[color=#1a1a1b]  leds[1] = CRGB::Black;[/color]
[color=#1a1a1b]  leds[3] = CRGB::Green;[/color]
[color=#1a1a1b]  for (int i = 4; i < NUM_LEDS; i++) {[/color]
[color=#1a1a1b]    leds[i] = CRGB:: White;[/color]
[color=#1a1a1b]    FastLED.show();[/color]
[color=#1a1a1b]    delay(100);[/color]
[color=#1a1a1b]    leds[i] = CRGB::Black;[/color]
[color=#1a1a1b]
[/color]
[color=#1a1a1b]  }[/color]
[color=#1a1a1b]  leds[3] = CRGB::Black;[/color]
[color=#1a1a1b]  leds[1] = CRGB::Red;[/color]
[color=#1a1a1b]  for (int i = NUM_LEDS - 1; i >= 4; i--) {[/color]
[color=#1a1a1b]    leds[i] = CRGB:: White;[/color]
[color=#1a1a1b]    FastLED.show();[/color]
[color=#1a1a1b]    delay(100);[/color]
[color=#1a1a1b]    leds[i] = CRGB::Black;[/color]
[color=#1a1a1b]  }[/color]
[color=#1a1a1b]
[/color]
[color=#1a1a1b]}[/color]
[color=#1a1a1b]

What you are wanting to do is a big step up in code skill. I would advise you get more prestige with normal code first.

The technique you want to use is called a state machine, it allows running several tasks seemingly at the same time. Here is an introduction https://forum.arduino.cc/index.php?topic=223286.0

It rather depends on how lifelike you want to make your simulation. It would be fairly easy to make each elevator pick a random floor every so often and have the LEDs indicate that it goes there.

For a single elevator, I suppose that would be a fair approximation of proper operation. If you have six though, you might expect that the nearest available elevator would be summoned, so the algorithm becomes more complex.

I think you need to decide whether you're going to simulate people pressing buttons and act accordingly or whether you're going to just do something that moves your elevators around at random without pretending to be following a real optimal control pattern.

Probably best to start with the latter to get the hang of operating your LED strips.

However you do it, I suggest that you arrange to be able to run the same sequence again and again, by which I mean, don't do random picks to start with - you need to be able to test your code with the same test case(s) as you refine it.

I like the wall art idea. :grinning:

"Elevator control" is entirely trivial for a microcontroller, there is absolutely no reason you would need more than one Arduino Nano (much more practical than a UNO) and in fact, separate microcontrollers make it much more difficult to coordinate and needless to say, multiple lifts (as we use where I live) are coordinated.

Can you guys help me with finding a easy to understand book, for the beginner, on writing Arduino code? I’m currently reading “Beginning Arduino Programming” by Brian Evans. Any other recommendations?
Thanks in advance!

The Arduino cookbook is good.

A C tutorial would be helpful. Just enough of it to get through if, loops, switch, arrays and functions. You will need to pick up a bit of C++ too, but don't worry about writing your own classes to start with, even though they would actually be helpful for your elevator project. I suspect that it would be a bridge too far at this point.

Once you know the bits of C I mentioned, just experiment with the examples that come with the IDE. Tweak them, break them, debug them. Book learning will help, but eventually you will have to learn by doing.

I found this C tutorial very helpful when I was learning C.

Thanks for all of your input, I'll start reading up! One or more quick questions, after looking a bit closer at what I am working with, I decided to use Alitove WS2811 leds due to the numeral spacings on the PI. I'm thinking of wiring the position indicator up first then tinkering with my programming later. I've got seven lines of numerals to light, six for the cars and direction indicators and two for the hall calls. Not that it makes that much difference in the wiring, but can I just series all 230 leds? Or will each lift/elevator require a separate output? Or will it be operating from just one output?
I know, a lot of questions, but hanks guys for your patients, this thing is going to look great someday.

but can I just series all 230 leds? ..... Or will it be operating from just one output?

Yes they can all be made with a single strip wired to a single output, wired in an up and down zig zag or serpentine pattern.

I decided to use Alitove WS2811 leds due to the numeral spacings on the PI.

Not too sure what you mean but often the WS2811 chips control three LEDs at a time. That means every three LEDs will be identical. You need the strip to be a 5V one and individually addressable.

Here’s what I ordered to be clearer :

https://www.amazon.com/gp/product/B01AG923GI/ref=ppx_yo_dt_b_asin_title_o01_s00?ie=UTF8&psc=1

Hope they’re the correct ones!

Thanks in advance Mike

Those will work.

I don't know how deep your panel is, but you may find that led strings like those make the whole circuit quite deep, because of the length of the LEDs and the bulky cables attached. They make great Christmas tree lights! But for a wall-hanging art work, it won't be very thin.

I would have considered 5mm round apa106 LEDs, and soldered the wires myself. Or the ws2812 LEDs that come mounted on small round PCBs, and again soldered the wires myself. I would make a back panel from 3mm plywood and drill 5mm holes to mount each led. The apa106 would push-fit into the holes, and the leads could be bent flat against the plywood for soldering. With the ws2812 LEDs, the holes might need to be slightly larger and the PCB could be glued to the plywood with the led shining through the hole.

s-l1600.png

s-l1600.png

Can you post a picture of the position indicator that you want to interface the microcontroller and give some details about it. I’d probably start by attempting to interface that first, then deal with the LEDs later.

Assuming you can interface to that, the rest of the project should be relatively easy. You’d probably represent the state of the 6 elevator cars by an array. The same array would be used to control the position indicator and the led display. You’d manipulate the array to simulate the position of the elevator cars, adding random direction changes and stops of various durations.

It sounds like a very interesting project.

PaulRB:
I would have consideed 5mm round apa106 LEDs, and soldered the wires myself.

But you then really need to provide a 0.1 µF bypass capacitor for each.

PaulRB:
Or the ws2812 LEDs that come mounted on small round PCBs, and again soldered the wires myself.

Perhaps more appropriate, flatter and include not only the bypass capacitor, but also the series 75 Ohm transmission line matching resistor. :sunglasses:

Paul__B:
really need to provide a 0.1 µF bypass capacitor for each

I was wondering about that. Could not find any clear direction on whether needed or not, or built into the plastic body with the chip. The "data sheet" I found does not show them, but it looks like a very poor data sheet.

https://1drv.ms/u/s!Atktwl84Bl8weiSIzcrpe8qIaGU?e=Mq5UQK

I originally stated this would be wall art , but after I dug it out of storage, lets say heavy coffee table instead. So I don't see depth as a problem. The PI is made of 1/4" stainless 21.5" x 36" weighing in at 40lbs at least. So the wall art is out, unless I inset it into a wall somehow, maybe later. The right and left rows red/green were for the hall calls. The center 6 rows are the separate lifts, the X (requiring some sort of pause) being the blind hatch where no floor stops are present. The first up/down arrows are car direction. next up arrow, green/ red dots and down arrow, I'm pretty sure were up and down peak indicators( many requests for up or down calls). Lastly the bottom white dots indicated the car was full and it would not be stopping for any more calls. I'm sure it will take a lot of advanced coding to really do it right, but for now I just would like to wire it up proper and tinker with the coding later as I learn. I'm thinking WiFi add on to make it easier to test things.
Sorry about my link to the pictures but being new I haven't figured that out, on short notice.

OK. I get it now from the pictures. I see that you intend to use only the shell of the existing indicator panel (with any existing electrical parts stripped out) and use the LED strips as a substitute for the original position indicating bulbs behind the panel.

For some reason, I assumed that the led strips would be separate, representing the positions of the lift cars and you would use the original panel (with existing electronics) to reflect position of the leds.

Yes. Just get something basic working and gradually refine it later to more faithfully model the real elevator behaviour.

OP's pics

image0.jpg

image1.jpg

image2.jpg

The forum software likes ".jpg" but does not like ".jpeg" for some reason.

Something a little larger than 320x240 would be clearer - I'm sure an iPhone 8 can manage that?

image0.jpg

image1.jpg

image2.jpg

Oh, yes delete that please

Done. So, yeah, some pics at around 2M pixels please, and turn off "record location of image" if you intend to post pics taken at home on line!

To attach images to your post, don't use the "quick reply" but instead click "REPLY". Then you should see "Attachments and other options" under the reply box, which will allow you to select phone camera pics. When you hit "Post" they will be shown with your post. But as I said earlier, the forum does not like ".jpeg", so you will need to find a way to change that to ".jpg". I'm not an iPhone guy, so I don't know how, but others here will. Changing the file extension doesn't change the file in any way, only it's name.