Dear DAVID Community,

As you are probably aware, the entire DAVID company, team and product range has been integrated into HP Inc.
This forum is now read-only. Relevant content has been migrated to HP and merged into HP's Support Forums on November 1, 2016.

To start new discussions for 3D Scanning, please register and post your new topic at the HP Support Forums

Arduino Turntable Sketch

Questions, problems, comments and tips regarding the 3d scanning process.

Arduino Turntable Sketch

Postby hyppyayo » Fri Apr 17, 2015 10:57 am

i Guys,

i'm newbie in Arduino, i need a hand to complete my automatized scans,

i build a nice turntable, and i use an Arduino with a L293d bridge to control the stepper.

i got this sketch and works well, but i need to make some changes to stop the scans when complete 360°.



#include <Stepper.h> //include the function library
#define STEPS 200 //7.5 deg motor (48 steps per rev) 22.5gradi

Stepper stepper(STEPS, 8, 9, 10, 11); //create the stepper
int ch = 0;
float scancount = 1.0; //Number of scans already done
float rot_angle = 20;

void setup() {

Serial.begin(9600); //setup library at 9600 bps
}

void loop() {


// SYSTEM READY TO START SCANNING
if(Serial.available()>0){
ch = Serial.read();
}

if (ch == 84){
ch = 0;
Serial.println("A"); //Tell david to move the scan to the scan list
Serial.println("4"); //Tell david to go back to Structured Light mode

int i;
stepper.setSpeed(10); //set speed to 30 rpm
delay(1000); //pause for effect
stepper.step(11.11111111111111); //move 360 deg one direction
delay(1000); //pause for effect

//SAVE
delay(2000);
Serial.println("S");
// TO MOVE TURN TABLE TO THE NEXT POSITION



if(Serial.available()>0){
ch = Serial.read();
}

if (ch == 84){
ch = 0;
Serial.println("A"); //Tell david to move the scan to the scan list
Serial.println("4"); //Tell david to go back to Structured Light mode

int i;
stepper.setSpeed(10); //set speed to 30 rpm
delay(1000); //pause for effect
stepper.step(11.11111111111111); //move 360 deg one direction
delay(1000); //pause for effect

//SAVE
delay(2000);
Serial.println("S");
// TO MOVE TURN TABLE TO THE NEXT POSITION



if(Serial.available()>0){
ch = Serial.read();
}

if (ch == 84){
ch = 0;
Serial.println("A"); //Tell david to move the scan to the scan list
Serial.println("4"); //Tell david to go back to Structured Light mode

int i;
stepper.setSpeed(10); //set speed to 30 rpm
delay(1000); //pause for effect
stepper.step(11.11111111111111); //move 360 deg one direction
delay(1000); //pause for effect

//SAVE
delay(2000);
Serial.println("S");
// TO MOVE TURN TABLE TO THE NEXT POSITION



if(Serial.available()>0){
ch = Serial.read();
}

if (ch == 84){
ch = 0;
Serial.println("A"); //Tell david to move the scan to the scan list
Serial.println("4"); //Tell david to go back to Structured Light mode

int i;
stepper.setSpeed(10); //set speed to 30 rpm
delay(1000); //pause for effect
stepper.step(11.11111111111111); //move 360 deg one direction
delay(1000); //pause for effect

//SAVE
delay(2000);
Serial.println("S");
// TO MOVE TURN TABLE TO THE NEXT POSITION

if(Serial.available()>0){
ch = Serial.read();
}

if (ch == 84){
ch = 0;
Serial.println("A"); //Tell david to move the scan to the scan list
Serial.println("4"); //Tell david to go back to Structured Light mode

int i;
stepper.setSpeed(10); //set speed to 30 rpm
delay(1000); //pause for effect
stepper.step(11.11111111111111); //move 360 deg one direction
delay(1000); //pause for effect

//SAVE
delay(2000);
Serial.println("S");
// TO MOVE TURN TABLE TO THE NEXT POSITION

if(Serial.available()>0){
ch = Serial.read();
}

if (ch == 84){
ch = 0;
Serial.println("A"); //Tell david to move the scan to the scan list
Serial.println("4"); //Tell david to go back to Structured Light mode

int i;
stepper.setSpeed(10); //set speed to 30 rpm
delay(1000); //pause for effect
stepper.step(11.11111111111111); //move 360 deg one direction
delay(1000); //pause for effect

//SAVE
delay(2000);
Serial.println("S");
// TO MOVE TURN TABLE TO THE NEXT POSITION

if(Serial.available()>0){
ch = Serial.read();
}

if (ch == 84){
ch = 0;
Serial.println("A"); //Tell david to move the scan to the scan list
Serial.println("4"); //Tell david to go back to Structured Light mode

int i;
stepper.setSpeed(10); //set speed to 30 rpm
delay(1000); //pause for effect
stepper.step(11.11111111111111); //move 360 deg one direction
delay(1000); //pause for effect

//SAVE
delay(2000);
Serial.println("S");
// TO MOVE TURN TABLE TO THE NEXT POSITION

if(Serial.available()>0){
ch = Serial.read();
}

if (ch == 84){
ch = 0;
Serial.println("A"); //Tell david to move the scan to the scan list
Serial.println("4"); //Tell david to go back to Structured Light mode

int i;
stepper.setSpeed(10); //set speed to 30 rpm
delay(1000); //pause for effect
stepper.step(11.11111111111111); //move 360 deg one direction
delay(1000); //pause for effect

//SAVE
delay(2000);
Serial.println("S");
// TO MOVE TURN TABLE TO THE NEXT POSITION

if(Serial.available()>0){
ch = Serial.read();
}

if (ch == 84){
ch = 0;
Serial.println("A"); //Tell david to move the scan to the scan list
Serial.println("4"); //Tell david to go back to Structured Light mode

int i;
stepper.setSpeed(10); //set speed to 30 rpm
delay(1000); //pause for effect
stepper.step(11.11111111111111); //move 360 deg one direction
delay(1000); //pause for effect

//SAVE
delay(2000);
Serial.println("S");
// TO MOVE TURN TABLE TO THE NEXT POSITION

if(Serial.available()>0){
ch = Serial.read();
}

if (ch == 84){
ch = 0;
Serial.println("A"); //Tell david to move the scan to the scan list
Serial.println("4"); //Tell david to go back to Structured Light mode

int i;
stepper.setSpeed(10); //set speed to 30 rpm
delay(1000); //pause for effect
stepper.step(11.11111111111111); //move 360 deg one direction
delay(1000); //pause for effect

//SAVE
delay(2000);
Serial.println("S");
// TO MOVE TURN TABLE TO THE NEXT POSITION

if(Serial.available()>0){
ch = Serial.read();
}

if (ch == 84){
ch = 0;
Serial.println("A"); //Tell david to move the scan to the scan list
Serial.println("4"); //Tell david to go back to Structured Light mode

int i;
stepper.setSpeed(10); //set speed to 30 rpm
delay(1000); //pause for effect
stepper.step(11.11111111111111); //move 360 deg one direction
delay(1000); //pause for effect

//SAVE
delay(2000);
Serial.println("S");
// TO MOVE TURN TABLE TO THE NEXT POSITION

if(Serial.available()>0){
ch = Serial.read();
}

if (ch == 84){
ch = 0;
Serial.println("A"); //Tell david to move the scan to the scan list
Serial.println("4"); //Tell david to go back to Structured Light mode

int i;
stepper.setSpeed(10); //set speed to 30 rpm
delay(1000); //pause for effect
stepper.step(11.11111111111111); //move 360 deg one direction
delay(1000); //pause for effect

//SAVE
delay(2000);
Serial.println("S");
// TO MOVE TURN TABLE TO THE NEXT POSITION

if(Serial.available()>0){
ch = Serial.read();
}

if (ch == 84){
ch = 0;
Serial.println("A"); //Tell david to move the scan to the scan list
Serial.println("4"); //Tell david to go back to Structured Light mode

int i;
stepper.setSpeed(10); //set speed to 30 rpm
delay(1000); //pause for effect
stepper.step(11.11111111111111); //move 360 deg one direction
delay(1000); //pause for effect

//SAVE
delay(2000);
Serial.println("S");
// TO MOVE TURN TABLE TO THE NEXT POSITION

if(Serial.available()>0){
ch = Serial.read();
}

if (ch == 84){
ch = 0;
Serial.println("A"); //Tell david to move the scan to the scan list
Serial.println("4"); //Tell david to go back to Structured Light mode

int i;
stepper.setSpeed(10); //set speed to 30 rpm
delay(1000); //pause for effect
stepper.step(11.11111111111111); //move 360 deg one direction
delay(1000); //pause for effect

//SAVE
delay(2000);
Serial.println("S");
// TO MOVE TURN TABLE TO THE NEXT POSITION

if(Serial.available()>0){
ch = Serial.read();
}

if (ch == 84){
ch = 0;
Serial.println("A"); //Tell david to move the scan to the scan list
Serial.println("4"); //Tell david to go back to Structured Light mode

int i;
stepper.setSpeed(10); //set speed to 30 rpm
delay(1000); //pause for effect
stepper.step(11.11111111111111); //move 360 deg one direction
delay(1000); //pause for effect

//SAVE
delay(2000);
Serial.println("S");
// TO MOVE TURN TABLE TO THE NEXT POSITION

if(Serial.available()>0){
ch = Serial.read();
}

if (ch == 84){
ch = 0;
Serial.println("A"); //Tell david to move the scan to the scan list
Serial.println("4"); //Tell david to go back to Structured Light mode

int i;
stepper.setSpeed(10); //set speed to 30 rpm
delay(1000); //pause for effect
stepper.step(11.11111111111111); //move 360 deg one direction
delay(1000); //pause for effect

//SAVE
delay(2000);
Serial.println("S");
// TO MOVE TURN TABLE TO THE NEXT POSITION

if(Serial.available()>0){
ch = Serial.read();
}

if (ch == 84){
ch = 0;
Serial.println("A"); //Tell david to move the scan to the scan list
Serial.println("4"); //Tell david to go back to Structured Light mode

int i;
stepper.setSpeed(10); //set speed to 30 rpm
delay(1000); //pause for effect
stepper.step(11.11111111111111); //move 360 deg one direction
delay(1000); //pause for effect

//SAVE
delay(2000);
Serial.println("S");
// TO MOVE TURN TABLE TO THE NEXT POSITION

if(Serial.available()>0){
ch = Serial.read();
}

if (ch == 84){
ch = 0;
Serial.println("A"); //Tell david to move the scan to the scan list
Serial.println("4"); //Tell david to go back to Structured Light mode

int i;
stepper.setSpeed(10); //set speed to 30 rpm
delay(1000); //pause for effect
stepper.step(11.11111111111111); //move 360 deg one direction
delay(1000); //pause for effect

//SAVE
delay(2000);
Serial.println("S");
// TO MOVE TURN TABLE TO THE NEXT POSITION



if (ch == 84){
ch = 84;
}}}}}}}}}}}}}}}}}}}}


