Author Topic: Crazy idea? Making a PWM controller without a microcontroller? Possible?  (Read 8317 times)

0 Members and 1 Guest are viewing this topic.

Offline MarkSTopic starter

  • Supporter
  • ****
  • Posts: 825
  • Country: us
74HC393 dual 4 bit counter wired as 8 bit counter and clocked to generate a digital ramp count. For each motor connect counter to one side of 74HC684 comparitor the other side to an eight bit latch. Use the > output as a PWM. Load latch for PWM value.
To make a bit neater use a two input nand to combine '>' and '=' outputs of the comparitor.
Two 20pin parts per motor with a common 14 pin counter........needs a clock from somewhere
madmac

Yes, but how would I adjust the duty cycle? The '393 just takes an input clock signal. That's all well and good, but I've got an 8-bit binary signal from the processor and the motor controller uses the duty cycle to set the motor speed. The value presented on the data bus needs to directly correlate to the PWM duty cycle.
 

Online PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 1608
  • Country: au
74HC393 dual 4 bit counter wired as 8 bit counter and clocked to generate a digital ramp count. For each motor connect counter to one side of 74HC684 comparitor the other side to an eight bit latch. Use the > output as a PWM. Load latch for PWM value.
To make a bit neater use a two input nand to combine '>' and '=' outputs of the comparitor.
Two 20pin parts per motor with a common 14 pin counter........needs a clock from somewhere
madmac

Yes, but how would I adjust the duty cycle? The '393 just takes an input clock signal. That's all well and good, but I've got an 8-bit binary signal from the processor and the motor controller uses the duty cycle to set the motor speed. The value presented on the data bus needs to directly correlate to the PWM duty cycle.
In that description the 20 pin 74HC684 comparitor takes the 8 bit value and compares with the ramp

TI can sell you 74HC684 for $3.583/1k   8)

 
The following users thanked this post: MarkS, Someone

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6416
  • Country: fi
    • My home page and email address
TI can sell you 74HC684 for $3.583/1k   8)
Mouser has a few dozen in stock, for 7.3€ (TI SN74HC684DW) or 10.7€ (TI SN74HC684N) apiece.  :popcorn:
 

Offline MarkSTopic starter

  • Supporter
  • ****
  • Posts: 825
  • Country: us
In that description the 20 pin 74HC684 comparitor takes the 8 bit value and compares with the ramp

 :palm:

The 74HC682 is virtually identical and still active.

One 74ACT16373 with two 74HC393's and 682's should work and allow me to use the full 16-bit data bus to control the two motors... Hmm....
« Last Edit: July 10, 2023, 09:21:39 pm by MarkS »
 

Offline RES

  • Regular Contributor
  • *
  • Posts: 109
  • Country: 00
LTC6992 - TimerBlox: Voltage-Controlled Pulse Width Modulator (PWM)

or

design a stable two stage transistor only PWM generator; triangle wave oscillator + comparator
« Last Edit: July 10, 2023, 10:14:47 pm by RES »
 

Online PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 1608
  • Country: au
One 74ACT16373 with two 74HC393's and 682's should work and allow me to use the full 16-bit data bus to control the two motors... Hmm....

I think you mean one 16373 or 16374 latch and one 74HC393 and two 682's ?
You will likely need a D-FF on the 682 output, as the 393 is a ripple counter so will give glitches.

You should always sanity-check this against a small MCU with maybe 1~2 dozen lines of assembler, to init the PWM block, and copy ports to pwm.
 
The following users thanked this post: MarkS

Offline MarkSTopic starter

  • Supporter
  • ****
  • Posts: 825
  • Country: us
I think you mean one 16373 or 16374 latch and one 74HC393 and two 682's ?

Yes.  :palm: :palm:

You will likely need a D-FF on the 682 output, as the 393 is a ripple counter so will give glitches.

Good idea!  :-+ I forgot about ripple counter stability issues.

You should always sanity-check this against a small MCU with maybe 1~2 dozen lines of assembler, to init the PWM block, and copy ports to pwm.

I've got an Arduino, multiple ESP-based microcontroller board and a Pico. That will not be a problem.
 

Offline gnuarm

  • Super Contributor
  • ***
  • Posts: 2246
  • Country: pr
I think you mean one 16373 or 16374 latch and one 74HC393 and two 682's ?

Yes.  :palm: :palm:

You will likely need a D-FF on the 682 output, as the 393 is a ripple counter so will give glitches.

Good idea!  :-+ I forgot about ripple counter stability issues.

What "stability" issues???  Ripple counters have no issues decoding a terminal state without additional latching, if that's what you are talking about.  The carry is not a signal that enables FFs, it is simply the Q output, which is used as a typically falling edge clock.  That means, every intermediate state, as the "ripple" propagates through the counter, is a lower numeric value, than the terminal state. 

Are you detecting intermediate states?
Rick C.  --  Puerto Rico is not a country... It's part of the USA
  - Get 1,000 miles of free Supercharging
  - Tesla referral code - https://ts.la/richard11209
 

Online PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 1608
  • Country: au
I've got an Arduino, multiple ESP-based microcontroller board and a Pico. That will not be a problem.
The PICO PIO state engine could likely manage this, stand alone, so an interesting challenge would be to do this entirely within a PIO, and then you have done it 'without a microcontroller'  ;)

If you want to apply this rule
However, when I say "retro", I really want to mean retro, i.e., any component available pre-1990's.
You could use any (modern) 8051 MCU with a PCA, as all that was designed and available pre-1990.
 

Offline MarkSTopic starter

  • Supporter
  • ****
  • Posts: 825
  • Country: us
With a little bit of tinkering in Logic.ly, I got madmac's idea to work. Logic.ly is just a toy when compared to LTSpice and whatnot, but it's a clever and easy to use little toy!

You can use Logic.ly's online demo to open and run the attached file.
 

Offline madmac

  • Contributor
  • Posts: 13
  • Country: gb
Going for 16 bit control might make the 74HC393 clock a bit high depending on the PWM frequency you want.
Retro designs going back to the mid eighties. 8 DC servo motors with incremental encoders plus 74HC684 / 74HC573 / HCTL2020 (16 bit position count)  for each motor and a 12MHz 8051 with crafted 8 x PID loop assembly code.
Serial RS485  input for control.
madmac
 

Offline r6502

  • Regular Contributor
  • *
  • Posts: 130
  • Country: de
Hello all,

Have a look at some older Keithley stuff. They used also PWM as DAC for analog signal generating, e. g. in K263 current calibrator.

Have a look on the part of the schematic, where thy do the PWM, attached to this post.

Guido
Science can amuse and fascinate us all, but it is engineering that changes the world - - Isaac Asimov
 

Offline MarkSTopic starter

  • Supporter
  • ****
  • Posts: 825
  • Country: us
Going for 16 bit control might make the 74HC393 clock a bit high depending on the PWM frequency you want.
Retro designs going back to the mid eighties. 8 DC servo motors with incremental encoders plus 74HC684 / 74HC573 / HCTL2020 (16 bit position count)  for each motor and a 12MHz 8051 with crafted 8 x PID loop assembly code.
Serial RS485  input for control.
madmac

The motor controller I'm going to use requires a 20 KHz PWM frequency. But maybe I'm misunderstanding you?
« Last Edit: July 11, 2023, 03:30:52 pm by MarkS »
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6416
  • Country: fi
    • My home page and email address
20 kHz PWM frequency at 8 bit duty cycle resolution = 20,000×28 = 5,120,000 or 5.12 MHz clock.
20 kHz PWM frequency at 16 bit duty cycle resolution = 20,000×216 = 1,310,720,000 or 1.31 GHz clock.

Remember, during each PWM period, the your counter counts through all values.
The Nexperia 74HC393 and 74HCT393 maximum clock frequency depends on supply voltage, but at 5V you can expect at least 20 MHz (but in room temperature up to 99 MHz).  20.48 MHz clock can provide 10 bit duty cycle resoution for 20 kHz PWM; 81.92 MHz clock 12 bit.


 
The following users thanked this post: MarkS

