Why is the 74HC240 wired to the L293DD motor controller this way? - Page 1
Forum section: electronics / projects

author: blubillcanada
author_rank: Contributor
timestamp: August 02, 2022, 03:01:45 am
content: This is the motor controller for a Celestron telescope. it's pretty straight forward but I can't fathom why the 74HC240 is required and why it's wired with a pair of diodes that appear to be a NOR gate from the L293DD going back to the 74HC240?Just seems odd to me, especially with all those unused output pins on the PIC16F876ANote: the PICs PWM outputs are RC1,RC2.

author: retiredfeline
author_rank: Frequent Contributor
timestamp: August 02, 2022, 03:43:39 am
content: I don't see any diodes. D might not mean diode, maybe it just marks a digital line.

author: blubillcanada
author_rank: Contributor
timestamp: August 02, 2022, 04:01:14 am
content: Diodes D1 thru D4 form a simple NOR gate.

author: retiredfeline
author_rank: Frequent Contributor
timestamp: August 02, 2022, 04:03:57 am
content: Yeah but where are the diode symbols? Are you assuming that D means diode? Are there diodes on the board?

author: pqass
author_rank: Super Contributor
timestamp: August 02, 2022, 06:32:08 am
content: Quote from: blubillcanada on August 02, 2022, 03:01:45 amThe pair of diodes form a 2-input AND gate.https://en.wikipedia.org/wiki/AND_gateThe 74HC240 is used as a convenient single package of 6 (of 8; 2 unused) inverting line drivers (Hi-Z function not used since G is grounded).When the MCUs send out a L,L on AZM_A,B or ALT_A,B then the ENn is driven L on the L293 which makes its outputs Hi-Z. Any other values (L,H or H,L or H,H) are inverted and present (driven) at the the L293 outputs. I assume the logic in doing this is so H,H brakes the stepper (output pair set to L; ie. shorted coil) and L,L lets the stepper spin freely (output pair Hi-Z; coil wires open).Yeah, the circuit could be simplified by dropping the 74HC240, 4 diodes+pullups, and just drive the ENn on the L293 from the MCUs. Oh, and why are there two MCUs vs just one + shift-register for GPIO expansion? I guess the developer enjoys multiprocessor debugging challenges.I don't know what the red-boxed bold text (D0-D8, notice missing D2) could mean. There's no diode symbol nearby.EDIT: I was assuming the attached motors are steppers but it just occurred to me that there is only one output wire pair per motor connector. So they can't be bipolar steppers (needs two output pairs on each connector). I guess they're just simple geared DC motors. Regardless, shorting the output pair (setting both wires to L) will brake the motor. Hi-Z will let it move freely.

author: m k
author_rank: Super Contributor
timestamp: August 02, 2022, 10:26:52 am
content: I'd say that HC240 is a protection against a possible transient of some sort.For dual MCU my guess is that since following a star is pretty slow process own controller for both axles guarantees a smoother operation.

author: Ian.M
author_rank: Super Contributor
timestamp: August 02, 2022, 11:36:23 am
content: The dual MCU is more likely a sign of a poor programmer*, from the era of single-thread sequential programming, and/or of piecemeal conversion from a dumb LSI logic controller. The PIC16F876 was released in 1998 and superseded by the PIC16F876A in 2001 so we can be fairly sure this design dates back to the turn of the millennium. Even 25 years ago, handling dual quadrature encoders (withoutLS7804 Encoder to Counter InterfaceICs) would have been nothing special so its almost certainly a minor revision of a much older design, updating it with a new cheaper and easier to program MCU.* Either they were probably never exposed to the basic concepts of real-time programming, (e.g. state machines, superloops, avoiding busy waits, etc.) so when the need to run two motor control processes concurrently came up, didn't push for a single MCU solution, or their boss learned their trade when dinosaurs roamed the earth, and simply didn't let them do more than a minimal update to the design.

author: ledtester
author_rank: Super Contributor
timestamp: August 02, 2022, 12:15:54 pm
content: Quote from: pqass on August 02, 2022, 06:32:08 amI think both MCUs are running the same code and act independently of each other without any coordination with one controlling the azimuth motor and the other the altitude motor.

author: blubillcanada
author_rank: Contributor
timestamp: August 02, 2022, 02:20:38 pm
content: Quote from: Ian.M on August 02, 2022, 11:36:23 amPoor / lazy programming was my first impression. The next version of this PCB (Celestron SLT series) had three PICs as a 16F505 was added to replace the expensive and appears to be out-of-production quadrature encoder ICs LS7084-S. Note the schematic is wrong in several places but gets the point across.I would love to redesign this thing just for fun. A single PIC18F27Q10 with its CLCs to help with the quadrature encoding or a RPi Pico W (if I could get my hands on one) and get those PIO to help with the quadrature encoding. The Pico W would also allow for remote functionality as described in the thread over at the Cloudy Nights forums.https://www.cloudynights.com/topic/766903-homebrew-all-in-one-wifibtusbethernetgpsjoystick/?p=11051862Want to see some strange hardware design, check out how the handheld pendant and other devices talk to the motor controller. Basically, TTL UART all tied together and a sort of busy line.http://rtr.ca/esp32_wifi+bt+gps/This all started because a faulty 7805 killed my motor board in a Celestron 127SLT I won at an auction. I was surprised to see three PICs and a motor driver, so I dug deeper as to why so many PICs to drive a pair of motors.

author: blubillcanada
author_rank: Contributor
timestamp: August 02, 2022, 02:22:29 pm
content: Quote from: ledtester on August 02, 2022, 12:15:54 pmFrom what I've read they do have slightly different firmware, they report different addresses on the UART bus (16 & 17)

author: blubillcanada
author_rank: Contributor
timestamp: August 02, 2022, 02:43:29 pm
content: More rabbit hole stuff, here's a motor with its encoders and gear train. I haven't figured out how they calculate the slop in the gears.The encoder is on the motor shaft only. The whole setup is a pair of these, motor controller PCB, power connector and some RJ12 jacks.Here's a teardown of the motor mount.https://www.cloudynights.com/topic/569987-disassembly-guide-for-celestron-slt-gt-mounts/