Magazine Mar2010 vol.4 [2 wheeled balancing robot]

Anything related to the ROBOT. Head to Toe Magazine.

Re: Magazine Mar2010 vol.4 [2 wheeled balancing robot]

Postby choyhong88 » Sat Feb 04, 2012 3:50 pm

From schematic diagram, switch S2 is a push button, which one should i use?

http://www.cytron.com.my/listProductGroup.php?pid=AQkyOTc2Gj0JCRYYAD0qItz/Y1sZ!!!!!oQalykjLb!!!!!FBoU=
choyhong88
Novice
 
Posts: 18
Joined: Thu Nov 03, 2011 1:05 am

Re: Magazine Mar2010 vol.4 [2 wheeled balancing robot]

Postby robosang » Sat Feb 04, 2012 9:19 pm

Ar? Why need to follow the switch type? Din check the schematic, but does it matter whether I use any of switches available? It just outlook, size and pin count. You can use any switch that connect and disconnect 2 terminal, I can even use mini jumper and header pin.
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: Magazine Mar2010 vol.4 [2 wheeled balancing robot]

Postby choyhong88 » Sat May 12, 2012 6:49 pm

The circuit schematic is edited based on cytron's balancing robot

correction to the diagram: forget to put +3V3 to MCP602 for this schematic diagram
Attachments
Balancing Robot schematic dspic30f4013.jpg
The circuit schematic is edited based on cytron's balancing robot
choyhong88
Novice
 
Posts: 18
Joined: Thu Nov 03, 2011 1:05 am

Re: Magazine Mar2010 vol.4 [2 wheeled balancing robot]

Postby choyhong88 » Sat May 12, 2012 7:53 pm

after assembly and built the circuit based on the above post.
i the compile the code provided by the magazine and load the hex file into the chip, the motor hav no any respond all even i try to turn the circuit board around every axis to see whether the motor turning or not.
Since i dont want to control the robot wirelessly, i remove the uart_initialize(),
may i know what else should i take alert to edit the code? please give some hint, i hav no idea...
Attachments
IMG_0202 copy.jpg
after assembly and built the circuit based on the above post.
choyhong88
Novice
 
Posts: 18
Joined: Thu Nov 03, 2011 1:05 am

Re: Magazine Mar2010 vol.4 [2 wheeled balancing robot]

Postby ober » Tue May 15, 2012 4:21 pm

Have you check the code? I think the code have a start button. Do you have the start button and have you press the start button?
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm

Re: Magazine Mar2010 vol.4 [2 wheeled balancing robot]

Postby choyhong88 » Tue May 15, 2012 10:20 pm

the switch(start button) is near the bottom of the microcontroller which is also equvalent to the S2 in the schematic diagram ,am i right? i did press the button, but the motor no respond.
choyhong88
Novice
 
Posts: 18
Joined: Thu Nov 03, 2011 1:05 am

Re: Magazine Mar2010 vol.4 [2 wheeled balancing robot]

Postby waiweng83 » Wed May 16, 2012 10:23 am

Have you make sure that your MCU is actually running? You can write a simple LED blinking program to ensure it.
This project is not a plug and play project. Do not expect to simply copy the schematic and download the firmware, it will works out of the box magically.
Furthermore, you are using a different MCU than the example, although this shouldn't be a problem.

So for a good start, write a simple program to test your circuit and make sure it's functioning, part by part. You can start from a LED first, then followed by switch motor and etc.
With the power of dream, nothing is impossible...
User avatar
waiweng83
Moderator
 
Posts: 208
Joined: Wed Apr 15, 2009 2:17 pm

Re: Magazine Mar2010 vol.4 [2 wheeled balancing robot]

Postby choyhong88 » Thu May 17, 2012 10:23 pm

hav tested with simple LED blinking...................................working
tested with direct driving motor but without PWM............working
choyhong88
Novice
 
Posts: 18
Joined: Thu Nov 03, 2011 1:05 am

Re: Magazine Mar2010 vol.4 [2 wheeled balancing robot]

Postby waiweng83 » Fri May 18, 2012 9:55 am

How about with PWM?
Try using the drive_motor() function in the sample source code. Remember to initialize the PWM before calling the function.
With the power of dream, nothing is impossible...
User avatar
waiweng83
Moderator
 
Posts: 208
Joined: Wed Apr 15, 2009 2:17 pm

Re: Magazine Mar2010 vol.4 [2 wheeled balancing robot]

Postby choyhong88 » Fri May 18, 2012 5:48 pm

i have some doubt in the provided source code, filename adc.c

why all the adc result is put in (signed int)ADCBUF0? will each of the result overwrite the previous result, then in the end we will only obtain the adc result for si_adc_right_motor_2 and the rest of result is gone? :?


