In the original thread on co-development of hardware and software, one topic briefly covered was the possibility of using the Numato General Purpose Input Output (GPIO) board as a means of connecting a PC to custom electronic circuitry. Numato makes 8, 16, 32, and 64 bit versions of the board. Each version has some pins that besides being used for digital I/O can be used to read analog levels converted by the board to binary values.
I am currently using the 8 bit version and thought I would show some "demo" code to operate the board. I am using Python and therefore this code is written in python. This requires the "pyserial" be installed and that the user is a member of Group "dialout". You can make yourself a member of dialout with:
sudo adduser -G dialout username
For more details reference the Numato manual at their web site: http://numato.com/8-channel-usb-gpio...analog-inputs/
Here is the python demo code for the Numato 8 bit GPIO board.
# This program is not written as an example of good Python code Errors are not trapped
# etc. Instead it is quite minimal with the purpose of: Showing that Pyserial can be used
# to operate the Numato GPIO - 8 board. Get an idea of how fast the data to and from the
# board can be run. Experiment with ways to parse the data coming back from the board.
# This is not a characterization of the board or a test of the board. For this test each I/O
# pin of the board has an LED connected in series with a 1 K Ohm resistor connected to
# the board Ground. When a board output is at logic "1" the LED is on.
# This list contains a list of board commands that will be sent to the board in listed order.
# This is not a comprehensive list of possible board commands.
DigCommands = ['ver', 'id get', 'gpio writeall 00', 'gpio set 0', 'gpio clear 0', 'gpio set 1', 'gpio clear 1', 'gpio set 2',
'gpio clear 2', 'gpio set 3', 'gpio clear 3', 'gpio set 4', 'gpio clear 4', 'gpio set 5', 'gpio clear 5',
'gpio set 6', 'gpio clear 6', 'gpio set 7', 'gpio clear 7', 'gpio writeall ff', 'gpio readall', 'adc read 0',
'adc read 1', 'adc read 2', 'adc read 3', 'adc read 5', 'adc read 6', 'gpio writeall 00', 'gpio readall',
'adc read 0','adc read 1', 'adc read 2', 'adc read 3', 'adc read 5', 'adc read 6']
# This list will be the receiver for the string read form the board.
BytesIn = 
# Opens the serial connection to the board and checks for success.
Ser = serial.Serial('/dev/ttyACM0')
if Ser is None:
raise ValueError('Numato 8 - Bit GPIO not found')
# Set the amount of time that Pyserial waits for the requested number of bytes to be
# received from the board. Strings from the board are not reliably read when the
# timeout value is below 0.005 seconds. This value can be increased to throttle
# the speed of sequencing through the commands by delaying completion of the
# reads. Read and write for that matter are independent of the set baudrate.
# This is to be expected as the board is a USB based Com port emulation.
Ser.timeout = 0.010
# Wake up the board with an empty string.
# Print the characteristics of the serial port to sysout (the console window in the Eclipse IDE).
# Determine the number of commands in the command list. Commands may be
# added to or deleted from the list above without modification to the code below.
RangeCom = range(0, (len(DigCommands)))
# Sequence through the commands in listed order.
for NowCom in RangeCom:
# Get a command.
Command = DigCommands[NowCom]
# Add a "CR" to the end of the command and send it to the board.
Ser.write(Command + '\r')
# Read up to 64 bytes from the board. This is intentionally much larger than
# a single string from the board will be. Read is Blocking, but the time
# out above will allow the program to proceed though there will not be 64
# bytes received
BytesIn = Ser.read(64)
# Determine how long the string from the board is.
BytesInLen = len(BytesIn)
# Prepare to check that the echoed command is equal to the sent command
comLength = len(Command)
CheckCom = BytesIn[0:comLength]
# Parse out just the returned data
Return = BytesIn[comLength:BytesInLen]
# Ignor the "LF CR >" characters at the end
ReturnLen = len(Return)-3
ReturnData = Return[2:ReturnLen]
# Send command and results to sysout (the console window in the Eclipse IDE).
print "Command Number: = ", NowCom, " Command = ", Command, " Sent = Echoed = ", (Command==CheckCom), " Returned Data = ", ReturnData
# Close the serial connection to the board.