Saturday, April 12, 2014

What a fail...

Just don't know why the LM317 did not work for me. The output is 3.85 V which should be 1.777777778 V. Wasted my 0.1uf and 10 uf cap and several copper wires. Bad luck for me.




I  think there has a short circuit between the adj and output pin, after I use the tip to take out some fat it still not work. I guess the LM317 broke anyway.

R1 is 810 and R2 is 342 as I measured in the circuit. It is just not working now and I may need a new LDO, well....

Thursday, April 3, 2014

UAV competition in school SF State at March 15

   Hmm, The UAV competition in SF state is funny even though we did not get the first place. The whole run is really stressed since the atmosphere of it. 

    Now, we will change to the other place to continue compete. See you in Ca Poly!



Monday, March 24, 2014

The new quadcopter made from our team and flight test video

The frame changed for a more flexible aspect. More convenient for plug and unplug battery. A more Decent look llike bottom. We change the motor to 1000kv from 800kv. It become more powerful!

Here's the video we took today. It looks like good for self-level. The flight controller we are using is called KK 2.1.

http://www.youtube.com/watch?v=27Xw3a1D6Zk&feature=youtu.be

or  http://v.youku.com/v_show/id_XNjg5NzU5MTMy.html




Saturday, February 22, 2014

Lilttle narrow one for the stm32f313v flight controller(V2)

This may be the last Eagle version for the controller. I do not think I did care more about the trace smoothness when I was layoutting, but it probably fitted there.
I deleted some useless thing such as the RTC emergency ridiculous battery instant substitutional voltage source. And of course I delete the big switch and reverse plug protection components and traces. I don't know. It probably the most useless part I 've ever seen.



                                       
GY-86 is probably not best choice but it is still a good choice. If you have ever seen the guy in the web using the Eight bit PIC and a IMU as a combination component. You will know that it is better that use a 8 bit microcontroller  to separate the task efficiently. I will  not do that because I am doing just a simple flight controller. It is enough to solve problems now by using just one 32 bit MCU.






Thursday, February 20, 2014

2 layer Eagle PCB for STM32F3 version Flight Controller

As soon as I am concerned, eagle PCB is a very good tool of easy designing and layoutting. For more professional design and layout, Capture CIS schematic and Allegro are better. BTW, I think there is no point to compare these two different style things.

The auto router is ok for just layoutting a simple circuit. The STM32F313 is a very strange mcu since now STMICRO is not offering any information relate to this mcu.

The circuit is just based on PX4 2.43 circuit. What I was doing is just to edit and delete some thing. I did delete the battery management circuit since I think that is really too much for a middle level flight controller. And I also deleted the LED management circuits. I found that was not really necessary to use.

Also, if thinking about the price of MS5611 IC and MPU6050 , and the potential of damaging them when soldering. It is good to just buy a cheap and small board GY-86 from ebay, which will really save your time.

It is not easy to do the layout when you want to do smaller layout such as 1.5x1.5 inches (Especially when you do the 2-layer). I did not care about the layout at the first time, then it resulted a big layout 3.1x2.15 inches layout and it will take me 35$ in OSHPark..

Anyway, I think I probably will transfer this to allegro. I do think some vertical angles generated by the autorouter is hardly adjusted by hands in eagle.

Here's the layout generated by auto router from EAGLE PCB.




Saturday, February 15, 2014

STM32F103 assembly code for just turning on LED (Keil MDK)

If you ask how pain it is for just using assembly language to turning on the led, I WOULD say very very very very....pain in the ass!!

Last year I was using STK200 which has atmega16 on it. I was able to display a simple digital clock by just using AVR assembly, which just took me several hours to write the code and display it on the Putty.

But I have to admit, Cortex-M3 is so different than that one. It would take several hours to review the ARM instructions and architecture. And probably it will still has compile error in the code.

Here's a little example:


GPIOC_CRL   EQU     0x40011000
GPIOC_CRH   EQU     0x40011004
GPIOC_IDR   EQU     0x40011008
GPIOC_ODR   EQU     0x4001100C
GPIOC_BSRR  EQU     0x40011010
GPIOC_BRR   EQU     0x40011014
GPIOC_LCKR  EQU     0x40011018
;STACK_TOP EQU 0X20002000
    AREA RESET,CODE,READONLY
;DCD STACK_TOP ;MSP pointer
DCD start  ;reset

            AREA    RESET, CODE, READONLY

            ENTRY
start
           
    LDR   r1, =GPIOC_CRH      ; Address for port c control register
            LDR   r0, [r1]
STR   r0, [r1]            ; Write to contorl register

            MOV32   r1, #GPIOC_ODR      ; Address for port c output data register
            MOV     r0, #0x0A00         ; Value for port c
            STR     r0, [r1]            ; Write value
loop
            B       loop
            ALIGN
            END

I ediited a little bit from the original version. You will know that it won't even debug step in for you since the crazy "MOVS R0,R0"....

