PIKODER PiKoder/SPE User manual

PiKoder/SPE User Manual
ii
Content
Overview 3
Features 5
Pin Description and Packaging 7
Description of pins............................................................................................8
Standard application 10
LED status indication (in USB mode)..........................................................10
The PiKoder Control Center G2 13
Getting started..................................................................................................13
Real-time control .............................................................................................14
Watchdog..........................................................................................................14
UART baudrate................................................................................................14
PPM Settings ....................................................................................................14
Startup ...............................................................................................................15
Save Parameters ...............................................................................................15
Serial Interface 17
ASCII Command Interface............................................................................17
Mini SSC Protocol ...........................................................................................19
Connect the SPE to a Raspberry Pi 21
Connect the SPE to an Arduino 23

1
Overview
The PiKoder/SPE (Serial PPM Encoder) is a single chip solution using a
modern PIC controller to generate a PPM-Stream with 2 –8 channels con-
trolled from serial port (UART) of an SBC (Single Board Computer) such as
a Raspberry Pi or an Arduino.
As a second generation PiKoder the SPE features a USB interface for cus-
tomizing the controller to the requirements of your application in addition to
the serial port.
This User Manual covers the features, the programming, and the command
interface of the PiKoder/SPE as well as common applications.
In section 2 you will find a brief description of key features, the overall func-
tion and an overview of the interfaces supported. It is recommended to care-
fully read this section to get a good basic understanding of the PiKoder/SPE.
The next two sections 3 and 4 deal with the controller hardware. Section 3
provides the pinning and section 4 describes the reference schematic for the
PiKoder/SPE. Please note that the applications and interfaces de-
scribed in the following sections assume that the PiKoder/SPE is setup
in line with this reference schematic.
Your next step is most likely to commission and test your PiKoder/SPE.
Rather than using the “bits and bytes”-serial interfaces directly, which are laid
out in section 6, you may consider using the more sophisticated PCC G2
(PiKoder Control Center Generation 2) Windows 10 software with a graph-
ical user interface described in section 5.
Section 7 demonstrates how you would interface your PiKoder/SPE to a
Raspberry Pi and Section 8 focusses on connecting the PiKoder/SPE to an
Arduino.
This User Manual is based on the most recent hard- and firmware version 4.0
available for the PiKoder/SPE and the related PCC programming software.

PiKoder/SPE User Manual
4
Please check for updated information and new software releases on
www.pikoder.com.
Hyperlinks were integrated into the text for convenience. You would also
find all downloads referenced on the PiKoder/SPE webpage.
Please share with me any comments, improvement ideas or errors you will
find or encounter in working with your PiKoder/SPE. I can be reached at
[email protected]. Thank you very much!

