Saturday, January 16, 2016

It Just Got a Lot Better - My New Tools.

I thought the beginning of 2016 would be a good time to share where I am now in my trading. Let me be clear, the basis has not changed. I trade inside out trades by trading the pullbacks in the trens as well as outside in trqades fading overbought and oversold conditions, all in a Market Profile context.

Lets start by talking about where Pete Steidlmayer is now. Here. Pete talks about trading the swings between accummulation and distribution. He tracks VOLUME. Now that actual live volume is available, he says that TPOs are outmoded. While I don't totally agree with that as I believe that Market Profile provides both support and resistance information as well as a big picture information of where value is moving, I do agree that we now are able to rtrack volume on a much more granular scale.

I tried using Pete's Volume Strips that he refers to in the video when they first became available, but I did not "see" the order flow clearly at all.  I then tried to use Pete's Cap32 software and had a guide with me for a week. Sadly, this did not add anything to my seeing order flow. Perhaps it was just me.

What began to provide me with more information was firstly cumulative volume delta and then MarketDelta's Volume Imbalance charts. Finally, the order flow was becoming visible.

What I have now done is to capture both the order flow and volume information to trade the same way I did before in order to more precisely see my entry and exit points. You still see the CCI to measure trend as well as Keltners and Bollingers to identify overbought and oversold. What is additional is the inside the bar trades and the Volume Profile (VP) to understand the order flow in each swing and to identify, more precisely, my entries and exits (stops and targets). These changes to my chart have provided a huge improvement, especuially in the types of markets we are trading in this modern eara where:
  • there are no floor locals - everyone is an electronic local
  • Algos make up for a great majority of the trades and volume that takes place every day in most markets
 So lets talk a few specifics. The VP identifies whether a pullback is a probable entry point or not. The VP also allows me to use tighter and better stops. To achieve this, I use multiple VPs on my chart as the swings develop.  The inside the bar information you see allows me to fine tune entries and to better identify exits.

The final piece is the buttons on the right I call GEL. These buttons allow me to hybrid trade and use specific rules in specific context whwre a set of pressed buttons are only valid for the particular trade I am attempting. They reset to zero after the trade is entered.



The Volume Profile is available from PureLogic. I'll provide more info on this great tool in subsequent posts. You can see the Volume Profile on any bars you select and shows, for that selection, VA, VAL VAH, POC, VWAP and Standard Deviations plus a lot more.You can buy it here.

Speed Motor's Variator Using STM32

Speed Motor's Variator Using STM32


R�sultat de recherche d'images pour "stm32 motor"


La variation de vitesse de moteur a courant continu dans cet article est bas�e sur le protocole PWM qu'on peut le d�finir comme ceci :


PWM

La modulation de largeur d'impulsions (MLI ; en anglais : Pulse Width Modulation, soit PWM), est une technique couramment utilis�e pour synth�tiser des signaux continus � l'aide de circuits � fonctionnement tout ou rien, ou plus g�n�ralement � �tats discrets.
Le principe g�n�ral est qu'en appliquant une succession d'�tats discrets pendant des dur�es bien choisies, on peut obtenir en moyenne sur une certaine dur�e n'importe quelle valeur interm�diaire.
R�sultat de recherche d'images pour "pwm mli definition"
Ce ph�nom�ne est fortement recommand� pour assurer la variation de vitesse de moteur a courant continu, aujourd'hui je vais vous d�montrer comment on peut g�n�rer un signal PWM d�une STM32 et visualiser son pr�sence sur des diodes LEDs.

Voici un exemple de comment on genere un signal PWM using Mikro C for ARM et STM32F4:
//Let's Electronic By Aymen Lachkhem
// www.letselectronic.blogspot.com
// Hello in this tutoriel we are going to use 4 buttons (digital Input), the first two will increase and decrease the current duty for the
// first Led and the second two will make the same thing with the other Led.
unsigned int current_duty, old_duty, current_duty1, old_duty1;
unsigned int pwm_period1, pwm_period2;

