Show Posts
Pages: [1] 2
1  Using Arduino / Project Guidance / Re: Stepper Motor Speed Problems on: December 01, 2013, 09:10:45 am
Thanks for the help!

why/how will the L298 over amp the motor?
2  Using Arduino / Project Guidance / Stepper Motor Speed Problems on: December 01, 2013, 01:49:36 am
Hello, I am working on a code using stepper motors.  I am using the stepper motor shown here:
https://www.sparkfun.com/products/9238

I am using an L298N driver shown here
http://www.ebay.com/itm/Dual-H-Bridge-DC-Stepper-Motor-Drive-Controller-Board-Module-Arduino-L298N-/321240042444?pt=LH_DefaultDomain_0&hash=item4acb660bcc

I have implemented a wiring schematic similar to what is shown in the link below. I have attached a power supple capable of 12v at 5amp.
http://learn.adafruit.com/adafruit-arduino-lesson-16-stepper-motors/breadboard-layout

And I am using the following code:
 
Code:
/*
Adafruit Arduino - Lesson 16. Stepper
*/
 
#include <Stepper.h>
 
int in1Pin = 12;
int in2Pin = 11;
int in3Pin = 10;
int in4Pin = 9;
 
Stepper motor(200, in1Pin, in2Pin, in3Pin, in4Pin); 

void setup()
{
  pinMode(in1Pin, OUTPUT);
  pinMode(in2Pin, OUTPUT);
  pinMode(in3Pin, OUTPUT);
  pinMode(in4Pin, OUTPUT);
 
  // this line is for Leonardo's, it delays the serial interface
  // until the terminal window is opened
  while (!Serial);
 
  Serial.begin(9600);
  motor.setSpeed(150);
}
 
void loop()
{
  if (Serial.available())
  {
    int steps = Serial.parseInt();
    motor.step(steps);
Serial.print(steps); Serial.println(" completed!");
  }
}

Everything works as expected except when I increase the speed beyond 150rpms. As soon as this happens the motor seems to jitter noisily and move very slowly. I am not sure why this is the case. 150 works fine, anything >150 does not seem to work as expected.
3  Using Arduino / Programming Questions / Re: Robot_Control\ArduinoRobot.cpp errors on: October 26, 2013, 12:31:03 pm
Well, I am having the same issues... here are the errors that I get.
Code:
ArduinoRobot.cpp : : In constructor 'RobotControl::RobotControl()':
ArduinoRobot.cpp : 'LCD_CS' was not declared in this scope
ArduinoRobot.cpp : 'DC_LCD' was not declared in this scope
ArduinoRobot.cpp : 'RST_LCD' was not declared in this scope
ArduinoRobot.cpp : : In member function 'void RobotControl::begin()':
ArduinoRobot.cpp : 'MUXA' was not declared in this scope
ArduinoRobot.cpp : 'MUXB' was not declared in this scope
ArduinoRobot.cpp : 'MUXC' was not declared in this scope
ArduinoRobot.cpp : 'MUXD' was not declared in this scope
ArduinoRobot.cpp : 'MUX_IN' was not declared in this scope
ArduinoRobot.cpp : 'BUZZ' was not declared in this scope
keyboard.cpp : : In member function 'int8_t RobotControl::keyboardRead()':
keyboard.cpp : 'KEY' was not declared in this scope
Melody.cpp : 'SQUAWK_PWM_PIN5' was not declared in this scope
Melody.cpp : : In function 'void __vector_17()':
Melody.cpp : 'SQUAWK_PWM_PIN5' was not declared in this scope
Sensors.cpp : : In member function 'void RobotControl::analogWrite(uint8_t, uint8_t)':
Sensors.cpp : 'TKD4' was not declared in this scope
Sensors.cpp : : In member function 'uint8_t RobotControl::_getTypeCode(uint8_t)':
Sensors.cpp : 'TKD0' was not declared in this scope
Sensors.cpp : 'TKD1' was not declared in this scope
Sensors.cpp : 'TKD2' was not declared in this scope
Sensors.cpp : 'TKD3' was not declared in this scope
Sensors.cpp : 'TKD4' was not declared in this scope
Sensors.cpp : 'TKD5' was not declared in this scope
Sensors.cpp : : In member function 'uint8_t RobotControl::_topDPortToAPort(uint8_t)':
Sensors.cpp : 'TKD0' was not declared in this scope
Sensors.cpp : 'TKD1' was not declared in this scope
Sensors.cpp : 'TKD2' was not declared in this scope
Sensors.cpp : 'TKD3' was not declared in this scope
Sensors.cpp : 'TKD4' was not declared in this scope
Sensors.cpp : 'TKD5' was not declared in this scope
Sensors.cpp : : In member function 'int RobotControl::knobRead()':
Sensors.cpp : 'POT' was not declared in this scope
Error compiling

