Greenpower GpSpeed Software


Content

View
View Content

Account

Username
Password
Forgotten my password

Pictures

Welding, more welding ...
Welding, more welding ...

Greenpower GpSpeed Software
Preliminary

These directories contain some basic examples of Python software to run on a PC, laptop or Raspberry PI computer to allow the download and viewing of GpSpeed data logs and/or telemetry data. They can also form the basis or give ideas for other speed controllers and data loggers.

The code needs a ltiile more work and some more testing but we have released it as version 0.1 for people to get started.

The code is simple to give a basic idea of how to develop such programs in Python. They are not complete, it is left as an exercise for the student to understand and then develop them for there own uses. We want to encourage the learning and experimentation with areas of engineering rather than provide fully complete working code.

There are a few programs here that can run on a Linux based system or a Microsoft Windows based system. They all use Python version 2.7 and a number of extra libraries to provide GUI (Graphical User Interface) features. See the information on installing the necessary software in the GreenpowerSoftware.html information.

We have tried to use a simple Python system that the students are likely to be learning at school. A tricky bit may be the graphical user interface GUI library. We have used the wxPython library for this as it is fairly easy to use and similar in design to more sophisticated GUI systems. However other GUI librarirs such as PyQt could be used instead.

gpspeed-datalog-gui

System Overview

The GpSpeed controller has a simple Picaxe micro-controller that can run programs in a Basic like programming language. They are often used in schools for teaching. This is a very simple 8 bit CPU and the Picaxe Basic language is a bit simplistic, but it can be used to do all we want for Greenpower.

http://www.greenpower.beamweb.co.uk/groups/electronics/GpSpeed/index.html

There is an additional GpSpeedDataLog module available that has a real-time clock chip and some memory to store data logs. Information on this is at:

http://www.greenpower.beamweb.co.uk/groups/electronics/GpSpeedDataLog/index.html

The GpSpeed controller has two serial ports available. One is a full serial hardware supported serial port and the other is a software bit-bashed serial port which is also used to program and debug the Picaxe. We use the software bit-bashed serial port in these examples although the other port can be used as well and will likely be the best port to be used for telemetry applications.

There are two main ways we might want to get data from the GpSpeed:

Telemetry: Here a radio transceiver is attacher to one of the GpSpeed's serial ports and sends the data over the radio link to a PC/Laptop running at the pits. This allows the real-time data to be viewed by the student pitside engineer. Note that, depending on the radio technology user, on most circuits telemetry data will be limited to around 500m line of site and so not all of the circuit will be covered.

DataLogging: Here the GpSpeed measures and stores data in its on-board non volatile memory. The full data can be retrieved after the race by downloading it to a Laptop/PC over a serial link.

The data can be sent from the GpSpeed to the Laptop/PC in a similar way for both of these modes. For the telemetry mode a set of data will be sent once a second or every 10 seconds. In the case of the DataLogging download they will be send as fast as possible.

For more info see:

http://www.greenpower.beamweb.co.uk/groups/electronics/GreenpowerElectronics/DataLogging.html

Data Structure and Protocol

To simplify data transfer with the Picaxe processor used on the GpSpeed controller and to make the data transfer readable for ease of debug we use a simple ASCII text data protocol. For each sample time a single line of text with each data element in a fields separated by space character and with the line terminated by a NL (0x0A) character is used. The data line has the following fields in the example code.

2016-09-22T09:45:00 2410 1516 1614 45.16 100 33 1415

DateTime

Voltage

Current

Throttle

Speed

Distance

Temp

CurrentAvg

2016-09-22T09:45:00

2410

1516

100

4516

1655

33

1415



The fields have the following values:

DateTime

The date and time in ISO format

Voltage

The battery voltage scaled by 100

Current

The motor current scaled by 100

Throttle

The throttle position in %

Speed

The speed in km/H scaled by 100

Distance

The distance travelled in 10's of meters

Temperature

The motor temperature

CurrentAverage

The average current (per lap ?) scaled by 100

Most of the numeric fields are scaled by 100 so we can use fixed point numbers using the integer arithmetic of the Picaxe processor.

Picaxe Programming/Debug serial port

The Picaxe uses a bit-bashed software driver serial port for programming it and for debug purposes. This is not as fast or as robust as the hardware serial port it has but it is convenient to use. This serial port can be connected to the Laptop/PC using a standard Picaxe download cable like the AXE027.

With the Picaxe 28x2 this runs at 9600 Baud (Bits/sec) by default.

Examples

All of the following examples can be downloaded as one ZIP file if wanted. The is in one of the Greenpower-*.*.zip files below (different versions).
These software programs include a suitable GpSpeed picaxe program for running with them This is jusrt a simple cutdown program. You will have to generate the full running GpSpeed program yourself.

GpSpeed DataLog download command line program

This is a very simple command line program. It sends a command to the Picaxe when it is run asking it to send all of the data it has in it's log. This is read into the Laptop/PC and saved to a data.csv file on the hard disk. This file can be used with many data analysis programs including simple spread sheet programs like Libreoffice Calc or Microsoft Excel.

The program is written in Python 2.7 and only requires some basic Python libraries which includes pyserial for the serial port access.

GpSpeed DataLog download GUI program

This is a simple GUI program. It provides the ability to download data from the GpSpeed's data log and save this data to a data.csv file on the hard disk. It also shows the data graphs for a number of the data items. This file can be used with many data analysis programs including simple spread sheet programs like Libreoffice Calc or Microsoft Excel.

This program is written in Python 2.7. It also uses the Python wxWidgets library for GUI work and the matplotlib library for graph plotting. See the GreenpowerSoftware.html information for more details.

This program can easily be extended to do a lot more.

GpSpeed Telemetry GUI program

This is a simple GUI program. It provides the ability to plot data from the GpSpeed's telemetry output.

This program is written in Python 2.7. It also uses the Python wxWidgets library for GUI work and the matplotlib library for graph plotting. See the GreenpowerSoftware.html information for more details.

This program can easily be extended to do a lot more.
See the GreenpowerSoftware.html page for more information on installing and using the laptop/PC software.

Documentation

There are plenty of Python and wxPyton tutorials on the Internet. Here are some initial websites offering information:

Python 2.x
https://docs.python.org/2/
wxPython
https://wxpython.org/

Notes

  • All this code is designed to run under Python 2.7.
  • The TAB character is used for indentation. Make sure you do not mix spaces with TAB's. Most editors can be configured to use TAB's rather than spaces for indentation.