Author Topic: How Fast Could Serial Bits, Read from a Table in SRAM, Be outputted?  (Read 3804 times)

0 Members and 1 Guest are viewing this topic.

Offline KerimFTopic starter

  • Regular Contributor
  • *
  • Posts: 163
  • Country: sy
Hi all,

Please note that the purpose of this topic is validating the well-known saying: “Necessity is the mother of invention... or innovation”.

I had an ATmega8 and an 8 MHz crystal for it. I needed to output as fast as possible a delta bit stream (its bits are stored as bytes in the MCU SRAM space) whose size could be 96 up to 103 bits.
The outputted serial bits are supposed to generate, after filtering, a sinewave signal.

I ended up, after many months (being not very smart), writing a code (not trivial) that outputs the bits (read from a SRAM table) at a rate of 4 MCU cycles (0.5 us). Therefore, in case of delta Nbits per cycle, the frequency of the generated sinewave is:
F_sine = 1 / (4 * MCU_cycle * Nbits)

Nbits= 96  ==> 20,833 Hz
Nbits= 97  ==> 20,619 Hz
Nbits= 98  ==> 20,408 Hz
Nbits= 99  ==> 20,202 Hz
Nbits= 100  ==> 20,000 Hz
Nbits= 101  ==> 19,802 Hz
Nbits= 102  ==> 19,608 Hz
Nbits= 103  ==> 19,417 kHz

Obviously, the sinewave loop, while running (generating the sinewave), needs to detect the last bit in the SRAM table and restart from the first bit without taking any extra MCU cycle.

For instance, while 96 bits are saved in 12 bytes (12*8-bit), the 97 to 103 bits per cycle have to be saved with an extra byte to include the extra bits, MOD(Nbits,8).
And, in a practical application, if Nbits is odd, the bit stream should be made for 2 sinewave cycles instead of one. For example, if Nbits=97, the size of the bit stream is 194 bits, saved in 24+1 bytes (the extra byte is for the remaining 2 bits).
 
Sorry, I don’t think any of the readers here has an idea now on how to write such a fast code; not because I am smarter than others but because no one likely ‘needed it’, as I did, in the first place. But, if someone did (needed it), he surely found out how to do it.
For instance, I will be surprised really if someone will be able to find the solution by searching it in the internet.

I will post my work after hearing some serious comments.

Have fun,
Kerim

Added:
Please note that I attached how I did the 4-cycle_per_bit.asm on reply #20
« Last Edit: September 20, 2023, 08:49:39 am by KerimF »
A philosopher: A living thing has no choice but to execute its pre-programmed instructions embedded in it (known as instincts).
Therefore, the only freedom, a human may have, is his ability to oppose or not his natural robotic nature.
But, by opposing it, such a human becomes no more of this world.
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 5912
  • Country: es
Re: How Fast Could Serial Bits, Read from a Table in SRAM, Be outputted?
« Reply #1 on: September 11, 2023, 04:44:38 pm »
No idea what are you talking about. Where do these "stream bits" go to?
Are you making a sort-of pwm modulation with those bits?

"After many months"... Why? Using a prehistoric atmega in 2023 is totally no sense, you have lots of *much* faster, cheaper devices!
« Last Edit: September 11, 2023, 04:46:43 pm by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Online bingo600

  • Super Contributor
  • ***
  • Posts: 1989
  • Country: dk
Re: How Fast Could Serial Bits, Read from a Table in SRAM, Be outputted?
« Reply #2 on: September 11, 2023, 05:20:56 pm »
 
The following users thanked this post: KerimF

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: How Fast Could Serial Bits, Read from a Table in SRAM, Be outputted?
« Reply #3 on: September 11, 2023, 06:10:52 pm »

