Show Posts
|
|
Pages: [1] 2
|
|
1
|
Using Arduino / Programming Questions / Re: Stepper Motor Drive Problem
|
on: December 06, 2012, 01:54:54 pm
|
|
OK dywOOd, I'm not a programmer. What goes and what stays? I moved the stepper motor stop time delay after the second switch check.
Stepper_Motor_with_Button.cpp: In function 'void loop()': Stepper_Motor_with_Button:121: error: expected `}' at end of input
// read the state of the switch into a local variable: int reading = digitalRead(buttonPin);
// check to see if you just pressed the button // (i.e. the input went from LOW to HIGH), and you've waited // long enough since the last press to ignore any noise:
// If the switch changed, due to noise or pressing: if (reading != lastReading) { // reset the debouncing timer lastDebounceTime = millis(); // save the reading. Next time through the loop, // it'll be lastReading: lastReading = reading; } if ((millis() - lastDebounceTime) > debounceDelay) { // whatever the reading is at, it's been there for longer // than the debounce delay, so accept the button changed state: // toggle the LED if the state of the button changes from LOW to HIGH: if (lastButtonState == LOW && reading == HIGH) { if (ledState == HIGH) { ledState = LOW; } else { ledState = HIGH; } digitalWrite(ledPin, ledState); } lastButtonState = reading; delay(mappedValue); //Stop Stepper Motoer val time. } }
john Mims, Fl
|
|
|
|
|
2
|
Using Arduino / Programming Questions / Stepper Motor Drive Problem
|
on: December 06, 2012, 10:03:30 am
|
|
All, I’m having problems with my sketch to run a stepper motor. This is what I’m trying to do. I start with my stepper set at 0° I turn on my Arduino UNO and give it a start input from a push button (start the motor turning). The input of the push button is used to generate an output (pin 12 high) which is applied to an And gate (SN74LS08) on my driver board to start the motor. I want to look for an input from the switch two times, at the start of the run loop and at the end, this way I will keep the stepper motor synchronize with the program. The first switch input (start) works OK, but when I add the sceond switch input (stop) this is where I‘m having the problem. Here is the error message I am getting. Help!!!!!!!!!!
Stepper_Motor_with_Button.cpp: In function 'void loop()': Stepper_Motor_with_Button:121: error: expected `}' at end of input
/* Stepper motor 200 pluses per rev. Turns on a coil for 5 milis , then off for 5 milis, repeatedly. I used the Blink shetch to run the stepper motor and the analog input shetch to get the delay time. john Mims, Fl. */ const int buttonPin = 2; // the number of the pushbutton pin const int ledPin = 12; // the number of the LED pin
// Variables will change: int ledState = LOW; // the current state of the output pin int lastButtonState = LOW; // the previous debounced button state int lastReading= LOW; // the previous reading from the input pin int sensorPin = A0; int STP1 = 8; // stepper 1 coil output int STP2 = 9; // stepper 2 coil output int STP3 = 10; // stepper 3 coil output int STP4 = 11; // stepper 4 coil output int STP5 = 13; // run indicator int sensorValue = 0; int mappedValue;
// the following variables are long's because the time, measured in miliseconds, // will quickly become a bigger number than can be stored in an int. long lastDebounceTime = 0; // the last time the input pin was toggled long debounceDelay = 50; // the debounce time; increase if the output flickers
void setup() { pinMode(buttonPin, INPUT); pinMode(ledPin, OUTPUT); pinMode(STP1, OUTPUT); pinMode(STP2, OUTPUT); pinMode(STP3, OUTPUT); pinMode(STP4, OUTPUT); pinMode(STP5, OUTPUT); // initialize the serial port: Serial.begin(9600); }
void loop() { // read the state of the switch into a local variable: int reading = digitalRead(buttonPin);
// check to see if you just pressed the button // (i.e. the input went from LOW to HIGH), and you've waited // long enough since the last press to ignore any noise:
// If the switch changed, due to noise or pressing: if (reading != lastReading) { // reset the debouncing timer lastDebounceTime = millis(); // save the reading. Next time through the loop, // it'll be lastReading: lastReading = reading; } if ((millis() - lastDebounceTime) > debounceDelay) { // whatever the reading is at, it's been there for longer // than the debounce delay, so accept the button changed state: // toggle the LED if the state of the button changes from LOW to HIGH: if (lastButtonState == LOW && reading == HIGH) { if (ledState == HIGH) { ledState = LOW; } else { ledState = HIGH; } digitalWrite(ledPin, ledState); } lastButtonState = reading; //start the spepper motor turning to 36 deg. digitalWrite(STP5, HIGH); // out test delay(5); digitalWrite(STP1, HIGH); // turn the LED on (HIGH is the voltage level) delay(5); // wait for 5 milisecond digitalWrite(STP1, LOW); // turn the LED off by making the voltage LOW delay(5); // wait for 5 milisecond digitalWrite(STP2, HIGH); // turn the LED on (HIGH is the voltage level) delay(5); // wait for 5 milisecond digitalWrite(STP2, LOW); // turn the LED off by making the voltage LOW delay(5); // wait for 5 milisecond digitalWrite(STP3, HIGH); // turn the LED on (HIGH is the voltage level) delay(5); // wait for 5 milisecond digitalWrite(STP3, LOW); // turn the LED off by making the voltage LOW delay(5); // wait for 5 milisecond digitalWrite(STP4, HIGH); // turn the LED on (HIGH is the voltage level) delay(5); // wait for 5 milisecond digitalWrite(STP4, LOW); // turn the LED off by making the voltage LOW delay(5); // wait for 5 milisecond digitalWrite(STP5, LOW); // turn off led 13 for test sensorValue = analogRead(sensorPin); // Read the value of the pot voltage Serial.print("Time in 0 to 1023, bits, " ); Serial.println(sensorValue); mappedValue = map(sensorValue, 0, 1023, 0, 6000); mappedValue = (mappedValue*2); Serial.print("Time in milisec " ); Serial.println(mappedValue); delay(mappedValue); //Stop Stepper Motoer val time. // read the state of the switch into a local variable: int reading = digitalRead(buttonPin);
// check to see if you just pressed the button // (i.e. the input went from LOW to HIGH), and you've waited // long enough since the last press to ignore any noise:
// If the switch changed, due to noise or pressing: if (reading != lastReading) { // reset the debouncing timer lastDebounceTime = millis(); // save the reading. Next time through the loop, // it'll be lastReading: lastReading = reading; } if ((millis() - lastDebounceTime) > debounceDelay) { // whatever the reading is at, it's been there for longer // than the debounce delay, so accept the button changed state: // toggle the LED if the state of the button changes from LOW to HIGH: if (lastButtonState == LOW && reading == HIGH) { if (ledState == HIGH) { ledState = LOW; } else { ledState = HIGH; } digitalWrite(ledPin, ledState); } lastButtonState = reading; } }
|
|
|
|
|
4
|
Using Arduino / General Electronics / Cadsoft Eagle PCB solfware
|
on: November 21, 2012, 02:59:07 pm
|
|
All, Has anyone used Cadsoft Eagle PCB software. I would like to down load the free starter program. I have a circuit I would like to make a schematic for it. Has anyone had any problems with the down load corrupting your computer? John Mims, Fl
|
|
|
|
|
5
|
Using Arduino / Project Guidance / Re: need to read an analog voltage
|
on: November 20, 2012, 06:52:23 pm
|
|
Victor, You can increase your voltage by using an op amp like a LM741. You can take your 130mv and change it to 1.30 volts or what every you would like. Just be sure you do not go over 5.00 volts out (op amp) or 5.0 volts into your analog input channels. john Mims, Fl.
|
|
|
|
|
7
|
Using Arduino / Project Guidance / Re: No restart on UNO after power down
|
on: November 19, 2012, 05:57:43 pm
|
|
be80be The 10 turn pot is from the 5.0 volt pin to ground, the wipper picks up a voltage form the 2.0K resistor in the pot it can be from 0 to 5.0 volts the A0 input just reads the voltage. Anyway my UNO will not start with the pot in the circuit or out of the cirucit. Also I am just running the blink sketch and it it willnot restart. Yes PeterH it will not work on the blink sketch, with nothing connected to the board (just power, USB or Battery). Right now I have it running the blink sketch with the USB cable but if I remove the USB cable and REconnect it the blink sketch will not start. john Mims, Fl
|
|
|
|
|
9
|
Using Arduino / Project Guidance / Re: No restart on UNO after power down
|
on: November 19, 2012, 03:33:53 pm
|
|
Ok, I have a 10 turn photometer across the UNO 5.0 volt pins this is only 2.5 ma of current drop on the 5 volt bus. I’m taking the wiper output which is from 0 to 5.0 volts and inputting it to the A0 pin to convert a voltage to a stop time. I tried the blink program and it did the same thing. The blink only uses the onboard led. With nothing connected to the board it will run the blink program as it should but if I power down and repower with either a 9 volt battery or the USB cable it will not start the blink program. And I pressed the reset button. john Mims,Fl
|
|
|
|
|
10
|
Using Arduino / Project Guidance / No restart on UNO after power down
|
on: November 19, 2012, 02:04:16 pm
|
|
Ok, Here is the problem I am having with my Arduino Uno. I have a program that I wrote for a stepper motor drive. It starts by turning a stepper motor 36º, stop for the time you have set by a voltage input on A0. The program works find, but here is the problem. I can down load the program to my UNO and it will run after the down load, but if I disconnect the USB cable and connect a 9 volt battery to the power input of the processor it will not start. If I hit the reset button it has no effect on starting the program. If I remove the 9 volt battery and reinstall the USB cable, hit the restart button the program will not start. I can go back and reinstall the program and it will start to run again. HELP!!!!!!!!!!!!!!!!!! john Mims,Fl
|
|
|
|
|
11
|
Using Arduino / Project Guidance / Reset Input
|
on: September 15, 2012, 07:29:11 am
|
|
Anyone, Can you use the reset input to hold an Arduino Uno at the program start point for an indefinite time? I want to power the Uno with the reset button in the hold position (SPST toggle switch), get the processes ready and turn off the reset switch and start the program (rotate a stepper motor 36 degs and stop).
john Mims, Fl.
|
|
|
|
|
14
|
Using Arduino / Motors, Mechanics, and Power / Stepper motor control circuit
|
on: August 23, 2012, 06:09:28 pm
|
|
For my stepper motor controller I’m using a CD4050 non inverting buffer, output of the Arduino Uno to input of the CD4050 and the output of the CD4050 to drive a TIP120. The Tip120 will apply the ground to complete the coil circuit on the stepper motor. I will put a 1N4001 diode across each coil. I will have four each circuits driving the motor. The motor I’m using is a 3.6V, 2 amps unipolar. I know the TIP will handle 2 amps, but what amp power supply do I need? The way I’m running the stepper is I turn on one coil at a time. I would think a 3amp supply would be more than enough. Think this will work? john Mims,Fl
|
|
|
|
|