Using matplotlib to plot NI DAQmx data file (big data)

Due to the recent research requirement, I need to replot and analysis signal of high sampling rate (several mega samples per seconds) with PCIe card.

I planned to use numpy and matplotlib to plot, but I was a bit worried on the capability of using npTDMS and matplotlib to processing big data (100MB to 1GB, but big data in modern sense)

A quick test shows it works (to draw array of several mega samples), seems not worse than NI AIdem for visualization, all subject to serious delay during zooming in. However, the loading is much slower,  as npTDMS is pure python, not C API implemented.

And the program just consume as little memory as it is on disk size.

Continue reading

Posted in Uncategorized | Leave a comment

using OpenCV in Qt4 GUI using python

This python read from webcam and display into Qt4 widget(not highGUI) code is adapted from example code from : #http://wrdeoftheday.com/?page_id=2

since not all source code is attached, I complete the code and make it available for downland. This can serve as a better starting point for more complicated app.

zip password: iesensor.com

zip file:  qtcvpy

Continue reading

Posted in Programming | Leave a comment

beaglebone black debian wheezy usb net configuration and ssh login on windows and Linux

 

follow the tutorial and make usbnet boot automatically
http://hipstercircuits.com/enable-serialuarttty-on-beaglebone-black/

on my BBB debian wheezy:

sudo cat  /etc/modprobe.d/usbnet.conf

#auto load usbnet
options g_multi file=/usbnet.img stall=0
#there is a usbnet.img already there under /

Continue reading

Posted in Uncategorized | Comments Off

batch post-Process Ansys Fluent CFD Case And Plot In Python using Matplotlib or Tecplot

Features:

1. parse the ansys fluent profile text file into python list of dict;  draw velocity profiles by matplatlib (“see source code of draw_profile.py”)

2. generate tecplot batch and macro file to draw contours automatically in batch mode.  (see “vizCFDbytecplot.py”)

download the source file here,

vizFluentbytecplotandPython

I hope it can inspire you, but it will not serve you directly.

Edit some variables at the beginning of source code should make it work for you.

you need to record your own tecplot macro to style the plot.

 

 

License:BSD

Qingfeng Xia  2013

“CFD study of synthetic jet at low Reynolds numbers”

University of Manchester

 

Posted in Programming, Research | Comments Off

solutions for python pip install gcc compilation error: -mno-cygwin

 

(1)install unofficial python extension package  binary installer

Unofficial Windows Binaries for Python Extension Packages

by Christoph Gohlke, Laboratory for Fluorescence Dynamics, University of California, Irvine.

 

(2)
MinGWmay be not compatible with python pip compiler:   -mno-cygwin
remove the official mingw from path. or install mingw built for python

Windows GCC (MinGW) binaries for Python developers  gcc4.3

 

(3) Remove the  -mno-cygwin  option

-mno-cygwin in Python\Lib\distutils\cygwinccompiler.py causes this problem: see Compiling with cython and mingw produces gcc: error: unrecognized command line option ‘-mno-cygwin’ or http://korbinin.blogspot.com/2013/03/cython-mno-cygwin-problems.html.

My Python distribution (Anaconda)’s cygwinccompiler.py does not have that though. Anyway, after removing all -mno-cygwin in the definition of the Mingw32CCompiler class you should be able to compile.

Posted in Uncategorized | Comments Off

Recommend RT-Thread RTOS to Linux programmers

In a nutshell, Linux programmers will love RT-Thread API.
  1. Thread in RT-Thread works like  POSIX thread:  #include <posix_types.h>
  2. Each thread has TCB (task control block),  like Linux kernel thread, share the global memory, but has its own stack (pre-decleared array with fixed size), has event and timer for each thread;  Thescheduler, which uses bitmap algorithm,  is similar with Linux kernel
  3. RT-Thread is high performance RTOS, mainly focusing on ARM cortex-M 32bit CPU.
  4. RTGUI/FTK   (object-oriented style widget,  just like GTK+)
  5. Device model like Linux device tree.
  6. IPv4 and IPv6 are supported by lwIP lib with <socket.h>, but 6LowPAN is not supported as Contiki.
  7. Simulator on Linux and Windows (32bit  x86 only) and good documentation.
  8. Python scons building system; but it is easier than Makefile to control multiple targets building.

Most important, it is free even  for commercial usage, via applying free license and keep RT-thread banner.

Finally, this is the host place:  https://github.com/RT-Thread

Posted in Uncategorized | Comments Off

Software SPI library for Arduino tested on Mega2560

Since there is only one hardware SPI, but it is used by Ethernet or Wifi shield. If you wantto conenct some other sensors via SPI, the Ethernet lib is reluctant to cooperate.

So a software bit-banging library may be necessary.

Four SPI modes are supported, just change the macro definition in header file.

Continue reading

Posted in Uncategorized | Comments Off

[notes]Arduino IDE can NOT include libraries within project subfolders

The IDE requires every file to be in the same directory as the main program!

Continue reading

Posted in Uncategorized | Comments Off

Setup Codelite to work with visual studio toolset

I am tired to upload figures , I just give it as PDF file with figures inside

Setup Codelite to work with visual studio toolset (totorial version)

Posted in Uncategorized | Comments Off

python pinyin module support simplified and traditional chinese codecs

git clone https://github.com/qingfengxia/pinyin.py.git

Pinyin python module

Origin:      Author:cleverdeng      E-mail:clverdeng@gmail.com (not reachable)

forked by Qingfeng Xia based on v0.9:  
               (1)renamed class name from PinYin to Pinyin, 
               (2)dict file "word.data"  is  renamed  as "pinyin.data" 
               (3) add encoding support, or it will not work for windows cmd prompt! 
               (4) move load_word() (renamed as loaddict() ) into __init__(), to make API concise
               (5) word.data  "ord(UNICODE)= list of pinyin", for quick loading and human readable check
                  why some unicode has multiple pinyin units??? 

installation: 
               copy the two files:  pinyin.py, pinyin.data , into your project folder, or under $PYTHONPATH , or your sitepackages

test:   testing code is under __main__ section
               python -m pinyin.py

 Continue reading 
Posted in Download, Programming | Comments Off

Comparsion of DateTime classes in popular programming Languages (2)

as a further explanation to:

” Comparsion of DateTime classes in popular programming Languages (1)”

This part is a copy and paste of lang/lib spec.

Continue reading

Posted in Programming | Comments Off

Comparsion of DateTime classes in popular programming Languages (1)

C    boost::Datetime  Java JDK8(javax.time)  Qt Python and Javascript

(1) Table comparison

(2) Further explanation from each language spec

Joda package for (Java) is not described here, whose API is analoguous to Qt and Python. As there is new API of LocalDateTime,  it is the equivalent to QDatetime, and python’s datetime.

Table: Comparsion of DateTime classes in popular programming Languages

Author: Qingfeng Xia  2013    Versioin 0.1             http://www.iesensor.com

see attached word doc

Table Comparison of DateTime classes in popular programming Languages

Continue reading

Posted in Programming | Comments Off

You must know C++11, but have you noticed C11?

Previous C++ standard is C++03 (2003); previous C std is C99.They are not released together, but they did this time as  a combo of C11 and C++11.

__STDC_VERSION__ == 201112L

C11 (formerly C1X) is an informal name for ISO/IEC 9899:2011  (see wiki)

http://en.wikipedia.org/wiki/C11_%28C_standard_revision%29

Continue reading

Posted in Programming | Comments Off

Four wheel car robot based on Arduino Mega2560 and Raspberry Pi

git clone https://github.com/qingfengxia/arduinorobotcar.git

Datasheets (most of them in Chinedse) for robot parts makes the git size big

=========================================

Recently, I have been working on Arduino 2/4 wheel car robot in my spare time.

===============design goals==================

Robot car composing 4 DCMotors, Senors, ServoArm, BlueTooth remote control

Phase 1:
(1)   two/four wheel driving car steering,
There is no designated positive or negative pole for DC motor,  swapping pin1 and pin2 can made motor rotate reversely

Phase 2:
(2) sensors:  using  PID for sensor fusion ,
a)  altrasound range sensors included
b)  acceleration or angle speed
c) Infrared receiver
(3) Control by Infrared remote or PC control via bluetooth

Phase 3:
(4)  usb Camera supervision using Raspberry Pi usb wifi
(5) voice command recogniation by raspberry Pi connected to internet

Continue reading

Posted in Programming, Robot | Comments Off

Melexis90620 IR sensor controlled by Arduino and Raspberry Pi

I have made a C++ library class for Melexis90620 (in order to use multiple sensors simultanuously ),  a test program to demo this class, python program to show the contour.

Also, I made I2C C program to control itby Raspberry PI, but raspberry Pi can not read from RAM (reading EEPROM is fine).

A new plan under evaluation is to use 4 Melexis90620 togother to make 16X16 pixel IR camera. The only obstacle is to change the I2C slave address. I saw some guy has change the address of Melexis90614.  I dump EEPROM of reserved addr,  I found some byte should be addr, but I dont know how to write EEPROM. (command sequence)

Continue reading

Posted in Download, Programming, Robot, Sensor | Comments Off

my robotics lab is ready to go

IMG_20130303_170947

Posted in Robot | Comments Off

QtCore vs C++ STL & boost lib (4) smart pointers

see “Count with me: how many smart pointer classes does Qt have?”

http://blog.qt.digia.com/blog/2009/08/25/count-with-me-how-many-smart-pointer-classes-does-qt-have/

Smart pointers  Introduction Ver
QPointer<T> Qt Object , guarded pointer,
set NULL after delete/deconstruction
However, pointed resource not released
 Qt4.0
QSharedPointer reference-counted strong sharing of pointers Qt4.5
QWeakPointer reference-counted weak sharing of pointers Qt4.5
QScopedPointer Qt4.6
QScopedArrayPointer QScopedPointer drived Qt4.6
QSharedDataPointer Qt (Implicit Sharing) copy-on-write Qt4.0
QExplicitlySharedDataPointer ExplicitlyShared Qt4.4

C++11 <smart_pointer>

Introduction to smart pointers:   http://en.wikipedia.org/wiki/Smart_pointer

std::auto_ptr  Not recommended in C++11  C++03
std::shared_ptr Reference counting C++11
std::weak_ptr Intended for Garbage collection C++11
std::unique_ptr non-copyable, but can be transfered C++11
boost::scoped_ptr<T> Equal to QScopedPointer

neither copyable nor movable.

Continue reading

Posted in Programming | Comments Off

QtCore vs C++ STL & boost lib (3) Threading

Threading is always tricky, I dare not comment on this topics.

If some useful articles are found, this page will be updated!

 

Posted in Programming | Comments Off

QtCore vs C++ STL & boost lib (2) Container

 

just read the article: < Understand the Qt containers >

http://marcmutz.wordpress.com/effective-qt/containers/

key points

(1) difference:

a)Qt Containers:  implicitly shared (Copy-On-Write) !

b) size type: QT return signed int, while STL return size_t (unsigned int)

c) Iterator

(2)Qt has C++ STL style API, stick to these API style(3) Usage QVector  instead of QList as much as possible

 

Qt containers and their STL counterparts

The following table summarises the main sequential and associative Qt containers and their STL counterparts. For the most part, we will ignore the string classes, even though technically, they are also containers.

Qt STL
Sequential Containers
QVector std::vector
std::deque
QList
QLinkedList std::list
std::forward_list
Associative Containers
QMap std::map
QMultiMap std::multimap
std::set
std::multiset
QHash std::unordered_map
QMultiHash std::unordered_multimap
QSet std::unordered_set
std::unordered_multiset
Posted in Programming | Comments Off

QtCore vs C++ STL & boost lib (1) IO

QFile is the class for  everyday File IO, while C++ STL using  stream

===========based class: std::stream =========
<iostream> (qDebug()  or #include <iostream> cin/cout )
<fstream>  (QFile)
<sstream> (QBuffer)
<boost/archive> ( QDataStream for serialization )

===========QIODevice===========
The QIODevice class is the base interface class of all I/O devices in Qt.

#include <QIODevice>

Inherits: QObject.

Inherited by: Q3Socket, Q3SocketDevice,
QAbstractSocket, QBuffer, QFile, QLocalSocket, QNetworkReply,
and QProcess  ( just like bash shell pipe input and output, Python).

 

Continue reading

Posted in Programming | Comments Off