void InitMain() {
GPIO_Digital_Input (&GPIOA_BASE, _GPIO_PINMASK_3 | _GPIO_PINMASK_4 | _GPIO_PINMASK_5 | _GPIO_PINMASK_6); // configure PORTA pins as input
}

void main() {
InitMain();
current_duty = 100; // initial value for current_duty
current_duty1 = 100; // initial value for current_duty1

pwm_period1 = PWM_TIM1_Init(5000);
pwm_period2 = PWM_TIM4_Init(5000);

PWM_TIM1_Set_Duty(current_duty, _PWM_NON_INVERTED, _PWM_CHANNEL1); // Set current duty for PWM_TIM1
PWM_TIM4_Set_Duty(current_duty1, _PWM_NON_INVERTED, _PWM_CHANNEL2); // Set current duty for PWM_TIM4

PWM_TIM1_Start(_PWM_CHANNEL1, &_GPIO_MODULE_TIM1_CH1_PE9);

PWM_TIM4_Start(_PWM_CHANNEL2, &_GPIO_MODULE_TIM4_CH2_PD13);

while (1) { // endless loop
if (GPIOA_IDR.B3) { // button on RA3 pressed
Delay_ms(1);
current_duty = current_duty + 5; // increment current_duty
if (current_duty > pwm_period1) { // if we increase current_duty greater then possible pwm_period1 value
current_duty = 0; // reset current_duty value to zero
}
PWM_TIM1_Set_Duty(current_duty, _PWM_NON_INVERTED, _PWM_CHANNEL1); // set newly acquired duty ratio
}

if (GPIOA_IDR.B4) { // button on RA4 pressed
Delay_ms(1);
current_duty = current_duty - 5; // decrement current_duty
if (current_duty > pwm_period1) { // if we decrease current_duty greater then possible pwm_period1 value (overflow)
current_duty = pwm_period1; // set current_duty to max possible value
}
PWM_TIM1_Set_Duty(current_duty, _PWM_NON_INVERTED, _PWM_CHANNEL1); // set newly acquired duty ratio
}

if (GPIOA_IDR.B5) { // button on RA5 pressed
Delay_ms(1);
current_duty1 = current_duty1 + 5; // increment current_duty
if (current_duty1 > pwm_period2) { // if we increase current_duty1 greater then possible pwm_period2 value
current_duty1 = 0; // reset current_duty1 value to zero
}
PWM_TIM4_Set_Duty(current_duty1, _PWM_NON_INVERTED, _PWM_CHANNEL2); // set newly acquired duty ratio
}

if (GPIOA_IDR.B6) { // button on RA6 pressed
Delay_ms(1);
current_duty1 = current_duty1 - 5; // decrement current_duty
if (current_duty1 > pwm_period2) { // if we decrease current_duty1 greater then possible pwm_period1 value (overflow)
current_duty1 = pwm_period2; // set current_duty to max possible value
}
PWM_TIM4_Set_Duty(current_duty1, _PWM_NON_INVERTED, _PWM_CHANNEL2);
}

Delay_ms(1); // slow down change pace a little
}
}
    Voici une d�monstration vid�o de fonctionnement :




L�objectif de ce tutoriel est de mettre en oeuvre le contr�le de vitesse de moteur a courant continu de fa�on autonome 
Pour ceci on aura besoin de 
Un Moteur DC
STM32 F4
Transistor TIP122
Diode
Deux boutons poussoirs 
deux r�sistances 1 K

Le principe est tout � fait simple on aura deux boutons poussoirs ou la premi�re va incr�menter la vitesse de moteur et la deuxi�me va faire exactement le contraire.

L�incr�mentation continuera jusqu�� alimenter le moteur en r�gime de rapport cyclique complet puis conditionnement une autre incr�mentation va le remettre a 0 tour/s, le m�me truc se passe avec la d�cr�mentation de rapport d�ja nul va le rendre on vitesse maximale.


Voici un exemple de comment on varie le vitesse de moteur a courant continu using Mikro C for ARM et STM32F4:

//Let's Electronic By Aymen Lachkhem
//
www.letselectronic.blogspot.com
// In This Tutorial We are going to control the speed of dc motor using Stm32 PWM.
unsigned int current_duty, old_duty;
unsigned int pwm_period1, pwm_period2;

