Lissajous figures occur when two harmonic signals are plotted against each other. They were studied by the French physicist Jules Antoine Lissajous, which is why they are known under his last name.
Before the days of digital frequency meters and phase-locked loops, Lissajous figures were used to determine the frequencies of sounds or radio signals. A signal of known frequency was applied to the horizontal axis of an oscilloscope, and the signal to be measured was applied to the vertical axis. The resulting pattern was a function of the ratio of the two frequencies (source: Math.com).
In this exercise we will use Ubidots' synthetic variables engine to generate trigonometric series, and then plot them in XY graphs to explore Lissajous figures.
Creating a Lissajous graph
The variable "t" will be an incremental series between 0 and 1000. It will act as a seed variable for us to generate all the other functions like "sin(t)" or "cos(t). We will create that data from a Python script later on. Make sure to take note of your "variable id".
3. Create trigonometric functions using the "derived variables" option
One of the cool things about Ubidots is that allows you to generate new data from Math expressions. Inside your data source, click on "Add Synthetic Variable" and type the corresponding math formula. Do this procedure one time for each trigonometric function you wish to explore. In our case, we generated the following function:
Adding "sin(2t)" derived variable
4. Create a Python script to send data to the seed variable "t"
We have all set to start sending data!
Let's grab your Api Key from your Ubidots profile:
Make sure you have the Ubidots Python Library installed:
sudo pip install ubidots
Then create a file "send_t.py" with the following code:
from ubidots import ApiClient
# Create a Ubidots object
api = ApiClient('PUT_YOUR_API_KEY_HERE')
# Get our t variable using its variable ID
t = api.get_variable('VARIABLE_ID')
# Send a series of values between 1 and 1000
for i in range(1, 1000):
Finally, run the Python script and watch you variables get filled with dots to create nice Lissajous graphs!
5. Create the XY widgets in your dashboard
Now that we have our math functions, let's prepare the dashboard to plot some of data. Go to the dashboard tab and click on "Add new widget" then click on the "Scatter" widget type and then select which series to graph. In our case, we created 6 scatter plots.