Process Journal #1: XBee + Metronomes

Xbee Metronome
Process Journal #1
Olivia Prior

LCD screen

 

In this class, our assignment was to explore XBee radio communication through the concept of high (“H”) and low (“L”) commands as incoming data. Our class was each given an XBee radio, and an XBee breakout board to experiment transmitting and receiving radio commands. Our final assignment was to set up our XBee radios to control an actuator of our choice on Arduino that would respond to a “metronome” that was transmitting a count from an accompanying  XBee.

Part 1: Testing with the XBee Radios

Step 1: Internally sending and receiving

The first step was to connect my XBee radio to CoolTerm to test if my Arduino Micro would respond to high and low commands. I opened up CoolTerm, connected to the serial port that my Arduino was hooked up to, and tested typing “H” and “L” commands to turn on and off an LED. I had no problem with this working.

Using CoolTerm as serial communication, I type H to turn the LED on and L to off the LED.
Step 2: Connecting to a friend
Upon my initial testing, many students in the class had upfront issues with connecting to another XBee radio. I paired with a classmate in the studio and we switched our ATID to be on the same channel, and I changed my ATDL to match their ATMY. At first, my LED light was not responding immediately so we were unsure if the connection was working. We then realized there was a small lag within the communication, but were satisfied with the results knowing that we were able to transmit and receive commands to each other’s Arduinos.
To ensure that this was completely wireless, I changed the Serial library in the code to use “Serial1” to allow my Arduino to be disconnected from the machine.

A classmate and I testing out our transmitting and receiving with each other. They are transmitting “H” and “L” to control the LED light on the Arduino. 

 Step 3: Playing with new actuators
I removed the single LED and connected a small strip of addressable LED lights to my circuit. I jumped 5v to on side of the circuit as to not overpower the breakout board for the XBee on the other side which requires 3.3V. Using the same “H” and “L” commands as before, I used this data to turn on and off the strip lights. I used the AdaFruit NeoPixel library to control these LEDs.

Turning the LED lights on and off using “H” and “L” commands. 

Step 4: Changing the code

I was inspired by the realization that the Philip’s Hue Lights use a type of radio communication as controls. I have a few within my own possession and wanted to see if I could create a very simplified version. I copied the “H” and “L” command code, but rather than simply turning on and off the lights, I used different keys to change the colour of the strips. Here in the video below, I use the commands “R” for red, “G” for green, “B” for blue, “P” for pink, “Y” for yellow, “O” for orange, and “W” for white.

Creating a simplified version of Philip’s Hue Light by transmitting simple letter commands to control the hue of the LED strip. 

Part 1 overall outcome

At this point in my radio experimentation journey, the most exciting part is the ability to control one, or multiple other, devices through transmitting commands. I feel quite inspired through the mock “Philip’s Hue Lights” test to create smaller bespoke lamps for my own bedroom.

When testing by myself, the simple commands for turning the actuators on and off do not feel that different from what I have the ability to do with an Arduino solely.

When testing with others, I found that it was interesting to see the differences in “lag” depending on the radio. The classmate I was testing with had about a second delay on their commands, which led for confusion when attempting a proof of concept. The lag only went one way; when I would send commands their LED would turn on and off almost instantly. I wonder if this has anything to do with the machine speed on either side.

Part 2: Metronome

For this part of the experiment, I wanted to count how many “beats per a minute” the metronome was outputting. I decided upon this after choosing as my output, which was an LCD display.

Step 1: Choosing an output

For this experiment, I rifled through my toolkit to see what I had that would be newer and interesting to play with. I found an LCD LiquidDisplays that I had inherited from my Dad’s electronic supply and decided the use it.

LCD LiquidDisplay
LCD LiquidDisplay

I found readily available documentation for the LCD screen on AdaFruit. I followed the tutorial and connected the screen to my Arduino Uno. I was able to get a “hello world” screen up and counting the seconds that have passed.

LCD screen displaying the LiquidCrystal example which prints out “hello, world!” and on the second line counts how many seconds the program has been on.

Step 2: Connecting the XBee and LED lights