2
Features
This section will familiarize you with the feature set and provide a high-level
overview of the intended use of the PiKoder/SPE allowing you to customize
the controller to your specific needs and requirements.
The PiKoder/SPE generates a PPM stream which is controlled by a com-
mand protocol via a UART port. More specific, the PiKoder/SPE features a
two-way ASCII-Protocol designed to be used in combination with standard
terminal programs such as (but not limited to) Tera Term and TTY.
In addition, various application specific parameters such as startup position
after powering up, failsafe value per channel, PPM polarity, the number of
channels and the baud rate of the UART can be adjusted to your specific
needs and the settings are maintained in a non-volatile memory.
You can connect an SBC (Single Board Computer) such as your Arduino or
Raspberry Pi without any additional interface hardware directly to the
PiKoder’s UART (please refer to sections 7 and 8 for more details). In this
capacity the PiKoder would free up the Arduino or Raspberry Pi of respond-
ing to real-time events such as generating pulses within “real-time” and thus
free up resources such as internal timers and PWM generators ('Set and For-
get'-function).
You would program the PiKoder/SPE by connecting it with a standard USB
cable to your computer. A free graphical and intuitive configuration and con-
trol program, the “PCC G2 (PiKoder Control Center Generation 2)” is avail-
able for Windows 10, making it simple to test and program the controller
over USB (please refer to section 5 for more details). All settings are stored
in a non-volatile memory.
The PiKoder/SPE does support a failsafe position for the use in autonomous
and RC applications. You can activate a watchdog-timer for 0.1 s to 99.9 s to

PiKoder/SPE User Manual
6
monitor the communication. If no message is received within this preset time
frame, then the PiKoder would set all channel values to the failsafe position.

PiKoder/SPE User Manual
8
A complete description of the pins is given on the following page. If a differ-
ent package would be required for your application, then please contact
Description of pins
Pin
Symbol
Description
1
VDD
Supply voltage. Connect to 3,3 –5 V DC
2
BM
Boot Mode. If this pin is high while booting, the
PiKoder will start in USB mode (activating the
USB interface), otherwise UART would be active
3
NC
Not connected (reserved for later use)
4
MCLR/VPP
Reset pin, active low. Connects directly to Vss for
automatic reset at power up.
5
RX
UART receive. Active only when BM = 0 when
starting up
6
TX
UART transmit. Active only when BM = 0 when
starting up

9
7
LED
LED indicator output (please refer to Appendix B
for more information)
8
PPM_OUT
Output pin with PPM signal
9
PGC
Clock pin for In-Circuit-Serial-Programming
10
PGD
Data pin for In-Circuit-Serial-Programming
11
VUSB3V3
Positive supply for USB transceiver; 470n capaci-
tor required
12
D-
USB data line
13
D+
USD data line
14
VSS
Ground connection

PiKoder/SPE User Manual
10
4
Standardapplication
The following schematic shows the standard application of the
PiKoder/SPE. Please note that the bi-color LED indicates the USB status
and is optional and will remain red in UART mode.
LED status indication (in USB mode)
This following table shows the status of the USB connection (“DEVICE
STATE”) based on the LED signaling state (“LED RESPONSE”).
DEVICE STATE
LED RESPONSE
DETACHED
OFF
ATTACHED
RED
POWERED
RED
DEFAULT
RED & GREEN
ADRESS
RED & GREEN
CONFIGURED
GREEN


5
ThePiKoderControlCenterG2
The USB2PPM’s USB interface provides access to configuration options as
well as support for real time control. The PCCpro PiKoder Control Center is a
Windows 10 based graphical tool that makes it easy for you to use this inter-
face. For almost any project you will start by using the PCCpro PiKoder Contol
Center to set up and test your PiKoder. This section explains the features of
the PCCpro PiKoder Control Center.
Getting started
The hardware setup is simple and straight forward with a PiKoder/SPE en-
gineering board or your own prototype. You must connect your
PiKoder/SPE with the USB port of your Windows PC using a suitable cable.
This cable will provide also for the power supply of the board.
When you connect your PiKoder/SPE for the first time, Windows will auto-
matically install the drivers needed. On the engineering board the LED would
be blinking red in fast mode during the installation process. Please refer to
section 4 for more information regarding the LED indicator.
The PCC G2 app is available free of charge in the Windows app store. It is
highly recommended that you install the latest version of the program to en-
joy the complete feature set of your PiKoder/SPE.
Please make sure to connect your PiKoder to a USB port before starting the
PCC as the PCC will scan your computer’s USB ports to automatically con-
nect to the PiKoder.
The connection is made and the actual parameters of the PiKoder are dis-
played.

PiKoder/SPE User Manual
14
You would now have full control of your PiKoder/SPE: either for real-time
control by the sliders or for changing the settings with respect to PPM polar-
ity, number of channels, startup values, etc.
Real-time control
The sliders are used for controlling the PiKoder’s outputs and the respective
numerical fields monitor the status in real time displaying the current channel
value in µs within a range of 1000 –2000 µs. A separate row of controls is
displayed for each of the active channels.
Watchdog
The watchdog would be used to make sure that the failsafe values for all
channels are set when the connection to the host would be interrupted. Ac-
tivating the watchdog is comprised of setting the value (default is 300 ms)
and activating the watchdog itself by checking the respective box.
UART baudrate
The PiKoder/SPE offers baudrates of 9600, 19200, 38400, 57600 and
115200. The setting would become effective after the next reset of the
PiKoder.
PPM Settings
The PiKoder/SPE features either a negative or positive PPM stream. The
polarity is related to the output of the PPM_OUT pin. The following picture
presents the signals. Also, you can select the number of channels encoded in
the stream. A range from 1 to 8 channels is supported; more than 8 channels
can technically not be encoded in a standard 50 Hz PPM frame.

15
Above: “positive” PPM Frame at PPM_OUT (7 channels selected)
Above: “negative” PPM Frame at PPM_OUT (8 channels selected)
Startup
In many applications the pulse width for the neutral value would be 1.5 ms.
However, some ESCs (Electronic Speed Controllers) for drones might need
1.0 ms as a start-up value to make sure that they are not spinning immediately
after turning the PiKoder/SPE on. To address these applications, you would
set the initial value and safe the parameters by hitting the respective button
on the lower right of the screen.
Save Parameters
Changes made while using the PCC G2 will not be permanent unless you
select to save the parameters. Hitting this button transfers all settings into the
non-volatile memory of the PiKoder/SPE to be retrieved when started up
the next time.
Please note that saving new values may take some time and requires disabling
some internal interrupt logic. This may result in erroneous servo behavior.

PiKoder/SPE User Manual
16

17
6
Serial Interface
The PiKoder/SPE supports a two-way ASCII-Protocol named Ascii Com-
mand Interface (ACI) designed to support controlling PiKoders with stand-
ard terminal programs such as (but not limited to) Tera Term.
ASCII Command Interface
The ASCII Command Interface (ACI) is probably the most versatile way to
program any PiKoder without any specific host software such as the PCC G2
PiKoder Control Center. All commands are simple ASCII and are sent using a
Windows based terminal program such as Tera Term. The commands can be
typed in right away and the response of the controller is readable without
referring to any specific code tables. Please note that neither 'CR' nor 'LF' is
needed to send the command to the controller.
There are two basic types of commands: commands for querying parameters
and for setting parameters.
If a parameter is read the PiKoder will provide for proper formatting by send-
ing a “CRLF” prior to sending the parameter value and support readability
by sending another “CRLF” after the parameter value.
If a parameter is set the PiKoder will acknowledge the proper execution by
sending an “!” framed by “CRLF”.
If a command could not be interpreted at all then a question mark '?' framed
by 'CR' 'LF' would be echoed. Please note that protocol syntax checking is
extremely limited now.

PiKoder/SPE User Manual
18
The following ACI commands are available:
-'?': query the PiKoder type information; PiKoder/SPE will respond
in a format 'UART2PPM' framed by 'CR' 'LF'
-'0': query the firmware version; PiKoders will respond in a format
'n.nn' framed by 'CR' 'LF'
-'i?': query the current pulse width for channel i (i = 1..8); PiKoders
will respond 'CR' 'LF' 'xxxx' 'CR' 'LF' with xxxx representing the pulse
width in µs
-'i=xxxx': set the pulse width for channel i to xxxx µs (xxxx in decimal
format, i = 1..8); PiKoders will acknowledge execution of the pro-
gram by sending an 'CR' 'LF' '!' 'CR' 'LF'
-'B?': query the current UART baud rate. PiKoder/SPE will respond
a number from 0..4 meaning 0=9600, 1=19200, 2=38400, 3=57600,
and 4=115200 - the command is not case sensitive
-'B=k': set the UART baud rate with k = 0..4 (see encoding above) -
the command is not case sensitive and the PiKoder will acknowledge
execution with a '!' framed by 'CR' 'LF'.
-'C?': query the current number of PPM channels in the frame.
PiKoder/SPE will respond a number from 1..8 - the command is not
case sensitive
-'C=k': set the number of channels in the PPM frame with k = 1..8 -
the command is not case sensitive and the PiKoder will acknowledge
execution with a '!' framed by 'CR' 'LF'.
-'Nk?': query the startup value for channel k. PiKoders will respond
'xxxx' with xxxx representing the pulse width in µs (xxxx in decimal
format, k = 1..8) - the command is not case sensitive
-'Nk=xxxx': set the startup value for channel k to xxxx µs (xxxx in
decimal format, k = 1..8); - the command is not case sensitive and the
PiKoders will acknowledge execution with a '!' framed by 'CR' 'LF'.
-'P?': query the current PPM polarity. PiKoder/SPE will respond 'N'
with 'P' for positive and 'N' for negative - the command is not case
sensitive
-'P=x': set the PPM parameters with x representing the polarity of the
PPM signal (‘P’ or ‘N’). The command is not case sensitive and the
USB2PPM will acknowledge execution with a '!' framed by 'CR' 'LF'
-SU]U], sU]U]: will save the current parameters to the controller’s
non-volatile memory making the current servo positions the start up
positions after powering up; returns a '!' upon successful completion
framed by 'CR' 'LF'
-'T?': query the current watchdog value. PiKoders will respond 'xxx'
with xxx representing the time in increments of 20 ms (frames
missed) - the command is not case sensitive.