void InitMain() {
GPIO_Digital_Input (&GPIOA_BASE, _GPIO_PINMASK_3 | _GPIO_PINMASK_4 ); // configure PORTA pins as speed control input
}

void main() {
InitMain();
current_duty = 100; // initial value for current_duty


pwm_period1 = PWM_TIM1_Init(5000);


PWM_TIM1_Set_Duty(current_duty, _PWM_NON_INVERTED, _PWM_CHANNEL1); // Set current duty for PWM_TIM1

PWM_TIM1_Start(_PWM_CHANNEL1, &_GPIO_MODULE_TIM1_CH1_PE9);



while (1) { // endless loop
if (GPIOA_IDR.B3) { // button on RA3 pressed
Delay_ms(1);
current_duty = current_duty + 1; // increment speed
if (current_duty > pwm_period1) { // if we increase current_duty greater then possible pwm_period1 value
current_duty = 0; // reset current_duty value to zero
}
PWM_TIM1_Set_Duty(current_duty, _PWM_NON_INVERTED, _PWM_CHANNEL1); // set newly acquired duty ratio
}

if (GPIOA_IDR.B4) { // button on RA4 pressed
Delay_ms(1);
current_duty = current_duty - 3; // decrement speed
if (current_duty > pwm_period1) { // if we decrease current_duty greater then possible pwm_period1 value (overflow)
current_duty = pwm_period1; // set current_duty to max possible value
}
PWM_TIM1_Set_Duty(current_duty, _PWM_NON_INVERTED, _PWM_CHANNEL1); // set newly acquired duty ratio
}

Delay_ms(1); // slow down change pace a little
}
}
    Voici une d�monstration vid�o de fonctionnement :




   




Friday, January 15, 2016

STM32 F4 (PWM,SPI and ADC Test Examples)

STM32 F4 (PWM,SPI and ADC Test Examples)


R�sultat de recherche d'images pour "stm32"


On Commence par definir ces 3 grandes protocoles �lectroniques :

PWM

La modulation de largeur d'impulsions (MLI ; en anglais : Pulse Width Modulation, soit PWM), est une technique couramment utilis�e pour synth�tiser des signaux continus � l'aide de circuits � fonctionnement tout ou rien, ou plus g�n�ralement � �tats discrets.
Le principe g�n�ral est qu'en appliquant une succession d'�tats discrets pendant des dur�es bien choisies, on peut obtenir en moyenne sur une certaine dur�e n'importe quelle valeur interm�diaire.
R�sultat de recherche d'images pour "pwm mli definition"
Ce ph�nom�ne est fortement recommand� pour assurer la variation de vitesse de moteur a courant continu, aujourd'hui je vais vous d�montrer comment on peut g�n�rer un signal PWM d�une STM32 et visualiser son pr�sence sur des diodes LEDs.

Voici un exemple de comment on genere un signal PWM using Mikro C for ARM et STM32F4:
//Let's Electronic By Aymen Lachkhem
// www.letselectronic.blogspot.com
// Hello in this tutoriel we are going to use 4 buttons (digital Input), the first two will increase and decrease the current duty for the
// first Led and the second two will make the same thing with the other Led.
unsigned int current_duty, old_duty, current_duty1, old_duty1;
unsigned int pwm_period1, pwm_period2;

void InitMain() {
GPIO_Digital_Input (&GPIOA_BASE, _GPIO_PINMASK_3 | _GPIO_PINMASK_4 | _GPIO_PINMASK_5 | _GPIO_PINMASK_6); // configure PORTA pins as input
}