CODE: SELECT_ALL_CODE
void adc_start_conversion(void)
{
        // Turn off PWM and let the back EMF become stable.
        // While waiting, we will sample the other channels first.
        OC1CONbits.OCM = 0;
        OC2CONbits.OCM = 0;
       
       
        // Select AN0 (Vin).
        ADCHSbits.CH0SA = 0;
       
        // Start sampling.
        ADCON1bits.SAMP = 1;
       
        // Delay 100uS.
        __delay32(_XTAL_FREQ/40000);
       
        // Stop sampling and start conversion.
        ADCON1bits.SAMP = 0;
       
        // Wait for conversion to finish.
        while (ADCON1bits.DONE == 0);
       
        // Save the value.
        sui_adc_supply = (signed int)ADCBUF0;
       
       
       
        // Select AN1 (Acc - X).
        ADCHSbits.CH0SA = 1;
       
        // Start sampling.
        ADCON1bits.SAMP = 1;
       
        // Delay 100uS.
        __delay32(_XTAL_FREQ/40000);
       
        // Stop sampling and start conversion.
        ADCON1bits.SAMP = 0;
       
        // Wait for conversion to finish.
        while (ADCON1bits.DONE == 0);
       
        // Save the value.
        sui_adc_acc_x = (signed int)ADCBUF0;
       
       
       
        // Select AN3 (Gyro).
        ADCHSbits.CH0SA = 3;
       
        // Start sampling.
        ADCON1bits.SAMP = 1;
       
        // Delay 100uS.
        __delay32(_XTAL_FREQ/40000);
       
        // Stop sampling and start conversion.
        ADCON1bits.SAMP = 0;
       
        // Wait for conversion to finish.
        while (ADCON1bits.DONE == 0);
       
        // Save the value.
        sui_adc_gyro = (signed int)ADCBUF0;
       
       
       
        // Select AN4 (Left Motor Voltage - 1).
        ADCHSbits.CH0SA = 4;
       
        // Start sampling.
        ADCON1bits.SAMP = 1;
       
        // Delay 100uS.
        __delay32(_XTAL_FREQ/40000);
       
        // Stop sampling and start conversion.
        ADCON1bits.SAMP = 0;
       
        // Wait for conversion to finish.
        while (ADCON1bits.DONE == 0);
       
        // Save the value.
        si_adc_left_motor_1 = (signed int)ADCBUF0;
       
       
       
        // Select AN5 (Left Motor Voltage - 2).
        ADCHSbits.CH0SA = 5;
       
        // Start sampling.
        ADCON1bits.SAMP = 1;
       
        // Delay 100uS.
        __delay32(_XTAL_FREQ/40000);
       
        // Stop sampling and start conversion.
        ADCON1bits.SAMP = 0;
       
        // Wait for conversion to finish.
        while (ADCON1bits.DONE == 0);
       
        // Save the value.
        si_adc_left_motor_2 = (signed int)ADCBUF0;
       
       
       
        // Select AN6(Right Motor Voltage - 1).
        ADCHSbits.CH0SA = 6;
       
        // Start sampling.
        ADCON1bits.SAMP = 1;
       
        // Delay 100uS.
        __delay32(_XTAL_FREQ/40000);
       
        // Stop sampling and start conversion.
        ADCON1bits.SAMP = 0;
       
        // Wait for conversion to finish.
        while (ADCON1bits.DONE == 0);
       
        // Save the value.
        si_adc_right_motor_1 = (signed int)ADCBUF0;
       
       
       
        // Select AN7 (Right Motor Voltage - 2).
        ADCHSbits.CH0SA = 7;
       
        // Start sampling.
        ADCON1bits.SAMP = 1;
       
        // Delay 100uS.
        __delay32(_XTAL_FREQ/40000);
       
        // Stop sampling and start conversion.
        ADCON1bits.SAMP = 0;
       
        // Wait for conversion to finish.
        while (ADCON1bits.DONE == 0);
       
        // Save the value.
        si_adc_right_motor_2 = (signed int)ADCBUF0;
       
       
       
        // Turn on PWM.
        OC1CONbits.OCM = 0b110;
        OC2CONbits.OCM = 0b110;
       
        // At last, before we exit, we start sampling AN0 (Vin) as it has a low output impedance.
        ADCHSbits.CH0SA = 0;
       
        // Start sampling.
        ADCON1bits.SAMP = 1;
}       


should we save the adc value in this way

sui_adc_supply = (signed int)ADCBUF0;
sui_adc_acc_x = (signed int)ADCBUF1;
sui_adc_gyro = (signed int)ADCBUF2;
si_adc_left_motor_1 = (signed int)ADCBUF3;
si_adc_left_motor_2 = (signed int)ADCBUF4;
si_adc_right_motor_1 = (signed int)ADCBUF5;
si_adc_right_motor_2 = (signed int)ADCBUF6;


And another doubt, the circuit diagram show that using 2 out of the 3 axis in accelerometer but in the source code only 1 axis is need. So, acually 1axis + 1 gyro rate are enough for balancing ..
choyhong88
Novice
 
Posts: 18
Joined: Thu Nov 03, 2011 1:05 am

PreviousNext

Return to ROBOT. Head to Toe Magazine

Who is online

Users browsing this forum: No registered users and 1 guest

cron