Quote
I will be surprised really if someone will be able to find the solution by searching it in the internet.
Also 4 cycles/bit (including clock manipulation):  http://nerdralph.blogspot.com/2015/03/fastest-avr-software-spi-in-west.html
(Didn't find it by searching; I remember when Ralph announced it on AVRFreaks)
Using the hardware you can do 2 cycles/bit - people have used the UART (in "SPI Mode") to produce bit-banged video.

« Last Edit: September 11, 2023, 06:20:29 pm by westfw »
 

Offline KerimFTopic starter

  • Regular Contributor
  • *
  • Posts: 163
  • Country: sy
Re: How Fast Could Serial Bits, Read from a Table in SRAM, Be outputted?
« Reply #4 on: September 11, 2023, 07:08:05 pm »
No idea what are you talking about. Where do these "stream bits" go to?

They will go to a LPF (acting as a buffer too) as in the case of basic delta modulation/demodulation.
 
Are you making a sort-of pwm modulation with those bits?

No, I am just making the MCU acts as a conventional delta modulation at a relatively high rate (2 MHz in the presented example),
You surely heard of DDS (Direct Digital Synthesis). What I did could be called DSS (Delta Sinewave Synthesis).
While DDS requires an R-2R ladder, DSS just needs a somehow simple LPF, at one MCU pin, which can cover a relatively wide spectrum.
But there is always a price when the hardware is simplified, the DSS code for generating the delta stream table (satisfying a certain criteria) for every frequency is not simple at all, as it is the case for DDS. This explains why all programmers didn't think about it. Most of them, unlike I, have the privilege to use other advanced alternatives; exactly as you kindly point it out.

Just for knowledge, due to world's regulations made by the World's Elite Group since many decades ago, I don't have the privilege to order any component (I have to rely on the local retailers only) or access any site providing technical services (as advanced compilers for PCs or MCUs) to almost all engineers in the world, for free or paid. So, I have to use the prehistoric C compiler for DOS (of Borland C 3.1, I bought in the 80's) whenever I need to write a program for an in-house application. Naturally, I used to write all my MCU codes (for Z80, C51 then AVR lately) in assembly language only.

So be glad that you can get whatever you may need as tools and devices, for free or not.
On my side, I simply enjoy thinking out of the box every time I design a product for the local consumers while using prehistoric tools and components :)
A philosopher: A living thing has no choice but to execute its pre-programmed instructions embedded in it (known as instincts).
Therefore, the only freedom, a human may have, is his ability to oppose or not his natural robotic nature.
But, by opposing it, such a human becomes no more of this world.
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 5912
  • Country: es
Re: How Fast Could Serial Bits, Read from a Table in SRAM, Be outputted?
« Reply #5 on: September 11, 2023, 07:22:35 pm »
Yeah, well, similar to pwm anyways.
Ah yeah, the world power countries are totally bullies.
Like China and EEUU right now.
« Last Edit: September 11, 2023, 07:24:44 pm by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline KerimFTopic starter

  • Regular Contributor
  • *
  • Posts: 163
  • Country: sy
Re: How Fast Could Serial Bits, Read from a Table in SRAM, Be outputted?
« Reply #6 on: September 11, 2023, 07:41:06 pm »
Maybe Jesper's minidds

http://www.radanpro.com/Radan2400/mikrokontroleri/Jesper%27s%20AVR%20pages%20-%20MiniDDS.htm

Thank you for the interesting site.

As you know, DDS hardware needs an R2R ladder.
What I try saying here is using just one MCU output to generate sinewaves covering a relatively wide spectrum (20 kHz, 96 bits, down to about 650 Hz, 3088 bits). One LPF works for all, by making the delta bit rate (2 MHz here) much higher than the generated frequencies. The MCU firmware acts as a basic delta modulation to synthesize sinewaves.
A philosopher: A living thing has no choice but to execute its pre-programmed instructions embedded in it (known as instincts).
Therefore, the only freedom, a human may have, is his ability to oppose or not his natural robotic nature.
But, by opposing it, such a human becomes no more of this world.
 

Offline langwadt

  • Super Contributor
  • ***
  • Posts: 4427
  • Country: dk
Re: How Fast Could Serial Bits, Read from a Table in SRAM, Be outputted?
« Reply #7 on: September 11, 2023, 07:47:04 pm »
No idea what are you talking about. Where do these "stream bits" go to?

They will go to a LPF (acting as a buffer too) as in the case of basic delta modulation/demodulation.
 
Are you making a sort-of pwm modulation with those bits?

No, I am just making the MCU acts as a conventional delta modulation at a relatively high rate (2 MHz in the presented example),
You surely heard of DDS (Direct Digital Synthesis). What I did could be called DSS (Delta Sinewave Synthesis).
While DDS requires an R-2R ladder, DSS just needs a somehow simple LPF, at one MCU pin, which can cover a relatively wide spectrum.
But there is always a price when the hardware is simplified, the DSS code for generating the delta stream table (satisfying a certain criteria) for every frequency is not simple at all, as it is the case for DDS. This explains why all programmers didn't think about it. Most of them, unlike I, have the privilege to use other advanced alternatives; exactly as you kindly point it out.