void main() {
InitMain();
current_duty = 100; // initial value for current_duty
current_duty1 = 100; // initial value for current_duty1

pwm_period1 = PWM_TIM1_Init(5000);
pwm_period2 = PWM_TIM4_Init(5000);

PWM_TIM1_Set_Duty(current_duty, _PWM_NON_INVERTED, _PWM_CHANNEL1); // Set current duty for PWM_TIM1
PWM_TIM4_Set_Duty(current_duty1, _PWM_NON_INVERTED, _PWM_CHANNEL2); // Set current duty for PWM_TIM4

PWM_TIM1_Start(_PWM_CHANNEL1, &_GPIO_MODULE_TIM1_CH1_PE9);

PWM_TIM4_Start(_PWM_CHANNEL2, &_GPIO_MODULE_TIM4_CH2_PD13);

while (1) { // endless loop
if (GPIOA_IDR.B3) { // button on RA3 pressed
Delay_ms(1);
current_duty = current_duty + 5; // increment current_duty
if (current_duty > pwm_period1) { // if we increase current_duty greater then possible pwm_period1 value
current_duty = 0; // reset current_duty value to zero
}
PWM_TIM1_Set_Duty(current_duty, _PWM_NON_INVERTED, _PWM_CHANNEL1); // set newly acquired duty ratio
}

if (GPIOA_IDR.B4) { // button on RA4 pressed
Delay_ms(1);
current_duty = current_duty - 5; // decrement current_duty
if (current_duty > pwm_period1) { // if we decrease current_duty greater then possible pwm_period1 value (overflow)
current_duty = pwm_period1; // set current_duty to max possible value
}
PWM_TIM1_Set_Duty(current_duty, _PWM_NON_INVERTED, _PWM_CHANNEL1); // set newly acquired duty ratio
}

if (GPIOA_IDR.B5) { // button on RA5 pressed
Delay_ms(1);
current_duty1 = current_duty1 + 5; // increment current_duty
if (current_duty1 > pwm_period2) { // if we increase current_duty1 greater then possible pwm_period2 value
current_duty1 = 0; // reset current_duty1 value to zero
}
PWM_TIM4_Set_Duty(current_duty1, _PWM_NON_INVERTED, _PWM_CHANNEL2); // set newly acquired duty ratio
}

if (GPIOA_IDR.B6) { // button on RA6 pressed
Delay_ms(1);
current_duty1 = current_duty1 - 5; // decrement current_duty
if (current_duty1 > pwm_period2) { // if we decrease current_duty1 greater then possible pwm_period1 value (overflow)
current_duty1 = pwm_period2; // set current_duty to max possible value
}
PWM_TIM4_Set_Duty(current_duty1, _PWM_NON_INVERTED, _PWM_CHANNEL2);
}

Delay_ms(1); // slow down change pace a little
}
}
    Voici une d�monstration vid�o de fonctionnement :




SPI

Une liaison SPI (pour Serial Peripheral Interface) est un bus de donn�es s�rie synchrone baptis� ainsi par Motorola, qui op�re en mode Full-duplex. Les circuits communiquent selon un sch�ma ma�tre-esclaves, o� le ma�tre s'occupe totalement de la communication. Plusieurs esclaves peuvent coexister sur un m�me bus, dans ce cas, la s�lection du destinataire se fait par une ligne d�di�e entre le ma�tre et l'esclave appel�e chip select.

R�sultat de recherche d'images pour "spi protocol"

Voici un exemple de comment interfacer un afficheur LCD 2X16 avec la carte STM232 en utilisant le Mikro c for ARM:
//Let's Electronic By Aymen Lachkhem
// www.letselectronic.blogspot.com

// LCD module connections
sbit LCD_RS at GPIOB_ODR.B2;
sbit LCD_EN at GPIOB_ODR.B3;
sbit LCD_D4 at GPIOB_ODR.B4;
sbit LCD_D5 at GPIOB_ODR.B5;
sbit LCD_D6 at GPIOB_ODR.B6;
sbit LCD_D7 at GPIOB_ODR.B7;
// End LCD module connections

unsigned int adc_value;


void main(){


Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);

while(1) {
Lcd_Out(1, 3, "STM32 With LCD");
delay_ms(10);
}
}
    Voici une d�monstration vid�o de fonctionnement :


Convertisseur Analogique Num�rique ADC

Un convertisseur analogique-num�rique (CAN, parfois convertisseur A/N), ou en anglais ADC pour (Analog to Digital Converter) ou plus simplement A/D, est un montage �lectronique dont la fonction est de traduire une grandeur analogique en une valeur num�rique(cod�e sur plusieurs bits), proportionnelle au rapport entre la grandeur analogique d'entr�e et la valeur maximale du signal.
Le signal converti est le plus souvent une tension �lectrique.
R�sultat de recherche d'images pour "convertisseur analogique num�rique"



Voici un exemple de comment utiliser le protocole ADC avec la carte STM232 en utilisant le Mikro c for ARM:
//Let's Electronic By Aymen Lachkhem
// www.letselectronic.blogspot.com

unsigned int adc_value;


void main(){

adc_value = ADC1_Read(3); // read analog value from ADC1 module channel 3


while(1) {
GPIOC_BASE = adc_value;
delay_ms(10);
}
}
 Voici une d�monstration vid�o de fonctionnement pr�c�dant juste ici on va lire la valeur analogique sur le potentiom�tre et la �crire sur le comportement d'une diode LED.  




Thursday, January 14, 2016

Let's Discover STM32 (Blinking Led, Delay, GPIO I/O)

Let's Discover STM32 (Blinking Led, Delay, GPIO I/O)

La famille des microprocesseurs STM32 de ST Micro�lectroniques fournit une vaste gamme de p�riph�riques autour d'un c�ur d'ARM Cortex, allant du simple GPIO (port d'entr�e-sortie g�n�raliste) et interface de communication serie synchrone (SPI) ou asynchrone (RS232) aux interfaces aussi complexes que l'USB, Ethernet ou HDMI. 




 
Un point remarquable est qu'un certain nombre de ces processeurs poss�dent deux convertisseurs analogique-num�riques, permettant un �chantillonnage simultan�e de deux grandeurs analogiques. Cadence sur un r�sonateur interne ou sur un quartz externe haute fr�quence 8 MHz (multiplie en interne au maximum  a 72 MHz).
Afficher l'image d'origine



R�sultat de recherche d'images pour "stm32 microcontrollers"
Le kit STM32F4Discovery de STMicroelectronics est con�u pour �valuer les caract�ristiques des microcontr�leurs des s�ries STM32F407 et STM32F417. Les microcontr�leurs STM32F407 et STM32F417 sont bas�s sur le c�ur 32 bits ARM Cortex-M4F hautes performances.
Les familles STM32F405, STM32F407, STM32F415, STM32F417 de microcontr�leurs sont bas�es sur le noyau RISC 32 bits ARM Cortex-M4 de qualit� sup�rieure qui fonctionne � une fr�quence de jusqu'� 168 MHz. Le noyau Cortex-M4 offre une unit� de virgule flottante (FPU) � pr�cision simple qui prend en charge toutes les instructions de traitement de donn�es et types de donn�es � pr�cision simple ARM. Il ex�cute �galement toute une s�rie d'instructions DSP et une unit� de protection de m�moire (MPU) qui am�liore la s�curit� d'application.

         Microcontr�leur STM32F407VGT6 avec noyau Cortex-M4F 32 bits ARM, flash 1 Mo, 192 Ko de RAM dans un bo�tier LQFP100
         ST-LINK/V2 int�gr� avec choix de commutation des modes pour utiliser le kit comme
         ST-LINK/V2 autonome (avec connecteur SWD pour la programmation et le d�bogage)
         L'alimentation de la carte se fait par bus USB ou via tension d'alimentation externe de 5 V
         Alimentation d'application externe : 3 et 5 V
         Acc�l�rom�tre LIS302DL ou LIS3DSH ST MEMS
         MP45DT02, capteur audio ST MEMS, microphone num�rique omnidirectionnel
         CS43L22, DAC audio avec pilote de haut-parleur de classe D int�gr�
         Huit LED : LD1 (rouge/verte) pour la communication USB, LD2 (rouge) pour la mise sous tension 3,3 V.
         Quatre LED utilisateur, LD3 (orange), LD4 (verte), LD5 (rouge) et LD6 (bleue), 2
         LED OTG USB LD7 (vertes) VBus et LD8 (rouge), surintensit�
         Deux boutons-poussoirs (utilisateur et Reset)
         USB OTG FS avec micro-connecteur AB
         Extension d'embase pour toutes les E/S LQFP100 de connexion rapide pour la
 
  SDIO (entr�e/sortie num�rique s�curis�e)
USART, SPI, I�C
  I�S (son Inter-IC) + PLL audio
Timers 16 et 32 bits
ADC jusqu'� 3 x 12 bits
Basse tension 1,7 � 3,6 V
     
     Voici des exemples de r�alisation pratique �quip�es avec les codes sources et des vid�os d�monstratifs
     
     1- STM32 Tutoriel #1 (Control Leds Using externel Button) 



CODE IS HERE :


/*Let's Electronic By Aymen Lachkhem */ #include "stm32f4xx_hal.h" int main() { GPIO_InitTypeDef GPIO_InitStructure; //HAL_Init(); /* GPIO Ports Clock Enable */ __GPIOD_CLK_ENABLE(); __GPIOA_CLK_ENABLE(); /* Configure PD10 as output pushpull mode */ GPIO_InitStructure.Pin = GPIO_PIN_10; GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStructure.Speed = GPIO_SPEED_LOW; GPIO_InitStructure.Pull = GPIO_PULLDOWN; HAL_GPIO_Init(GPIOD, &GPIO_InitStructure); /* Configure PA1 in input mode*/ GPIO_InitStructure.Pin = GPIO_PIN_1; GPIO_InitStructure.Mode = GPIO_MODE_INPUT; GPIO_InitStructure.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStructure); while(1) { if (HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_1) == GPIO_PIN_SET) HAL_GPIO_WritePin(GPIOD, GPIO_PIN_10, GPIO_PIN_SET); else HAL_GPIO_WritePin(GPIOD, GPIO_PIN_10, GPIO_PIN_RESET); } }
Have Fun 

   2- STM32 Tutoriel #2 (Control DC Motor in Both Direction) 




CODE IS HERE :

/*Let's Electronic By Aymen Lachkhem*/ #include "stm32f4xx_hal.h" int main() { GPIO_InitTypeDef GPIO_InitStructure; //HAL_Init(); /* GPIO Ports Clock Enable */ __GPIOD_CLK_ENABLE(); __GPIOA_CLK_ENABLE(); /* Configure PD11, PD10 in output pushpull mode to control DC Motor / GPIO_InitStructure.Pin = GPIO_PIN_10 | GPIO_PIN_11 ; GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStructure.Speed = GPIO_SPEED_LOW; GPIO_InitStructure.Pull = GPIO_PULLDOWN; HAL_GPIO_Init(GPIOD, &GPIO_InitStructure); /* Configure PA1 in input mode for DC motor's direction*/ GPIO_InitStructure.Pin = GPIO_PIN_1; GPIO_InitStructure.Mode = GPIO_MODE_INPUT; GPIO_InitStructure.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStructure); while (1) if (HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_1)){ HAL_GPIO_WritePin(GPIOD, GPIO_PIN_11,GPIO_PIN_SET); HAL_GPIO_WritePin(GPIOD, GPIO_PIN_10,GPIO_PIN_RESET); } else { HAL_GPIO_WritePin(GPIOD, GPIO_PIN_11,GPIO_PIN_RESET); HAL_GPIO_WritePin(GPIOD, GPIO_PIN_10,GPIO_PIN_SET); }}

Have Fun 

    3 - STM32 Tutoriel #3 (Toggle Leds Using Mikro C for ARM)  




CODE IS HERE :


// Let's Electronic By Aymen Lachkhem unsigned int oldstate; void main() { GPIO_Digital_Input(&GPIOA_IDR, _GPIO_PINMASK_0); // Set PA0 as digital input GPIO_Digital_Output(&GPIOD_ODR, _GPIO_PINMASK_ALL); // Set PORTD as digital output oldstate = 0; do { if (Button(&GPIOA_IDR, 0, 1, 1)) // detect logical one on PA0 pin oldstate = 1; if (oldstate && Button(&GPIOA_IDR, 0, 1, 0)) { // detect one-to-zero transition on PA0 pin GPIOD_ODR = ~GPIOD_ODR; // invert PORTD value oldstate = 0; } } while(1); // endless loop }

Have Fun 

3