Serial Wombat
a general-purpose digital interface device for hobbyists, engineers and students

 


Home
Overview
Protocol
Documentation
Overview
Analog Inputs
Channel Modes
Public Data
Timed IO
Getting Started
Connectivity
Pin Mode SDK Beta
Sample Projects
Downloads
Contact Us
Purchase
Forum

Did you know...

 

Overview

The Serial Wombat comes pre-programmed, ready to jump into action at your command. When you power-up your Serial Wombat, it begins listening on the serial pins for commands from its host.

I/O

The Serial Wombat is designed to carry out I/O tasks for the host, and generally provide an interface to the outside world. The Serial Wombat pins can be controlled directly by the host, or each pin can be configured to carry out common interfacing tasks which require faster or more precise transistions than could be achieved through individual serial commands.

Analog Inputs

The Serial Wombat supports up to 13 channels of A/D conversion. By default, 4 channels (pins 2,3,4, and 5) are configured for A/D conversion. Users can enable or disable A/D functionality for additional pins using the Configure Analog Channels property of the Set System Parameter command. Signals being measured by the Serial Wombat's internal A/D should have an input impedance of 2k Ohms or less to achieve 10-bit accuracy.

Each enabled A/D is sampled at the beginning of each frame (by default every 1ms). The Serial Wombat has a single A/D converter which is multiplexed among pins. Therefore, the A/Ds are not all sampled at the same time, but rather within a few uS of each other.

In order to understand A/D conversion, it's important to understand a fundamental concept: All physical measurements and their units are arbitrary. For instance, at some point somebody in Europe decided that water was a good way to relate mass and length. If you create a box 1cm by 1cm by 1cm and fill it with pure water at a certain temperature, then it will weigh 1g, because it's defined that way. If that person had filled their box with lead, or oil, or some other substance, then the definition of a gram (or perhaps 1cm, depending on which they arbitrarily chose first) would have been different. It's the same way with Voltage, except that the story is longer and more complicated, and requires a bunch more definitions of other fundamental units along the way.

Number systems are the same way. We likely use Base-10 in our normal lives because we have 10 fingers. We use base-2 (binary) in computers, because it's a convenient way to do math with transistors. Some ancient civilizations used a base 60 system for astronomy, because there's lots of different numbers you can divide 60 by and still get whole numbers. The point is, number systems are somewhat arbitrary.