I then moved the connections to my Arduino Micro. I used the same code that worked for initial experimentation that made the addressable LED lights turn on and off. Rather than simply turning the LEDs on and off, I changed the brightness of them. I found that if I turned them on and off fully, it was too much of a drain of the power in the circuit. This would cause the LCD screen to flicker. As well, on the high command, on the screen I printed out “high” and on the low command I printed out “low”.

LCD screen connected to CoolTerm, and receiving “High” and “Low” commands to change the input of the screen, and as well the brightness of the LED strip. 

Step 3: Counting the beats

Because I was testing this at home, I wrote a pseudo metronome in my code to mimic different speeds of a count.

Mock metronome for testing purposes
Mock metronome for testing purposes

I would change the value of the metronome to get varying results. I would count the passing millisecond’s in-between counts, take 60000 and divide the result, and multiply by two to take into account the offbeat. I took this count and printed it out to the LCD screen.

LCD screen displaying a rudimentary BPM of the program

Step 4: What are you dancing too?

I took the BPM of the mock metronome, and then created statements that would print out what type of music correlated to the actual bpm that was listed. If the BPM was lower than 60 or higher than 200, messages of “slow is also good” come up, or a warning saying “Don’t dance too fast!” appear.

 

LCD screen showing the bpm of the program & what type of dance music is associated with that beat.

The one bug I have yet to fix is that the program initially detects that the bpm is half of what it is within the first couple of counts. It quickly fixes itself upon the second round of metronome counts.

Part 2 overall

I found this program to be interesting because it was not simply turning something “on” or “off”. It dynamically takes in data and will be able to print out the data accordingly so.

Testing out the screen with the metronome did not give as specific data as I thought. The range for the metronome was 100 – 5000 milliseconds, while my code is optimized for a range 200-1500 milliseconds. This is not necessarily a bad thing, as it requires someone to slowly go through the range as opposed to just cranking the potentiometer in either direction.

Overall the experiment was an interesting exercise in communication. It was interesting to see what other folks did with the metronome data in the class. Some interpreted the data to count every fourth beat, while others used the data to control servo-motors. The work altogether was interesting to see, and because of the nature of the rhythm of the metronome, it seemed to all connect in a collage-like way.

Liquid Crystal: https://www.arduino.cc/en/Reference/LiquidCrystal

Tutorial for LCD screen: https://learn.adafruit.com/adafruit-arduino-lesson-11-lcd-displays-1

Different music types: https://accusonus.com/sites/default/files/media/blog/Electronic_music_tempo-.pdf

 

Papillon

Project Name: Papillon

Project Members: Omid Ettehadi

Code: https://webspace.ocad.ca/~3170557/UbiquitousComputing/Week1/Papillon.rar

Process Journal:

The XBee Chat Exercise was a fascinating opportunity to explore the XBee devices and to test out the capabilities of the XBee and the CoolTerm Software. Wireless communication in its simplest form can lead to a much simpler connection between different devices in a project.

While doing the exercise, I could not stop thinking about how this system can replace the complicated, internet-based systems that I had used for my previous projects, and how much things would become more reliable with a much shorter lag time.

To make a metronome receiver device, I decided to start with a simple example first, to test the limits of the XBee and find out the range and the kind of packaging I could use in my project. I ran the “Physical Pixel” example and placed the device in different locations to see how different materials affect the range.

For my next step, I changed the Serial in the example to Serial1 and used another XBee with the CoolTerm software to send data to the device.

mvimg_20190113_132413For this project, I wanted to play with something that I hadn’t had the chance to play with before. I decided to create a simple piano by playing different frequencies for each note and allowing the metronome device to set the tempo for the music.

To create different frequencies, I used the “Melody” example, I turned on the speaker, waited for the period of the note and then turned the speaker off and waited for the period of the speaker again. I repeated the same procedure for 20 times so that the note is created. For the music, I chose the soundtrack of the movie Papillion and wrote down the notes for the song in an array.  Every time the device receives an H or an L, it will play a note from the array.

To add more to the project, I added a servo motor installed on a drum piece, so that after every 4 notes, the drum will make a sound as well, keeping the beat of the music.

mvimg_20190114_162206mvimg_20190114_163832

mvimg_20190115_092041

Component List:

components-list

Final Schematic:

circuit_bb

 

 

 

XBee + Metronome – Birthday Box

 

Have your own birthday accompaniment with the Birthday Box!

1.