You will never know how to deal with it unless you know this device, cortex-m3 will probably need to initialize the stack otherwise the debugger will not give a fxxx to you.
So if uncomment the two statements above in the code, the debugging will start working. I would said do not try using pure assembly in CORTEX-M4, that is a different device and more bugs waiting.








Friday, January 31, 2014

First Flight Test, We did it!

Our J22 team just began the first flight test hours ago. The flight test was so smooth and very enjoyable. We did it!
First Flight Test
Video link: http://www.youtube.com/watch?v=LShO8eHxFqY




Thursday, January 23, 2014

3V3 STM32 I/O drive radioshack IRF510 MOSFET using Orcad Capture CIS simulator

              I still being lazy to identify the difference between P MOS and N MOS, J FET is even more impossible for me to identify. Well, that does not stop me to play with it. The Orcad capture pretty much helps me. The simulation model I use is not the radioshack one but ON Semiconductor one, but the model no is almost the same IRF510.

            I simply use a NPN BJT() to use as a switch to control the ON/OFF of MOS. Before doing this, SUPPOSE I use the I/O port to control the NPN BJT PN2221 (Because now is just simulation). Use this MOSFET will need to be carefully. If you see the datasheet before, it is very detailed two pages about the power. voltage and current...temperature. The term Continuous Source-Drain Diode Current simply says that the max continuous current could not exceed 5.6A and Pulsed diode Forward Current cannot exceed 20A. Otherwise the MOSFET will probably cracked due to high temperature..          
       
          Here is my simulation of the MOSFET driver:


         And waveform is always fake like hell...in matlab you may create fake noise, in capture you cannot even did like that.
And yes that is all of it i got.  
 

       

Friday, January 17, 2014

QUADROTOR DC MOTOR CONTROL OF PIC18

It is a initial sketch for the dc motor controller, there still has a lot of things will not be needed and also some parts need to be modified.



Monday, December 30, 2013

Driving ESC from STM32F4-DISCOVERY

It's way easier by simply driving ESC to make the 750kv HP2217 three phase BLDC motor rotate. The motor is far away smaller than the electric scooter I had in the summer. The control is way more suitable than the previous bldc motor. I do not need extra driver for rotating clockwise and counterclockwise. The direction is fixed to either CW or COUNTER CW.

The connection is easy for just driving the motor to rotate using the ESC. BLACK Wire from the ESC go to the GND to the discovery board. Do not connect red cable, so far i still do not know why the ESC has the red cable and without BEC.

And the White wire is the signal in wire, go to the PWM output pin of the Discovery board. And I guess it is the TTL rule of voltage recognition not CMOS.

Anyway it works for me, just changing the original code to 50hz and pulse to 1ms-1.2ms.

 PrescalerValue = (uint16_t) ((SystemCoreClock /2) / 1000000) - 1;//generate 1Mz frequency

  /* Time base configuration */
  TIM_TimeBaseStructure.TIM_Period = 20000-1;//down to 50hz
  TIM_TimeBaseStructure.TIM_Prescaler = PrescalerValue;//84-1

TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure;
TIM_OCInitTypeDef  TIM_OCInitStructure;
uint16_t CCR1_Val = 1000-1;
uint16_t CCR2_Val = 1200-1;


It is not really surprising as thinking in time domain. 20ms for one period and 1ms or 1.2ms pulse. 1ms it will turn off the motor and 1.2ms will probably make it rotate CW or CCW, it depends on the connection from ESC  to motor.

Code in github: https://github.com/bli19/UAV_Compete-Source

Sunday, December 29, 2013

 STM32F4  PWM MODE simple code (1 Channel for LED blink )

Editing the example PWM output code from 大舟 by changing the routine a little bit and the code is more close the original example from ST. Either could be the PWM1 or other pins with PWM mode. It can add more channels as long as the timer module could support. I found that it is a little bit abstract and vague when just using the example from ST, which is just can observe the voltage difference from voltmeter. And oscilloscope is way too expensive.

Here's part of code, hardly to say the period is what, this is what i confuse now. In the ST example:

 ARR = (TIM3 counter clock / TIM3 output clock) - 1= 665

It said that  28Mhz for the counter clock and 30 KHz for the output clock, this is probably a wrong calculation since it will got 933 but not 665.

Anyway, ARR itself is just a counter from 0 to TIM_Period for up counting in this post. There is a prescaler configure library function from ST is very easily to yse,

void TIM_PrescalerConfig(TIM_TypeDef* TIMx, uint16_t Prescaler, uint16_t TIM_PSCReloadMode)

Here using TIM3. And to make the output more visible, using probably 3 or 5hz for update.

TIM_PrescalerConfig(TIM3, PrescalerValue, TIM_PSCReloadMode_Immediate);

 PrescalerValue = (uint16_t) ((SystemCoreClock /2) / 500000) - 1;

In this case, the Value would be 168.

Also TIM_TimeBaseStructure.TIM_Period = 65535; this is important so that it will cycle counting.

 To enable the compare mode interrupt, using :

TIM_ITConfig(TIM3, TIM_IT_CC1 | TIM_IT_CC2 | TIM_IT_CC3 | TIM_IT_CC4, ENABLE);


The CCR1_Val is about the pulse value assignment, which i prefer large value such as 54618 so that its result is visible.Other wise need to change the ISR, which could be very headache.

I delete some if statement for the original code. It works for the Green LED on the stm32f4-discovery:
void TIM3_IRQHandler(void)
{
if (TIM_GetITStatus(TIM3, TIM_IT_CC1) != RESET)
{
TIM_ClearITPendingBit(TIM3, TIM_IT_CC1);

if(CCR1_Val==5000)
{
STM_EVAL_LEDOn(LED4); //PD12=0。ARR增加5000后,到达这条语句。
CCR1_Val=2500; //所以低电平的百分比为5000/7500=2/3。即占空比为1/3
}
else
{
STM_EVAL_LEDOff(LED4); //PD12=1
CCR1_Val=5000;
}
capture = TIM_GetCapture1(TIM3);
TIM_SetCompare1(TIM3, capture + CCR1_Val);//在原来的CCR1(即capture)基础上加5000,则再过5000,又会触发中断
//另外,有个问题,进入中断时,当ARR计数器快加到65535,而又不足5000时,不是会有数据多余,而产生波形的移动吗?
//回答:不用担心。例如进入中断是,ARR=65000,65000+5000=70000>65535,那么高位会舍去,即为70000-65536=4464
//等于是来了个循环,两次中断间ARR的增量还是5000。所以为了波形的稳定,初始化时,必须要有TIM_Period = 65535
}


}


The setup of the interrupt is easy as long as using the ST Library code, but maybe need to worry if ST begin charging some fees for that, who knows...

NVIC_InitTypeDef NVIC_InitStructure;

  /* TIM3 clock enable */
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);

  /* Enable the TIM3 gloabal Interrupt */
  NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);

  /* Initialize Leds mounted on STM32F4-Discovery board */
  STM_EVAL_LEDInit(LED4);
  STM_EVAL_LEDInit(LED3);
  STM_EVAL_LEDInit(LED5);
  STM_EVAL_LEDInit(LED6);

  /* Turn on LED4, LED3, LED5 and LED6 */
  STM_EVAL_LEDOn(LED4);
  STM_EVAL_LEDOn(LED3);
  STM_EVAL_LEDOn(LED5);
  STM_EVAL_LEDOn(LED6);



Also need to #include "stm32f4_discovery.h", it is necessary for turn on the LED to see the toggeling frequency of the LED. Here is the formula of calculating the toggling frequency.

 CC1 update rate = TIM3 counter clock / CCR1_Val
  Toggling CC1 update rate/2 HZ
Other parts are the same as the original code from ST, the LED will blink at 9.1/2=4.5 Hz. Which means it blinks 4.5 times per second.











Thursday, November 14, 2013


              Here is latest updating of the UAV(quadcopter) project, it is not cheaper than I think. I bought most of stuff from RCtimer and Hobbyking. It took me about 360 USD and I still need to buy flight controller and the T connector to XT60 transfer wires.
            Well, it's just my first try. So probably I have all the things not really DIYed, but that really need a step to go to DIY. I am planning to try to get the feelings of quadcopter flying and then design a board for flight controller. I am not good at frame design, so probably I have one mechanical guy design the frame and I am responsible for RC board,  flight control and programming part. Also a computer science teammate will responsible software programming in PC.









Tuesday, October 15, 2013

Two touch sensors added to senior project

          This is not fancy, two touch sensors which just being tested today. They are better than ordinary touch sensor though. The voltage of the output will be close to the VCC of microcontroller, and yes the touch sensor output has much more drifting when VCC change from 2 to 3V.
           The other good news is the ILI9325 and STM32F4 communicate successfully at today. I remembered last semester just crazy to make it work.
           And the camera for replacement from an ebay seller the just arrive. It will be good to see if I can make it to feature extraction, which is really advanced embedded technology....

Sunday, October 6, 2013

Just upload three posts in github for last summer funny stories with STM32. 


Here's The Three phases BLDC special little driving circuit for clock-wising and counter-wising.



Saturday, October 5, 2013

 Curious that I cannot really get the stm32f1 talk to the IMU mpu6050 and outputting to LCD. The IIC simulate mode is not awful than hardware IIC but I still trapped into it. Now I am guessing it is my soldering problem. I will try serial port if there has a conflict between LCD and IIC interface. Or the IMU is just borke.

Sunday, September 15, 2013

   Just got a board for stm32f1v, which is mainly for testing the imu i got. The problem is soldering such a small and weird pins. Probably will get a hot air gun and also a QFN 24pins board to fit the IMU, but  think a PCB is really expensive and need to pay more than 50 USD. Well, may get a new one which is already on board.

Saturday, September 14, 2013

        Hi, Everyone i know or do not know. My name is Bo Li. I am studying in San Francisco State University. This blog mainly about my projects in progressing and in the future.