If I uninstall 1.0.5 and install 1.0.3 It compiles just fine. Is it worth upgrading to 1.0.5?? I am not sure what the differences are.

I solved this issue by deleting both the Robot_Control and Robot_Motor libraries
4  Using Arduino / Project Guidance / Re: Water Level Detection Using Interrupt on: October 08, 2013, 10:05:02 pm
thanks for the input and information on interrupts. I believe I will attempt to implement  Jack Christensen circuit without using interrupts.  Thanks for the comments!
5  Using Arduino / Project Guidance / Re: Water Level Detection Using Interrupt on: October 08, 2013, 05:51:37 pm
That is a good point, I understand the concept of non blocking code and unfortunately there are several portions that are.  A lot of comments keep referring to the speed of the event, from reading the info on the ardunio site and a few others, it seems that both the speed and priority of the event are considered when deciding to use an interrupt. If you have several say, 100 sequential events and one additional event that requires priority, does it make sense to code all 100 "non blocking" just for the one high priority event to be timely captured or would it make more sense to just use an interrupt.
6  Using Arduino / Project Guidance / Re: Water Level Detection Using Interrupt on: October 08, 2013, 04:59:29 pm
This makes sense, thanks for the suggestion on the switching and the circuit.

Regarding the interrupt... I am still having a hard time understanding why not using an interrupt would be beneficial.  I am filling a 6ml container, yeah tiny. I have a trip two trip sensors setup to detect levels and those work well while the sensors are ON and being monitored.  I am executing SEVERAL other functions which include several FOR loops, WHILE loops, etc.

I am not sure if we are understand the concept of a fail safe design, this is assuming something goes wrong, for example a pump fails ON, or a sensor is not tripped, and any one that has used a float switch for an extended period of time will know it is not a matter of IF it fails but WHEN. I would like the interrupt to be triggered and triggered instantly without waiting to exit a loop. The alternative would be to place a monitor in every loop in the code.
7  Using Arduino / Project Guidance / Re: Water Level Detection Using Interrupt on: October 08, 2013, 12:51:39 pm
I'm have not used interrupts before but from the little research it seems like this problem is best solved using interrupts. It will be very impractical to "monitor the input at suitable intervals", and it seems to me that this is the whole point of using interrupts; to prevent you from writing code that continuously monitors an input?

I have used float switches before but I cannot at this time due to space limitations. Additionally this is a fail safe measure i.e. if the normally stopping mechanisms fails (float switch, sensors, etc.) this interrupt will trigger a function to prevent an overflow. I would like to have the water it self be the trigger and not use additional hardware interfaces. That is easy and I have already implemented those. I am just fishing to see if I can add additional safety to the system.

The external circuit is identical to that found in the digital read page, http://arduino.cc/en/Tutorial/DigitalReadSerial

The IDEA is to have two leads in the container, one will be pulled down to ground as shown in the circuit and the other will be a charged lead either 12v or 5v. Once the water "shorts" the two, the interrupt is triggered. Again this is just an idea, and I would like to know if this is a possibility or if it will fry the board, etc.

And here is the current test code which is modified from the arduino site.
Code:
int pin = 13;
volatile int state = HIGH;

void setup()
{
  Serial.begin(9600);
  pinMode(pin, OUTPUT);
  attachInterrupt(1, blink, RISING);
}

void loop()
{
  digitalWrite(pin, state);
  delay(1000);
Serial.println("checking");
}

void blink()
{
  Serial.println("Interrupt Triggered");
  state = !state;
}


The above approach triggers the interrupt but sometimes also crashes the board.
8  Using Arduino / Project Guidance / Re: Water Level Detection Using Interrupt on: October 08, 2013, 08:11:29 am
Quote
The approach did not the yield the expected results.
But, you aren't going to show us the code, or tell us what the actual results were, or what the expected results were? Well, then, good luck.

Quote
Any suggestions would be great!
Hmmm. I somehow doubt that.

The code??  Here it is, but it is nothing earth shattering
Code:
pinMode(19, OUTPUT);
digitalWrite(19,HIGH);
attachInterrupt(4, DrainFUNCTION, CHANGE);