The introduction to the XBees for our first assignment was exciting for me, as I enjoy being introduced to different ways to connect/network with low-fidelity setup. It felt as “magical” as using pub-nub in terms of seeing its potential used in many instances that require devices to talk to one another.

In testing the chat through radio, I had a bit of a challenge setting up the XBee due to problems with the serial port installation. I swapped my radio kit to the Lilypad but CoolTerm still had problems recognizing my usb port. Soon after I realized that I had to install an older FTDI drive for my Mac OSX. It was a miss-step on my part (Always remember to check your operating system!) and once that was set up, the chat worked, albeit with some missing letters when it appeared on my peer’s screen. Using this as primarily a chatting tool might prove to be faulty. Regardless of the overlap when typing simultaneously with another person, it was simple and straightforward to use. I can see myself preferring to use this in future connectivity projects.

NOTES:
ATRE – to RESET configuration.
ATID – to determine the radio channel.
ATMY – to determine your radio ID.
ATDL – to set the ID of the radio you are sending information to.

2.

Before jumping into the output sensor for the experiment, I had to make sure that my XBee can send and receive data from other radios. We all sat together and made sure that we can accomplish connections between our radios by changing the atdl configuration. After multiple tests, I realized that there was a problem with my XBee, as it can send values but cannot receive. Even with my Arduino uploaded with the changed “PhysicalPixel” example, (adding 1 after Serial) it would not activate the LED. I tried debugging it multiple ways from resetting my settings on CoolTerm to changing the circuit and trying my XBee on different breakout boards.

What turned out to be the problem was my soldering technique. I was rather sloppy in soldering the pins to my XBee breakout board and had some solder connecting pins next to each other. After fixing the problem, it was Finally able to receive values from another, with “H” turning on the LED while “L” turned it off.

img_7263
Breakout board after fixing the soldering

To complete this experiment, I decided to use the speaker as I am quite familiar with it from previous projects. I wanted to look for a tune that is more familiar with others and can be used for social events. As a result, I found a tune for the Happy Birthday song and implemented that in the toneMelody code. The Arduino code for this experiment can be found here: https://github.com/antariksacp/Birthday-Box. When the XBee receives an H, the speaker will play the Happy Birthday tune.

In regards to testing it with the metronome coordinator Kate provided, the potentiometer can be used to set how frequently the song will play. Once the values are sent, the song will play until it completes and once it receives another “H”, it will then play again. The slowest duration would be it repeating every few seconds, and the longest would have a delay of about 5-10 seconds.

In forming the circuit, I had first placed the components on the breadboard but managed to place it in the box with a smaller one. A few things I had to note were to make sure that the GND on the Arduino connected to ground, otherwise the circuit would not work(!) I tested a variety of ways to place the breadboard in the box to make sure that when closed, the radio can still receive the signal. I found that by placing it nearer to the lid proved to work (as shown in the video), as opposed to just placing it in the bottom of the box. I also used a different 8 ohm speaker than the one provided the kit as it had a slightly louder volume.

img_7267
Using the normal breadboard
box-01
Placing the smaller breadboard inside the box

There were also other possibilities to play around with the “H” and “L” values in terms of controlling the Happy Birthday melody. Perhaps once the “L” value is sent, the tune can stop instead of playing until the end, or as the potentiometer is turned to the slower values, the speed of the song can be altered instead of the frequency. For now at least, we have the traditional Birthday Box.

 

Metronome Gong

What’s an orchestra without a percussion section? This little robot bangs a gong with aplomb, filling the air with an irritating ring.

The XBee Chat exercise in class was, for me, an opportunity for play. Being able to communicate directly, free of the constraints of networking via the internet, felt like discovering the magic of chatting with a friend over walkie-talkie. Omid and I goofed around like kids, sending jokes and ASCII images back and forth through the XBees.

The freedom of being able to communicate relatively code-free, without having to worry about packets or JSON (which I must admit are a concept I still have trouble wrapping my head around) is relevatory and I’m excited to explore.

The Metronome Receiver device was an opportunity to explore an idea I’ve had since early in the first semester. I had an idea for exploring sensor-controlled percussion instruments way back in the This + That experiment of Creation & Computation that I had to shelve at the time. I had conceived of an Arduino-powered device that struck a  singing bowl when certain criteria were met. When we were given this assignment, I was excited for the chance to try it out.