Fractions are our way of expressing part of a whole number. What's a fraction and what's a whole number depends on what we consider the number 1 to mean. If a chicken lays two eggs, it sees two eggs (I'm guessing..). The farmer who sells cartons of eggs at his roadside stand, however, may see 1/6 of a carton of eggs. It depends on what you consider "1" to be. Keep this in mind, as it will bear later on our discussion of reference voltage.

Now, assume that you a have a linear potentiometer, a magnifying glass, and a really fine pointed magic marker. (If you don't know how to generate a variable voltage with a Pot, check here). You take and put 65536 equally-spaced marks on the potentiometer. You now have a potentiometer who's position can be defined with a number (we'll use 0 to 65535), where 0 is a short to one side, and 65535 is a short to the other side.

If I tell you that I want you to set the potentiometer to position 32768, you can do that. What voltage will then come out of the Pot wiper? That depends. It depends on what the voltages on the high side and low side are. If we use 5.0 V and 0, then what comes out will be 2.5V. You know this because you have 65536 steps, and you've gone have way, effectively creating a 50% voltage divider. 32768/65536 * (5.0 - 0) = 2.5. However, if you hooked the high side to 7.5V, then position 32768 would create 3.75 volts.

Now, lets go the other way. What if you wanted 1.25 volts on a 0 to 5 scale? You'd say 1.25 / 5 * 65536 = 16384, and set the pot to line number 16384. What if you wanted pi? You'd say 3.141592654 / 5 * 65536 = 41177.448 . So you want to move the Pot to position 41177.448. Except by our rules, you can't do that. You can only set it to a whole number. So, you settle for position 41177, and just accept that 3.14156 is the closest you can get to pi. How exactly you can represent non-whole numbers is your resolution.

Suppose, however, that you knew you'd never need a voltage higher than 3.3v. You could supply the high side of the pot with 3.3V. Now, your equation is 3.141592654 / 3.3 * 65536 = 62390.13. We'd probably round that to 62390, which would give us 3.1415863. That's closer! Because you used the same 65536 marks, but spread them over a smaller range, each tick now represents a finer number. The down side is that now you can only output 0 to 3.3, rather than 0 to 5. The fraction x/65536 where x is the pot position represents what portion of the range we're outputting. In the first example, we defined a fraction of 1 (or 65536/65536) to be the whole range of 5 volts. In the second, the value of a fraction of 1 was 3.3v. We define what a "whole" is by the values we put on the pot.

Now, let's talk about an A/D converter. In your mind, a simple but pretty useful way to see it is as a Pot that works backwards. Like a pot, it has a high reference and a low reference (these are often just tied internally to ground and the voltage supplying the PIC, and this is the only Serial Wombat option as of v2.1.0). Instead of a voltage being output on the wiper, a voltage is input on the pin. Instead of a turning the Pot to a particular number, the A/D displays the number to you.

As before, if we have 0 and 5 volts as our references, and put in 2.5 volts, then we expect the number 32768 to pop out of the A/D. But what if we put in 3.14159 volts? The A/D can't give us a number to exactly express this. So, it will output an approximation of 41152.

The Serial Wombat's internal A/D converter is a 10-bit resolution converter. This means that it is capable of measuring an input as one of 1024 different values. That means that the Wombat can't actually measure a voltage small enough to express every number between 0 and 65535. Instead, it will create a number of "buckets" or ranges which span 64 counts each.

The thing to remember about A/D converters is that the number you get back represents a range, not an exact measurement. When you get 41152 back, you know that the measurement was greater than or equal to 51152 and less than or equal to 41216. So, somewhere between 3.13965 and 3.1445. You don't know where inside of that range. Similarly, a value of 0 represents any value between 0V (or even less than it) and .000977v. 65472 represents anything bigger than 4.9951 V.

Most A/D converters (including the Serial Wombat's internal converter) use a successive approximation method to do their conversion. You might google this, as it could give you more insight.

The Serial Wombat's on-board A/D converter provides 10 bits of resolution. All Serial Wombat analog quantities are expressed using 16 bits. This method is used because it provides compatibility between various resolution inputs and outputs. For instance, a 10 bit A/D measuring 2.73215 V on a 0 to 5 volt scale would return the value 0x8BC0 . (A 16 bit converter would convert it as 0x8BE2). Higher or lower resolution simply means more or less increments between 0 and 0xFFFF. The Wombat takes this concept to its extreme when an analog measurement is requested from a digital pin. Since the pin has only 1 bit resolution (high or low), a result of 0 or 65535 is returned, with no possible steps in-between. Analog values which represent the maximum value for a particular input (such as 0xFFC0 for a 10-bit A/D) are converted to 0xFFFF, so that 65,535 consistently means the maximum possible measured value for an input or output. But again, this value should be understood to be somewhere in a range, not necessarily equal to the highest possible voltage

Future versions of the Serial Wombat will support the use of off-board A/D converters attached to the Wombat via a SPI bus. This will allow higher resolution conversions. Use of reference voltages other than the Wombat's power supply will also likely be supported.

PWM output

The Serial Wombat is based on a Microchip PIC 18F4620 microcontroller. The Serial Wombat firmware attempts to make use of as many of the chip's special hardware functions as possible. Because of this, some tasks, such as PWM generation, can most effectively be performed by pins which have special hardware to support that task. When a task is assigned to a pin without hardware assistance, then the task is done in software when possible. For example, pins 16 and 17 have support for hardware driven PWMs. When commanded to generate an Analog output, these pins will generate a PWM of approximately 31kHz, and 10 bit resolution. Pins without this hardware support, such as pin 15 will generate a PWM in software. The user can choose a trade-off between frequency and resolution, but in any case the performance will be much worse than the hardware assisted pins (by default 61 Hz at 4 bit resolution).

D/A output

The Serial Wombat has one pin which can be used as a low-resolution D/A channel. Pin 4 can output 16 analog levels between 0 and 3.3 volts. This pin is the output of a 16 tap resistor ladder, and can only provide very low current output. It is suggested that this output be buffered with an op-amp or other circuit if used with a circuit requiring a lower output impedance. Note that software versions prior to 1.1.2 had a bug which caused incorrect setting of the D/A pin 4 when set through the 'W' command.

The Serial Wombat supports the Microchip MCP4821 12-bit D/A converter. This chip is interfaced to the Wombat through the SPI lines, with the selected pin being used for the chip-select. When a pin's hardware mode is set to MCP4821, any command which would set that Pin's PWM value is translated instead into a SPI command. Therefore, any pin mode or command which normally outputs a PWM can instead generate a true analog voltage from 0 to 4.095 volts in 1mV steps. Using this off-board chip requires that the pins 18 and 24 be dedicated to SPI bus usage, as well as the pin acting as the chip-select. Multiple D/A converters can be attached and share pins 18 and 24, as long as each has a separate chip-select.

Digital I/O

Up to 32 pins on the Serial Wombat can be used for Digital I/O. In order to use pins which are analog-to-digital capable as digital I/O, the analog function must be turned off using the Configure Analog Channels property of the Set System Parameter command. Each pin can be configured as an input, or a high or low output. Pins 33 through 40 have internal pull-up resistors, allowing switches, rotary encoders and keypads to be used with no external components. The pull up resistors for these pins can be turned on or off as a group using the Set System Parameter command. When configured as inputs, all pins behave as Schmitt-Triggered inputs, except pins 2,3,4,5,7, 13, 14 and 33 through 40 which behave as TTL inputs. This difference will not matter to most users.

The Serial Wombat's I/O pins can sink or source up to 25mA per pin. This allows LEDs to be driven directly from the I/O pins with only a current-limiting resistor. However, the total amount of sourced and sunk current cannot exceed 200 mA. Therefore, the Serial Wombat cannot, for example, turn on 32 LEDs at once without additonal external hardware.

Pin Modes

Each I/O pin of the Serial Wombat has its own state machine. In each frame (by default every 1ms) every pin's state machine is serviced. Pins are serviced in ascending order. By default all pins from 2 through 40 are serviced. However, the Start and End service pins can be changed with the Set System Parameter. Since the Serial Wombat has a single CPU core to share among all pins, the frequency with which it can service all the pin state machines is limited. For some applications it may be desired to update a pin's state machine 10,000 times per second or more, instead of the normal 1000. This can be achieved by using the Set System Parameter command to reduce the number of pins serviced. Since less pins are serviced, CPU time is freed up to service them more often. The update frequency can be set by altering the Frame Counter Update Value using the Set System Parameter command. See the CPU Throughput section below for more information.

Early documentation called each pin a channel. Therefore, pin modes and channel modes are the same thing. To avoid breaking existing Internet links, the two terms are used interchangably.

By default, pins 2,3,4, and 5 come up in A/D Raw mode at powerup. In this mode the Analog value present on the pin is converted to a number ranging from 0 to 65535. All other pins come up in Direct mode, set as inputs.

A list of all available pin modes can be found here.

Some pin modes require more than one pin in order to operate. A few examples of this are stepper motor control, rotary encoder input, matrix keypad scanning, and LCD display control. For each of these modes only a single pin is configured. However, when configuring that pin you also tell it what other pins to use. These other pins are set to Controlled Mode. Controlled pins do not need to be serviced. Only the main pin needs to be serviced. For example, an LCD driver mode which requires a total of 11 pins only requires the main configured pin to be serviced by the executive. The other pins are used only for I/O, and in some cases their state machine memory is used by the main pin. In some cases, controlled pins can be shared among multiple master pins. For example, it is permissible to share data pins among multiple LCD displays, enabling the Serial Wombat to drive 10 or more independent displays in some cases. See each pin mode's documentation for information about what pins play nice together.

Memory

There are four memory regions in the Wombat in which users may be interested: the Public Data area, the User RAM area, the EEPROM area, and the User Flash area.

Public Data Area

Each pin's state machine provides a single public 16 bit location. This location can be used to provide information to other pins or to the user. Many pin modes, such as hysteresis, rely on input from other pins' public data in order to operate. Additionally, many interesting system properties such as timers, a random number generator, and received byte counters can act as public data sources. See the public data page for more information.

User RAM Area

All RAM not used by the Serial Wombat firmware is made available for use by the user. The amount of available User RAM may vary from release to release, but is guaranteed to be at least 512 bytes. The User RAM area is indexed from zero, regardless of where it actually falls in the physical RAM area of the 18F4620 for a particluar Wombat build.

Some pin modes expect the user to put data into RAM for the pin mode to read. A good example of this are the LCD driver modes, where the user puts the string to be displayed somewhere in the User RAM area, and tells the pin mode where to look as part of initialization. Data can be placed into RAM using the Set User Ram commands.

Queues can be created in User RAM. Some pin modes expect to read data out of queues. For example, the morse-code pin mode gets the characters to transmit out of a queue. Other modes put data into queues. For example, the matrix keypad decoder mode can put key presses into a queue for later retreival by the host. A number of commands exist for creating, reading, and writing to queues.

EEPROM Area

The Serial Wombat's EEPROM is used to store internal settings, such as the baud rate the Serial Wombat will use at Powerup.

Bytes at EEPROM addresses from 512 to 1023 are available for use by the user. This allows the user to store data such as a serial number in the Serial Wombat.

If EEPROM address 511 is set by the user to a value other than 0, then the value in address 511 is taken to be the number of commands stored in EEPROM which are to be executed at powerup. Each command will be processed as if it came in over the serial port. For example, if address 511 is set to three, then three sets of 8 bytes (addresses 512 to 519, 520 to 527, and 528 to 535) will be interpreted as 3 commands. This allows pins to be configured at powerup for certain functions. This is useful for achieving a safe state for a system if an unexpected Wombat processor reset occurs.

EEPROM can be read and written using the Read From EEPROM and Write To EEPROM commands.

EEPROM programming strings for initialization sequences can be generated using the command processor CGI script. Enter the commands you wish to be executed at powerup, and submit. Connect to the Serial Wombat using Hyperterminal at a slow speed (300 baud works good, since the chip stalls momentarily while the EEPROM programming occurs), and paste the EEPROM string from the .cgi script to the Wombat. Then power cycle your Wombat and verify that programming was successful.

User Flash Area

16k of the Serial Wombat's internal flash has been reserved for use by the user. There is currently no support for this area, but future Serial Wombat firmware versions may support downloading of code or data to this area.

 

Copyright Wombat Interface Products, 2005-2008. All Rights Reserved.