Generatore onde box

This is a simple assembly of some component that I have in the drawers.

I got an Arduino UNO r3 and a LCD display with some electronic component, because I need to simulate an encoder. In addition I have written in the program is also a second frequency which oscillates at low frequencies (nell’ order of a few cents).

The frequencies were simulated, reliably a good precision. Since I have no frequency meter in order to measure, the result can only see the display.

The first frequency range from 2 Hz up to just under 8 MHz. The task is accomplished by timer1, microcontroller, with its hardware features. In the program, however it has been preset to a limit of 50 Khz.


This does not disturb the rest dell'Arduino, much less slows the program. In order to simulate an encoder, there is also a second phase, that is in quadrature from the first.

Unfortunately, in their haste I have not found a way to reverse the phase sequence. In my purpose it is used to test the maximum speed acceptable to another project (subsequently I publish it).

A second frequency is possible by 0,01 Hz a 5 Khz.

In this configuration we have the frequency of 2 phases on legs D9 and D10, while for the slow frequency l’ output is expected to D11 leg.

The first two outputs are fixed assigned by’ hardware, while the slow frequency is possible to vary the configuration of the output pin, slightly modifying the program to the line 13. I describe further down the other variants of the sketch, for a different compilation.

Wiring diagram

Functional description

As can be seen from the diagram, there is provided a control with a button and with a potentiometer.

After the’ Start presents the following screen.

Moving the potentiometer in the position in addition to half of its value, determines which frequency you'll want to modify, then press once to enter.

So sign appears < on the respective frequency change.

To vary the value using the potentiometer as of magnitude multiplier. Half high value increases, while the lower half will subtract the value. They are therefore expected 5 multipliers. Gives 0 a 5, dependent on the position of the potentiometer relative to the center.

It is also possible three types d 'increase, operating with the button.

  1. A short strokes you advance of that value outlined by potentiometer.

  2. Hold down the’ increment advances by continuous.

  3. After a while you continue to hold the’ increase increases more rapidly. There is a compile time option to vary the
    delay.

To exit the frequency setting function, you will have to do it with a double tap on the button.

At that point, the frequency is already operating on the outputs. Returning to the main menu you can stop outputs simultaneously pressing and holding the button.

If it was instead necessary to disable one of the frequencies, It should bring its value to zero.

Description compiling options

In the sketch, there are some #define you can change, depending on your needs.

One relates to the output of the second frequency, the line 13 you can put a number of those pins that are not engaged.

from the line 5 a 10, including, are the assignments for connections to the liquid crystal display.

The line 14 It determines where you'll want to connect the potentiometer.

The line 15 is that for the button.

The line 16 It defines the period in milliseconds to validate the pressure of the button. In case it is too sensitive or less, you can adjust its value.

The line 17 it is instead used for a period of waiting for a long press on the button.

The line 18 It is the one that defines the pause period before the’ increase expedite. All’ actual expected 3 seconds.

Finally the line 19 It used for debugging. The messages will be presented to the serial. Obviously, once it is completed the tests, you will not need the serial connected, much less communication.

This sketch has already commented on the said line.

The demonstration video You note the positioning for low frequencies in order to make the three flashing LEDs, you notice accordingly.

Obviously, the high frequencies are not demonstrable on the screen and then I did not over.

The libraries used in the compilation with Arduino IDE v 1.8.1, They are included in the package which can be downloaded at link.

Last revision

I tried again to fill in the sketch with the latest Arduino IDE version and I can say I've experienced problems.
Additionally in the package there is another sketch that does not use the potentiometer for setting the value of the frequencies. Rather than using two buttons.

A button is labeled SET and the other as ENTER.

When you start comes the waiting screen that the SET button is pressed to access the low-frequency. Or if you press ENTER to access the programming of the high frequency.

If you press a double click on the SET, the frequencies will be disabled.

During the programming phase is used in the following ways:

1) If September does a double click, It is abandoned without changing the procedure.

2) If you press SET increases the current figure, until it returns to zero cliclo.

3) If you press ENTER is passed to the higher value digit and you can edit it with the SET button.

4) If ENTER is pressed and held, you complete programming and return to the value set.

Regarding the reliability of the generated frequency, I'd say it was delicious after being able to measure it.

VOTE
2 replies
  1. gvsoft
    gvsoft says:

    I would have liked to see a description of how you reach that certain frequency and parameters that distinguish.
    In my opinion more than a description of the sketch lines is a better description of the methods with which it is realized in tuue project in its forms and characteristics. Do not forget that on this site and in other similar, the articles are not read only by experts or such but many beginners who access these sites just to begin to study and understand.
    regards

    Approvals

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Specify Instagram App ID and Instagram App Secret in Super Socializer > Social Login section in admin panel for Instagram Login to work