____


How could i fix it to stop scans after 360°?

thanks!
Windows 7 pc
Acer P1165 projector + Logitech C920 cam
Black & Decker Laser Line Level
hyppyayo
 
Posts: 41
Joined: Fri Oct 26, 2012 3:02 pm
Location: Riccione (italy)

Re: Arduino Turntable Sketch

Postby micr0 » Fri Apr 17, 2015 2:51 pm

I just looked at this quickly but a few notes:

First. for what you want to do you have WAY too much code. If all you are trying to do is trigger the indexing and subsequent scan of a rotary a fixed number times a single if statement should be all you need.

Second. The communication between David and the turntable is more simple that what you have. David triggers the turntable when it's done scanning and the turntable (arduino) should then tell David when to start scanning. unless you want each new scan saved to disk at the time of scanning there is no other serial communication necessary. I have the scan passed to the list and a rough alignment done (set in David) before the next scan is done then David starts the next scan but there is nothing that passes between the arduiino and David until a new scan is finished.

third the lines where you ask ch==84 then set ch to a value look like part of your problem.
you just want to increment the variable holding the scan number till it reaches a certain number then stop sending the start command to David and then reset the variable to 0. Have a look at Walters code in his turntable examples.

I heavily modified his code to work with the stepper.h library and the read (2) 6 position angle selector switchs. I still have a bug or two to work out and I need to update it for a 4x20 display but I'll post it to the forum soon.

µ
µ
micr0
 
Posts: 315
Joined: Wed Mar 19, 2014 3:54 pm
Location: NYC

Re: Arduino Turntable Sketch

Postby cuongtran » Thu Jul 07, 2016 3:23 pm

i've got the uno r3.i've ever tried to installed the turntable leo 1-2,3-2 and 3-3.but all of them can not work with my david.can anyone give me the working firmware .thanks!
cuongtran
 
Posts: 8
Joined: Sun May 22, 2016 6:10 pm


Return to 3D Laser Scanning

Who is online

Users browsing this forum: No registered users and 1 guest

cron