I started by considering exactly what I wanted to make: a small arm that would bang a gong. Having worked with solenoids last semester I felt comfortable with their coding and operation. I bought a cheap one and tested it out.

Here was my first pass on the code, for testing the solenoid:

int incomingByte; // variable for incoming serial data
int solenoidPin = 2; //control the solenoid
void setup() {
    Serial.begin(9600);
    pinMode(solenoidPin, OUTPUT);
    }
void loop() {
    digitalWrite(solenoidPin,HIGH);
    if (Serial.available() > 0) {
       incomingByte = Serial.read();
       if (incomingByte == 'H') {
//strike the gong then recede
           digitalWrite(solenoidPin, LOW);
           delay(100);
           digitalWrite(solenoidPin, HIGH);
            }
        }
    }
}

Animated GIF - Find & Share on GIPHY

This worked nicely, though I was alarmed at how hot the solenoid got as it was required to stay engaged at HIGH for the majority of the time the circuit was active. I checked my wiring repeatedly and found no mistakes. I looked it up and found multiple sources reporting that this was normal, as long as the heat stayed uniform and did not continually increase. I resolved to keep an eye on it and not keep the circuit engaged for extended periods.

Rather than seek out a drum or gong, I decided to use the singing bowl I own. However, I noticed that the bowl had a high-pitched and long ringing peal, which I thought might be irritating. So I rewrote the code so the solenoid only fired on the third beat:

int incomingByte; // variable for incoming serial data
int solenoidPin = 2; //control the solenoid
int beat = 0; //an integer for monitoring the beat
void setup() {
   Serial.begin(9600);
   pinMode(solenoidPin, OUTPUT);
   }

void loop() {
   digitalWrite(solenoidPin,HIGH);
   if (beat >= 4) {
     beat = 0;
     }

   if (Serial.available() > 0) {
     incomingByte = Serial.read();
     if (incomingByte == 'H') {
       beat++;
     if (beat == 3){
//strike the gong then recede
       digitalWrite(solenoidPin, LOW);
       delay(100);
       digitalWrite(solenoidPin, HIGH);
       }
     }
   }
}

ubiqgong-fritz_bb

Finally, to keep the solenoid in place, I made a little stand out of a coffee cup.

Some issues still to explore and solve:

The XBee only gets reliable reception when it is physically close to the transmitter.

Even when close, it seems to miss or drop beats occasionally.

Parts:

  • Arduino Micro
  • XBee and XBee Breakout Board
  • Barrel Jack
  • 12V 2A AC/DC Adaptor
  • TIP120 Darlington Transistor
  • 1K Ohm Resistor
  • IN4001 Diode
  • Solenoid
  • Alligator clips x2
  • Wiring

Process Journal #1

1. Chat

Worked mostly as expected. Loose USB cable caused minor problems. Received possibly interference? from other radios communicating as we would occasionally receive input neither of us had sent, despite having set each other as addressees.

2. Metronome

I wanted to explore working with a servo for this. Plugging the servo in, and seeing the regular beat of its movement reminded me of the dull rhythm of working out. At first, i was just using the servo arm to push the cutout up and down, but found I could give it more life by tying a string to the wrist and attaching it to the servo arm. This way, as the arm moves away to push the cutout up, it pulls the arm in. The string relaxes as the arm resets, and lets the cutout “relax” its own arm.

The metronome itself was easy enough to coordinate with, except that I was too far to receive its signal the first time the attempt was made. There is also an obvious delay between the transmitting radio and the reception of its data on the Arduino, noticeable when it takes a few beats for the speed to change after adjusting the potentiometer.

Process Journal 1- Jingpo

In this class we had experimented with the XBee devices and explore the possibility to complement with Arduino boards(micro and feather). Firstly, we set a chat between two computers using the XBee’s without Arduino; secondly, as an extra activity, we decided to establish a chat such as the messages sent from one computer through an XBee, were received by a second XBee connected to the Arduino. Then we tried to set up communication between two Arduino.

XBee Chat Exercise:

We used the following components:
  • 2 Digi XBee.
  • 2 Xbee Explorer.
  • 2 cables.
  • 2 Computers.
  • 2 Arduino micro.
  • 2 Breadboard.
  • Several wires to interconnect the breadboard and Arduino.

Step1: Download software(CoolTerm) and driver(FTDI USB). The first step consists in achieving communication between two machines connected to the following set:

screen-shot-2019-03-01-at-10-59-01-am

 

Step2: Change the configurations of the radio in command mode. In this second part we are going to show how we can display the information transmitted between two XBee in a screen connected to Arduino. To do that, we need to understand how the XBee Explorer works:

The pins we must connect to the Arduino in order to be able to display the information sent by the other XBee module. The input voltage must be 3V instead of 5V to avoid potential problems. The XBee Explorer is not only important to connect the XBee to the computer, but also to put it in the breadboard so as connections can be set. screen-shot-2019-03-01-at-10-59-10-am

1) Attach Xbees to SainSmart boards and plug into computer

2) Open two CoolTerm Sessions and click on one of the Options buttons.

3) In the Options pop-up select the COM Port of either Xbee and then go into the Terminal Tab and select Local Echo (in order to see what is being transmitted). Then press OK. No additional changes are necessary for standard comms.

4) Repeat the above step for the other Xbee in the other port. If either time you do not see the Xbee’s port as an option, or if you plug it in with the options box open, press the Re-Scan Serial Ports button show in the red box from the above image.

5) Now press Connect for each terminal and you can now type in either and it will transmit to the other. Press Disconnect when finished with the session to ensure it is available for other programs to use.

6) We need to configure XBees to enable the communication. These radios are configured with AT commands, so we learnt some basic AT commands from AT command set:

ATRE = factory reset – this will wipe any previous settings
ATMY = my address – the label on your radio
ATDL = destination low – the label on your partners radio
ATID = pan ID – the agreed upon “channel” both radios are using to communicate
ATWR = write to firmware – this will make sure the configurations are saved even when the radio loses power
ATCN = end command mode

Open CoolTerm:

Go to Options → Serial Port

Go to Terminal → Select Local Echo

Step 3: Let’s chat!

screen-shot-2019-01-14-at-3-50-36-pm

img_0164

 

Once connectivity between the two XBee modules has been established, we can implement the part where we display the information on computer screen.

 

Metronome Receiver Device:

Arduino Code:

Use “Serial” to test the code. Change “Serial” to “Serial1” when arduino is connected to xBee and send the “H” and “L” commands via the serial monitor.

Sample Code is from Arduino example, Physical Pixel. It is an example of using the Arduino board to receive data from the computer.

screen-shot-2019-01-14-at-3-57-39-pm

Add a servo and change the Arduino code:

 

screen-shot-2019-01-14-at-4-00-09-pm

screen-shot-2019-03-01-at-11-18-38-am

img_2832-2

Circuit:

Connect the circuit as show in the figure below:

  1. The servo motor has a female connector with three pins. The darkest or even black one is usually the ground. Connect this to the Arduino GND.
  2. Connect the power cable that in all standards should be red to 5V on the Arduino.
  3. Connect the remaining line on the servo connector to a digital pin on the Arduino.

Notes:

  • Servo red wire – 5V pin Arduino
  • Servo brown wire – Ground pin Arduino
  • Servo yellow wire – PWM pin Arduino

img_3528

I want to have a fan connected to the servo, so I went to dollar store and got this candy toy for 2 dollars, along with an unexpected free motor, a button and a battery.

img_3289img_2411

img_2597

It was my first time to use servo though we had c&c last semester. Usually, they have a servo arm that can turn 180 degrees. Using the Arduino, we can tell a servo to go to a specified position and it will go there. I don’t know how to make it work like a fan. I think I need to choose another type of servo. The code I had will turn a servo motor to 0 degrees, wait 1 second, then turn it to 90, wait one more second, turn it to 180, and then go back. I need to check if I can make it rotate in one direction(not back and forth).

 

 

 

 

Process Journal 1-April

  1. Design pattern 

design-pattern

Since Serial1 would not work on Serial Monitor on Arduino, to make sure the pattern works as expected, “Serial” was used in programming. The expected result is that when “H” is entered, the blue led (ledPin), green led (green) and white led (white) quickly blink in order and then all light up. When “L” is entered, all three led light out. 

Please click here to view the pattern.

password: pattern

 

2. Configure the radio

radio

To make sure two radios can chat.

3. Program Arduino

program1

program2

This time “Serial1” is used to allow Arduino to receive commands from the radio. It is okay that we do not test it after uploading since we did it in step 1. If there is any problem, it should not be the code.

4. Light!

After this step, we successfully lit my Arduino led using coolterm in Jing’s laptop. We did not succeed in once. Please see analysis in the next paragraph “Problems and Findings”.

Problems&Findings

  1. The RX and GND should be plugged in the very left two holes of the breakout board as the photo shows.solution1
  2. When a chat is successfully made, directly unplug the XBee from radio pad and plug it onto Arduino. There is no need to enter +++ again in coolterm.
  3. To make sure the command is delivered, use send string instead of directly typing it.
  4. Just send “H” or “L”, don’t go like “HHHHH” or “LLLL”.

 

Process Journal #1 – Radio Rabbit (Tyson)

Radio Rabbit

Video: pic.twitter.com/mjzqA4hqOe

Day 1:

We were introduced to the XBEE radio transceivers. My radio kit came with a Lilypad Arduino which conveniently could be used to configure the radios. I tested the device out with another student and we sent several strings back and forth between eachother.

Reminds me of the command terminal on computers / past arduino serial communication experiments. The XBEEs were relatively easy to setup with the aid of the lecture slides provided by our professors and the necessary firmare. Transmissions have been clean so far, but will have to watch out for dropped packets when testing in the future.

Since the XBEEs don’t natively fit on breadboards, I soldered the breakout board provided to us after class.

The important things to note:
– 3.3v power supply
– RX / TX pairing between the arduino micro and xbee on setup
– serial can be used to communicate with the XBEE for testing purposes, but ‘Serial1’ must be used in the Arduino code to denote communication with the 1 and 2 pins.

Day 2:

For the sake of our task to create a device to interact with a metronome signal I was inspired to use several servos I had leftover from last semester to create some sort of rabbit. I wanted the project to be relatively simple but demonstrate motion and have an entertaining appearance. I first tested out the servos with both a 9V power supply and a USB power supply. Supplying the four small devices that would be the legs worked as expected and operated fine with some demo code provided through Arduino’s IDE (Servo Sweep and Physical Pixel), although I discovered yesterday that the charge remaining in my battery supply seemed to have diminished overnight and lost its efficiency. The weight of the device on the breadboard began to concern me as I thought about how the device would be supported if it were to be an enclosed object.

When it came time to design lasercut parts for the device, I created two types of legs to test (forelegs and back legs), with multiple copies cut to allow them to be laminated for thickness. The servos were mounted beneath the device’s breadboard with Weldbond and a second panel and oriented as appropriate for the four-legged mammal. The legs were mounted to the servos with the kit attachments, some glue and screws; without the screws, the legs were unable to support the weight of the device.

20190109_174258 capture

Day 3:

The code has been designed to operate in two different states: a wide stance for a “High” signal and a narrow stance for a “Low” signal, in similar appearance to the visual look of a sprinting rabbit. The orientation of the servos required, for example, that the left back leg was positioned to a different angle than that of the right back leg in order to appear symmetrical. For my code, this meant that the angles for the respective servos were at opposite ends of a range between 0 and 180. Naturally, having the legs span the whole range of the servos looked peculiar and caused some technical hiccups with the leg behavior, so it was reduced to an appropriate span.

The back legs seem to perform more effectively than the forelegs, which often get caught in awkward angles causing disruptive behavior. This may also be due to my selection of servos for the forelegs, which are of a different, cheaper make than the hind ones supplied by last year’s Creation and Computation class kits.

20190109_181210fritz

Day 4: 

Along with several other classmates I tested out my device’s functionality with the radio signals of other XBEEs. It took a bit of troubleshooting to detect but it turns out the device works fine, if a bit finicky sometimes with receiving the data packets. This could be due to the amperage draw of the servos competing with the XBEE; given some of my past experiences with servos I’m fairly surprised how well the circuit has been working up to this point.

I did end up getting a replacement battery, which worked just once with the remote signal but afterwards lacked the capacity to support the circuit. Perhaps I will look into using 12V instead of 9V in the future.