Pages: [1]   Go Down
Author Topic: Using AccelStepper to listen to USB  (Read 1201 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I am brand new to the electronics world and am seeking help. I have googled as much as I can but am just overwhelmed by the sheer volume of information and need someone to help me sort it all out and get started.

Goal: to use the Arduino Lorenzo as stepper motors control in conjunction with a easydrivers 4.2, and gphoto2, running on a computer.

I am confused on a few things: The AccelStepper library seems to do exactly what I want; acceleration is something I will require to be gentle to the DSLR. However, I would like to be able to issue commands from the laptop, to the arduino, to the easy driver. It seems to me that (this is my first sketch, so be patient with me!) to make the arduino execute stepper commands, you burn (upload?) a file to the ATMega chip over USB and it executes it. So, in the AccelStepper examples that I have found, these run in a continuous loop executing whatever stepper commands you included with the burn/upload.

However, what I want to do is have the arduino listen for input from the computer before executing usb-contained stepper commands. I plan to start out issuing these commands via BASH and eventually in a python program.
My main question is, what is the best way to do this? Do you just re-upload the AccelStepper library + commands each time you want one of the motors to do something? Is there a way to configure AccelStepper to loop on the Arduino, listening for USB commands, and then execute them (if so, do you have an example)? Or would you use another library completely that is designed just for this sort of thing? My biggest question is, what is the most efficient way to go about this and not be uploading something all the time that isn't a complete waste of USB communication, and isn't re-burning/re-defining the entire "OS" onto the ATMega all the time, or uploading the library with each command execution? Or is this exactly what you do?

Thank you for your help (and patience)!
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Is there a way to configure AccelStepper to loop on the Arduino, listening for USB commands

The Arduino implements a virtual serial port over USB. All you need to do is send serial data from your PC, and use the Serial functions in your Arduino sketch to control what it is doing.

http://arduino.cc/en/Reference/Serial
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 630
Posts: 49998
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Do you just re-upload the AccelStepper library + commands each time you want one of the motors to do something?
No. You can get the "what to do" information from the serial port, as dxw00d points out.

Quote
Is there a way to configure AccelStepper to loop on the Arduino, listening for USB commands, and then execute them
Maybe, but that is not the intent of that library. The listen to the serial port part should be part of the sketch, not the library.

Quote
Or would you use another library completely that is designed just for this sort of thing?
Yes. The HardwareSerial class (implemented as Serial) is what you need.

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you everyone
Logged

Pages: [1]   Go Up
Jump to: