View unanswered posts | View active topics It is currently Thu Dec 18, 2014 4:14 pm






Reply to topic  [ 8 posts ] 
Coding for Torque Encoder and Brake encoder for Electric Veh 
Author Message
Rookie

Joined: Sun Mar 03, 2013 2:52 pm
Posts: 6
Post Coding for Torque Encoder and Brake encoder for Electric Veh
i just started to make a acceleration pedal and brake pedal for formula race car
i am gonna use a IR sensor for sensing the acceleration and brakes..can someone please give me the basic code for IR sensor in ROBOTC (Arduino UNO)


Sun Mar 03, 2013 3:02 pm
Profile
Rookie

Joined: Sun Mar 03, 2013 2:52 pm
Posts: 6
Post Re: Coding for Torque Encoder and Brake encoder for Electric
please share the basic code for ultrasonic sensor also pleaseee :( (i think , my teammates can switch to ultrasonic and i have to do the coding for them )


Sun Mar 03, 2013 3:08 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 619
Post Re: Coding for Torque Encoder and Brake encoder for Electric
Electric Vehicle wrote:
i just started to make a acceleration pedal and brake pedal for formula race car
i am gonna use a IR sensor for sensing the acceleration and brakes..can someone please give me the basic code for IR sensor in ROBOTC (Arduino UNO)


For the IR sensor, I would suggest taking a look through the IR Sensor with Arduino UNO project on the ROBOTC wiki, as it shows what an IR sensor is, how they work, and how to use them on a robot. You will need to modify the code to suit your particular needs.

Electric Vehicle wrote:
please share the basic code for ultrasonic sensor also pleaseee :( (i think , my teammates can switch to ultrasonic and i have to do the coding for them )


Which ultrasonic sensor are you using exactly? We have sample programs built in to ROBOTC for the PING Ultrasonic Sensor (by Parallax) and the SRP-04 Ultrasonic Sensor (the standard VEX ultrasonic sensor). We have another project dealing with Using the PING Sensor with the Arduino UNO on the ROBOTC wiki you may want to look at.

For instance, below is a segment of code using the Parallax PING sensor to detect distance and display the applicable 'range' on two LED's:

Code:
#pragma config(CircuitBoardType, typeCktBoardUNO)
#pragma config(PluginCircuitBoard, typeShieldParallaxBoeBot)
#pragma config(UART_Usage, UART0, uartSystemCommPort, baudRate200000, IOPins, dgtl1, dgtl0)
#pragma config(Sensor, dgtl3,  ping,           sensorSONAR_Ping_inch)
#pragma config(Sensor, dgtl5,  led1,           sensorDigitalOut)
#pragma config(Sensor, dgtl6,  led2,           sensorDigitalOut)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
  while (true)
  {
    if (SensorValue[ping] > 7)
    {
      //led1 on and led2 off
      SensorValue[led1] = 1;
      SensorValue[led2] = 0;
    }

   else if (SensorValue[ping] == 7)
    {
      //both leds on
      SensorValue[led1] = 1;
      SensorValue[led2] = 1;
    }

    else if (SensorValue[ping] < 7)
    {
      //led1 off and led2 on
      SensorValue[led1] = 0;
      SensorValue[led2] = 1;
    }

    else
    {
      //something happened
      //we don't know what to do so
      //let's just turn off the leds
      SensorValue[led1] = 0;
      SensorValue[led2] = 0;
    }
  }
}


You can also configure the sensors manually through the Motors and Sensors Setup window inside of ROBOTC (http://www.robotc.net/wiki/ARDUINO_328_ ... ns_Sensors), so even if you are not using the PING or VEX sonar sensors you should still be able to configure and use them.


Without knowing the exact setup (which board you are using, which specific sensors you are using, how exactly you wish to use them, etc), it will be difficult to point you to specific resources that pertain to what you want to do.

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our Wiki and our Forums.

I just met you,
And this is crazy,
But here's my code now,
So fix it, maybe?
~ Carly Rae Jepsen parody


Tue Mar 05, 2013 1:37 pm
Profile
Rookie

Joined: Sun Mar 03, 2013 2:52 pm
Posts: 6
Post Re: Coding for Torque Encoder and Brake encoder for Electric
"NOTE: ROBOTC is currently unable to make the IR LEDs flash at 38kHz. As such this section is on hold." i saw this in the link which u referred..is this problem fixed yet?? or can i simply proceed with the same basic code with robotc...??? will it work with hardware?


Wed Mar 06, 2013 10:00 am
Profile
Rookie

Joined: Sun Mar 03, 2013 2:52 pm
Posts: 6
Post Re: Coding for Torque Encoder and Brake encoder for Electric
Actually, there are problems with IR sensor

1) Heat is more when the vehicle is running near pedal

2)its dark, which will effect the efficiency of IR sensor