Offline MarkSTopic starter

  • Supporter
  • ****
  • Posts: 825
  • Country: us
20 kHz PWM frequency at 8 bit duty cycle resolution = 20,000×28 = 5,120,000 or 5.12 MHz clock.
20 kHz PWM frequency at 16 bit duty cycle resolution = 20,000×216 = 1,310,720,000 or 1.31 GHz clock.

Remember, during each PWM period, the your counter counts through all values.
The Nexperia 74HC393 and 74HCT393 maximum clock frequency depends on supply voltage, but at 5V you can expect at least 20 MHz (but in room temperature up to 99 MHz).  20.48 MHz clock can provide 10 bit duty cycle resoution for 20 kHz PWM; 81.92 MHz clock 12 bit.




The circuit is split into two 8-bit duty cycles. The counter is split between the two comparators, but is only counting from 0 to 255. Each comparator is connected to a separate byte of the data bus. A 5 MHz clock is well within the tolerance of the '393. If I'm not understanding, please explain further.
 

Offline DiTBho

  • Super Contributor
  • ***
  • Posts: 3946
  • Country: gb
20 kHz PWM frequency at 8 bit duty cycle resolution = 20,000×28 = 5,120,000 or 5.12 MHz clock.
20 kHz PWM frequency at 16 bit duty cycle resolution = 20,000×216 = 1,310,720,000 or 1.31 GHz clock.

That's why I suggested the digital resistor hack: it doesn't require high clock, it has other problems.
Anyway, 5Mhz is feasable.

The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14659
  • Country: fr
Do you really need 16-bit resolution for a PWM controller that (from what I got) is meant to control motors? :-//
 
The following users thanked this post: MarkS

Offline MarkSTopic starter

  • Supporter
  • ****
  • Posts: 825
  • Country: us
Do you really need 16-bit resolution for a PWM controller that (from what I got) is meant to control motors? :-//

No no no! It's only 8-bit resolution per channel. The circuit I showed has two separate channels. The 74ACT16373 consists of two 8-bit latches in one package. The full 16-bit data bus is connected to the latch, with the lower byte controlling one motor and the upper byte controlling the second. These are two separate circuits sharing two chips (the '393 and '16373). I combined the Latch Load and Clear inputs in the simulation for simplicity. In the actual circuit, these would be gated to address decode logic and the UDS and LDS strobes from the processor.

I removed the hex displays and it makes the wiring somewhat clearer.
« Last Edit: July 11, 2023, 09:17:42 pm by MarkS »
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6416
  • Country: fi
    • My home page and email address
The 74ACT16373 consists of two 8-bit latches in one package. The full 16-bit data bus is connected to the latch, with the lower byte controlling one motor and the upper byte controlling the second.
Yep, no problem there.

I read:
Going for 16 bit control might make the 74HC393 clock a bit high depending on the PWM frequency you want.
as a side note, saying that two 8-bit PWM channels are fine, but using full 16 bits for a single channel would require a low PWM frequency, as the 74HC393 is limited with respect to the input clock rate it can handle.  The mentioned Agilent HCTL2020 is a 16-bit counter with an 8-bit parallel interface; looking at the datasheet gives ideas on how these were used back in the day.
 
The following users thanked this post: MarkS

Offline MarkSTopic starter

  • Supporter
  • ****
  • Posts: 825
  • Country: us
as a side note, saying that two 8-bit PWM channels are fine, but using full 16 bits for a single channel would require a low PWM frequency, as the 74HC393 is limited with respect to the input clock rate it can handle.  The mentioned Agilent HCTL2020 is a 16-bit counter with an 8-bit parallel interface; looking at the datasheet gives ideas on how these were used back in the day.

That's good to know, but I don't see any need for that kind of resolution for this application. The PWM signals will just control motor speed. This is a small hobbyist robot, not a racecar! :-DD In fact, I'm probably going to wind up using only 7-bits of the data bus per channel with the 8th bit being dedicated to direction control.
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6020
  • Country: es
« Last Edit: July 13, 2023, 03:40:14 pm by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf