Modifying PR18 (BIPED)

LED Blinking, Walking with Cytron Servo, Displaying RFID, Multi-function Mobile Robot......

Modifying PR18 (BIPED)

Postby himura_ryuu » Wed Oct 13, 2010 4:40 pm

Hello guys...

Currently i', trying to modifying the Cytron PR18 which i have purchased last month.
What i'm trying to do was to add in the accelerometer to the circuit.

Here is the schematic i've done. Can anyone gave me idea or correct me if i did something wrong with the connection. Tq..
Full.jpg
Drawn by using DipTrace


I'm using Cytron Triple Axis Accelerometer Breakout (SN-ADXL335)
"Q.E.D
Shoumei Shouryou"
himura_ryuu
Apprentice
 
Posts: 34
Joined: Wed May 20, 2009 6:08 pm

Re: Modifying PR18 (BIPED)

Postby kl84 » Thu Oct 14, 2010 1:17 pm

You can't use voltage divider to get 3.3V needed by the sensor. What the sensor needs is not a reference voltage, but the proper power supply. LM7833, LD1117-3.3 or LM2937-3.3 will do the job.
User avatar
kl84
Amateur
 
Posts: 166
Joined: Thu Jul 08, 2010 12:14 pm

Re: Modifying PR18 (BIPED)

Postby himura_ryuu » Thu Oct 14, 2010 3:07 pm

kl84 WROTE:You can't use voltage divider to get 3.3V needed by the sensor. What the sensor needs is not a reference voltage, but the proper power supply. LM7833, LD1117-3.3 or LM2937-3.3 will do the job.


i see.. Thanks for the correction..
Anything else that i did wrong?? any connection mistakes??
i mean, i'm concern about the connection of the accelero itself.. Can i really connected it directly like that?
"Q.E.D
Shoumei Shouryou"
himura_ryuu
Apprentice
 
Posts: 34
Joined: Wed May 20, 2009 6:08 pm

Re: Modifying PR18 (BIPED)

Postby ober » Thu Oct 14, 2010 5:44 pm

Very good work, is still far from a working project, but you have taken the 1st step, to modify.

Besides the voltage regulator highlighted by kl84 which I agreed, there is another connection you need to take care.

Yes, Accelerometer's output can be connected directly to PIC analog input, but you will need to take care of analog pin mixing with digital pin.

As you can see from the schematic, AN0, AN1 and AN2 is use for digital input and you plan to use AN3, RA4 and AN4 for analog input.
1. RA4 is not analog input pin. Analog pin is label with "AN", there are RA0, RA1, RA2, RA3, RA5 for PIC16F876A. There are only 5 analog input for this model.

2. If you use higher number AN pin for analog input, the configuration in ADCON1 will make lower number AN pin become analog too. In other words, if AN4(RA5) is analog input, AN3(RA3), AN2(RA2)..... AN0 (RA0) will become analog input. Analog input cannot read digital logic in normal method.

Try to use other pin for push button or use AN0, AN1 and AN2 for accelerometer.
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: Modifying PR18 (BIPED)

Postby himura_ryuu » Thu Oct 14, 2010 8:27 pm

ober WROTE:Very good work, is still far from a working project, but you have taken the 1st step, to modify.

Besides the voltage regulator highlighted by kl84 which I agreed, there is another connection you need to take care.

Yes, Accelerometer's output can be connected directly to PIC analog input, but you will need to take care of analog pin mixing with digital pin.

As you can see from the schematic, AN0, AN1 and AN2 is use for digital input and you plan to use AN3, RA4 and AN4 for analog input.
1. RA4 is not analog input pin. Analog pin is label with "AN", there are RA0, RA1, RA2, RA3, RA5 for PIC16F876A. There are only 5 analog input for this model.

2. If you use higher number AN pin for analog input, the configuration in ADCON1 will make lower number AN pin become analog too. In other words, if AN4(RA5) is analog input, AN3(RA3), AN2(RA2)..... AN0 (RA0) will become analog input. Analog input cannot read digital logic in normal method.

Try to use other pin for push button or use AN0, AN1 and AN2 for accelerometer.


which means i can't use RA3, RA4 and RA5 for the push button if I'm connecting the accelerometer to AN0, AN1 and AN2~ Am i right??

So, any idea which pin i can use for the push button or do i need to change the microcontroller since i can't see any free i/o pin from PIC16F876A if i connect accelero to AN0, AN1 and AN2~
"Q.E.D
Shoumei Shouryou"
himura_ryuu
Apprentice
 
Posts: 34
Joined: Wed May 20, 2009 6:08 pm

Re: Modifying PR18 (BIPED)

Postby himura_ryuu » Sun Oct 17, 2010 8:08 pm

I think i have found the answer~ All i need to do is configure the analog channel am i right???

I found this coding...
CODE: SELECT_ALL_CODE
  unsigned int adc_rd;
 
  void main() {
    ANSEL  = 0b00000100;  // Configure AN2 pin as analog
    TRISA  = 0b00000000;  // PORTA is input
    ANSELH = 0b00000000; // Configure other AN pins as digital I/O
    TRISC  = 0b00111111;  // Pins RC7, RC6 are outputs
    TRISB  = 0b00000000;  // PORTB is output
 
    do {
      temp_res = ADC_Read(2);   // Get 10-bit results of AD conversion
      PORTB = temp_res;         // Send lower 8 bits to PORTB
      PORTC = temp_res >> 2;    // Send 2 most significant bits to RC7, RC6
    } while(1);
  }


Can it be used?? Concerning about only analog channel config for PORT A~
"Q.E.D
Shoumei Shouryou"
himura_ryuu
Apprentice
 
Posts: 34
Joined: Wed May 20, 2009 6:08 pm

Re: Modifying PR18 (BIPED)

Postby ober » Mon Oct 18, 2010 10:54 am

Try 1st. It will not destroy your board.
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: Modifying PR18 (BIPED)

Postby himura_ryuu » Mon Oct 18, 2010 1:11 pm

ober WROTE:Try 1st. It will not destroy your board.


will do~ huhuhuhu~
"Q.E.D
Shoumei Shouryou"
himura_ryuu
Apprentice
 
Posts: 34
Joined: Wed May 20, 2009 6:08 pm

Re: Modifying PR18 (BIPED)

Postby himura_ryuu » Sat Dec 11, 2010 9:40 am

ober WROTE:Try 1st. It will not destroy your board.


Hye, its me again.

I've successfully include the accelerometer and define the difference between analog port and digital port in port A. However, my next question is, in the cytron's coding, it stated that the default turn for the servo is preset to be 732. What is the number means? I mean the unit of the number.. Radian? How can i understand it more?

And per reading of the accelerometer. How can i change it to degree reading?? The actual converted reading from the accelerometer is in what unit?? i've tried using normal radian to degree formula (deg = rad*180/pi), but it didn't show it correctly.

Any idea from cytronians??? 8-) :roll:
"Q.E.D
Shoumei Shouryou"
himura_ryuu
Apprentice
 
Posts: 34
Joined: Wed May 20, 2009 6:08 pm

Re: Modifying PR18 (BIPED)

Postby ober » Sun Dec 12, 2010 1:08 pm

himura_ryuu WROTE:I've successfully include the accelerometer and define the difference between analog port and digital port in port A. However, my next question is, in the cytron's coding, it stated that the default turn for the servo is preset to be 732. What is the number means? I mean the unit of the number.. Radian? How can i understand it more?

And per reading of the accelerometer. How can i change it to degree reading?? The actual converted reading from the accelerometer is in what unit?? i've tried using normal radian to degree formula (deg = rad*180/pi), but it didn't show it correctly.

Any idea from cytronians??? 8-) :roll:


The 732 is the initial value of servo center position. Is just a reference for the rest of program to refer that is center position, if you study the program carefully, you will notice all the movement is - or + from this value. When using SC16A, the servo position can be control from with 12 bit value. Please refer to the User's Manual of SC16A.

woh.... where did you get deg = rad*180/pi? You will need to understand what is the value from accelerometer before you can use it, same applied for everything that you use. Accelerometer is giving us acceleration (pecutan in Malay), ideally it got nothing to do with angular, or angle. You can refer to PR21: Gaming with Accelerometer for more details. It takes time to understand 8-)
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm

Next

Return to DIY Project Set

Who is online

Users browsing this forum: No registered users and 6 guests

cron