74HC126 and I/O

I am working with a 3.3v SBC, BeagleY-AI, and looking to get I/O working in a specific manner…

I have a DM542T motor driver. It accepts Step and Direction. I am using two, separate GPIO pins for the Step and Direction. I am also using another GPIO pin for Input to the SBC which would cancel the movement of the motor…

I am currently using a 74HC126 buffer.

I can get the I/O to work but with the input works or the output works, e.g. the I/O does not work with itself in this category.

So, I command the Input to work. It works. I command the output to work, it works. I command the output to work when the input acts on an event, it does not work.

I believe so far these are the factors:

  1. Input is not hardwired to Output outside of the SBC.
  2. The 74HC126 does not have connections within itself to handle such a task.

Do you know how to wire a 74HC126 so that the Input controls the Output when I command it? I mean to ask this idea:

a. What other components would I need to successfully handle the I/O commands from the SBC (GPIO) to the 74HC126 (buffer) that is tri-state?

b. Is it even possible to hardwire this hardware like I am asking?

If I am not clear enough, please let me describe more of it to you. I currently do not own any circuitry design software. So, all I can really do now is draw it out.

Basically,

--> SBC Output (GPIO 1) 
--> 10k Ohm resistor 
--> Input 1 of the 74HC126 
--> Output 1 of the 74HC126 
--> Step of the DM542T motor driver

The 74HC126 only buffers individual signals. It does not connect its channels internally. Software must connect the input and output logically.

Hi @silver2row ,

What is the supply voltage for the 74HC126?

  • If it is 5V, then the input must go above ~4V to drive output high.
  • If it is 3.3V, then the buffer cannot output high enough logic level to the driver (>4V is required for high level).

You need to supply the buffer from 5V. Use 74HCT126 for input range that is compatible with your MCU.

https://www.digikey.com/en/products/detail/nexperia-usa-inc/74HCT126D-653/1230613

Note that you do not need to use a tri-state buffer. I would use discrete low-side transistors instead (see the DM542T datasheet, page 4, figure 2).

Cheers, heke

I found a solution…

So, it seems while using the SN74HC126 for I/O from the beagley-ai to the motor driver (DM542T), my inputs really needed a set up of sorts.

So, the hardware approach was to interfere the GPIO Output to the 74HC126 with the GPIO Input and make the logic in the source code understand this set up.

I have not gotten around to making the schematic (I am still new to schematics).

Here is a “viral” on it:

You can see the hardwiring and breadboard first. It is really difficult to see the final result of the hardwiring because of the missing schematic so far. I will keep trying.

@heke ,

Hey there…Vcc is 3.3v. For some reason, the driver understands the logic at 3.3v output to input to output to the driver.

@heke , as you can tell, my wiring in the video (photo section) is a bit “abstract” for now.

I am using this buffer to handle the “tidiness” of the wiring (if it helps me at all). I will keep in mind the tri-state buffer should maybe be left aside for now and to use a low-side transistor.

!

Also…side note:

I think my current is not holding back even while the GPIO from the beagley-ai is not triggered.

I need to check more into this effort on my part. I think this is why my driver is not understanding how to keep the motor cool to the touch.

I have been researching a bit. Not too much but what I found was that motor stalls with continuous current creates heat. Lucky for me, I am not holding the motor. It gets pretty hot.

Also, since these are “simple” stepper motors, the heat really has no way to release itself away from the interior. “Radiates” comes to mind. I am still working on the schematic. Autodesk Fusion is the only CAD/CAM that handles the 74HC126 for some reason.

Hi @silver2row ,

Yeah, the driver has opto-isolators at the inputs, thus may work with 3.3V at reduced noise margin.

Your motor should not get hot. Check that the motor wiring is correct.

You do not need a design software to draw a schematic. Just use pencil and paper, and scan or photograph the artwork.

Cheers, heke

I am using GPIO and resistors to counter the Output pins from becoming damaged before the Input to the 74HC126. I may be mistaken on the forward logic but I figured SBC-Output to 74HC126-Input and then to the…well anyway. Please see below:

[ BeagleY-AI ]       ----------->    [ 74HC126 ]
 GPIO 1 to R1        ------------>       1A
 GPIO 2 to R2        ------------>       2A
     GND             ------------>       GND

   [ Vcc ]
    3.3v             ------------>       Vcc

                                     [ Output ]
                                         1Y ---------> DM542T STEP for Motor
                                         2Y ---------> DM542T DIR for Motor

[ BeagleY-AI ]       ------------>   [ Input ]
 GPIO 3 to R3        ------------> 3Y to R4 to 3.3v?


Yes sir, there is something I am missing. The source runs and performs functions but the Input to 3Y to R4 to Vcc is off maybe?

Hi @silver2row ,

You need to connect the 74HC126 pins 1OE and 2OE (and 3OE?) to +3.3V. Cannot leave them floating All unused inputs (4A, 4OE) should preferably be tied to GND. What is connected to 3A?

Use pull-down resistors for 1A, 2A, 3A as they may float during power-up.

Cheers, heke

GND.

1, 2, and 3 OE pins are all GND now. All of 4 is GND too. 3A is GND too. I think using the resistors for the GPIO pins is a good idea. Floating pins cause issue.

@heke , if I connect the OE pins to Vcc, the driver starts on its own and my movements, linear moves, start without source code.

I can use a switch to handle everything… I would rather not for simplicity.

Scratch. I am still building something that has been near perfected but for my enjoyment. Off the shelf stuff is okay but making something seems more of a learning process.

Hi @silver2row ,

If you have spare GPIO at hand, connect 1OE and 2OE pins to it and provide a pull-down resistor (e.g. 4k7). That way the signals 1Y, 2Y that go to the driver stay high-impedance, until you enable them by configuring that GPIO as output and pulling it high.

Cheers, heke

Hey @heke , I will test this soon. Thank you for updating me.

Just an update here. So, for one driver and a breadboard with the 74HC126…

  • Six GPIO pins are needed and this includes motor driver side.
    • Step (motor driver) / GPIO 1 / Output
    • Dir (motor driver) / GPIO 2 / Output
    • Enable (motor driver) / GPIO 3 / Output
    • E-Stop (BeagleY-AI) / GPIO 4 / Input
    • Limit Switch (BeagleY-AI) / GPIO 5 / Input
    • OE Pins * 3 (74HC126) / GPIO 6 / Output

This got way more complicated than a swift brush game. Please give me more time. I will need it.

Update

I think I found what I did versus what needed to be done. Like you say, for instance, use the GPIO 1 pin to handle OE of OE1. Okay. I used a GPIO 1 for OE1 with resistor configured but it is not in series from GPIO to OE. It is parallel with another pin on the 74HC126. Blah…

The data I got was off. I should have known when the motor would get hot all of a sudden, e.g. even when not performing motion moves.

Anyway, it has taken me quite some time to review and understand. I will try to handle the build soon and report back with a simple video and mark this completed. I am sorry it is taking me so long.

Hey @heke ,

Okay. I am a simpleton here. I made it 100% more complicated than it needed to be during the initial tests.

Anyway, I am having some phantom starts while plugging in the PSU.

The driver has a 5v and 24v use case on it. So, I can easily flip the switch from 5v to 24v (DM542T).

So, I am using a 24v PSU but 3.3v logic to handle the Input to the 74HC126 and then to the DM542T. It works. I can start from -240mm to 0mm to 240mm and back again… This is not a real concern so far. It is just nice to be able to use the stepper motor and ball screw for now.

I will check on the phantom power to the driver again later in the day or in the next couple of days. Literally, I plugged in the PSU/driver and the stepper motor started moving in very slow RPM moves towards the limit switch.

Hi @silver2row ,

Do not blame yourself about anticipated simpletonness, it’s learning by doing.

Is your motor still getting hot? Note that there are DIP switches on the driver to set the motor current. Try with the lowest current setting first.

Does the observed motor crawl happen also if you completely unplug the control signals (i.e. separate the SBC from the driver)? Will it also happen if you select 24V with switch S2?

Cheers, heke

Hey @heke ,

I will get on this data later. I will check the newly configured set up, crawling of the motor on PSU power on, and try to see if the crawl still happens when the driver is separated from the SBC.

I will also check 24v applied by way of S2 to see if this was the cause.

Funny thing and no, the motor was not getting hot this time around. I will attempt this work and report back.

@heke ,

Hey there…Okay.

So, I turn on the SBC. I plug in the PSU. Then, the motor turns.

Also, I leave the SBC off. I plug in the PSU. Then, the motor does not turn.

So far:

SBC GPIO 1 --> to OE 1 on the 74HC126

SBC GPIO 2 --> to Input 1 on the 74HC126

Output 1 on the 74HC126 --> STEP on the Motor Driver

Direction (DIR) is the same as Step (PULSE) but with GPIO 3 and GPIO 4 with output to the DIR on the motor driver.

The confusing part is that the manual/datasheet for the driver (DM542T) seems to say Vcc on DIR from the controller…

See here:

See the controller on the left side. DIR has a Vcc marking but it goes nowhere.

I always thought when not using ENABLE (GPIO) from the controller side (SBC), I would just have the motor driver engaged with it being in a held torque state. Anyway…back to square one for me.

The diagram is what I have currently set up on the breadboard from the SBC to breadboard (74HC126) to motor driver.

My GND was off on the breadboard. It seems to be working now…

Solution

SBC GPIO 1 --> to OE 1 on the 74HC126

SBC GPIO 2 --> to Input 1 on the 74HC126

Output 1 on the 74HC126 --> STEP on the Motor Driver

SBC GPIO 3 --> to OE 2 on the 74HC126

