Arduino control Full state space Ball and Beam

Hi all, I am new to this forum and to arduino as well. I am working on project arduino control ball and beam which is

Can you please help me out in the C code that should be done for this kind of CE106 ball and beam apparatus.

Greatly Thank full to Any Replies :slight_smile:
Frank..

Perhaps if you told us what it should do, we could help.

Thanks PaulS.... Actually what i mean is that the beam should balance the ball as per the movement of the ball on the beam there should be corresponding change in the beam angle to balance.

I am not so good at C coding. so can you please help me out. You can check the detail of CE106 ball and beam here

http://control-systems-principles.co.uk/whitepapers/ball-and-beam1.pdf

or Can you give me any ideas of writing the code or sample programs for this kind of apparatus with Arduino in C

How does the Arduino connect to this device? Can it read the ball position? Can it control the motor?

Yes the arduino can control the device as the beam is connected to a Servo motor inside. So arduino will control the motor movement through input ports provided accordingly. As potentiometer can also be helpful for constant inputs.

As the sensors will detect the ball movement on the beam

If all of this doesn't work then i can connect inclinometer to the beam to control the ball movement on the beam.

I hope so now u got a clear idea abt this. So can u plz help me out in the C code for this??

Here in this video u can find a similar eg. of arduino control of ball and beam

So can u plz help me out in the C code for this??

So what form of help are you looking for:

  1. Write the program for you?
  2. Show you how to start learning programming?
  3. ?

Lefty

Thanks for your replies....Yes i need C code for this...If you can write the program for me that will be Greatly thankful :slight_smile:

Bcz i am not able to find similar sort of programs in the web as for example so i am not able to figure out or if u can help me in writing the program any kind of support will be greatly appreciated :slight_smile:

Frank..

Some special reason you want to do this? Is it for a class? If so, what class?

So is getting us to write the code going to help you in passing the class that you don't deserve to pass?

I would suggest that you start off by writing a program that tilts the beam backwards and forwards in a fixed pattern and don't worry about the ball.

Then you add some feedback as to the balls position. Maybe block up the ends so the ball doesn't fall out at first.

Finally integrate the two to get your balance. Then maybe you will have learnt something and then deserve that pass in the class. We are all keen to help you learn but not so keen in helping you cheat.

Hi all, you think so that this code can help me in tilting the beam back and forth in this ce 106 ball and beam

#include <Servo.h> // include the servo library

Servo servoMotor; // creates an instance of the servo object to control a servo

int analogPin = 0; // the analog pin that the sensor is on
int analogValue = 0; // the value returned from the analog sensor

int servoPin = 2; // Control pin for servo motor. As of Arduino 0017, can be any pin

void setup() {
servoMotor.attach(servoPin); // attaches the servo on pin 2 to the servo object
}

void loop()
{
analogValue = analogRead(analogPin); // read the analog input (value between 0 and 1023)
analogValue = map(analogValue, 0, 1023, 0, 179); // map the analog value (0 - 1023) to the angle of the servo (0 - 179)
servoMotor.write(analogValue); // write the new mapped analog value to set the position of the servo
delay(15); // waits for the servo to get there
}

then after how can i add sensor to this? for sensing the ball position? can i use tilt sensor for this? can u help me out with code