You also asked for the expected results, I thought I stated what I need implemented, that is the EXPECTED results, to detect when the water is at the wire and then trigger the interrupt. If you mean to ask what the unexpected results were that I experienced then it was random at best. It seemed to CHANGE at a whim.

Thanks for your comments, hope this clarifies things.  Any additional help would be GREAT!!
9  Using Arduino / Project Guidance / Water Level Detection Using Interrupt on: October 08, 2013, 07:36:27 am
Hello all, I am working on project that performs several functions one of which is to fill a small container with water. I currently use sensors to determine if it water is at the desired level. 

I would like to build a “secondary stop” that uses the interrupt pin. Such that regards where you are in the program if this secondary stop is tripped I can stop the program.

My first attempt was to simply place a wire in the container and watch for CHANGE. I expected that once the water reach the wire the interrupt will be triggered. The approach did not the yield the expected results.
Any suggestions would be great! I would like to avoid using another sensor for this.
10  Using Arduino / Programming Questions / Re: ****What is wrong or problematic with this Function**** on: June 07, 2013, 11:30:28 am
Thanks a ton for the suggestions. Used the MemoryFree.h file and I noticed that I was very low on mem. I implemented the PROGMEM routine and it seems to have solved the issue.

Now I need to do this at several other locations in the code.
11  Using Arduino / Programming Questions / Re: Help with PROGMEM on: June 06, 2013, 09:17:26 pm
great thanks!
12  Using Arduino / Programming Questions / Help with PROGMEM on: June 06, 2013, 05:39:30 pm
I am working on a program and I am trying to use PROGMEM. I noticed that I was not getting the results as expected so I decided to start from the basic code shown on the site and I have the same issue. Here is the sample code from the site. I expect to get 65000 sent to serial but that is not the case. What am I missing here?

Code:

#include <pgmspace.h>
//#include <avr/pgmspace.h>

// the setup routine runs once when you press reset:
void setup() {             
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // save some unsigned ints
  PROGMEM  prog_uint16_t charSet[]  = { 65000, 32796, 16843, 10, 11234};
 
  // save some chars
  prog_uchar signMessage[] PROGMEM  = {"I AM PREDATOR,  UNSEEN COMBATANT. CREATED BY THE UNITED STATES DEPART"};
 
  unsigned int displayInt;
  int k = 0;    // counter variable
  char myChar; 
 
  // read back a 2-byte int
   displayInt = pgm_read_word_near(charSet + k);
 
  // read back a char
  myChar =  pgm_read_byte_near(signMessage + k);
  Serial.println(displayInt);
  delay(1000);
}
13  Using Arduino / Programming Questions / Re: ****What is wrong or problematic with this Function**** on: June 05, 2013, 03:23:06 pm
    Very helpful response.
     
  • I will look into using float.h
  • The L_estimate is not currently being used so I can remove
  • TC_test was replaced with generic values since I am posting in a public forum. But you do bring up a good point. If the real data can be fit to a polynomial it would be worth replacing.
  • I looked into the PROGMEM. I have never used it before and I was discourage by the lack of float support. I will go ahead and implement this change this evening
  • I like the suggestion on the magvector variable that will be changed also
  • I believe the varibles h s l are passed to rgb2hsl the declaration of the function looks like this. void rgb2hsl(float &R, float &G, float &B). I have not had an issue doing it this way. Please let me know if there is a proper way to do this
  • You are correct that the function does not change any globals etc. The purpose is to match the RGB readings to a predetermined set.
  • You guys are correct on the use of -1 on the for loop.


Thanks again for the help
[/list]
14  Using Arduino / Programming Questions / Re: ****What is wrong or problematic with this Function**** on: June 05, 2013, 11:17:26 am
Thanks, I will look into that once I get home.

Any other suggestions regarding the function. I have only been using C++/Arduino for a few months so I am open to suggestions.
15  Using Arduino / Programming Questions / Re: Help With TCS3200 Color Sensor (Understanding Output) on: June 05, 2013, 10:26:28 am
Great writeup!! This helped shed light on several items. Though I am no longer using this sensor(I seemed to get better results with HDJD color sensor) it seems that the approach described is slightly more complex. My approach with this sensor was to average several of the values from the pulsein function. Which if I understand the write up it is similar using the time period in that several measured values are obtained for a single reading. 

Another different is the forumla described in the paper uses f_d. I am curious what type of values are you getting for f_d. I did not considered mearsuing f_d so in my case f_d is (0,0,0). This would reduce the equations to x = 255fo/fw which is the approach I used.
Pages: [1] 2