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

Help Needed - Arduino Controlled 2-Axis Turntable

Help Needed - Arduino Controlled 2-Axis Turntable

Postby dannym11 » Tue Aug 27, 2013 6:13 pm

Hey,

Can I use the Arduino IDE's Serial Monitor to communicate with the David Software? I have built a 2 axis turntable for structured light scanning. This is the code I used, and I'm not sure why when I send "S", the scan doesn't begin?

Any help would be much appreciated thanks!

Daniel

#include <SoftwareSerial.h>
#include <Servo.h>
Servo myservo;

int tiltcounter = 0;

int spincounter = 0;

int stepperFineDistance = 0;

int davidMessage = Serial.read();

int led = 13;
int resetPin =7;

void setup() //Initial Code
{
pinMode(led, OUTPUT);

digitalWrite(led, LOW);

myservo.attach(4); // attaches the servo on pin 1
pinMode(6, OUTPUT);
pinMode(5, OUTPUT);

digitalWrite(6, LOW);
digitalWrite(5, LOW);

Serial.begin(9600);
while(!Serial)
{
delay(1);
}
Serial.println("5, ");
delay(1000);

Serial.println("4, ");
delay(1000);

Serial.println("3, ");
delay(1000);

Serial.println("2, ");
delay(1000);

Serial.println("1. ");
delay(1000);

}


void loop()
{

Serial.write("4\n");
delay(100);

Serial.write("E\n");
delay(100);

Serial.write("S\n");
delay(100);
while(tiltcounter < 1)
{String s1 = " ";
String s3 = " degrees,";

while(spincounter <= 2286) //First Round of Scans
{


/*while(davidMessage != "T")
{
delay(1);
}*/

digitalWrite(led, HIGH);
delay(500);

digitalWrite(led, LOW);
delay(1);

for (stepperFineDistance = 0; stepperFineDistance <= 381; stepperFineDistance++)
{digitalWrite(5, HIGH);
delayMicroseconds(300);
digitalWrite(5, LOW);
delayMicroseconds(300);
spincounter++;
stepperFineDistance++;
}

stepperFineDistance = 0;
delay(2000);
if (spincounter == 2286)
{Serial.println("Vertical scans complete. Overall scan progress: 33.3% Complete");
spincounter=0;}
delay(1);
}
spincounter = 0;

for(int i=90;i<=180;i++) //First Tilt

{
myservo.write(i);
delay(20);
if (i%10 == 0)
{
String sF = s1 + i + s3;
Serial.println(sF);
}
}
while(spincounter <= 2286) //Second Round of Scans
{
Serial.write("4\n");
delay(100);

Serial.write("E\n");
delay(100);

Serial.write("S\n");
delay(100);

/* while(davidMessage != "T")
{
delay(1);
}*/

digitalWrite(led, HIGH);
delay(500);

digitalWrite(led, LOW);
delay(1);

for (stepperFineDistance = 0; stepperFineDistance <= 381; stepperFineDistance++)
{digitalWrite(5, HIGH);
delayMicroseconds(300);
digitalWrite(5, LOW);
delayMicroseconds(300);
spincounter++;
stepperFineDistance++;
}
stepperFineDistance = 0;
delay(2000);
if (spincounter == 2286)
{Serial.println("Far reach scans complete. Overall scan progress: 66.6% Complete");

delay(1);
}
}
spincounter = 0;

for(int x=180;x>=0;x--) //Second Tilt

{
myservo.write(x);
delay(20);
if (x % 10 == 0)
{
String sF2 = s1 + x + s3;
Serial.println(sF2);
}
}

while(spincounter <= 2286) //Third Round of Scans
{
Serial.write("4\n");
delay(100);

Serial.write("E\n");
delay(100);

Serial.write("S\n");
delay(100);

/*while(davidMessage != "T")
{
delay(1);
}*/

digitalWrite(led, HIGH);
delay(500);

digitalWrite(led, LOW);
delay(1);

for (stepperFineDistance = 0; stepperFineDistance <= 381; stepperFineDistance++)
{digitalWrite(5, HIGH);
delayMicroseconds(300);
digitalWrite(5, LOW);
delayMicroseconds(300);
spincounter++;
stepperFineDistance++;
}
stepperFineDistance = 0;
delay(2000);
if (spincounter == 2286)
{Serial.println("Far reach scans complete. Overall scan progress: 66.6% Complete");
delay(1);

}
}
spincounter = 0;

for(int z=0;z<=90;z++)

{
myservo.write(z);
delay(20);
if (z%10 == 0)
{
String sF3 = s1 + z + s3;
Serial.println(sF3);
}
}
Serial.println("Scan tray is back to its starting position. Overall scan: 100% Complete. You may now remove the part.");

tiltcounter++;

};
}
dannym11
 
Posts: 15
Joined: Tue Aug 20, 2013 2:36 pm
Location: Ottawa, Canada