SBC GPIO 4 --> to Input 2 on the 74HC126

Output 2 on the 74HC126 --> DIR on the Motor Driver

Put a 0.1uF Cap from GND to Vcc on the 74HC126.

Just for reference here:

1. I think I may not need to use OE at all.
2. The reason I may not need OE 1 - 3:
   a. My source does not call in code OE 1 - 3.
   b. The driver still acts like OE is called on 1 - 3.
   c. This is without ENABLE on the motor driver using positive.
3. So, I am using negative on ENABLE from the driver only.

If this seems like an okay way to go about things, please let me know.

Also sir, I forgot to set up the grounding well enough and this is causing jittering until I run a program. For instance, all unused pins should be pushed to GND or Vcc.

In my case, do you think I should use GND or Vcc for the remainder of the unused pins?

Update

Just to reiterate here, I am receiving jittering on PWR ON from the PSU while the SBC is plugged in. Once running some type of program, the jitter stops but I will need to reboot the system from time to time…

Another Update

You were right about the S2 switch and 24 volts compared to the 5v switch which is used under 24v from a PSU. Blah. Gosh, this just keeps getting more complicated. The jittering is gone with the 24v/5v switch (S2) set to 24v but now nothing is working on the driver. No motor movement and high heat with the same set up… Blah. I will keep trying.

Third Update and Last One Hopefully…

Okay. So, PUL should not be a GPIO pin. It should be a PWM peripheral pin from the SBC. Then, I can set up the 2.5uS differences in ON/OFF while the PWM pin is HIGH or LOW. Gosh. Let me know what you think when you have time, please.

Second to Another Update

So, I went back to 5v on the switch to the driver. I then proceeded to use a 12v PSU. Nothing is working again. I am almost out of ideas.

Hi @silver2row ,

First of all, do not give up :).

If your stepper motor is rated 24V, you’ll need to use 24V supply. If the supply causes SBC reboots, it is not beefy enough. Thy other supply and use as short wiring as possible.

If the motor crawls only when the SBC is plugged in, it means that the SBC is toggling the PUL GPIO for some reason. Of course if the ground wiring was missing somewhere, that certainly causes all kinds of weird states.

It may be a good way to first programmatically control the GPIO pins to make the system work, and after that think about using PWN or other timing functions for the pulse generation.

The VCC on manufacturer’s datasheet’s diagram goes to a stable power supply (in your case is the supply of the 74HC126). All three transistors (for PUL, DIR and ENABLE) are connected to VCC, It is a bug in the diagram where only one transistor is connected to VCC.

Cheers, heke

That last part about the “bug” in their diagram…

  1. This would explain a lot…
  2. For instance, why I am getting various applications with similar wiring to/from the SBC.
  3. And…yes. The GND pin(s) were off of the 74HC126.

I will get back on it. I did give up. I used a logic level shifter instead with no success so far.

I will try again…

Thank you.

@heke ,

Just to reiterate what has been stated so far:

  1. Would I use common-cathode connections or common-anode connections from their DM542T diagram?
    1. If common-cathode, would GND to the SBC in this case control the motor driver from ENABLE -/negative?
  2. If using the common-anode style, which I have not been using, would I need to apply a 1k ohm resistor and where would I apply this resistor?

I feel I have tried various applications without success and “without success” is mostly due to the motor overheating quickly while applying commands to the GPIO pins through the 74HC126 to the driver…

Right now:

a. GPIO 1 --> 1A Input of the 74HC126 --> 1Y Output of the 74HC126 --> PUL + of the driver

b. GPIO 2 --> 2A Input of the 74HC126 --> 1Y Output of the 74HC126 --> DIR + of the driver

c. Vcc (3.3v) --> Vcc of the 74HC126 --> 0.1 uF capacitor to GND --> GND of SBC

d. All -/negative pins on the motor driver are connected and finally go to GND of the 74HC126

I think this is called common-cathode on the datasheet. Should I be utilizing common-anode at all?

If so, I will just rewire the motor driver.

And…should I use Vcc and GND from the SBC to chip to driver?

I tried both common-cathode and common-anode types of connections and have come to one conclusion:

  1. No matter the connection type of the SBC, 74HC126, and DM542T, there is going to be a connection issue:
    1. Here are the connection issues as I see so far:
      1. creeping/crawling of the motor when powered on
      2. no movement and enabled
      3. movement and enabled and the motor housing gets extremely hot
      4. no movement and not enabled
      5. movement and not enabled
  2. I tried a resistor but I am currently unsure as to where it belongs on the DM542T.
    1. I applied the resistor to EN +/- with a line to GND (common-cathode and crawling to PWR of SBC)
    2. I applied the resistor to EN +/- with a line to Vcc (common-cathode and crawling at PWR to PSU)
  3. I will try another form of connection soon, e.g. as I am out of ideas.

Seth