發表文章

目前顯示的是 5月, 2013的文章

Auto start a Python service on beaglebone angustrom

after making several python web service, I wish to have the web service starts when power on beaglebone, this link is the reference: http://stackoverflow.com/questions/11152657/angstrom-start-up-processes-beaglebone example: Go in to /lib/systemd/system/ and open  the bone101.service, this is a service file for 101 stuff. so we have to create our service I have a PyBBIO web service stuff named as u4glass_tank.py saved as glass_tank.service [Unit] Description=Python glass tank web service [Service] WorkingDirectory=/home/root/PyBBIO/examples ExecStart=/usr/bin/python u4glass_tank.py [Install] WantedBy=multi-user.target Then go to terminal do the following: systemctl enable glass_tank.service To start the service, you can reboot or execute systemctl start glass_tank.service To check if the service is running and get the latest outputs from the script: root@beaglebone:~# systemctl status glass_tank.service in terminal it would return like this: glas

blue tooth low energy

Idea is to use TI2541 chip module source: 1. in Taiwan, but don't see and firmware http://www.joybien.com/download/DATASHEET_EN(UART)A.pdf 2.BLE112 Bluetooth Low Energy Breakout http://www.inmojo.com/store/jeff-rowberg/item/ble112-bluetooth-low-energy-breakout/ http://www.bluegiga.com/BLE112_Bluetooth_low_energy_module BGlib: https://github.com/jrowberg/bglib/tree/master/Arduino how to Programming the BLE112 using BGScript: http://blog.bluetooth-smart.com/2012/09/16/programming-the-ble112-using-bgscript/ Programming the BLE112 with C code using IAR: http://blog.bluetooth-smart.com/2012/09/11/programming-the-ble112-with-c-code-using-iar/#more-213 another BLE112 based shield: source:http://www.mkroll.mobi/?p=517 http://www.mkroll.mobi/?page_id=386 well documented: https://github.com/michaelkroll/BLE-Shield redbear BleFirmata using CC2540 USB interface one http://redbearlab.com/bleshield/ with central support BLEmini SDK http://redbearlab.com/blemini#SDK

low pass filter for arduino PWM control to reach 10V Analog control

Arduino PWM control frequency is about 488Hz for pin 3,9,10,11.. and 977Hz for P5,6, in order to make it analog out put. we selected a low pass RC filter where R=4.7K, C=3.3uF, which result a cut off frequency at about 10Hz...response time about 0.1-0.2 sec. then we need to amplify it to 10V http://arduino.cc/forum/index.php/topic,12135.0.html 2 ways are considered: lpf 5v pwm and switch up tp 10V http://www.3reef.com/forums/i-made/arduino-pwm-0-5v-0-10v-121705.html using 10V source and MOSFET then lpf http://www.reefcentral.com/forums/showthread.php?t=1995554

python periodic doing something

10 is the interval in second...foo is the function to run. >>> import time, threading >>> def foo(): ... print(time.ctime()) ... threading.Timer(10, foo).start() ... >>> foo() Thu Dec 22 14:46:08 2011 >>> Thu Dec 22 14:46:18 2011 Thu Dec 22 14:46:28 2011 Thu Dec 22 14:46:38 2011

How to out put HEX array with Pyserial

import serial import array ser=serial.Serial('COM3',38400,timeout=1) """ To turn on all LED on 255 FF FF 00 01 FF FF FF FF FF FF FF 0D To turn on at half FF FF 00 01 7F 7F 7F 7F 7F 7F 00 0D To turn off FF FF 00 01 00 00 00 00 00 00 00 0D """ LedOn=[0xFF,0xFF,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x0D] Test=[0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x50,0x51,0x0D] ser.write(array.array('B',LedOn).tostring()) ser.close() the command array can still be a 0x type to indicate hex array. but for pyserial, it take char, if you want to print out hex it need to be \x41 (which is an "A") if you have an arry say: My=[0x41,0x42,0x43] need to pass to pyserial write as '\x41\x42\x43' good thing is there is a array function to do so: array.array('B', My.tostring() which will out put '\x41\x42\x43'

Arduino based DMX library

Arduino based DMX ArtNet-Node I tried severail library for DMX, most of them modify the serial hardware setting on 168/328. 250000bps is supported, 2 stop bits are also supported. the first start 88us is using 115200 bps to send 0x00. But when I wish to run them on mega, most lib does not support. although we know we can modify the lib to fit mega, but this one claim to support mega, and able to do 4 universe. I'm going to try it!! but this lib only runs on 0023 version. I tried this Arduino based DMX ArtNet-Node v0.2 lib in 0022 version, it's pretty good, no need for modify hardwareserial.cpp and it works great on mega... Installation Instructions: Copy the folder “Dmx” included in the package to the folder arduino-0023/libraries/ Copy the folder “artnet_node” to Arduino sketches folder, in my case “Arduino” Now we can open the sketch of the “artnet_node”, compile the code and upload to Arduino. it seems if you don't use artnet function, it could work