19
-'T=xxx': set the timeout value in increments of 20 ms; - the command
is not case sensitive and the PiKoder/SPE will acknowledge execu-
tion with a '!' framed by 'CR' 'LF'.
-'W?': query the current watchdog status. The PiKoder/SPE will re-
spond either with ‘1’ indicating an active watchdog or ‘0’ for watch-
dog not activated. - the command is not case sensitive.
-'W=b': activate / deactivate watchdog. For b=1 the watchdog would
be activated, for b=0 the watchdog would be turned off; - the com-
mand is not case sensitive and the PiKoder/SPE will acknowledge
execution with a '!' framed by 'CR' 'LF'.
Mini SSC Protocol
The PiKoder/SPE supports the miniSSC protocol for the first eight chan-
nels. The protocol is simple, and it only takes three serial bytes to set the
target position of one servo.
The miniSSC protocol is to transmit 0xFF as the first (command) byte, fol-
lowed by a servo number byte, and then the 8-bit servo target byte for the
servo position. This means that the miniSSC protocol allows for 255 posi-
tions (0xFF is not available as it indicates a command start) resulting in about
4 µs as a maximum resolution compared to 1 µs in the Ascii command mode.
A servo target byte of 127 (0x7F) will always indicate the neutral position
maintained as a PiKoder/SSC parameter.
The servo position will be calculated by
servo position = (target byte –0x7F) * 4 µs
for a target byte bigger than 0x7F and by
servo position = target byte * 4 µs
for a target byte smaller than 0x7F.
For testing the miniSSC protocol you may want to use a byte oriented tool
such as the “Pololu Serial Transmitter”utility for Windows (see
https://www.pololu.com/docs/0J23 for more details).
After installing and starting the software you would have to connect to the
PiKoder/SPE by selecting the COM port and pushing the connect button.
The miniSSC-protocol is a three-byte command and should be entered in the
respective column as shown below.

PiKoder/SPE User Manual
20
Once you hit the “Send 3-byte command”-button the bytes are sent to the
PiKoder (see below); as per protocol definition there is no response by the
SSC.
Table of contents
Other PIKODER Microcontroller manuals
Popular Microcontroller manuals by other brands

Texas Instruments
Texas Instruments Chipcon Products CC1110DK user manual

AMS
AMS TDC-GP30 quick start guide

Onion
Onion Omega2 First-time setup

Texas Instruments
Texas Instruments CC2531 user guide

Cypress
Cypress CY8CKIT-042-BLE manual

Silicon Laboratories
Silicon Laboratories Telegesis ETRX357DVK product manual