-->the best way to go is to use a Hall Effect and a potentiometer ( CAN SOME1 PLEASE SHARE YOUR KNOWLEDGE ABOUT HALL EFFECT SENSOR AND POTENTIOMETER sensor ) please.... dead line to my work is near..


Fri Mar 08, 2013 1:51 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 619
Post Re: Coding for Torque Encoder and Brake encoder for Electric
It's going to be difficult to point to any resources without knowing what exactly you are doing. For instance, how do you plan on using the potentiometer in a pedal? Potentiometers are variable resistors; when wired correctly, they will output a voltage between the high voltage and ground (usually 0-5 volts to keep the values digital logic friendly) depending on the location of the potentiometer's sweeper. You can find more information on potentiometers here.

You can find information on the Hall Effect on Wikipedia; it is an advanced concept that deals with magnetic fields and currents (and the interaction between the two).

Without knowing the exact sensors and schematic that you are using, it will be very difficult to assist with any debugging; for instance, this IR sensor is different from this IR sensor, but both can be used to detect distance. Since you are using custom parts (and not VEX or Lego sensors, which ROBOTC already has full support for), you will need to figure out which parts you are using and how you want to accomplish your goal, then write some code to control the sensors.

Once that is done (and assuming the schematic, wiring, and parts are correct), we will be able to take a look at your code and hopefully help you debug it. We can help you with the code, but we will not be able to design a robot for you. Also note that we are very wary about how much help we will give out related to school projects or homework; again, we will usually help, but you will have to learn the concepts and have an understanding of what you are trying to do (and how you are trying to do it) before we will give any input. We will not do your homework for you :)

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our Wiki and our Forums.

I just met you,
And this is crazy,
But here's my code now,
So fix it, maybe?
~ Carly Rae Jepsen parody


Fri Mar 08, 2013 2:47 pm
Profile
Rookie

Joined: Sun Mar 03, 2013 2:52 pm
Posts: 6
Post Re: Coding for Torque Encoder and Brake encoder for Electric
oops.. sorry that i didnt do a proper post....
i will tell all the details clearly now
works i am doing now are

1)i discussed with my technical head and i bought hall effect sensor..its good actually soo what i will do is very simple..i will connect the hall sensor to the analog pins and i will connect the lcd module to controller(i know the lcd module, really well ) and i will take the readings of the hall effect sensor (voltage values ) on the lcd module , so after checking the values..i will calibrate the reading in such a a way that..i will give a loop to make motors run at different speeds from the calibrated values using PWM

2) i am also using the hall effect sensor to make a rpm check..( since u told about homework..we actually keep a magnet on shaft and when the shaft rotates.. the hall sensors detects the counts of the no. of turns it made )

3)i also bought a temperature sensor (LM35, since LM36 is not available) ..i think i have make a code for temp sensor also.. to display ..its values on lcd module.

SO, NOW, Sir..i will do the code now..i hopefully succeed or if i happen to have any consistent error..then , i will get back to forum and i will post my code (good enough naa :) )
Sir thanks alot for your co-operation :) , i will share the result of my work soon.. i think after this.. many people can get some useful info from this post.. :D


Sat Mar 09, 2013 3:24 pm
Profile
Rookie

Joined: Sun Mar 03, 2013 2:52 pm
Posts: 6
Post Re: Coding for Torque Encoder and Brake encoder for Electric
Code:
#pragma config(CircuitBoardType, typeCktBoardDuemilanove)
#pragma config(Sensor, anlg0,  hall,           sensorAnalog)
#pragma config(Sensor, dgtl13, led,            sensorDigitalOut)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//
#include"ArduinoLcd.h"
task main()
{

int temp =SensorValue[hall];

lcd_init();   /* lcd initializing*/

lcd_gotoxy(0,0);  /*lcd cursor goes to 0,0 */

while(1)
   {
      lcd_clear();  /*lcd clears */
      lcd_gotoxy(0,0); /*lcd goes to 0,0 */
      wait1Msec(2000);
      lcd_showvalue(temp);  /* should display the sensed value */
      
   }
}





Sir please, my lcd showed once correct readings and then again, they are gone after i made a small modification ( i didnt get correct output again :'( ) please check this code... will be waiting for reply sir..cause after a few hours...i have to show my teammates..what i made :'(


Sat Mar 09, 2013 8:09 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 8 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.