Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete code re-write plus new feature (frequency control) #3

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

csatt
Copy link

@csatt csatt commented Nov 21, 2019

This pull request is to add a version 4.0 of the Arduino sketch. This is a new file, so if this pull request is accepted, the previous code will remain available and unchanged.

The new feature is the ability to adjust the base frequency using the same knob that is used for LED brightness control. The code was also re-written from scratch in the hope that it will be easier to understand for anyone wanting to make their own modifications or to leverage it for another project.

Please see the header comment for the TimeFrame_V4_0_full.ino file for details.

This a complete re-write of the sketch with the following changes:

   - More comments to help reader understand how it works
   - More use of named constants for readability
   - More use of functions for readability
   - Better constant and variable names
   - Unnecessary code removed
   - On-board LED heartbeat is now always on, but code rewritten to
     not interfere with timing
   - Implementation of Paul Hutchison's improvements:
       - Glowing LED for pushbutton (OPTIONAL)
       - Frame starts in standby mode
       - Removed LED only mode
       - Additional analog input to control electromagnet duty
         (OPTIONAL)
       - Adjustments to ranges
   - NEW FEATURE: frequency control

Note that this sketch is compatible with with both the original hardware
design and with either or both of the hardware modifications added by
Paul Hutchison (pushbutton LED and electromagnet strength knob.)
However, the constants HW_HAS_PUSHBUTTON_LED and
HW_HAS_MAG_STRENGTH_KNOB must be set appropriately below.

The frequency control feature uses the same knob (potentiometer) as the
LED brightness. The ability to vary the frequency allows the user to
find the resonant frequency of the object(s). Frequency control mode is
entered by "double clicking" the pushbutton when it is in the standby
mode. The LED brightness value is captured on entry to the frequency
control mode, and the knob is temporarily re-purposed to control the
frequency. The speed control knob and the electromagnet strength knob
work as normal while in frequency control mode. Frequency control mode
is exited and normal slow motion mode is entered when the pushbutton is
pressed. At this transition, the frequency value is captured and
continues to be used while the frame is powered on. Additionally, the
value is written to EEPROM. This value is read the next time the frame
is powered on and is used until the user enters frequency control mode
again to change it.

In frequency control mode, the pushbutton LED blinks rapidly. On
hardware that does not implement the pushbutton LED, the only way to
tell that it is in frequency control mode is to go ahead and turn the
knob that normally controls the brightness and see if it instead is
controlling the frequency.
Restored the mode that Paul Hutchison had removed in which the magnet is turned off and only the LED strip is on. However, there is a constant INCLUDE_MAGNET_OFF_MODE that may be set to "false" to skip this mode.

Also renumbered the modes to be in their more logical order. This is purely cosmetic; the current code doesn't even require the numerical values to be consecutive.
The PUSHBUTTON_LED_STANDBY_PERIOD_MS constant is change from 2000 to 3000 to slow the "throbbing" down even more (personal preference).

The BASE_FREQ_HZ and FREQ_RANGE_HZ are changed to 77.0 and 14.0 respectively. This gives a frequency range from 70 Hz to 84 Hz, tunable in the new frequency control mode.
Fixed one comment and one blank line.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant