BBB and serial communication 
https://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black/uart


http://bradsmc.blogspot.cz/2013/05/exam ... tween.html

import serial
import time
import datetime
import re

serial = serial.Serial("/dev/ttyO1", baudrate=38400)

resp = ""

while True:
while (serial.inWaiting() > 0):
data = serial.read()
resp += data
if "\r\n" in resp:
now = datetime.datetime.now()
timestamp = "%02d/%02d/%d %02d:%02d:%02d" % \
(now.month,now.day,now.year,now.hour,now.minute,now.second)
matchObj = re.match(r'\^([0-9A-F]+)\r\n', resp)
print matchObj.group(1)
resp = ""
serial.flush();
serial.write(matchObj.group(1) + " OK: " + timestamp + "\n")


Return the number of chars in the receive buffer.
http://pyserial.sourceforge.net/pyseria ... .inWaiting



[ add comment ]   |  [ 0 trackbacks ]   |  permalink
python: convert variable into listo of bytes 
>>> hex_str = "0xffff"
>>> list(struct.pack('!I', int(hex_str, 16)))
['\x00', '\x00', '\xff', '\xff']
>>> list(struct.pack('I', int(hex_str, 16)))
['\xff', '\xff', '\x00', '\x00']


list(bytearray(struct.pack('!I', int(hex_str, 16))))


>>> list(bytearray(struct.pack('!I', 65534)))
[0, 0, 255, 254]


>>> list(bytearray(struct.pack('!H', 65534)))
[255, 254]



x pad byte no value
c char string of length 1 1
b signed char integer 1 (3)
B unsigned char integer 1 (3)
? _Bool bool 1 (1)
h short integer 2 (3)
H unsigned short integer 2 (3)
i int integer 4 (3)
I unsigned int integer 4 (3)
l long integer 4 (3)
L unsigned long integer 4 (3)
q long long integer 8 (2), (3)
Q unsigned long long integer 8 (2), (3)
f float float 4 (4)
d double float 8 (4)
s char[] string
p char[] string
P void * integer (5), (3)


[ add comment ]   |  [ 0 trackbacks ]   |  permalink
Learn and Understand AngularJS 
Master AngularJS and the Javascript concepts behind it, design custom directives, and build a single page application.

https://www.udemy.com/learn-angularjs/?couponCode=YOUTUBE119

[ 1 comment ]   |  [ 0 trackbacks ]   |  permalink  |  related link
BBB 
Enable the I2C devices on the BeagleBone Black
http://beaglebone.cameon.net/home/i2c-devices


PyBBIO, PinMux
https://github.com/graycatlabs/PyBBIO/wiki
https://github.com/graycatlabs/PyBBIO

Pinmux Map
http://www.element14.com/community/thre ... hread=true



[ 1 comment ]   |  [ 0 trackbacks ]   |  permalink
optimal resistor accuracy while building DAC - R2R ladder 
optimal resistor accuracy while building DAC - R2R ladder

----------------------
12 bit R2R =

2^12 = 4092

precission of a single resistor

(1/4092)*100 = 0,025

10 bit ladder requires 0.025% precission resistors

----------------------

10 bit R2R =

2^10 = 1024

precission of a single resistor

(1/1024)*100 = 0,09765625

10 bit ladder requires 0.1% precission resistors

----------------------

9 bit R2R =

2^9 = 512

precission of a single resistor

(1/512)*100 = 0,19%

----------------------

8 bit R2R =

2^8 = 256

precission of a single resistor

(1/256)*100 = 0,39%

----------------------

7 bit R2R =

2^7 = 128

precission of a single resistor

(1/128)*100 = 0,78125%


---------------------------


6 bit R2R = 64

2^6 = 64

precission of a single resistor

(1/128)*100 = 1,5625%


---------------------------




[ add comment ]   |  [ 0 trackbacks ]   |  permalink  |  related link
Cheep PCB board manufacturing - comparision 
http://pcbshopper.com/

EEVblog PCB manufacturing
https://www.youtube.com/watch?v=Uemr8xaxcw0

pcb+stencil
http://www.shenzhen2u.com/PCB


[ 7 comments ]   |  [ 0 trackbacks ]   |  permalink  |  related link
hackaday 
http://hackaday.io/project/1662-global- ... ng-network

text


[ add comment ]   |  [ 0 trackbacks ]   |  permalink  |  related link
výroba z tenkostěnných plechů 
http://www.koopron.cz/
http://www.kovosreal.cz/178-zpracovani-plechu-cz

[ add comment ]   |  [ 0 trackbacks ]   |  permalink
Rotary Encoder Interfacing With MSP430 LaunchPad  
http://www.circuitvalley.com/2013/09/ro ... chpad.html


[ add comment ]   |  [ 0 trackbacks ]   |  permalink  |  related link
MSP430 i2c code 4 DCO 

/*
* This file is automatically generated and does not require a license
*
* ==== WARNING: CHANGES TO THIS GENERATED FILE WILL BE OVERWRITTEN ====
*
* To make changes to the generated code, use the space between existing
* "USER CODE START (section: <name>)"
* and
* "USER CODE END (section: <name>)"
* comments, where <name> is a single word identifying the section.
* Only these sections will be preserved.
*
* Do not move these sections within this file or change the START and
* END comments in any way.
* ==== ALL OTHER CHANGES WILL BE OVERWRITTEN WHEN IT IS REGENERATED ====
*
* This file was generated from
* C:/ti/grace_3_00_01_48_eng/packages/ti/mcu/msp430/csl/interrupt_vectors/InterruptVectors_init.xdt
*/
#include <msp430.h>

/* USER CODE START (section: InterruptVectors_init_c_prologue) */
#include <stdint.h>

extern unsigned char calibrate_flag;

struct Voice {

uint8_t osc_divider;
uint8_t osc_counter_lsb;
uint8_t osc_counter_msb;
uint8_t osc_dac_lsb;
uint8_t osc_dac_msb;

} voice;

unsigned int i2c_cntr = 0;
unsigned int virtual_TA0CCR0;
unsigned int virtual_TA0CTL;
unsigned char play_midi_note_toggle_bit;
/* USER CODE END (section: InterruptVectors_init_c_prologue) */

/*
* ======== InterruptVectors_graceInit ========
*/
void InterruptVectors_graceInit(void)
{
}


/* Interrupt Function Prototypes */



/*
* ======== USCI A0/B0 TX Interrupt Handler Generation ========
*
* Here are several important notes on using USCI_A0/B0 TX interrupt Handler:
* 1. User could use the following code as a template to service the interrupt
* handler. Just simply copy and paste it into your user definable code
* section.
* For UART and SPI configuration:

if (IFG2 & UCA0TXIFG) {

}
else if (IFG2 & UCB0TXIFG) {

}

* For I2C configuration:
if (IFG2 & UCA0/B0TXIFG) {

}
else if (IFG2 & UCA0/B0RXIFG) {

}


* 2. User could also exit from low power mode and continue with main
* program execution by using the following instruction before exiting
* this interrupt handler.
*
* __bic_SR_register_on_exit(LPMx_bits);
*/
#pragma vector=USCIAB0TX_VECTOR
__interrupt void USCI0TX_ISR_HOOK(void)
{
/* USER CODE START (section: USCI0TX_ISR_HOOK) */
if (IFG2 & UCB0TXIFG) { // callback to transmit bytes

UCB0TXBUF = 0xff;

} else if (IFG2 & UCB0RXIFG) { // callback for bytes received

switch(i2c_cntr) {

case 0:
voice.osc_divider = UCB0RXBUF;
i2c_cntr++;
break;

case 1:
voice.osc_counter_msb = UCB0RXBUF;
i2c_cntr++;
break;

case 2:
voice.osc_counter_lsb = UCB0RXBUF;
i2c_cntr++;
break;

case 3:
voice.osc_dac_msb = UCB0RXBUF;
i2c_cntr++;
break;

case 4:
voice.osc_dac_lsb = UCB0RXBUF;
i2c_cntr++;

virtual_TA0CCR0 = voice.osc_counter_msb; // (2) CCR0 - set CCR0 (compare register value)
virtual_TA0CCR0 = virtual_TA0CCR0 << 8;
virtual_TA0CCR0 |= voice.osc_counter_lsb;

if(voice.osc_divider == 1) {
// (4) TA0CTL - clock src & divider & mode
// start TIMER0_A0
// TASSEL_2 == Timer A clock source select: 2 - SMCLK
// ID_0 == Timer A input divider: none
virtual_TA0CTL = TASSEL_2 | ID_0 | MC_1; // MC_1 == Timer A mode control: 1 - Up to CCR0

} else if(voice.osc_divider == 2) {
// (4) TA0CTL - clock src & divider & mode
// TASSEL_2 -- SMCLK
// ID_1 -- Timer A input divider: 1 - /2 *
virtual_TA0CTL = TASSEL_2 | ID_1 | MC_1; // MC_1 -- Timer A mode control: 1 - Up to CCR0

} else if(voice.osc_divider == 4) {
// (4) TA0CTL - clock src & divider & mode
// TASSEL_2 -- SMCLK
// ID_2 -- Timer A input divider: 2 - /4 *
virtual_TA0CTL = TASSEL_2 | ID_2 | MC_1; // MC_2 -- Timer A mode control: 1 - Up to CCR0

} else if(voice.osc_divider == 8) {
// (4) TA0CTL - clock src & divider & mode
// TASSEL_2 -- SMCLK
// ID_2 -- Timer A input divider: 3 - /8
virtual_TA0CTL = TASSEL_2 | ID_3 | MC_1; // MC_2 -- Timer A mode control: 1 - Up to CCR0

} else if(voice.osc_divider == 16) {
// (4) TA0CTL - clock src & divider & mode
// TASSEL_2 -- SMCLK
// ID_2 -- Timer A input divider: 3 - /8
virtual_TA0CTL = TASSEL_2 | ID_3 | MC_3; // MC_3 -- Timer A mode control: 3 - Up/Down

} else if(voice.osc_divider == 0xff) { // calibration request (0xff)

calibrate_flag = 1; // set calibration flag
P1OUT |= BIT2; // ON LED; BIT0(P1) is MCU pin 2

}

}

if(!calibrate_flag) {

//
// TOGGLE play_midi_note_toggle_bit & SET
//

play_midi_note_toggle_bit ^= BIT7; // toggle play_midi_note_toggle_bit

if(play_midi_note_toggle_bit != 0) {

P1OUT |= BIT3; // BIT3(P1) is MCU pin 5

} else {

P1OUT &= ~(BIT3); // BIT3(P1) is MCU pin 5

};

//
// set voltages on R2R
//
if(voice.osc_dac_msb != 0) { // prevent ower-current when MSB state changes
// ie. 10 11111000 <-> 11 10000000
P3OUT = 0;

}

voice.osc_dac_msb |= 0xfc;
P2OUT &= voice.osc_dac_msb;

voice.osc_dac_msb &= 0x03;
P2OUT |= voice.osc_dac_msb;

P3OUT = voice.osc_dac_lsb;

}

}

/* USER CODE END (section: USCI0TX_ISR_HOOK) */
}

/*
* ======== USCI A0/B0 RX Interrupt Handler Generation ========
*
* Here are several important notes on using USCI_A0/B0 RX interrupt Handler:
* 1. User could use the following code as a template to service the interrupt
* handler. Just simply copy and paste it into your user definable code
* section.
* For UART and SPI configuration:

if (IFG2 & UCA0RXIFG) {

}
else if (IFG2 & UCB0RXIFG) {

}

* For I2C configuration:
if (UCB0STAT & UCSTTIFG) {

}
else if (UCB0STAT & UCSTPIFG) {

}
else if (UCB0STAT & UCNACKIFG) {

}
else if (UCB0STAT & UCALIFG) {

}

* 2. User could also exit from low power mode and continue with main
* program execution by using the following instruction before exiting
* this interrupt handler.
*
* __bic_SR_register_on_exit(LPMx_bits);
*/
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR_HOOK(void)
{
/* USER CODE START (section: USCI0RX_ISR_HOOK) */
if (UCB0STAT & UCSTTIFG) { // start condition interrupt (1 is pending)

i2c_cntr = 0; // transmission begins
UCB0STAT &= ~UCSTTIFG; // clear start condition int flag

} else if (UCB0STAT & UCSTPIFG) { // stop condition interrupt (1 is pending)

UCB0STAT &= ~UCSTPIFG; // clear stop condition int flag

} else if (UCB0STAT & UCNACKIFG) { // slave not acknowledge received data (if master)

UCB0STAT &= ~UCNACKIFG;

} else if (UCB0STAT & UCALIFG) { // two or more masters start trans. simultaneously

// master code

}
/* USER CODE END (section: USCI0RX_ISR_HOOK) */
}

/*
* ======== Timer0_A3 Interrupt Service Routine ========
*/
#pragma vector=TIMER0_A0_VECTOR
__interrupt void TIMER0_A0_ISR_HOOK(void)
{
/* USER CODE START (section: TIMER0_A0_ISR_HOOK) */

TA0CTL = virtual_TA0CTL;
TA0CCR0 = virtual_TA0CCR0;

/* USER CODE END (section: TIMER0_A0_ISR_HOOK) */
}




[ 7 comments ]   |  [ 0 trackbacks ]   |  permalink

<<First <Back | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Next> Last>>