Show Posts
Pages: 1 2 [3]
31  Using Arduino / Programming Questions / Re: motor shield current monitoring code on: December 07, 2012, 03:42:28 pm
Just tried this and I get 16 as the value.

Code:
void loop () {
 // read the value from the sensor:
  sensorValue = analogRead(sensorPin);   
  //int sensorValue=analogRead(A1);
//  float voltage = sensorValue * (5.0 / 255);
 int limit =10; //Value that triggers motor to shutoff once it has reached endpoint
  analogWrite  (motorspdB,255);
  digitalWrite (motorB,HIGH);
  digitalWrite (Bbrake,LOW);
  delay(2000);
  Serial.println(sensorValue);
  if (sensorValue>limit)
  {
    digitalWrite (Bbrake,HIGH);
    delay(5000);
}/code]
32  Using Arduino / Programming Questions / Re: motor shield current monitoring code on: December 07, 2012, 03:35:04 pm
Just tried value 10 and 20 and it makes no difference to what the serial monitor writes.
33  Using Arduino / Programming Questions / Re: motor shield current monitoring code on: December 07, 2012, 03:25:11 pm
but why doesn't the serial monitor change it's value if i load up the motor.  Surely if the motor has load on it at the point the program reads the serial print command it will display the change from the value it would read if the motor had no load?
34  Using Arduino / Programming Questions / Re: motor shield current monitoring code on: December 07, 2012, 03:16:12 pm
I can't get the serial monitor to show any value that relates to the current draw from the motor.  when i test pin A1 with my multimeter it registers a voltage change appropriate to the values listed in the spec 2amps equivalent to 3.3V, i'm getting about .4v.  What do i need to change on the code to read the change in voltage at pin A1 as i load up the motor?

Code:
void loop () {
 // read the value from the sensor:
  sensorValue = analogRead(sensorPin);   
  //int sensorValue=analogRead(A1);
  float voltage = sensorValue * (5.0 / 255);
 int limit =.22; //Value that triggers motor to shutoff once it has reached endpoint
  analogWrite  (motorspdB,255);
  digitalWrite (motorB,HIGH);
  digitalWrite (Bbrake,LOW);
  delay(2000);
  Serial.println(voltage);
  if (sensorValue>limit)
  {
    digitalWrite (Bbrake,HIGH);
 
  delay(5000);
}/code]
35  Using Arduino / Programming Questions / Re: motor shield current monitoring code on: December 07, 2012, 03:01:43 pm
opps understand < not >
36  Using Arduino / Programming Questions / Re: motor shield current monitoring code on: December 07, 2012, 02:57:38 pm
I set it at 1 to see if it worked.  it did and it would work up to 16 but it made no difference to the value when i load up the motor.  it stays at 16.  my motor stalls at 0.5amps.  i'm not using any resistors in the circuit, i'm using the Arduino motor shield, should I being using resistors somewhere in the circuit?  I've got the motor connected to the outputs for the motor and a seperate 6v supply on the board nothing else is wired in.  I'll look up the >instead of< code.

This help is much appreciated, thank you.

Colin
37  Using Arduino / Programming Questions / Re: motor shield current monitoring code on: December 07, 2012, 11:53:16 am
I can't understand how i get the board to read the current the motor is pulling and then incorporate that in an if statement.  Here's my code efforts to date.  At the moment the value that prints is always 16 regardless of how much load i apply to the motor.

Code:
int Bbrake=8;//brake signal for motor B
int Abrake=9;//brake signal for motor A
int motorspdB=11;//PWM speed signal for motor B
int motorspdA=3;//PWM speed signal for motor A
int motorA=12;
int motorB=13;
//int limit=A0

void setup () {
  // int sensorValue=analogRead(A1);
  pinMode(A1,INPUT);//motor current monitor B
  pinMode(A0,INPUT);//motor current monitor A
  pinMode (13, OUTPUT);//motor B enable and direction HIGH or LOW
  pinMode (12, OUTPUT);//motor A enable and direction HIGH or LOW
  pinMode (8, OUTPUT);//Brake motor B
  pinMode (9, OUTPUT);//Brake motor A
 
//  int Current = 0; //Value of current
  Serial.begin(9600);
 
   
  }
  void loop () {
 
  int sensorValue=analogRead(A1);
 
 int limit =1; //Value that triggers motor to shutoff once it has reached endpoint
  analogWrite  (motorspdB,255);
  digitalWrite (motorB,HIGH);
  digitalWrite (Bbrake,LOW);
  delay(2000);
  Serial.println(sensorValue);
  if (sensorValue<limit)
  {
    digitalWrite (Bbrake,HIGH);
 
  delay(5000);
}
 // digitalWrite (Bbrake,LOW);
 // delay(5000);
  digitalWrite (motorB,LOW);
  digitalWrite (Bbrake,LOW);
  delay(3000);
  digitalWrite (Bbrake,HIGH);
  delay (1000);
//  Serial.println(sensorValue);
}/code]
38  Using Arduino / Programming Questions / motor shield current monitoring code on: December 07, 2012, 11:19:45 am
Can anyone help with the code that will monitor pin A0 and A1 on the Arduino motor shield R3.  I want to stop the motors once the A0 and A1 pins detect a set parameter for overcurrent i.e. motor stall?
39  Using Arduino / Programming Questions / Re: if statement reading motor shield current monitoring pin on: December 06, 2012, 06:28:03 pm
Think i've got it right now