Don Lancaster wrote about "magic sinewaves" 20 years ago, https://www.tinaja.com/magsna1.shtml

 
The following users thanked this post: KerimF

Offline KerimFTopic starter

  • Regular Contributor
  • *
  • Posts: 163
  • Country: sy
Re: How Fast Could Serial Bits, Read from a Table in SRAM, Be outputted?
« Reply #8 on: September 11, 2023, 07:50:38 pm »
Yeah, well, similar to pwm anyways.

Sorry, I didn't know that a delta modulation with a bit rate of 2 MHz (using 8 MHz crystal) could be seen as PWM.
A philosopher: A living thing has no choice but to execute its pre-programmed instructions embedded in it (known as instincts).
Therefore, the only freedom, a human may have, is his ability to oppose or not his natural robotic nature.
But, by opposing it, such a human becomes no more of this world.
 

Offline KerimFTopic starter

  • Regular Contributor
  • *
  • Posts: 163
  • Country: sy
Re: How Fast Could Serial Bits, Read from a Table in SRAM, Be outputted?
« Reply #9 on: September 11, 2023, 07:58:31 pm »
Don Lancaster wrote about "magic sinewaves" 20 years ago, https://www.tinaja.com/magsna1.shtml

Thank you too for the interesting site.
I will have a look at it.
I am curious to know the fastest rate (in MCU clock) of the delta serial bits that was achieved... 20 years ago :)
A philosopher: A living thing has no choice but to execute its pre-programmed instructions embedded in it (known as instincts).
Therefore, the only freedom, a human may have, is his ability to oppose or not his natural robotic nature.
But, by opposing it, such a human becomes no more of this world.
 

Offline KerimFTopic starter

  • Regular Contributor
  • *
  • Posts: 163
  • Country: sy
Re: How Fast Could Serial Bits, Read from a Table in SRAM, Be outputted?
« Reply #10 on: September 11, 2023, 08:19:32 pm »

