Sunday, 24 March 2019

Alpha V1 Open-Source Arduino Compatible Transmitter (Remote Controller)

I have been working on Alpha V1 for the past two years. I wanted to make sure Alpha V1 become the ultimate remote controller for variety of projects and as a result I ended up coding for most of the last 2 years.

Alpha V1 Open-Source Arduino Compatible Transmitter (Remote Controller)


Alpha V1 is an open-source transmitter (remote controller) with arduino compatible hardware. That would be Alpha V1's definition in one sentence but Alpha V1 is more than that. Alpha V1 is a transmitter that allow users to customize and modify their transmitter like never before. Alpha V1 does not only allow you to do that, it actually assist you because it let you do a lot of code-free modifications. Alpha V1 will be open-source not because we want you to get involved with the code for every small modification; instead we just want to make sure we do not give you any limitation in your projects. I have personally worked really hard to make sure code-free modification become a strong core value of Alpha V1 and I think we have achieved that to a reasonable level. Of course we cannot support every hardware that is out there, but we have managed to take care of many common devices.
I think it is the appropriate time to write more about Alpha V1, therefore I decided to write a post about it.

We will be launching a crowdfunding campaign for Alpha V1 and if you want to get notified at launch, subscribe at: https://www.craetech.com/alpha-v1

If you want to get the latest update about Alpha V1, follow CRAE Tech's social media pages:


Saturday, 25 January 2014

How to Find Torque for R/C Brushless Motors

I was looking for a solution to find the torque of my brushless motors for ages. I could not find any solution. I was chatting with my friend Shane Colton and he told me how to do it.

So these are the steps, for now I don't show why it is correct but it is not that hard to prove just play around with units.
Step 1: KV is usually provided. KV's unit is rpm/Volt
change rpm/Volt to (radian/sec)/Volt
Hint: just multiply by 2Pi/60 or use this.
step 2: inverse the result in step 1. So the unit becomes Volt/(radian/s)
Step 3: Find the current input of the motor.
In case you want to find maximum torque find the max power of the motor in the voltage you are using the motor. Sometimes it is provided by the manufacturer. Then use P=VI to find maximum I.
Step 4: multiply current to what you found in step 2. This answer is torque and the unit is Nm

the equation for the torque would be:
Torque = Step_2_result * Current

Sunday, 2 September 2012

Review on HRLV-MaxSonar®-EZ™ Sensors (MB1013) )

I have tried three different ultrasonic sensors, one from Devantech (I guess it was SRF05 but not so sure), one was the first series of MaxBotix when they had resolution of 1 inch and recently I tried MB1013 from high resolution series. With no doubt the last one was the best I have seen. I am going to use this sensor for a competition where I have to detect a wall with hight of 10 cm and my sensor is located 5 cm away from the ground and It did a very good job during our tests. I designed few different tests to see how much I can rely on my ultrasonic sensor.
I found a line of best fit for its output to make sure my reading are the best possible.
These are my points and their ADC reading:
Average ADC reading:                     Distance:
76.3929                                           40
126.9655172                                   65
176.0333333                                   90
226.3103448                                   115
256.8125                                         130
296.0714286                                   150

The best line fit:
y =   0.501x + 1.67
distance = 0.501  *  ADC_reading + 1.67

The equation works quite well. The ultrasonic has 3 different types of output:
1) Analog: which I like it, since it is fast, easy but less accurate compare to others but fine for me
2) Pulse width: a bit more complicated since you have to use a timer. I am using Arduino which does not have a lot of timer and for my robot, I will be using most of timers. If you want  very accurate result then go for next option.
3) Serial output: This is the most accurate output. But wasting a UART may not be a good idea. The other issue is that if you use interrupt to read your UART input, you have to turn other interrupts off which may not be suitable for some situation. If you read UART without interrupt it will take some time since the baud rate is 9600. (I may try this in future just for sake of accuracy)

they are two modes of reading the output from sensor:
1) free run:
It has a filter included and I prefer to use this since it has a filter.
2) Real time:
It has no filter and it will do its reading when you send a signal.

Now I start with tests.

Testing different material:
The sensor has the same output for different type of materials. I tried with metal sheet, carton and polystyrene.

Testing different shapes:
It could detect the cylinder without any issue from sides and it showed an accurate output. Flat surfaces are definitely detected and there is no issue with them.

Object with different size:
the size of object is not going to change the output.

Detecting the closest object:
Even if there is a big object at the back and small object in front, sensor output will be the distance to closest one.

Detecting 15 degrees ramp:
It could detect the ramp with acceptable accuracy from 30 cm to 15o cm. The length of the ramp is 60cm.

I used this ultrasonic on my robot and I think you have to consider the following if you are going to use one:
1) In the real time mode you do not get a very reliable reading (I tried it in a parking lot and I was not happy with it)

2) If you are using the free run mode, your readings are impressive, however you cannot move very fast because it takes some time for changes to appear on you reading. (This is what you should expect when you are using ultrasonic, I did some research and I found out that laser range finder can do a better job at much higher. Hopefully I will be making one laser range finder with my friend.)

3) If you are using the sensor very close (5 cm) to a surface which is not supposed to be detected, you have to make sure that the surface is flat. To give you an idea we had to wooden sheet next to each other with a gap around 1mm. The sensor was detecting the edge from 190 cm. It was detecting the edge of the gap (located at 190cm) instead of the wall which was located ~240 cm away.

Conclusion:
A good sensor for application where respond time can have a delay of 1s. Accuracy is good. Sensor has 3 different outputs which make them easier to use. If you want to have a fast robot forget about ultrasonic and go for laser range finder.

Wednesday, 21 March 2012

Vexta DC Brushless Motor Running with PWM

If you live in Malaysia and Cytron is one of your resources, you should have seen all those expensive brush less motors called Vexta. They come with a gearbox and a speed controller.
I looked at the data sheet and I did not see anything about PWM, so I tried to use PWM to control it and I failed. I was using a roughly 60KHz PWM and it did not work. I tried with 16MHz and I am getting a very good result from them. I am using an AVR board which has an Atmega 1280 on it.
I just wrote the following program to make it work.
////////////////////

  int a=0;
      while(1)
      {
      OCR0A=a;
      OCR0B=a;
      a+=10;
      delay_ms(3000);   //delay_us(500)
        if(a>240)
        {
        a=0;
        }
   
      }
//////////////////////
necessary registers are the following:

PORTB=0x00;
DDRB=0x80;



TCCR0A=0x83;
TCCR0B=0x01;
TCNT0=0x00;
OCR0A=0x00;
OCR0B=0x00;

Keep in mind that I was using a 16MHz clock.


There is something else that I have to share, in the catalog there is a page called connection and operation, in that page all on are indicating gnd and all off the indicate +5 (High). (I don't know why)
So in order to run it with PWM, this is what you do with the speed controller:

PIN 1: not connected
PIN 2: not connected
PIN 3: GND
PIN 4: GND
PIN 5: PWM
PIN 6: not connected
PIN 7: +5V (HIGH)

PIN 8: +5V (HIGH)
PIN 9: GND for clockwise. 1 for counter clockwise
PIN 10: GND
PIN 11: GND

This is the video of the Vexta motor running.

Saturday, 10 March 2012

Review on L6203 Full Bridge Driver

This is an amazing motor driver. It has temperature protector which really works and cut down the current. One of the best thing is that even at high temperature it does not cut the whole current, it will bring down the current. This can be good for the condition where you have to apply force but your motor is stalled for some time.
I have never had any problem using L6203, and honesty it is hard to burn them. To give you an idea, once I connect all pins in opposite order and it did not burnt. The other time I connected the Vs to GND and GND to 36V and it is still working, although it was drawing 3 A. It has even short circuit protector for outputs, which means that even by short circuiting out 1 and 2, nothing bad going to happen. (I have never tried though)
The only thing which I found important is that you can't use Vref as a HIGH for input 1 and input 2. I am not sure why, but I am sure from my real life experience.
You may use Vref for enable but not for inputs.
This is how I use my L6203:
1: Output 2 which is connected to a 15nF cap and one of the wires coming from motor. (the other side cap is connected to boot2)
2: Supply voltage that you want to run motor with it
3: Output 1 which is connected to a 15nF cap and the other wire coming from motor. (the other side cap is connected to boot1)
4: Boot 1. This is connected to the other side of 15nF cap that you have connected to out 1
5: Input 1, just make sure you do not connect Vref as a high for inputs
6: Ground
7: Input 2, just make sure you do not connect Vref as a high for inputs
8: Boot 2. This is connected to the other side of 15nF cap that you have connected to out 2
9: Vref, This is a reference voltage around 12 V. You may use this to apply a high to Enable pin and make the L6203 to always be on.
10: Sense, you can connect this directly to ground, if you don't want to get any feedback from current. If you want to get a feedback from current connect a resistor between this pin and ground. Than read the voltage between this pin and resistor.
11: Enable, by adding high to this pin you will turn on L6203

If you want to get the best out of this component just add a heat sink and a fan, then it works forever with high output current.

This component is much better than L298 and L293. I have used them all and I found L6203 much more reliable, specially if you are going to attend a competitions, you can rely on L6203. I have explode L298 and L293 after using them for long time or drawing high current, but never had any issue with L6203.

If you want to control speed of a motor and its direction, you can simply use one of the inputs as a PWM and connect the other input to any I/O of micro controller which is assigned as output. By changing the value of PWM you will change the speed and by changing the value of I/O from Low to High or High to Low you can change the direction.

Tuesday, 6 March 2012

How To Use Pulse Width Modulation (PWM) To Control Electrical Speed Controller (ESC)?

In this post we will have some specific talk about AVR since I have experience with.
The objective is to make a pulse with period of 10 ms and pulse width less than 2 ms and more than 1 ms. [1ms,2ms].
At first we look at a case where we have an external 16 MHz clock and we are using 16 bits timer.
If you have a 16 MHz clock then the possible clocks for your PWM are the followings:
16/1 = 16 MHz
16/8 = 2 MHz
16/64 = 0.25 MHz = 250kHz
16/256 = 0.0625 MHz = 62.5 kHz
16/1024 = 0.015625 MHz = 15.625 kHz
So now we will find which of the following will gives us 10 ms period.
we start with the one with lowest period which is working at 16 MHz.
1/(16*10^6) * 2^16  = 0.004096 = ~ 4 ms
This is too fast. We need at least 10ms. so we try with 2MHz
1/(2*10^6) * 2^16  = 0.032768 = ~ 33 ms
This means that this timer will give us a period of 33 ms before overflow.
We know that every 1/(2*10^6) timer counts one, therefore our resolution is 1/(2*10^6) = 0.0000005s = 0.5us
10 ms / 0.5 us = 10 ms / 0.0005 ms =  20,000
20,000 indicates that after this number we have to start from zero. (resetting the timer)

1 ms / 0.5 us = 1 ms / 0.0005 ms =  2,000 steps for minimum speed
2 ms / 0.5 us = 2 ms / 0.0005 ms =  4,000 steps for maximum speed

Here I do not want to talk abou PWM I will do it here, so I will just leave the required value of registers in order to achieve what it is explained above:
//defining I/Os as output so later on we will generate the waveform on these pins


// Port B initialization
// Func7=Out Func6=Out Func5=Out Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=0 State6=0 State5=0 State4=T State3=T State2=T State1=T State0=T
PORTB=0x00;
DDRB=0xE0;


// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: 2000.000 kHz
// Mode: Fast PWM top=ICR1
// OC1A output: Non-Inv.
// OC1B output: Non-Inv.
// OC1C output: Non-Inv.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer 1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
// Compare C Match Interrupt: Off
TCCR1A=0xAA;
TCCR1B=0x1A;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x4E;
ICR1L=0x20;
OCR1AH=0x07;
OCR1AL=0xD0;
OCR1BH=0x07;
OCR1BL=0xD0;
OCR1CH=0x07;
OCR1CL=0xD0;

This will make the PWM to work in the way that we want. (This code was tested in real life) It will give three different PWMs.

Now this is the function that will change the pulse width for output A from timer 1.


void motor_x(unsigned int speed )
{
OCR1AH = speed >> 8;
OCR1AL = speed;
}


I guess now you have got the idea, if there was any issue just post your questions in the comments.