Zanzal's Free Arduino/AVR Code

  • 1.1K Views
  • Last Post 29 August 2017
Zanzal posted this 22 August 2017

I am going to use this thread to post free code that others can use or customize as they wish. 

Attached is a software PWM snippet I worked on last night. The software PWM has some advantages over the Hardware PWM. It can be used to program more complex waveforms than the Arduino can normally produce and has good quality up to about 3 Khz. It will go higher, 100Khz+, but like any software PWM it has the usual limitations which is precision and the higher it goes the less precise the frequency and duty cycle you are requesting. I specifically wrote this one to produce as little "jitter" as possible. While it is not reasonable to expect a 16Mhz 8-bit device to produce perfect high frequency wave forms. It can be improved by running at higher Mhz and recoding it in assembly, however, there are limits to how perfect these improvements can be. Also, this is not the best implementation of a AVR software PWM, but rather it was the implementation that I needed for my purposes..

Attached Files

  • Liked by
  • Wistiti
  • Chris
Order By: Standard | Newest | Votes
Chris posted this 27 August 2017

Hey Zanzal - I have been working on a similar thing, not PWM as such, but what I call:

"***   Arduino Uni-Polar Parametric Switch V 1.0   ***"

I am using a few simple and very cheap components to detect peak current and trigger an On Pulse with in this time frame.

Early tests show some progress:

   

 

Of course, from our Parametric Research, we know why we are switching here:

 

There will be limits to my work, Read Time on the Analog Sensor will restrict the upper most frequency. 

Arduino is a great platform to experiment with, it is powerful and it is cheap. One could do what we have done for only a few dollars!

P.S: For those that don't know already, way back on: 10/01/2014 I published an article: Whats it going to take to Get OU? and also an Experiment: Paraformer or Parametric Transformers even earlier: 17/12/2013

This gives all the answers needed to understand the Parametric change in parameters needed. Including some basic math to see what sort of changes to look for. 

A more detailed post: Click Here

P.P.S: Nice Code!

   Chris

  • Liked by
  • Wistiti
  • Zanzal
Zanzal posted this 28 August 2017

That's awesome Chris. I wish I knew the basic electronics behind safely sending signals to the analog port of the arduino. Its one of the things on my todo list to figure out.. So much to do, so little time.

This weekend I wrote another Software PWM this time for the esp8266.  The problem with software PWMs is keeping the jitter down without blocking the CPU. The problem with the avr code I was using is the cpu is fully dedicated to the PWM. So if all one wanted to do was use the microcontroller for a pwm that might work, but it seems like such a waste when there is so much more it can do.

Assuming you can live with only one 10-bit analog port (or don't mind using a multiplexer) the ESP-12 is a couple bucks from Aliexpress. Its 32-bit and can be overclocked in firmware to 160MHz so it will not have issues with sample rate for frequencies in the high kHz. The ESP-32S is about $8 and has a ton of ports, dual core, etc. You can turn the wifi off on them to save power if not using it.

  • Liked by
  • Chris
Chris posted this 28 August 2017

Hey Zanzal - Keep Currents low and voltage within the analog port threshold all should be good.

The joys of single threaded MPU's or Code behind them makes multitasking difficult!

I went to the .NET Microframework for such tasks: https://www.ghielectronics.com/community/codeshare/entry/931

The thing is, the Teacher is always still a Student!

I will never stop Learning! I try to share what I have learned - You're right about Freeoresonance, it is Parametric Oscillations!

   Chris

  • Liked by
  • Zanzal
Zanzal posted this 28 August 2017

I know people really love their .NET in much the same way I love C++ and STL. Unfortunately, neither are particularly well suited for high performance micro-controller code. A single clock cycle at 160Mhz is 6.25ns. An interrupt can take several hundred clock cycles from the time the event is triggered until the handler begins to execute. There just isn't enough time to make everything nice and pretty. Its gotta be fast, no matter how ugly the code gets.

Atom + PlatformIO IDE plugin is the best I've found. Its a multi-framework IDE for C/C++ that supports Arduino, mbed, and others.. Its cross platform and works on Mac, Windows, and Linux.

When my ESP-32S arrives I'll try using the built-in hall sensor combined with a small inductor to measure the load current. We'll see if its that simple.

  • Liked by
  • Chris
Chris posted this 29 August 2017

Yes, this is true, .NET is not particularly fast, sad but true.

I will have to look into those IDE's thanks for the recommendations!

   Chris

  • Liked by
  • Zanzal
We're Light Years Ahead!
Members Online:

No one online at the moment


What is a Scalar:

In physics, scalars are physical quantities that are unaffected by changes to a vector space basis. Scalars are often accompanied by units of measurement, as in "10 cm". Examples of scalar quantities are mass, distance, charge, volume, time, speed, and the magnitude of physical vectors in general.

You need to forget the Non-Sense that some spout with out knowing the actual Definition of the word Scalar! Some people talk absolute Bull Sh*t!

The pressure P in the formula P = pgh, pgh is a scalar that tells you the amount of this squashing force per unit area in a fluid.

A Scalar, having both direction and magnitude, can be anything! The Magnetic Field, a Charge moving, yet some Numb Nuts think it means Magic Science!

Message from God:

Hello my children. This is Yahweh, the one true Lord. You have found creation's secret. Now share it peacefully with the world.

Ref: Message from God written inside the Human Genome

God be in my head, and in my thinking.

God be in my eyes, and in my looking.

God be in my mouth, and in my speaking.

Oh, God be in my heart, and in my understanding.

Your Support:

More than anything else, your contributions to this forum are most important! We are trying to actively get all visitors involved, but we do only have a few main contributors, which are very much appreciated! If you would like to see more pages with more detailed experiments and answers, perhaps a contribution of another type maybe possible:

PayPal De-Platformed me!

They REFUSE to tell me why!

We now use Wise!

Donate
Use E-Mail: Chris at aboveunity.com

The content I am sharing is not only unique, but is changing the world as we know it! Please Support Us!

Thank You So Much!

Weeks High Earners:
The great Nikola Tesla:

Ere many generations pass, our machinery will be driven by a power obtainable at any point of the universe. This idea is not novel. Men have been led to it long ago by instinct or reason. It has been expressed in many ways, and in many places, in the history of old and new. We find it in the delightful myth of Antheus, who drives power from the earth; we find it among the subtle speculations of one of your splendid mathematicians, and in many hints and statements of thinkers of the present time. Throughout space there is energy. Is this energy static or kinetic? If static, our hopes are in vain; if kinetic - and this we know it is for certain - then it is a mere question of time when men will succeed in attaching their machinery to the very wheelwork of nature.

Experiments With Alternate Currents Of High Potential And High Frequency (February 1892).

Close