Quote
I will be surprised really if someone will be able to find the solution by searching it in the internet.
Also 4 cycles/bit (including clock manipulation):  http://nerdralph.blogspot.com/2015/03/fastest-avr-software-spi-in-west.html
(Didn't find it by searching; I remember when Ralph announced it on AVRFreaks)
Using the hardware you can do 2 cycles/bit - people have used the UART (in "SPI Mode") to produce bit-banged video.

Thank you for the good reference.

My first attempt to produce delta serial bits was by using SPI. Unfortunately, the SPI protocol adds an idle state (at best, 1 MCU cycle and half, low or high which depends on the SPI user's configurations) between two consecutive transmitted bytes. This complicated the generation of the delta bit streams to achieve a low THD sinewave in certain situations. I finally decided to drop SPI and found instead a direct way to output a bit in 4 cycles while outputting the cyclic sequence of the sinewave bits.
 
« Last Edit: September 11, 2023, 08:27:02 pm by KerimF »
A philosopher: A living thing has no choice but to execute its pre-programmed instructions embedded in it (known as instincts).
Therefore, the only freedom, a human may have, is his ability to oppose or not his natural robotic nature.
But, by opposing it, such a human becomes no more of this world.
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 5912
  • Country: es
Re: How Fast Could Serial Bits, Read from a Table in SRAM, Be outputted?
« Reply #11 on: September 11, 2023, 09:52:37 pm »
I guess you're using an atmega8L (Which is 8MHz limited by spec), but did you know you you can easily overclock it to 16MHz (And even more) powering it with 5-5.5v ?
https://www.edaboard.com/threads/raising-atmega8l-speed-to-16-mhz.11601/

So you can't access any technical information but you can access the web freely?
Couldn't you enter any site and download a compiler right now?
Or get it sent by someone to your email?

I had a friend in Cuba circa 2006 with the same issues, the libraries had literature about electronic valves (at best), I remember burning and sending him several DVDs with datasheets, books, programs, lots of stuff for PICs, even some PICs I had from free samples, but it arrived opened and empty.
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 
The following users thanked this post: KerimF

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: How Fast Could Serial Bits, Read from a Table in SRAM, Be outputted?
« Reply #12 on: September 11, 2023, 10:15:29 pm »
Quote
Unfortunately, the SPI protocol adds an idle state (at best, 1 MCU cycle and half, low or high which depends on the SPI user's configurations) between two consecutive transmitted bytes.
The AVR UART in SPI mode doesn't have the extra bit (it's double-buffered on Xmit), which is why the video hackers used it instead of the SPI interface...
 
The following users thanked this post: KerimF

Offline peter-h

  • Super Contributor
  • ***
  • Posts: 3698
  • Country: gb
  • Doing electronics since the 1960s...
Re: How Fast Could Serial Bits, Read from a Table in SRAM, Be outputted?
« Reply #13 on: September 12, 2023, 07:39:06 am »
Why not just have a table in RAM, DMA in circular mode, and either feed the internal 12 bit DAC (use a timer to set the sample rate) or get the DMA to send the data to SPI to feed an external DAC? I've done this and once you work out the config for everything, it is pretty easy and works great. Arbitrary waveform generation with no CPU software running whatsoever.
« Last Edit: September 12, 2023, 07:57:42 am by peter-h »
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 
The following users thanked this post: KerimF

Offline KerimFTopic starter

  • Regular Contributor
  • *
  • Posts: 163
  • Country: sy
Re: How Fast Could Serial Bits, Read from a Table in SRAM, Be outputted?
« Reply #14 on: September 12, 2023, 07:59:57 am »
I guess you're using an atmega8L (Which is 8MHz limited by spec), but did you know you you can easily overclock it to 16MHz (And even more) powering it with 5-5.5v ?
https://www.edaboard.com/threads/raising-atmega8l-speed-to-16-mhz.11601/

Thank you for your remark.
In my actual application, only the audio spectrum is of interest (20 kHz down to 20 Hz).
By using a 16 MHz crystal, I will get frequencies higher than 20 KHz [40 KHz and lower). This may be useful in some other applications.
 
So you can't access any technical information but you can access the web freely?
Couldn't you enter any site and download a compiler right now?
Yes, I can access the web pages. But, meanwhile, I got apologies from many technical sites for not being allowed to open their door for me; otherwise they break their rules.

Or get it sent by someone to your email?
I used to respect other's rules. So, I use only the genuine programs which I was able to download legally. For example, I use LTspice IV which I downloaded before Linear Technology was acquired by Analog Device, and AVR Studio 6.2, before Atmel was acquired by Microchip.

I had a friend in Cuba circa 2006 with the same issues, the libraries had literature about electronic valves (at best), I remember burning and sending him several DVDs with datasheets, books, programs, lots of stuff for PICs, even some PICs I had from free samples, but it arrived opened and empty.

It is good to know that you are friendly. Some Americans friends also offered me their help in this respect. They are kind, but I don't like using other's works if I am not allowed to download them directly from their source.
A philosopher: A living thing has no choice but to execute its pre-programmed instructions embedded in it (known as instincts).
Therefore, the only freedom, a human may have, is his ability to oppose or not his natural robotic nature.
But, by opposing it, such a human becomes no more of this world.
 

Offline KerimFTopic starter

  • Regular Contributor
  • *
  • Posts: 163
  • Country: sy
Re: How Fast Could Serial Bits, Read from a Table in SRAM, Be outputted?
« Reply #15 on: September 12, 2023, 08:06:01 am »
Quote
Unfortunately, the SPI protocol adds an idle state (at best, 1 MCU cycle and half, low or high which depends on the SPI user's configurations) between two consecutive transmitted bytes.
The AVR UART in SPI mode doesn't have the extra bit (it's double-buffered on Xmit), which is why the video hackers used it instead of the SPI interface...

Thank you very much for this info. I missed it. Soon, I will have a look at this feature.
And, just to be sure, I guess you mean that this also applies on ATmega8L (or ATmega8A which could be available too at our local retailers).
Thank you.
A philosopher: A living thing has no choice but to execute its pre-programmed instructions embedded in it (known as instincts).
Therefore, the only freedom, a human may have, is his ability to oppose or not his natural robotic nature.
But, by opposing it, such a human becomes no more of this world.
 

Offline Sacodepatatas

  • Regular Contributor
  • *
  • Posts: 80
  • Country: es
Re: How Fast Could Serial Bits, Read from a Table in SRAM, Be outputted?
« Reply #16 on: September 12, 2023, 08:08:34 am »
Why not just have a table in RAM, DMA in circular mode, and either feed the internal 12 bit DAC (use a timer to set the sample rate) or get the DMA to send the data to SPI to feed an external DAC? I've done this and once you work out the config for everything, it is pretty easy and works great. Arbitrary waveform generation with no CPU software running whatsoever.

I don't remember that the atmega8 had a DMA peripheral. But there is a ton of MCS51's that have high speed DMA, for example, those of the cypress FX2LP series.
 
The following users thanked this post: KerimF

Offline KerimFTopic starter

  • Regular Contributor
  • *
  • Posts: 163
  • Country: sy
Re: How Fast Could Serial Bits, Read from a Table in SRAM, Be outputted?
« Reply #17 on: September 12, 2023, 09:03:29 am »
Why not just have a table in RAM, DMA in circular mode, and either feed the internal 12 bit DAC (use a timer to set the sample rate) or get the DMA to send the data to SPI to feed an external DAC? I've done this and once you work out the config for everything, it is pretty easy and works great. Arbitrary waveform generation with no CPU software running whatsoever.

Thank you for presenting this interesting method which is surely a more practical way to generate waveform by delta serial bits.

My problem is that I just have ATmega8 in quantity and it is not suitable for it.
Since I can't get advanced AVR MCUs or DAC ICs, I had to think out of the box to let the humble ATmega8 do the job.

For instance, I had to also write a code to generate/save the delta table of every sinewave frequency of interest (set by the delta Nbits per cycle). In the actual application, there are 970 frequencies, covering the audio spectrum. This is done while scanning a range of 'delta steps' to find out the sinewave that satisfies a certain criterion. For this code, and as an in-house tool, I had to get one ATmega32 for having 2K SRAM instead of 1K (ATmega8) since the largest Nbits is 3088, besides the space needed for the sine (and cosine) table from which the delta bits could be generated (for a certain 'delta step').
A philosopher: A living thing has no choice but to execute its pre-programmed instructions embedded in it (known as instincts).
Therefore, the only freedom, a human may have, is his ability to oppose or not his natural robotic nature.
But, by opposing it, such a human becomes no more of this world.
 

Offline KerimFTopic starter

  • Regular Contributor
  • *
  • Posts: 163
  • Country: sy
Re: How Fast Could Serial Bits, Read from a Table in SRAM, Be outputted?
« Reply #18 on: September 12, 2023, 09:14:52 am »
Why not just have a table in RAM, DMA in circular mode, and either feed the internal 12 bit DAC (use a timer to set the sample rate) or get the DMA to send the data to SPI to feed an external DAC? I've done this and once you work out the config for everything, it is pretty easy and works great. Arbitrary waveform generation with no CPU software running whatsoever.

I don't remember that the atmega8 had a DMA peripheral. But there is a ton of MCS51's that have high speed DMA, for example, those of the cypress FX2LP series.

You are right.
Perhaps, someday, I will have the chance to order such MCUs; assuming I will be allowed to download the assembler of this advanced family.
I have C51 assembler for the ATMEL old MCUs.
A philosopher: A living thing has no choice but to execute its pre-programmed instructions embedded in it (known as instincts).
Therefore, the only freedom, a human may have, is his ability to oppose or not his natural robotic nature.
But, by opposing it, such a human becomes no more of this world.
 

Offline peter-h

  • Super Contributor
  • ***
  • Posts: 3698
  • Country: gb
  • Doing electronics since the 1960s...
Re: How Fast Could Serial Bits, Read from a Table in SRAM, Be outputted?
« Reply #19 on: September 12, 2023, 01:55:08 pm »
OK; being in Syria you probably can't get modern chips, which is sadly a sign of the times but understandable since they would get shipped straight to Russia... and then sent to Ukraine :)
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Offline KerimFTopic starter

  • Regular Contributor
  • *
  • Posts: 163
  • Country: sy
Re: How Fast Could Serial Bits, Read from a Table in SRAM, Be outputted?
« Reply #20 on: September 13, 2023, 04:53:16 am »
Although this is not important to many of you, but to complete the topic as I promised I attached my work ‘4-cycle_per_bit.asm’.
Thank you all for your valuable technical comments.
A philosopher: A living thing has no choice but to execute its pre-programmed instructions embedded in it (known as instincts).
Therefore, the only freedom, a human may have, is his ability to oppose or not his natural robotic nature.
But, by opposing it, such a human becomes no more of this world.
 

Offline ComradeXavier

  • Contributor
  • Posts: 15
  • Country: us
Re: How Fast Could Serial Bits, Read from a Table in SRAM, Be outputted?
« Reply #21 on: September 17, 2023, 01:21:01 am »
It got stuck in my mind that it should be possible to clock out a cyclic bit-stream in 2 cycles per bit, if a few caveats are allowed:

  • The desired bitstream must be short enough to be preloaded into CPU registers (233 bits, in my code), avoiding any memory loads. Any memory load (I think) requires two cycles, which would be too much per-byte delay.
  • The bitstream can be arranged so that each cycle starts on a repeated symbol. ijmp (and every other jump, I think) requires two cycles during which the CPU cannot prepare and clock out a bit. I expect this to be true of any interesting cyclic signal.
  • There's no time to mask bits when writing to the port. None of the other pins on the output port can be used as outputs, and if used as inputs they cannot care about their internal pullup state.

On GitHub: https://github.com/comradex/avr-delta-mod-periodic. Key files also attached in case GitHub is not accessible.
 
The following users thanked this post: KerimF

Offline KerimFTopic starter

  • Regular Contributor
  • *
  • Posts: 163
  • Country: sy
Re: How Fast Could Serial Bits, Read from a Table in SRAM, Be outputted?
« Reply #22 on: September 17, 2023, 11:37:53 am »
Key files also attached in case GitHub is not accessible.

Thank you for posting your interesting work here.
A philosopher: A living thing has no choice but to execute its pre-programmed instructions embedded in it (known as instincts).
Therefore, the only freedom, a human may have, is his ability to oppose or not his natural robotic nature.
But, by opposing it, such a human becomes no more of this world.
 

Online Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3362
  • Country: nl
Re: How Fast Could Serial Bits, Read from a Table in SRAM, Be outputted?
« Reply #23 on: September 17, 2023, 12:27:56 pm »
Recently I came across a trick that apparently helps with smoothing PWM output a lot while adding minimal hardware.

The Idea is that you make an inverted copy  of the PWM signal, and then use a second RC combination, but with the resistor and capacitor in series, and then add that to the output of the original RC filter.

The Idea is that the AC part of the two "shark fin" signals cancel each other out, while maintaining the DC output, because the inverted channels is AC coupled. When you do this, you have to modify the RC time constant to fit your new circuit.

There is more about this in the X chapters of the art of electronics, chapter 4x.25. "Ripple reduction in PWM". page 383.

I'm having a lot of *&^%$#@! with Eclipse in getting an STM32 to get something useful, and as a fallback I want to run an ngSpice simulation but I have not figured out yet how to get an (ideal) inverter in ngSpice.
 

Offline KerimFTopic starter

  • Regular Contributor
  • *
  • Posts: 163
  • Country: sy
Re: How Fast Could Serial Bits, Read from a Table in SRAM, Be outputted?
« Reply #24 on: September 17, 2023, 01:43:29 pm »
\Recently I came across a trick that apparently helps with smoothing PWM output a lot while adding minimal hardware.

I have the impression that such a technique (that uses fixed resistors and capacitors) is practical for a single frequency and for a certain well-regulated Vcc.

By the way, the ATmega8 MCU, I have, can output simultaneously two PWMs with opposite polarity (at pins 15 & 16, OC1A and OC1B, controlled by the MCU 16-bit Timer 1).

And when I need to simulate two serial bit streams with opposite polarity, I simply use two 2-input XOR gates driven each by a single bit stream of interest. The second pin of the first XOR gate is grounded (setting it to non-inverting mode). The second pin of the second XOR gate is connected to Vcc (setting it to inverting mode).
A philosopher: A living thing has no choice but to execute its pre-programmed instructions embedded in it (known as instincts).
Therefore, the only freedom, a human may have, is his ability to oppose or not his natural robotic nature.
But, by opposing it, such a human becomes no more of this world.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf