Here I present a tutorial that walks you through the setup, and use of the PWM logger in concert with the ever popular Arduino. Let's get started!
To follow along with this walk through, it'll be helpful to have the following things.
- 1x Protean PWM logger
- 1x Arduino
- 1x Standard R/C servo
- 1x R/C transmitter and receiver
- 4x hook-up wires
- Soldering iron
- A computer with the Arduino IDE installed
First, let's become aquainted with the PWM Logger a little bit. In the photo above you can see a closeup of the input pins for the logger. These pins are intended to sport headers which allow you to plug into an R/C receiver or another source of PWM signals. Notice that the pins are organized as columns, labeled at the bottom as (S, +, -) those labels are there to help you identify which way your receiver will need to be oriented.
You can check the orientation by plugging your servo into the receiver. The white
wire on the servo is the signal line. That pin column on the receiver should be
matched up to the 'S' column on the PWM logger.
Note: Before going further, you must also make sure the + and - columns match up to the appropriate wires on your servo. Otherwise your servo or logger could be damaged
Similarly to the input pins, the PWM Logger also sports mirrored output pins (shown above). This bank of pins is where you will plug in your servo.
The PWM Logger also has 3 pins for connecting it to an I2C bus. All the board's features can be accessed or controlled through I2C using the Protean-PWM-Library.
Now, let's get to the tutorial itself. In this case, I'm using a 3 channel receiver we really only care about one of them, but just for completeness we will setup headers for all 3 of the channels.
First let's setup the input headers. I've found it to be easiest to plug them all into the receiver. It will do a good job at keeping them all aligned while you are soldering. Here the signal pin is pointed to. Line those pins up with the 'S' column on the PWM Logger and insert the pins into the inputs IN0 - IN2.
Next, fire up your soldering iron and melt a little solder onto your iron's tip. Use that solder to tack one of the pins (left). That will keep the headers from moving around on you. Then finish by soldering the remaining pins.
The solder joints on the pins should be clean and complete with no solder bridges. Notice that in this photo channel 1 on the receiver actually lines up with IN2. I only soldered it this way so that the PWM Logger lies ontop of the receiver neatly.
Now lets install the output headers. Another good alignment trick is to plug the male headers rotated 90 degrees into two female headers.
Use the same trick as before to solder the output headers.
Lastly, solder a female header into the I2C pads.
Now we move on to wiring the whole thing up. First connect hook-up wire to the 5 volt, and GND pins on the Arduino board.
Next, connect the 5 volt wire from the Arduino to the '+' pin column on the PWM Logger. Similarly connect the GND wire from the Arduino to the '-' pin column on the PWM Logger. Here I'm using Hook-ups that have little test clips on them. Which makes it a lot easier to grab those little pins. In a realworld scenario, the PWM Logger would be powered by the positive and negative lines coming out of the R/C speed controller.
Once you've done that. it should look something like this.
The next step is to connect wires to your Arduino's SDA and SCL pins.
Then connect the same wires to the corresponding pins on PWM Logger.
Finally, connect the servo to OUT2. Make sure that you line up the white signal wire with the 'S' column, and make sure the polarity of the '+' and '-' columns matches that of the servo's red and black wires.
Great! Now that the hookup is done, let's get to programming the Arduino.
Open up the Arduino IDE, make sure the sketch that was opened has been saved. After that click Sketch -> Show Sketch Folder. This will bring you to your sketch's location on your computer.
Next, navigate back one directory. This will bring you to your sketchbook directory. It should contain a folder called libraries.
Navigate into libraries then use git to clone Protean-PWM-Library into the libraries directory. Once that's done, restart the Arduino IDE.
Now that you're back in the IDE click File -> Examples -> Protean PWM Logger -> Protean -> PWMLoggerExample. This will open a brief sketch that allows you to manipulate the PWM Logger via the PWM library. Upload the sketch to your Arduino.
Finally, open the Serial Monitor in the Arduino IDE and select a 115200 baud rate. You should see some text printed in the monitor like the image above.
Turn your transmitter on, and enter
d 3 into the monitor's input box. If you hit send
it will enter a demo mode where the Arduino uses the PWM Logger to record a few seconds of servo signals from the
receiver and then plays those same signals back through the PWM Logger.
I hope this walkthrough has been useful! Happy making :)