Re: Help Needed - Arduino Controlled 2-Axis Turntable

Postby WalterMo » Tue Aug 27, 2013 8:37 pm

Daniel, have you seen this thread:
viewtopic.php?f=6&t=4154

I have used the letter „Z“ to trigger one motor for the next position. Best is to compare both codes.

Walter
User avatar
WalterMo
Moderator
 
Posts: 2363
Joined: Mon Apr 02, 2007 6:52 pm
Location: Braunschweig, Germany

Re: Help Needed - Arduino Controlled 2-Axis Turntable

Postby dannym11 » Tue Aug 27, 2013 8:59 pm

I meant how do I get Arduino to receive messages from DAVID and send messages to DAVID? Like what would I put in the code?
dannym11
 
Posts: 15
Joined: Tue Aug 20, 2013 2:36 pm
Location: Ottawa, Canada

Re: Help Needed - Arduino Controlled 2-Axis Turntable

Postby travandcon » Wed Aug 28, 2013 2:08 pm

Danny, at the risk of sounding like a smartass, have you tried serial.read?
http://forum.arduino.cc/index.php?topic=6666.0
Remember that the serial connection on an Arduino can only read and write on one channel so if youre running the Serial Monitor the arduino can only read and write to that.

Incidentally I'm trying to do the same thing but I have no engineering skills whatsoever. Any chance you could post some pics of the apparatus?
I assume youre building a pan and tilt turntable. Are servo motors strong enough?

BTW youre not actually in M11 are you?
travandcon
 
Posts: 47
Joined: Wed May 01, 2013 10:41 pm

Re: Help Needed - Arduino Controlled 2-Axis Turntable

Postby dannym11 » Wed Aug 28, 2013 3:56 pm

For Example: I'll scan this Arduino box (shown in the video I've attached). Right now it isn't automated with DAVID, this is what I'm trying to do, instead, I put something like a 300 millisecond delay between each rotation/tilt. Once I figure out the DAVID communication capabilities, I'll be right on that automation thing and will replace the delays.
Check out the video for the apparatus! :D

I'm not M11, and all the parts were designed by myself and then 3d printed or purchased (if they were pulleys, belts, shafts - the things that are standard not custom).

http://www.youtube.com/watch?v=svoh-Jsi ... e=youtu.be
dannym11
 
Posts: 15
Joined: Tue Aug 20, 2013 2:36 pm
Location: Ottawa, Canada

Re: Help Needed - Arduino Controlled 2-Axis Turntable

Postby travandcon » Wed Aug 28, 2013 7:49 pm

dannym11 wrote:For Example: I'll scan this Arduino box (shown in the video I've attached). Right now it isn't automated with DAVID, this is what I'm trying to do, instead, I put something like a 300 millisecond delay between each rotation/tilt. Once I figure out the DAVID communication capabilities, I'll be right on that automation thing and will replace the delays.
Check out the video for the apparatus! :D

I'm not M11, and all the parts were designed by myself and then 3d printed or purchased (if they were pulleys, belts, shafts - the things that are standard not custom).

http://www.youtube.com/watch?v=svoh-Jsi ... e=youtu.be


Whats the fidus architecture?
Are you building a commercial prototype or have you just adapted some other equipment?
Be useful to know for those of us trying to build our own...
travandcon
 
Posts: 47
Joined: Wed May 01, 2013 10:41 pm

Re: Help Needed - Arduino Controlled 2-Axis Turntable

Postby dannym11 » Wed Aug 28, 2013 9:45 pm

That's our company, I made a logo plate to stick onto the scanner. All the white and black plastic parts were designed by myself and 3D printed (nylon plastic). I'm a high school summer student building this as a summer project. The overall design was designed by me but was inspired by the traditional 1 axis turntable that others are making.

Just clarifying: How would I actually tell the Arduino program to start once it reads "T" for example from the DAVID software? And how would I get it to send "S" successfully to DAVID to start a scan? Could you show me with examples as I'm new to Arduino?

Thanks so much, I appreciate it man
dannym11
 
Posts: 15
Joined: Tue Aug 20, 2013 2:36 pm
Location: Ottawa, Canada

Re: Help Needed - Arduino Controlled 2-Axis Turntable

Postby WalterMo » Thu Aug 29, 2013 3:50 pm

I have attached a little Arduino code for testing sending of a 'S' and receiving a 'T' via the virtual COM port (by USB).

Simply also install the attached software Test COM 9. This software can be used for sending and receiving. You only have to set the right COM address (The same as what was used to upload the Arduino code to the board). But it's not possible to upload a code to the Arduino if the COM connection of COM9 is open!

How the Arduino works:
As long as the push button is pressed a lot of 'S' are sent and the red LED twinkles.
If Arduino receives a 'T' the yellow LED will shine for 1 sec.

Arduino Uno or Duemilanove can be used.
Attachments
TestCom9.zip
(558.75 KiB) Downloaded 121 times
TestTurntableTrigger6.zip
(637 Bytes) Downloaded 112 times
Test-Schaltplan Senden&Empfangen.jpg
User avatar
WalterMo
Moderator
 
Posts: 2363
Joined: Mon Apr 02, 2007 6:52 pm
Location: Braunschweig, Germany

Re: Help Needed - Arduino Controlled 2-Axis Turntable

Postby dannym11 » Thu Aug 29, 2013 7:23 pm

Can the Arduino Leonardo be used as well?
dannym11
 
Posts: 15
Joined: Tue Aug 20, 2013 2:36 pm
Location: Ottawa, Canada

Re: Help Needed - Arduino Controlled 2-Axis Turntable

Postby WalterMo » Thu Aug 29, 2013 7:49 pm

User avatar
WalterMo
Moderator
 
Posts: 2363
Joined: Mon Apr 02, 2007 6:52 pm
Location: Braunschweig, Germany

Re: Help Needed - Arduino Controlled 2-Axis Turntable

Postby dannym11 » Thu Aug 29, 2013 9:44 pm

As my time is limited on this project (tomorrow is my last day), I didn't have enough time to test it out with some LEDs. Instead, I grabbed the Serial Communication parts of your test code, added it to mine and tried to see when DAVID sends "T" (letting the Arduino know that the scan is done), will the table turn. Unfortunately, nothing happens, so I'm assuming that the Arduino Leonardo is not able to use Serial Communication. But, it's weird, I can print text to the Serial Monitor no problem, I just can't get DAVID to pick it up and I can't get the Arduino to pick up DAVIDs messages.

If someone knows what do, let me know, I'm curious and I'd really appreciate the help!
dannym11
 
Posts: 15
Joined: Tue Aug 20, 2013 2:36 pm
Location: Ottawa, Canada

Re: Help Needed - Arduino Controlled 2-Axis Turntable

Postby travandcon » Thu Aug 29, 2013 11:48 pm

dannym11 wrote:As my time is limited on this project (tomorrow is my last day), I didn't have enough time to test it out with some LEDs. Instead, I grabbed the Serial Communication parts of your test code, added it to mine and tried to see when DAVID sends "T" (letting the Arduino know that the scan is done), will the table turn. Unfortunately, nothing happens, so I'm assuming that the Arduino Leonardo is not able to use Serial Communication. But, it's weird, I can print text to the Serial Monitor no problem, I just can't get DAVID to pick it up and I can't get the Arduino to pick up DAVIDs messages.

If someone knows what do, let me know, I'm curious and I'd really appreciate the help!


A quick look here http://www.arduino.cc/en/Reference/Soft ... ialExample
shows that there is something unique about the leonardo that needs special codes for serial reads... what exactly i dont know, you'll have to read it.

Remember that if you are running the serial monitor the letter is sent there, it is NOT sent back to other software on your PC.
Serial monitor does not show you what is happening on the serial line it acts as though it is the serial line; the letters on the monitor do NOT get sent to other software only to the monitor program.
You need to turn off the serial monitor if you want other programs to read the serial data.

Check the com ports. Check that both are set up the same.
I find that when starting the Arduino software even though the correct com port is highlighted, it doesnt 'kick in' until I change it and then change it back again. Dont know why, just happens to me.

Baud rate - check the baud rate is the same for both pieces of software. 9600 is pre-selected in my David software.

Good luck with your project, kid.
travandcon
 
Posts: 47
Joined: Wed May 01, 2013 10:41 pm

Re: Help Needed - Arduino Controlled 2-Axis Turntable

Postby jantje » Fri Aug 30, 2013 2:48 pm

There is no reason why leonardo could not do it.
However Leonardo is a bit special and as such not my adviced board for beginners.
One of the differences is about the com port. As leonardo can simulate usb devices it actually uses 2 com ports in your os.
One at startup to allow to upload a sketch and one to be a USB device. This can be extremely confusing.
A quick look at the code shows me you have taken the leonardo changes into account. Maybe you are experiancing the different com port behaviour or any of the causes travandcon mentions.
Best regards
Jantje
User avatar
jantje
 
Posts: 107
Joined: Tue Mar 03, 2009 12:08 am
Location: Belgium

Re: Help Needed - Arduino Controlled 2-Axis Turntable

Postby dannym11 » Fri Aug 30, 2013 4:16 pm

The DAVID software has an input for 1-axis turntables and I was wondering if there's anyway to do automatic fusions, with a 2-axis turntable like mine.

Here's a video of the 2-axis turntable:
http://www.youtube.com/watch?v=svoh-Jsi ... =youtu.be/
dannym11
 
Posts: 15
Joined: Tue Aug 20, 2013 2:36 pm
Location: Ottawa, Canada


Return to Software

Who is online

Users browsing this forum: No registered users and 1 guest