Code:
if (sensorValue<limit)
  {
    digitalWrite (Bbrake,HIGH);
 
  delay(5000);
}/code]
40  Using Arduino / Programming Questions / Re: if statement reading motor shield current monitoring pin on: December 06, 2012, 06:21:23 pm
Thanks Paul,

Code:
  if (sensorValue<limit);
 
  {digitalWrite (Bbrake,HIGH)
 
  delay(5000);}/code]

Is this correct.  I've tried this but i get an error 'expected ';' before delay'.  i'm trying to get the motor to stop for 5 seconds.
41  Using Arduino / Programming Questions / Re: if statement reading motor shield current monitoring pin on: December 06, 2012, 06:06:42 pm
I'm very new to Arduino and programming, sorry if my post was vague.  I'm building a Replica large scale lightning and am trying to design some lightweight retractable undercarriage.  My previous tests with jets have led to them disintegrating in flight due to lose items entering the airstream at speed.  I want to use secure screwjack undercarriage retracts.  I have engineered the mechanical side of the undercarriage but now need to control the motor driving the gear up and down. 

I've trawled the net and found various older topics on Arduino and retracts and have been trying to utilise the code in these posts but i could do with some simple pointers. 

I can get the motor (just one connected at the moment) to run and brake and reverse, but i'm uncertain of the code i need to make to motor to stop at the end of it's travel.  I was hoping you might correct my if statement i know it's not right but can't see where i've gone wrong.
42  Using Arduino / Programming Questions / if statement reading motor shield current monitoring pin on: December 06, 2012, 05:35:56 pm
Anyone help please.

I'm trying to write code that will enable me to control a motor using stall current.  I have an UNO and motor shield R3. Here's my code i'm working on.  I'm trying to read the pin A1 and if the current is above.4amp i want to shut the motor down.


Code:
int Bbrake=8;//brake signal for motor B
int Abrake=9;//brake signal for motor A
int motorspdB=11;//PWM speed signal for motor B
int motorspdA=3;//PWM speed signal for motor A
int motorA=12;
int motorB=13;
//int limit=A0

void setup () {
  // int sensorValue=analogRead(A1);
  pinMode(A1,INPUT);//motor current monitor B
  pinMode(A0,INPUT);//motor current monitor A
  pinMode (13, OUTPUT);//motor B enable and direction HIGH or LOW
  pinMode (12, OUTPUT);//motor A enable and direction HIGH or LOW
  pinMode (8, OUTPUT);//Brake motor B
  pinMode (9, OUTPUT);//Brake motor A
 
//  int Current = 0; //Value of current
  Serial.begin(9600);
 
   
  }
  void loop () {
 
  int sensorValue=analogRead(A1);
 
 int limit =100; //Value that triggers motor to shutoff once it has reached endpoint
  analogWrite  (motorspdB,255);
  digitalWrite (motorB,HIGH);
  digitalWrite (Bbrake,LOW);
  delay(2000);
  Serial.println(sensorValue);
  if (sensorValue<limit);
 
  {digitalWrite (Bbrake,HIGH);
 
  delay(5000);}
 // digitalWrite (Bbrake,LOW);
 // delay(5000);
  digitalWrite (motorB,LOW);
  digitalWrite (Bbrake,LOW);
  delay(3000);
  digitalWrite (Bbrake,HIGH);
  delay (1000);
//  Serial.println(sensorValue);
}/code]

The motors running backwards and forwards for now but i want to develop the if statement to take into account current.
43  Topics / Robotics / Re: controlling 3 rc servos from one rc signal on: November 27, 2012, 06:05:46 pm
Have been through these tutorials and can see on the serial monitor how the code allows me to see the change in signal when i operate the transmitter but it doesn't explain how i transfer that to the servo, or is this obvious somwhere.
44  Topics / Robotics / controlling 3 rc servos from one rc signal on: November 27, 2012, 10:31:53 am
Can anyone point me in the right direction.  This probably very simple for most of you but i'm new to microcintrollers.  I have an rc plane and i want to operate the gear door lock. gear door and undercarriage servos with one switch on the tansmitter.  I am very confused with how to get the arduino to interpret the signal from the rc receiver.  can anyone give me some code to look at.
Pages: 1 2 [3]