Unable to control a stepper motor with multiple processors in parallel

Discussion in 'The Projects Forum' started by sheel, Aug 23, 2016.

  1. sheel

    Thread Starter New Member

    Aug 22, 2016
    12
    0
    Hello Everyone,
    I am working with three raspberry pi boards working for a particular task. I have programmed them such that they will all work simultaneously in different environments and the one that succeeds to complete its task, signals a stepper motor to move to a position based on the results of the program. I initially did this with a single Pi board and was successfully able to control the motor. However, with three boards working together, the motor takes no signal from any of the processors even when I have used a multiplexer (CD74HC4067). I have attached the circuit diagram below. To clarify, motor is being signalled by only one processor in a cycle.
    I am from the mechanical engineering background and a novice to electronics and have learnt about the components and their working with google. Kindly consider this and pardon me if I am being stupid anywhere.
     
  2. blocco a spirale

    AAC Fanatic!

    Jun 18, 2008
    1,438
    368
    You need to be careful when connecting the PI outputs together; are they set as inputs when not active? What is the multiplexer doing, you appear to have combined all the outputs together before they connect to it?

    And, did you notice that closing the start and stop switches shorts out the power-supply? There are lots of things wrong with your diagram.

    Explain concisely what you are trying to achieve, I can't imagine that it requires the processing power of 3 Raspberry PIs + some other stuff.
     
    Last edited: Aug 23, 2016
  3. sheel

    Thread Starter New Member

    Aug 22, 2016
    12
    0
    Thank you for the reply. I am trying to achieve something like vision based swarm robotics trying to find a template in a scene. The Pi that is first finds the template, signals the motor to move so as to change the scene.
    I am sorry I did not explain the circuit diagram. I have connected pin 4 of each Pi to the control pins of the multiplexer and have set them to LOW as default. The processor that is able to find the template, turns its pin 4 HIGH to gain access to the output pin of the multiplexer. The output pin is then controlled by pin 7. I have used the same circuit with output pin connected to an LED. The LED works as desired. However, the motor does not respond to these signals. The motor is not damaged as it works fine with a single processor.
     
  4. blocco a spirale

    AAC Fanatic!

    Jun 18, 2008
    1,438
    368
    Is it necessary to use a stepper motor?
    Can you OR the motor control signals rather than trying to switch them?
    Apart from other obvious errors; the start and stop switches still short the power-supply.
     
    Last edited: Aug 23, 2016
  5. atferrari

    AAC Fanatic!

    Jan 6, 2004
    2,644
    759
    Hola sheel,

    Let me see if I got your explanation right. Are you saying that any of your PI board, once it got the right image, could activate the motor?

    My questions, thinking of what I would do if in your shoes:

    One and only one PI at any time? Otherwise none, right? If so, isn't it an OR function: PI1 OR PI2 OR PI3? Just three diodes riding a pull down resistor came to mind...

    As Bloco says, different pins to a common point does not sound right. You are not telling the whole story or something is not right there. After all, WHAT the other pins do?

    Pull down resistors? Where are they?

    Something I learnt by myself when doing a similar thing was to write down a table of my logic (the three PI boards in this case) to see how I should use each pin.

    I feel that you are trying to solve the multiplexing by yourself and maybe in the wrong way.
     
  6. Papabravo

    Expert

    Feb 24, 2006
    10,135
    1,786
    I would control the motor with a single processor. That processor would receive messages from the others and be able to identify the processor that sent the 1st message. Problem solved.
     
  7. blocco a spirale

    AAC Fanatic!

    Jun 18, 2008
    1,438
    368
    I'm not sure that he cares which processor gets there first only that when any one "finds the template" it triggers the motor to "change the scene".
     
  8. ScottWang

    Moderator

    Aug 23, 2012
    4,848
    767
    You missed the I/O channels select input pin D(pin 13), you can't let pin D to keep floating, if you just using 8 I/O channels then you have to connected the pin D to Gnd, and another pin Inh also needs to set to Low when you want to active the I/O channels.

    CD4067 datasheet -- CMOS Analog Multiplexers/Demultiplexers.
     
  9. Papabravo

    Expert

    Feb 24, 2006
    10,135
    1,786
    Still it solves the problem of multiple processors trying to control the motor. The single processor can organize an arbitrary response to each incoming message without the conflicts in the original system.
     
  10. sheel

    Thread Starter New Member

    Aug 22, 2016
    12
    0
    It can be a stepper or a servo motor. But a motor is necessary.
    I am sorry, but I do not know how to make an OR circuit. If it is done by using diodes for each signal line, then I have already tried that. I have attached two more circuits that I tried with. But these didn't help either.
    The start and stop switches are only for triggering and do not lock. They are simple push button switches. I am sorry I didn't use the right symbols. IMG_20160824_101343.jpg IMG_20160824_101404.jpg
     
  11. sheel

    Thread Starter New Member

    Aug 22, 2016
    12
    0
    Hi atferrari,
    Yes, you got it right. I would say its an XOR instead of OR. I have tried the diode solution as I replied to Bloco, but that didn't help either.
    While using the multiplexer, I was able to blink an LED with the same circuit, but the motor does not seem to take up any signal. I used the truth table of the multiplexer from its datasheet.
     
  12. sheel

    Thread Starter New Member

    Aug 22, 2016
    12
    0
    Here I need to control the motor for different angles depending on the result of a few calculations performed by each processor. If I have to control the motor through a single Pi, I would need to transmit and receive the output data from the other two Pi. I am actually trying to achieve that using the UART communication. But I would like to know the cause of the error.
     
  13. sheel

    Thread Starter New Member

    Aug 22, 2016
    12
    0
    Thanks Scott for pointing that out. I tried that after reading your reply. I maintained the fourth control pin LOW along with Inhibit. No success yet.
     
  14. sheel

    Thread Starter New Member

    Aug 22, 2016
    12
    0
    I have learned that a multiplexer isolates each input from others and only one of the input signals is connected to the output at a time, depending on the logical status of the control pins. If I have understood it right, I don't think there should be any conflict for the motor in receiving the signals.
     
  15. sheel

    Thread Starter New Member

    Aug 22, 2016
    12
    0
    I am using Sanyo Denki 103H8221-5141 stepper motor and YS-SMS-D8 Microstepping driver.
    Just in case these make a difference.
     
  16. atferrari

    AAC Fanatic!

    Jan 6, 2004
    2,644
    759
    Please tell what pins 4, 5, 6, 7 do in each board.
     
  17. sheel

    Thread Starter New Member

    Aug 22, 2016
    12
    0
    Pin 4 of each board are output pins and operate the control pins of the multiplexer
    Pin 5 and 6 are the input pins which turn high if any other board succeeds. If these pins are high, that particular processor stops its task midway and returns to the initial state, waiting for the next scene.
    Pin 7 is an output pin to control the stepper motor.
     
  18. atferrari

    AAC Fanatic!

    Jan 6, 2004
    2,644
    759
    5 and 6 inputs, can't you go away with just one?

    Understand you are polling them, right?

    BTW, the motor has to do differently depending which board becomes active?

    Is the software exactly the same in the three boards?
     
  19. sheel

    Thread Starter New Member

    Aug 22, 2016
    12
    0
    The software is same in all the three boards. But the result depends on where the board finds the template in the given scene. This position will vary with every scene. The motor position depends on the position of the template image in the scene.
    If I go with just one pin, the circuit would be something as in the attachment. In this case, pin 4 of Pi 1 is connected to Pin 5 of Pi 2 and Pi 3. Thus, Pin 5 of Pi2 and Pi3 are interconnected. Similarly Pin 5 of Pi 1 and Pi2 are interconnected via Pin 4 of Pi3. If I turn Pin 4 of Pi1 HIGH, that turns Pin 5 of Pi2 HIGH. This would turn Pin 5 of Pi 1 HIGH due to interconnection via Pi3. Thus, Pin 4 of a Pi board would interfere with Pin 5 of the same board.
    Kindly let me know if the description was confusing
     
  20. atferrari

    AAC Fanatic!

    Jan 6, 2004
    2,644
    759
    Same in all three is good.

    You could go away with just one pin sensing the results of the 3 boards (its own one included). As I see it, you need to solve two things:

    a) In software, some code skipping the polling to avoid recognizing its own signal as coming from any of the other two. After all, the board who found a matching scene, knows it, thus why to poll?

    b) In hardware, how to bring safely to a common point the signal from 3 boards. Think of this: they are always 0 or 1 so if two output pins are low and the third goes high, somebody is going to suffer. The solution is a wired OR. Google and see where the diodes would go. By any chance, do you have any pin with an open collector output? That would fit here.

    When you have the above solved, not before, consider the logic to control the motor.

    Question: do the boards know at any time the position of the stepper? How?

    If I recall it right, Papabravo suggested one of the boards in charge of the motor. Not sure but could help depending of the answer to the above question.
     
Loading...