Notifications
Clear all

Crusher Code Issues

74 Posts
3 Users
30 Likes
4,765 Views
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7084
 

@clark77494 Here is the language reference link

https://www.arduino.cc/reference/en/

Look for 'control structure' then 'for' the syntax is a little different, but I am sure you can fill in the blanks

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
Clark77494 reacted
ReplyQuote
Clark77494
(@clark77494)
Member
Joined: 2 years ago
Posts: 69
Topic starter  

@zander Thank you I will check it out. 🙂

It's great to tip your server unless you work in the Server Room!


   
Ron reacted
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2538
 

@clark77494 

Instead of picking random sketches from the internet, I think you should run the example code supplied with the AccelStepper library and read the documentation so you'll understand what's going on.

Anything seems possible when you don't know what you're talking about.


   
Clark77494 and Ron reacted
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2538
 

@clark77494 

In C you would use a "for" statement also.

It's form and use is documented on the Arduino site.

Anything seems possible when you don't know what you're talking about.


   
Clark77494 and Ron reacted
ReplyQuote
Clark77494
(@clark77494)
Member
Joined: 2 years ago
Posts: 69
Topic starter  

@will I used this simple code this morning to get the motor to turn at 1,500 RPM. The code was provided by arduino.cc. It is now a simple matter of learning about loops to turn it off after a certain amount of cycles. I did work with AccelStepper.h a couple of hours yesterday and ran into the same limitations as Stepper.h. This code below brings the motor up to the 10 KHz it needs for 1,500 RPM. 

 

int outPin = 3;               // digital pin 3 PUL-

void setup() {
  pinMode(outPin, OUTPUT);    // sets the digital pin as output
}

void loop() {
  digitalWrite(outPin, HIGH); // sets the pin on
  delayMicroseconds(45);      // pauses for 45 microseconds
  digitalWrite(outPin, LOW);  // sets the pin off
  delayMicroseconds(45);      // pauses for 45 microseconds
}   

It's great to tip your server unless you work in the Server Room!


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2538
 

@clark77494 

OK

Anything seems possible when you don't know what you're talking about.


   
Ron reacted
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7084
 

@clark77494 Glad to see you are working it out yourself, so much more rewarding, and you learn in the process.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
Clark77494 reacted
ReplyQuote
Clark77494
(@clark77494)
Member
Joined: 2 years ago
Posts: 69
Topic starter  

@zander In the past I have avoided software like the plaque. Probably because I worked for a large corporation with excellent programmers, and when I built a project I would explain to the programmers how it was supposed to work and they would code it for me. Bill has been helping out by showing me a different way to get the motor to work by injecting a square wave into the Stepper Controller. I appreciate everyone's help with this project. Today I will work on learning the software. 🙂 

It's great to tip your server unless you work in the Server Room!


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7084
 

@clark77494 Ok, today I am working on learning Russian just in case. I imagine learning software doesn't take quite as long although I am not so sure about the boys at Microsoft.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
Clark77494 reacted
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2538
 
Posted by: @zander

today I am working on learning Russian just in case.

Just learn "Don't shoot" and "It's not my tractor" 🙂

Anything seems possible when you don't know what you're talking about.


   
Ron reacted
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7084
 

@will да

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
Clark77494 reacted
ReplyQuote
Clark77494
(@clark77494)
Member
Joined: 2 years ago
Posts: 69
Topic starter  

Can you use a Rotary Encoder to run software on the Arduino? When I turn on the Arduino I want the Rotary Encoder to read 1 for 100 RPM and go to the line of code that will step the motor to 100 RPM after the momentary switch is pressed. When the dial is turned one click I want it to read 2 and turn 200 RPM when the momentary switch is pushed etc. I also want it to display on the LCD 1=100 RPM, LCD 2=200 RPM etc. I am not much of a coder. Wanted to know if this is possible. 

It's great to tip your server unless you work in the Server Room!


   
Inst-Tech reacted
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2538
 

@clark77494 

It's certainly possible but it's overkill for that situation. Just have two buttons: one adds 100 RPM and the other subtracts 100 RPM and set the motor accordingly.

Anything seems possible when you don't know what you're talking about.


   
Inst-Tech and Clark77494 reacted
ReplyQuote
Clark77494
(@clark77494)
Member
Joined: 2 years ago
Posts: 69
Topic starter  

@will That makes a lot more sense. I will design it accordingly.

It's great to tip your server unless you work in the Server Room!


   
Inst-Tech reacted
ReplyQuote
Page 5 / 5