Need Help: Problem with my dimmer + stepper motor

Go To Last Post
15 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've built a system to dim three lamps (AC) and control three stepper motors. What I want to do is like:

If ldr < setpoint
  Open the blind 1/2(using stepper motor)
  If still ldr < setpoint
    Open blind full
    If still ldr < setpoint
       brighten the lamp

If ldr > setpoint
  Dim the lamp
  If still ldr > setpoint
     close blind 1/2
      If still ldr> setpoint
        close blind full

I've built the following code:
(attachment)

If I do not connect the motors (mean dim/brighten the lamps only), this code works very well. But when I connect the motors, everything mess up. Please, I really need help. I just don't know what to do again.

Thanks.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Perhaps you could post some drawings of all the communication and power connections, otherwise we are all just guessing at the cause.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think there is no problem with my hardware since I have test it one by one previously. I mean I tested the dimmer and they works well, then I tested the motors and everything is fine. I think the problem is just in the code when I tried to integrate both of dimmer and motors. Anyway I attach the proteus file if you want to see it.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Anybody ??

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The code doesn't know if your motors are connected or not, so why do you think it is the code?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Have you actually built any hardware or does this just exist inside Proteus?

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
The code doesn't know if your motors are connected or not, so why do you think it is the code?

I'm sorry, what do you mean? Previously I have succesfully control the motor as what I wanted. (motors only). The problem comes when I add the three lamps which are works well without motors.

Quote:
Have you actually built any hardware or does this just exist inside Proteus?

Yes I built the real hardware. It consists of three lamps and three stepper motors. So, any comments related to my problem?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Dondody wrote:
I think there is no problem with my hardware...

As Kartman points out, your software does not know if the motors are connected. So it must be your hardware.

Please show us your schematic along with details of your power supply arrangements.

PS, not all of us have Proteus so please post as PDF.

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think we have a bit of a language issue here. In your first post you say you "connect" the motors then it mess up.

Seems like when you combine the code, things don't work - but it works separately. Have you tried the simulator to see what happens? You might want to measure the execution time of your isrs to see how much cpu time is being consumed.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Please show us your schematic along with details of your power supply arrangements.

[/img]

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Seems like when you combine the code, things don't work - but it works separately.

^Yes, That is exactly the problem.

Quote:
Have you tried the simulator to see what happens?

Yes, I have. It is exactly the same as the real hardware. When the motors turn, all the triggering pulses are crazy.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

http://www.ti.com/lit/ds/symlink...

When energizing motor coils/inductive loads, switching diodes are usually placed in parallel with the motor to prevent the reactance from backfeeding into the source (shown on page 3 of the datasheet).

Can you test to see if your code works while not actuating the motors at all? Have everything connected but don't give a motor a command.

Furthermore, I see inputs directly coupled to the H Bridge. Try adding resistors in there, you would never really hook a low current sourcing output pin directly to a base. Put a series 1k resistor in place, maybe you are sourcing too much current out of your output pins and burning the controller up.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Can you tell me the ohms of one motor coil? Lets say its 100 ohms. You have 6 of them, so the power supply needs to be able to hump out 5V/minohms. You need bypass caps on the motor chips and all the other chips that use vcc to eat the little blips in the vcc when stuff turns on and off. Disable the int0 interrupt and see if that is messing you up. You dont have pins assigned to motor 3 yet. Can't wait to help you with the lcd stuff.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It is not a good idea to feed motors and mproc from the same point without any additional filtration.

And I do not see Vcc pin in the picture.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If the code fails in the simulator, then use the simulator to determine where it goes wrong! Short of replicating your setup, how can we diagnose the problem with such little information? I mentioned execution time - have you done any measurements? The atmelstudio simulator is good for such things.