Pages: 1 2 [3]   Go Down
Author Topic: help micro elevator code  (Read 3008 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Edison Member
*
Karma: 26
Posts: 1339
You do some programming to solve a problem, and some to solve it in a particular language. (CC2)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
i suck so much

I think you just need to take some time to review the C syntax and the Arduino API (arduino.cc => Reference).

About the hall sensor... You need to know when the elevator reached a particular floor. Isn't the floor switch enough ?
Logged

UK
Offline Offline
Shannon Member
****
Karma: 222
Posts: 12549
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
  Floor++; 
  Floor=Floor+2;
   Floor=Floor+3;

I doubt this will end up with the correct value in Floor. I haven't reviewed the whole sketch, but I'd expect to see Floor assigned to the value corresponding to the floor it has just reached (Floor = 3; etc) or incremented / decremented by one each time is passes a floor ( Floor++; Floor--; ).
Logged

I only provide help via the forum - please do not contact me for private consultancy.

0
Offline Offline
Sr. Member
****
Karma: 1
Posts: 341
UNO
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
  Floor++; 
  Floor=Floor+2;
   Floor=Floor+3;

I doubt this will end up with the correct value in Floor. I haven't reviewed the whole sketch, but I'd expect to see Floor assigned to the value corresponding to the floor it has just reached (Floor = 3; etc) or incremented / decremented by one each time is passes a floor ( Floor++; Floor--; ).

the problem comes when the elvator moves more than one floor but i dont think thats a problem, still i can  just use Floor= 2 directly instead or just increments o decrements
Logged

0
Offline Offline
Sr. Member
****
Karma: 1
Posts: 341
UNO
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

About the hall sensor... You need to know when the elevator reached a particular floor. Isn't the floor switch enough ?
[/quote]

the whole idea of the hall sensor, its no count steps, i dont want to counr how many steps i need to reach a floor,i just want to count how many times the hall sensor changes from low to high...
Logged

Offline Offline
Edison Member
*
Karma: 26
Posts: 1339
You do some programming to solve a problem, and some to solve it in a particular language. (CC2)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

To make the hall sensor counts useful you still have to know the distance covered by the elevator for each hall sensor transition. That's not very different from knowing how many cm you elevator travels per motor step.
Logged

0
Offline Offline
Sr. Member
****
Karma: 1
Posts: 341
UNO
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i dont need to know the distance, i just need to know when they canhge the state, from low to high, and how many times it changes,

using something like

Code:
for(hallcount=0,hallcount<=3,hallcaount++)
stepper(CW) or (CCW)
Logged

Offline Offline
Edison Member
*
Karma: 26
Posts: 1339
You do some programming to solve a problem, and some to solve it in a particular language. (CC2)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you don't need to know the distance, then why do you care about how many pulses the hall sensor does ? Why not just watching the floor switches ?
Logged

0
Offline Offline
Sr. Member
****
Karma: 1
Posts: 341
UNO
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

because i dont need to know the distance i need to know how many pulse the sensor gives, because in each floor there is a magnet, that magnet "sense" the elevator, so if i want to go from the first floor to the 4th i just need to start the stepper and stop it untill the the the hallcounter its 3, i dont need to measure distance or count steps, i just need to know in which direction i want the stepper to run
Logged

UK
Offline Offline
Shannon Member
****
Karma: 222
Posts: 12549
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

because i dont need to know the distance i need to know how many pulse the sensor gives, because in each floor there is a magnet, that magnet "sense" the elevator, so if i want to go from the first floor to the 4th i just need to start the stepper and stop it untill the the the hallcounter its 3, i dont need to measure distance or count steps, i just need to know in which direction i want the stepper to run

That seems reasonable enough - and straight forward to code. My main concern with that arrangement would be whether the sensor is accurate enough to let you stop the lift accurately aligned with the floor every time.

Given that you are using a stepper motor, though, this would enable you to achieve a much simpler and more consistent result just by measuring how many steps were needed to move the lift between two floors, and then just step the stepper that number of steps in order to move the lift.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

0
Offline Offline
Sr. Member
****
Karma: 1
Posts: 341
UNO
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i was planning to count steps first but, it involves too much time because i need to regulate and meassure or maybe calculate steps, and its very annoying to do....

as for de code the truth its that the only way a found myself to program its with a "for" for every "if" in the switch sentence, and it will be very long to programm...
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In a real elevator, you'd have a switch (your magnet and hall effect sensor would work fine) that said you were getting near the floor, and a switch that said that you were at the floor. When you get near the floor, slow down and sneak up on the floor.

Or, get over it and count the steps needed to get from floor to floor. Keep in mind that in a real building, the floors are not all the same distance apart.
Logged

0
Offline Offline
Sr. Member
****
Karma: 1
Posts: 341
UNO
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

well i think i will count the steps,cos its more easy to program for a noob like me....

maybe later will post results on the code once the stepper driver its ready i will start will try the code..

thanks a lot to everyone
Logged

Pages: 1 2 [3]   Go Up
Jump to: